modern_times 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/modern_times/jms_requestor/worker.rb +1 -18
- data/lib/modern_times/manager.rb +5 -3
- data/lib/modern_times/marshal_strategy.rb +1 -1
- data/lib/modern_times/railsable.rb +11 -6
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
@@ -10,18 +10,6 @@ module ModernTimes
|
|
10
10
|
def create_supervisor(manager, worker_options)
|
11
11
|
Supervisor.new(manager, self, {}, worker_options)
|
12
12
|
end
|
13
|
-
|
14
|
-
def request_marshal(option)
|
15
|
-
marshal(option)
|
16
|
-
end
|
17
|
-
|
18
|
-
def response_marshal(option)
|
19
|
-
@response_marshaler = ModernTimes::MarshalStrategy.find(option)
|
20
|
-
end
|
21
|
-
|
22
|
-
def response_marshaler
|
23
|
-
@response_marshaler || marshaler
|
24
|
-
end
|
25
13
|
end
|
26
14
|
|
27
15
|
def self.included(base)
|
@@ -41,17 +29,12 @@ module ModernTimes
|
|
41
29
|
@total_time = 0.0
|
42
30
|
end
|
43
31
|
|
44
|
-
def start
|
45
|
-
@reply_marshaler = self.class.response_marshaler
|
46
|
-
super
|
47
|
-
end
|
48
|
-
|
49
32
|
def perform(object)
|
50
33
|
start_time = Time.now
|
51
34
|
response = request(object)
|
52
35
|
response_time = Time.now - start_time
|
53
36
|
session.producer(:destination => message.reply_to) do |producer|
|
54
|
-
reply_message = ModernTimes::JMS.create_message(session,
|
37
|
+
reply_message = ModernTimes::JMS.create_message(session, self.class.marshaler, response)
|
55
38
|
reply_message.jms_correlation_id = message.jms_message_id
|
56
39
|
producer.send(reply_message)
|
57
40
|
end
|
data/lib/modern_times/manager.rb
CHANGED
@@ -114,9 +114,11 @@ module ModernTimes
|
|
114
114
|
@worker_file = file
|
115
115
|
if File.exist?(file)
|
116
116
|
hash = YAML.load_file(file)
|
117
|
-
|
118
|
-
|
119
|
-
|
117
|
+
config = @dummy_host && hash[@dummy_host]
|
118
|
+
unless config
|
119
|
+
host = Socket.gethostname.sub(/\..*/, '')
|
120
|
+
config = hash[host]
|
121
|
+
end
|
120
122
|
return unless config
|
121
123
|
# Don't save new states if the user never dynamically updates the workers
|
122
124
|
# Then they can solely define the workers via this file and updates to the counts won't be ignored.
|
@@ -37,7 +37,7 @@ module ModernTimes
|
|
37
37
|
when :json then JSON
|
38
38
|
when :bson then BSON
|
39
39
|
when :yaml then YAML
|
40
|
-
else raise "Invalid marshal strategy: #{
|
40
|
+
else raise "Invalid marshal strategy: #{marshal_option}"
|
41
41
|
end
|
42
42
|
elsif marshal_option.respond_to?(:marshal_type)
|
43
43
|
return marshal_option
|
@@ -6,9 +6,9 @@ module ModernTimes
|
|
6
6
|
def init_rails
|
7
7
|
# Allow user to use JMS w/o modifying jms.yml which could be checked in and hose other users
|
8
8
|
env = ENV['MODERN_TIMES_JMS_ENV'] || Rails.env
|
9
|
-
if @
|
9
|
+
if @config = YAML.load(ERB.new(File.read(File.join(Rails.root, "config", "jms.yml"))).result(binding))[env]
|
10
10
|
ModernTimes.logger.info "Messaging Enabled"
|
11
|
-
ModernTimes::JMS::Connection.init(@
|
11
|
+
ModernTimes::JMS::Connection.init(@config)
|
12
12
|
@is_jms_enabled = true
|
13
13
|
|
14
14
|
# Need to start the JMS Server in this VM
|
@@ -21,7 +21,7 @@ module ModernTimes
|
|
21
21
|
# Handle messages within this process
|
22
22
|
@manager = ModernTimes::Manager.new
|
23
23
|
# TODO: Formatting of configured workers in invm state with name and options
|
24
|
-
if worker_cfg = @
|
24
|
+
if worker_cfg = @config[:workers]
|
25
25
|
worker_cfg.each do |klass, count|
|
26
26
|
@manager.add(klass, count, {})
|
27
27
|
end
|
@@ -52,14 +52,15 @@ module ModernTimes
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def create_rails_manager
|
55
|
+
# Take advantage of nil and false values for boolean
|
55
56
|
raise 'init_rails has not been called, modify your config/environment.rb to include this call' if @is_jms_enabled.nil?
|
56
57
|
raise 'Messaging is not enabled, modify your config/jms.yml file' unless @is_jms_enabled
|
57
58
|
manager = ModernTimes::Manager.new
|
58
59
|
manager.stop_on_signal
|
59
60
|
manager.allowed_workers = rails_workers
|
60
|
-
manager.persist_file = @
|
61
|
-
manager.dummy_host =
|
62
|
-
manager.worker_file = @
|
61
|
+
manager.persist_file = @config[:persist_file] || File.join(Rails.root, "log", "modern_times.persist")
|
62
|
+
manager.dummy_host = Rails.env
|
63
|
+
manager.worker_file = @config[:worker_file] || File.join(Rails.root, "config", "workers.yml")
|
63
64
|
return manager
|
64
65
|
end
|
65
66
|
|
@@ -76,6 +77,10 @@ module ModernTimes
|
|
76
77
|
#raise "No worker config file #{file}" unless File.exist?(file)
|
77
78
|
end
|
78
79
|
|
80
|
+
def config
|
81
|
+
@config
|
82
|
+
end
|
83
|
+
|
79
84
|
def jms_enabled?
|
80
85
|
@is_jms_enabled
|
81
86
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: modern_times
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Pardee
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-05-
|
14
|
+
date: 2011-05-03 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|