Packet::Worker
BackgrounDRb workers are asynchronous reactors which work using events You are free to use threads in your workers, but be reasonable with them. Following methods are available to all workers from parent classes.
Above method connects to an external tcp server and integrates the connection within reactor loop of worker. For example:
class TimeClient
def receive_data(p_data)
worker.get_external_data(p_data)
end
def post_init
p "***************** : connection completed"
end
end
class FooWorker < BackgrounDRb::MetaWorker
set_worker_name :foo_worker
def create(args = nil)
external_connection = nil
connect("localhost",11009,TimeClient) { |conn| conn = external_connection }
end
def get_external_data(p_data)
puts "And external data is : #{p_data}"
end
end
Above method allows you to start a tcp server from your worker, all the accepted connections are integrated with event loop of worker
class TimeServer
def receive_data(p_data)
end
def post_init
add_periodic_timer(2) { say_hello_world }
end
def connection_completed
end
def say_hello_world
p "***************** : invoking hello world #{Time.now}"
send_data("Hello World\n")
end
end
class ServerWorker < BackgrounDRb::MetaWorker
set_worker_name :server_worker
def create(args = nil)
# start the server when worker starts
start_server("0.0.0.0",11009,TimeServer) do |client_connection|
client_connection.say_hello_world
end
end
end
can the responses be dumped?
# File server/lib/meta_worker.rb, line 214
214: def can_dump?(p_object)
215: begin
216: Marshal.dump(p_object)
217: return true
218: rescue TypeError
219: return false
220: rescue
221: return false
222: end
223: end
Periodic check for lost database connections and closed connections
# File server/lib/meta_worker.rb, line 317
317: def check_db_connection
318: begin
319: ActiveRecord::Base.verify_active_connections! if defined?(ActiveRecord)
320: rescue
321: logger.info($!.to_s)
322: logger.info($!.backtrace.join("\n"))
323: end
324: end
Check for enqueued tasks and invoke appropriate methods
# File server/lib/meta_worker.rb, line 267
267: def check_for_enqueued_tasks
268: if worker_key && !worker_key.empty?
269: task = BdrbJobQueue.find_next(worker_name.to_s,worker_key.to_s)
270: else
271: task = BdrbJobQueue.find_next(worker_name.to_s)
272: end
273: return unless task
274: if self.respond_to? task.worker_method
275: Thread.current[:persistent_job_id] = task[:id]
276: Thread.current[:job_key] = task[:job_key]
277: called_method_arity = self.method(task.worker_method).arity
278: args = load_data(task.args)
279: begin
280: if called_method_arity != 0
281: self.send(task.worker_method,args)
282: else
283: self.send(task.worker_method)
284: end
285: rescue
286: logger.info($!.to_s)
287: logger.info($!.backtrace.join("\n"))
288: end
289: else
290: task.release_job
291: end
292: end
Check for timer events and invoke scheduled methods in timer and scheduler
# File server/lib/meta_worker.rb, line 295
295: def check_for_timer_events
296: super
297: return if @worker_method_triggers.nil? or @worker_method_triggers.empty?
298: @worker_method_triggers.delete_if { |key,value| value[:trigger].respond_to?(:end_time) && value[:trigger].end_time <= Time.now }
299:
300: @worker_method_triggers.each do |key,value|
301: time_now = Time.now.to_i
302: if value[:runtime] < time_now
303: check_db_connection
304: begin
305: (t_data = value[:data]) ? send(key,t_data) : send(key)
306: rescue
307: logger.info($!.to_s)
308: logger.info($!.backtrace.join("\n"))
309: end
310: t_time = value[:trigger].fire_after_time(Time.now)
311: value[:runtime] = t_time.to_i
312: end
313: end
314: end
(Not documented)
# File server/lib/meta_worker.rb, line 264
264: def connection_completed; end
return job key from thread global variable
# File server/lib/meta_worker.rb, line 137
137: def job_key; Thread.current[:job_key]; end
loads workers schedule from options supplied from rails a user may pass trigger arguments to dynamically define the schedule
# File server/lib/meta_worker.rb, line 151
151: def load_schedule_from_args
152: @my_schedule = worker_options[:schedule]
153: new_load_schedule if @my_schedule
154: end
Load the schedule of worker from my_schedule instance variable
# File server/lib/meta_worker.rb, line 226
226: def new_load_schedule
227: @worker_method_triggers = { }
228: @my_schedule.each do |key,value|
229: case value[:trigger_args]
230: when String
231: cron_args = value[:trigger_args] || "0 0 0 0 0"
232: trigger = BackgrounDRb::CronTrigger.new(cron_args)
233: @worker_method_triggers[key] = { :trigger => trigger,:data => value[:data],:runtime => trigger.fire_after_time(Time.now).to_i }
234: when Hash
235: trigger = BackgrounDRb::Trigger.new(value[:trigger_args])
236: @worker_method_triggers[key] = { :trigger => trigger,:data => value[:trigger_args][:data],:runtime => trigger.fire_after_time(Time.now).to_i }
237: end
238: end
239: end
fetch the persistent job id of job currently running, create AR object and return to the user.
# File server/lib/meta_worker.rb, line 144
144: def persistent_job
145: job_id = Thread.current[:persistent_job_id]
146: job_id ? BdrbJobQueue.find_by_id(job_id) : nil
147: end
method is responsible for invoking appropriate method in user
# File server/lib/meta_worker.rb, line 183
183: def process_request(p_data)
184: user_input = p_data[:data]
185: if (user_input[:worker_method]).nil? or !respond_to?(user_input[:worker_method])
186: result = nil
187: send_response(p_data,result)
188: return
189: end
190:
191: called_method_arity = self.method(user_input[:worker_method]).arity
192: result = nil
193:
194: Thread.current[:job_key] = user_input[:job_key]
195:
196: begin
197: if called_method_arity != 0
198: result = self.send(user_input[:worker_method],user_input[:arg])
199: else
200: result = self.send(user_input[:worker_method])
201: end
202: rescue
203: logger.info($!.to_s)
204: logger.info($!.backtrace.join("\n"))
205: end
206:
207: if p_data[:result]
208: result = "dummy_result" if result.nil?
209: send_response(p_data,result) if can_dump?(result)
210: end
211: end
receives requests/responses from master process or other workers
# File server/lib/meta_worker.rb, line 165
165: def receive_data p_data
166: if p_data[:data][:worker_method] == :exit
167: exit
168: end
169: case p_data[:type]
170: when :request: process_request(p_data)
171: when :response: process_response(p_data)
172: when :get_result: return_result_object(p_data)
173: end
174: end
Gets called, whenever master bdrb process sends any data to the worker
# File server/lib/meta_worker.rb, line 157
157: def receive_internal_data data
158: @tokenizer.extract(data) do |b_data|
159: data_obj = load_data(b_data)
160: receive_data(data_obj) if data_obj
161: end
162: end
(Not documented)
# File server/lib/meta_worker.rb, line 176
176: def return_result_object p_data
177: user_input = p_data[:data]
178: user_job_key = user_input[:job_key]
179: send_response(p_data,cache[user_job_key])
180: end
send the response back to master process and hence to the client if there is an error while dumping the object, send “invalid_result_dump_check_log“
# File server/lib/meta_worker.rb, line 243
243: def send_response input,output
244: input[:data] = output
245: input[:type] = :response
246: begin
247: send_data(input)
248: rescue TypeError => e
249: logger.info(e.to_s)
250: logger.info(e.backtrace.join("\n"))
251: input[:data] = "invalid_result_dump_check_log"
252: send_data(input)
253: rescue
254: logger.info($!.to_s)
255: logger.info($!.backtrace.join("\n"))
256: input[:data] = "invalid_result_dump_check_log"
257: send_data(input)
258: end
259: end
called when connection is closed
# File server/lib/meta_worker.rb, line 262
262: def unbind; end
does initialization of worker stuff and invokes create method in user defined worker class
# File server/lib/meta_worker.rb, line 107
107: def worker_init
108: raise "Invalid worker name" if !worker_name
109: Thread.abort_on_exception = true
110:
111: log_flag = BDRB_CONFIG[:backgroundrb][:debug_log].nil? ? true : BDRB_CONFIG[:backgroundrb][:debug_load_rails_env]
112:
113: # stores the job key of currently running job
114: Thread.current[:job_key] = nil
115: @logger = PacketLogger.new(self,log_flag)
116: @thread_pool = ThreadPool.new(self,pool_size || 20,@logger)
117: t_worker_key = worker_options && worker_options[:worker_key]
118:
119: @cache = ResultStorage.new(worker_name,t_worker_key,BDRB_CONFIG[:backgroundrb][:result_storage])
120:
121: if(worker_options && worker_options[:schedule] && no_auto_load)
122: load_schedule_from_args
123: elsif(BDRB_CONFIG[:schedules] && BDRB_CONFIG[:schedules][worker_name.to_sym])
124: @my_schedule = BDRB_CONFIG[:schedules][worker_name.to_sym]
125: new_load_schedule if @my_schedule
126: end
127: if respond_to?(:create)
128: create_arity = method(:create).arity
129: (create_arity == 0) ? create : create(worker_options[:data])
130: end
131: return if BDRB_CONFIG[:backgroundrb][:persistent_disabled]
132: delay = BDRB_CONFIG[:backgroundrb][:persistent_delay] || 5
133: add_periodic_timer(delay.to_i) { check_for_enqueued_tasks }
134: end
--- SEC00031
--- ""
--- - name: cache rw: RW a_desc: "" - name: config_file rw: RW a_desc: "" - name: logger rw: RW a_desc: "" - name: my_schedule rw: RW a_desc: "" - name: run_time rw: RW a_desc: "" - name: thread_pool rw: RW a_desc: "" - name: trigger rw: RW a_desc: "" - name: trigger_type rw: RW a_desc: ""
---
- methods:
- visibility: public
aref: M000064
name: pool_size
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 92</span>\n\
92: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">pool_size</span>(<span class=\"ruby-identifier\">size</span> = <span class=\"ruby-keyword kw\">nil</span>)\n\
93: <span class=\"ruby-ivar\">@pool_size</span> = <span class=\"ruby-identifier\">size</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">size</span>\n\
94: <span class=\"ruby-ivar\">@pool_size</span>\n\
95: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
set the thread pool size, default is 20
</p>
params: (size = nil)
- visibility: public
aref: M000065
name: reload_on_schedule
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 98</span>\n 98: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">reload_on_schedule</span>(<span class=\"ruby-identifier\">flag</span> = <span class=\"ruby-keyword kw\">nil</span>)\n 99: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">flag</span>\n\
100: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">no_auto_load</span> = <span class=\"ruby-keyword kw\">true</span>\n\
101: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">reload_flag</span> = <span class=\"ruby-keyword kw\">true</span>\n\
102: <span class=\"ruby-keyword kw\">end</span>\n\
103: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
set auto restart flag on the worker
</p>
params: (flag = nil)
category: Class
type: Public
- methods:
- visibility: public
aref: M000075
name: can_dump?
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 214</span>\n\
214: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">can_dump?</span>(<span class=\"ruby-identifier\">p_object</span>)\n\
215: <span class=\"ruby-keyword kw\">begin</span>\n\
216: <span class=\"ruby-constant\">Marshal</span>.<span class=\"ruby-identifier\">dump</span>(<span class=\"ruby-identifier\">p_object</span>)\n\
217: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">true</span>\n\
218: <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">TypeError</span>\n\
219: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">false</span>\n\
220: <span class=\"ruby-keyword kw\">rescue</span>\n\
221: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">false</span>\n\
222: <span class=\"ruby-keyword kw\">end</span>\n\
223: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
can the responses be dumped?
</p>
params: (p_object)
- visibility: public
aref: M000082
name: check_db_connection
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 317</span>\n\
317: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">check_db_connection</span>\n\
318: <span class=\"ruby-keyword kw\">begin</span>\n\
319: <span class=\"ruby-constant\">ActiveRecord</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Base</span>.<span class=\"ruby-identifier\">verify_active_connections!</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-keyword kw\">defined?</span>(<span class=\"ruby-constant\">ActiveRecord</span>)\n\
320: <span class=\"ruby-keyword kw\">rescue</span>\n\
321: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
322: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">"\\n"</span>))\n\
323: <span class=\"ruby-keyword kw\">end</span>\n\
324: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Periodic check for lost database connections and closed connections
</p>
params: ()
- visibility: public
aref: M000080
name: check_for_enqueued_tasks
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 267</span>\n\
267: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">check_for_enqueued_tasks</span>\n\
268: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">worker_key</span> <span class=\"ruby-operator\">&&</span> <span class=\"ruby-operator\">!</span><span class=\"ruby-identifier\">worker_key</span>.<span class=\"ruby-identifier\">empty?</span>\n\
269: <span class=\"ruby-identifier\">task</span> = <span class=\"ruby-constant\">BdrbJobQueue</span>.<span class=\"ruby-identifier\">find_next</span>(<span class=\"ruby-identifier\">worker_name</span>.<span class=\"ruby-identifier\">to_s</span>,<span class=\"ruby-identifier\">worker_key</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
270: <span class=\"ruby-keyword kw\">else</span>\n\
271: <span class=\"ruby-identifier\">task</span> = <span class=\"ruby-constant\">BdrbJobQueue</span>.<span class=\"ruby-identifier\">find_next</span>(<span class=\"ruby-identifier\">worker_name</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
272: <span class=\"ruby-keyword kw\">end</span>\n\
273: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">task</span>\n\
274: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">respond_to?</span> <span class=\"ruby-identifier\">task</span>.<span class=\"ruby-identifier\">worker_method</span>\n\
275: <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">current</span>[<span class=\"ruby-identifier\">:persistent_job_id</span>] = <span class=\"ruby-identifier\">task</span>[<span class=\"ruby-identifier\">:id</span>]\n\
276: <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">current</span>[<span class=\"ruby-identifier\">:job_key</span>] = <span class=\"ruby-identifier\">task</span>[<span class=\"ruby-identifier\">:job_key</span>]\n\
277: <span class=\"ruby-identifier\">called_method_arity</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">method</span>(<span class=\"ruby-identifier\">task</span>.<span class=\"ruby-identifier\">worker_method</span>).<span class=\"ruby-identifier\">arity</span>\n\
278: <span class=\"ruby-identifier\">args</span> = <span class=\"ruby-identifier\">load_data</span>(<span class=\"ruby-identifier\">task</span>.<span class=\"ruby-identifier\">args</span>)\n\
279: <span class=\"ruby-keyword kw\">begin</span>\n\
280: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">called_method_arity</span> <span class=\"ruby-operator\">!=</span> <span class=\"ruby-value\">0</span>\n\
281: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">send</span>(<span class=\"ruby-identifier\">task</span>.<span class=\"ruby-identifier\">worker_method</span>,<span class=\"ruby-identifier\">args</span>)\n\
282: <span class=\"ruby-keyword kw\">else</span>\n\
283: <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">send</span>(<span class=\"ruby-identifier\">task</span>.<span class=\"ruby-identifier\">worker_method</span>)\n\
284: <span class=\"ruby-keyword kw\">end</span>\n\
285: <span class=\"ruby-keyword kw\">rescue</span>\n\
286: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
287: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">"\\n"</span>))\n\
288: <span class=\"ruby-keyword kw\">end</span>\n\
289: <span class=\"ruby-keyword kw\">else</span>\n\
290: <span class=\"ruby-identifier\">task</span>.<span class=\"ruby-identifier\">release_job</span>\n\
291: <span class=\"ruby-keyword kw\">end</span>\n\
292: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Check for enqueued tasks and invoke appropriate methods
</p>
params: ()
- visibility: public
aref: M000081
name: check_for_timer_events
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 295</span>\n\
295: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">check_for_timer_events</span>\n\
296: <span class=\"ruby-keyword kw\">super</span>\n\
297: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-ivar\">@worker_method_triggers</span>.<span class=\"ruby-identifier\">nil?</span> <span class=\"ruby-keyword kw\">or</span> <span class=\"ruby-ivar\">@worker_method_triggers</span>.<span class=\"ruby-identifier\">empty?</span>\n\
298: <span class=\"ruby-ivar\">@worker_method_triggers</span>.<span class=\"ruby-identifier\">delete_if</span> { <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">key</span>,<span class=\"ruby-identifier\">value</span><span class=\"ruby-operator\">|</span> <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger</span>].<span class=\"ruby-identifier\">respond_to?</span>(<span class=\"ruby-identifier\">:end_time</span>) <span class=\"ruby-operator\">&&</span> <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger</span>].<span class=\"ruby-identifier\">end_time</span> <span class=\"ruby-operator\"><=</span> <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">now</span> }\n\
299: \n\
300: <span class=\"ruby-ivar\">@worker_method_triggers</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">key</span>,<span class=\"ruby-identifier\">value</span><span class=\"ruby-operator\">|</span>\n\
301: <span class=\"ruby-identifier\">time_now</span> = <span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">now</span>.<span class=\"ruby-identifier\">to_i</span>\n\
302: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:runtime</span>] <span class=\"ruby-operator\"><</span> <span class=\"ruby-identifier\">time_now</span>\n\
303: <span class=\"ruby-identifier\">check_db_connection</span>\n\
304: <span class=\"ruby-keyword kw\">begin</span>\n\
305: (<span class=\"ruby-identifier\">t_data</span> = <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:data</span>]) <span class=\"ruby-operator\">?</span> <span class=\"ruby-identifier\">send</span>(<span class=\"ruby-identifier\">key</span>,<span class=\"ruby-identifier\">t_data</span>) <span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">send</span>(<span class=\"ruby-identifier\">key</span>)\n\
306: <span class=\"ruby-keyword kw\">rescue</span>\n\
307: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
308: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">"\\n"</span>))\n\
309: <span class=\"ruby-keyword kw\">end</span>\n\
310: <span class=\"ruby-identifier\">t_time</span> = <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger</span>].<span class=\"ruby-identifier\">fire_after_time</span>(<span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">now</span>)\n\
311: <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:runtime</span>] = <span class=\"ruby-identifier\">t_time</span>.<span class=\"ruby-identifier\">to_i</span>\n\
312: <span class=\"ruby-keyword kw\">end</span>\n\
313: <span class=\"ruby-keyword kw\">end</span>\n\
314: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Check for timer events and invoke scheduled methods in timer and scheduler
</p>
params: ()
- visibility: public
aref: M000079
name: connection_completed
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 264</span>\n\
264: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">connection_completed</span>; <span class=\"ruby-keyword kw\">end</span>"
params: ()
- visibility: public
aref: M000067
name: job_key
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 137</span>\n\
137: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">job_key</span>; <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">current</span>[<span class=\"ruby-identifier\">:job_key</span>]; <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
return job key from thread global variable
</p>
params: ()
- visibility: public
aref: M000070
name: load_schedule_from_args
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 151</span>\n\
151: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">load_schedule_from_args</span>\n\
152: <span class=\"ruby-ivar\">@my_schedule</span> = <span class=\"ruby-identifier\">worker_options</span>[<span class=\"ruby-identifier\">:schedule</span>]\n\
153: <span class=\"ruby-identifier\">new_load_schedule</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-ivar\">@my_schedule</span>\n\
154: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
loads workers schedule from options supplied from rails a user may pass
trigger arguments to dynamically define the schedule
</p>
params: ()
- visibility: public
aref: M000076
name: new_load_schedule
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 226</span>\n\
226: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">new_load_schedule</span>\n\
227: <span class=\"ruby-ivar\">@worker_method_triggers</span> = { }\n\
228: <span class=\"ruby-ivar\">@my_schedule</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">key</span>,<span class=\"ruby-identifier\">value</span><span class=\"ruby-operator\">|</span>\n\
229: <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger_args</span>]\n\
230: <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">String</span>\n\
231: <span class=\"ruby-identifier\">cron_args</span> = <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger_args</span>] <span class=\"ruby-operator\">||</span> <span class=\"ruby-value str\">"0 0 0 0 0"</span>\n\
232: <span class=\"ruby-identifier\">trigger</span> = <span class=\"ruby-constant\">BackgrounDRb</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">CronTrigger</span>.<span class=\"ruby-identifier\">new</span>(<span class=\"ruby-identifier\">cron_args</span>)\n\
233: <span class=\"ruby-ivar\">@worker_method_triggers</span>[<span class=\"ruby-identifier\">key</span>] = { <span class=\"ruby-identifier\">:trigger</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">trigger</span>,<span class=\"ruby-identifier\">:data</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:data</span>],<span class=\"ruby-identifier\">:runtime</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">trigger</span>.<span class=\"ruby-identifier\">fire_after_time</span>(<span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">now</span>).<span class=\"ruby-identifier\">to_i</span> }\n\
234: <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-constant\">Hash</span>\n\
235: <span class=\"ruby-identifier\">trigger</span> = <span class=\"ruby-constant\">BackgrounDRb</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Trigger</span>.<span class=\"ruby-identifier\">new</span>(<span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger_args</span>])\n\
236: <span class=\"ruby-ivar\">@worker_method_triggers</span>[<span class=\"ruby-identifier\">key</span>] = { <span class=\"ruby-identifier\">:trigger</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">trigger</span>,<span class=\"ruby-identifier\">:data</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">value</span>[<span class=\"ruby-identifier\">:trigger_args</span>][<span class=\"ruby-identifier\">:data</span>],<span class=\"ruby-identifier\">:runtime</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">trigger</span>.<span class=\"ruby-identifier\">fire_after_time</span>(<span class=\"ruby-constant\">Time</span>.<span class=\"ruby-identifier\">now</span>).<span class=\"ruby-identifier\">to_i</span> }\n\
237: <span class=\"ruby-keyword kw\">end</span>\n\
238: <span class=\"ruby-keyword kw\">end</span>\n\
239: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Load the schedule of worker from my_schedule instance variable
</p>
params: ()
- visibility: public
aref: M000069
name: persistent_job
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 144</span>\n\
144: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">persistent_job</span>\n\
145: <span class=\"ruby-identifier\">job_id</span> = <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">current</span>[<span class=\"ruby-identifier\">:persistent_job_id</span>]\n\
146: <span class=\"ruby-identifier\">job_id</span> <span class=\"ruby-value\">? </span><span class=\"ruby-constant\">BdrbJobQueue</span>.<span class=\"ruby-identifier\">find_by_id</span>(<span class=\"ruby-identifier\">job_id</span>) <span class=\"ruby-operator\">:</span> <span class=\"ruby-keyword kw\">nil</span>\n\
147: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
fetch the persistent job id of job currently running, create AR object and
return to the user.
</p>
params: ()
- visibility: public
aref: M000074
name: process_request
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 183</span>\n\
183: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">process_request</span>(<span class=\"ruby-identifier\">p_data</span>)\n\
184: <span class=\"ruby-identifier\">user_input</span> = <span class=\"ruby-identifier\">p_data</span>[<span class=\"ruby-identifier\">:data</span>]\n\
185: <span class=\"ruby-keyword kw\">if</span> (<span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:worker_method</span>]).<span class=\"ruby-identifier\">nil?</span> <span class=\"ruby-keyword kw\">or</span> <span class=\"ruby-operator\">!</span><span class=\"ruby-identifier\">respond_to?</span>(<span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:worker_method</span>])\n\
186: <span class=\"ruby-identifier\">result</span> = <span class=\"ruby-keyword kw\">nil</span>\n\
187: <span class=\"ruby-identifier\">send_response</span>(<span class=\"ruby-identifier\">p_data</span>,<span class=\"ruby-identifier\">result</span>)\n\
188: <span class=\"ruby-keyword kw\">return</span>\n\
189: <span class=\"ruby-keyword kw\">end</span>\n\
190: \n\
191: <span class=\"ruby-identifier\">called_method_arity</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">method</span>(<span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:worker_method</span>]).<span class=\"ruby-identifier\">arity</span>\n\
192: <span class=\"ruby-identifier\">result</span> = <span class=\"ruby-keyword kw\">nil</span>\n\
193: \n\
194: <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">current</span>[<span class=\"ruby-identifier\">:job_key</span>] = <span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:job_key</span>]\n\
195: \n\
196: <span class=\"ruby-keyword kw\">begin</span>\n\
197: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">called_method_arity</span> <span class=\"ruby-operator\">!=</span> <span class=\"ruby-value\">0</span>\n\
198: <span class=\"ruby-identifier\">result</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">send</span>(<span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:worker_method</span>],<span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:arg</span>])\n\
199: <span class=\"ruby-keyword kw\">else</span>\n\
200: <span class=\"ruby-identifier\">result</span> = <span class=\"ruby-keyword kw\">self</span>.<span class=\"ruby-identifier\">send</span>(<span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:worker_method</span>])\n\
201: <span class=\"ruby-keyword kw\">end</span>\n\
202: <span class=\"ruby-keyword kw\">rescue</span>\n\
203: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
204: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">"\\n"</span>))\n\
205: <span class=\"ruby-keyword kw\">end</span>\n\
206: \n\
207: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">p_data</span>[<span class=\"ruby-identifier\">:result</span>]\n\
208: <span class=\"ruby-identifier\">result</span> = <span class=\"ruby-value str\">"dummy_result"</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">result</span>.<span class=\"ruby-identifier\">nil?</span>\n\
209: <span class=\"ruby-identifier\">send_response</span>(<span class=\"ruby-identifier\">p_data</span>,<span class=\"ruby-identifier\">result</span>) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">can_dump?</span>(<span class=\"ruby-identifier\">result</span>)\n\
210: <span class=\"ruby-keyword kw\">end</span>\n\
211: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
method is responsible for invoking appropriate method in user
</p>
params: (p_data)
- visibility: public
aref: M000072
name: receive_data
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 165</span>\n\
165: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">receive_data</span> <span class=\"ruby-identifier\">p_data</span>\n\
166: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">p_data</span>[<span class=\"ruby-identifier\">:data</span>][<span class=\"ruby-identifier\">:worker_method</span>] <span class=\"ruby-operator\">==</span> <span class=\"ruby-identifier\">:exit</span>\n\
167: <span class=\"ruby-identifier\">exit</span>\n\
168: <span class=\"ruby-keyword kw\">end</span>\n\
169: <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-identifier\">p_data</span>[<span class=\"ruby-identifier\">:type</span>]\n\
170: <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:request</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">process_request</span>(<span class=\"ruby-identifier\">p_data</span>)\n\
171: <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:response</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">process_response</span>(<span class=\"ruby-identifier\">p_data</span>)\n\
172: <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:get_result</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">return_result_object</span>(<span class=\"ruby-identifier\">p_data</span>)\n\
173: <span class=\"ruby-keyword kw\">end</span>\n\
174: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
receives requests/responses from master process or other workers
</p>
params: (p_data)
- visibility: public
aref: M000071
name: receive_internal_data
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 157</span>\n\
157: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">receive_internal_data</span> <span class=\"ruby-identifier\">data</span>\n\
158: <span class=\"ruby-ivar\">@tokenizer</span>.<span class=\"ruby-identifier\">extract</span>(<span class=\"ruby-identifier\">data</span>) <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">b_data</span><span class=\"ruby-operator\">|</span>\n\
159: <span class=\"ruby-identifier\">data_obj</span> = <span class=\"ruby-identifier\">load_data</span>(<span class=\"ruby-identifier\">b_data</span>)\n\
160: <span class=\"ruby-identifier\">receive_data</span>(<span class=\"ruby-identifier\">data_obj</span>) <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">data_obj</span>\n\
161: <span class=\"ruby-keyword kw\">end</span>\n\
162: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
Gets called, whenever master bdrb process sends any data to the worker
</p>
params: (data)
- visibility: public
aref: M000073
name: return_result_object
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 176</span>\n\
176: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">return_result_object</span> <span class=\"ruby-identifier\">p_data</span>\n\
177: <span class=\"ruby-identifier\">user_input</span> = <span class=\"ruby-identifier\">p_data</span>[<span class=\"ruby-identifier\">:data</span>]\n\
178: <span class=\"ruby-identifier\">user_job_key</span> = <span class=\"ruby-identifier\">user_input</span>[<span class=\"ruby-identifier\">:job_key</span>]\n\
179: <span class=\"ruby-identifier\">send_response</span>(<span class=\"ruby-identifier\">p_data</span>,<span class=\"ruby-identifier\">cache</span>[<span class=\"ruby-identifier\">user_job_key</span>])\n\
180: <span class=\"ruby-keyword kw\">end</span>"
params: (p_data)
- visibility: public
aref: M000077
name: send_response
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 243</span>\n\
243: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">send_response</span> <span class=\"ruby-identifier\">input</span>,<span class=\"ruby-identifier\">output</span>\n\
244: <span class=\"ruby-identifier\">input</span>[<span class=\"ruby-identifier\">:data</span>] = <span class=\"ruby-identifier\">output</span>\n\
245: <span class=\"ruby-identifier\">input</span>[<span class=\"ruby-identifier\">:type</span>] = <span class=\"ruby-identifier\">:response</span>\n\
246: <span class=\"ruby-keyword kw\">begin</span>\n\
247: <span class=\"ruby-identifier\">send_data</span>(<span class=\"ruby-identifier\">input</span>)\n\
248: <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">TypeError</span> =<span class=\"ruby-operator\">></span> <span class=\"ruby-identifier\">e</span>\n\
249: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">e</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
250: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">e</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">"\\n"</span>))\n\
251: <span class=\"ruby-identifier\">input</span>[<span class=\"ruby-identifier\">:data</span>] = <span class=\"ruby-value str\">"invalid_result_dump_check_log"</span>\n\
252: <span class=\"ruby-identifier\">send_data</span>(<span class=\"ruby-identifier\">input</span>)\n\
253: <span class=\"ruby-keyword kw\">rescue</span>\n\
254: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
255: <span class=\"ruby-identifier\">logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">"\\n"</span>))\n\
256: <span class=\"ruby-identifier\">input</span>[<span class=\"ruby-identifier\">:data</span>] = <span class=\"ruby-value str\">"invalid_result_dump_check_log"</span>\n\
257: <span class=\"ruby-identifier\">send_data</span>(<span class=\"ruby-identifier\">input</span>)\n\
258: <span class=\"ruby-keyword kw\">end</span>\n\
259: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
send the response back to master process and hence to the client if there
is an error while dumping the object, send
“invalid_result_dump_check_log“
</p>
params: (input,output)
- visibility: public
aref: M000078
name: unbind
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 262</span>\n\
262: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">unbind</span>; <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
called when connection is closed
</p>
params: ()
- visibility: public
aref: M000066
name: worker_init
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 107</span>\n\
107: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">worker_init</span>\n\
108: <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-value str\">"Invalid worker name"</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-operator\">!</span><span class=\"ruby-identifier\">worker_name</span>\n\
109: <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">abort_on_exception</span> = <span class=\"ruby-keyword kw\">true</span>\n\
110: \n\
111: <span class=\"ruby-identifier\">log_flag</span> = <span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:backgroundrb</span>][<span class=\"ruby-identifier\">:debug_log</span>].<span class=\"ruby-identifier\">nil?</span> <span class=\"ruby-value\">? </span><span class=\"ruby-keyword kw\">true</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:backgroundrb</span>][<span class=\"ruby-identifier\">:debug_load_rails_env</span>]\n\
112: \n\
113: <span class=\"ruby-comment cmt\"># stores the job key of currently running job</span>\n\
114: <span class=\"ruby-constant\">Thread</span>.<span class=\"ruby-identifier\">current</span>[<span class=\"ruby-identifier\">:job_key</span>] = <span class=\"ruby-keyword kw\">nil</span>\n\
115: <span class=\"ruby-ivar\">@logger</span> = <span class=\"ruby-constant\">PacketLogger</span>.<span class=\"ruby-identifier\">new</span>(<span class=\"ruby-keyword kw\">self</span>,<span class=\"ruby-identifier\">log_flag</span>)\n\
116: <span class=\"ruby-ivar\">@thread_pool</span> = <span class=\"ruby-constant\">ThreadPool</span>.<span class=\"ruby-identifier\">new</span>(<span class=\"ruby-keyword kw\">self</span>,<span class=\"ruby-identifier\">pool_size</span> <span class=\"ruby-operator\">||</span> <span class=\"ruby-value\">20</span>,<span class=\"ruby-ivar\">@logger</span>)\n\
117: <span class=\"ruby-identifier\">t_worker_key</span> = <span class=\"ruby-identifier\">worker_options</span> <span class=\"ruby-operator\">&&</span> <span class=\"ruby-identifier\">worker_options</span>[<span class=\"ruby-identifier\">:worker_key</span>]\n\
118: \n\
119: <span class=\"ruby-ivar\">@cache</span> = <span class=\"ruby-constant\">ResultStorage</span>.<span class=\"ruby-identifier\">new</span>(<span class=\"ruby-identifier\">worker_name</span>,<span class=\"ruby-identifier\">t_worker_key</span>,<span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:backgroundrb</span>][<span class=\"ruby-identifier\">:result_storage</span>])\n\
120: \n\
121: <span class=\"ruby-keyword kw\">if</span>(<span class=\"ruby-identifier\">worker_options</span> <span class=\"ruby-operator\">&&</span> <span class=\"ruby-identifier\">worker_options</span>[<span class=\"ruby-identifier\">:schedule</span>] <span class=\"ruby-operator\">&&</span> <span class=\"ruby-identifier\">no_auto_load</span>)\n\
122: <span class=\"ruby-identifier\">load_schedule_from_args</span>\n\
123: <span class=\"ruby-keyword kw\">elsif</span>(<span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:schedules</span>] <span class=\"ruby-operator\">&&</span> <span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:schedules</span>][<span class=\"ruby-identifier\">worker_name</span>.<span class=\"ruby-identifier\">to_sym</span>])\n\
124: <span class=\"ruby-ivar\">@my_schedule</span> = <span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:schedules</span>][<span class=\"ruby-identifier\">worker_name</span>.<span class=\"ruby-identifier\">to_sym</span>]\n\
125: <span class=\"ruby-identifier\">new_load_schedule</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-ivar\">@my_schedule</span>\n\
126: <span class=\"ruby-keyword kw\">end</span>\n\
127: <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">respond_to?</span>(<span class=\"ruby-identifier\">:create</span>)\n\
128: <span class=\"ruby-identifier\">create_arity</span> = <span class=\"ruby-identifier\">method</span>(<span class=\"ruby-identifier\">:create</span>).<span class=\"ruby-identifier\">arity</span>\n\
129: (<span class=\"ruby-identifier\">create_arity</span> <span class=\"ruby-operator\">==</span> <span class=\"ruby-value\">0</span>) <span class=\"ruby-operator\">?</span> <span class=\"ruby-identifier\">create</span> <span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">create</span>(<span class=\"ruby-identifier\">worker_options</span>[<span class=\"ruby-identifier\">:data</span>])\n\
130: <span class=\"ruby-keyword kw\">end</span>\n\
131: <span class=\"ruby-keyword kw\">return</span> <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:backgroundrb</span>][<span class=\"ruby-identifier\">:persistent_disabled</span>]\n\
132: <span class=\"ruby-identifier\">delay</span> = <span class=\"ruby-constant\">BDRB_CONFIG</span>[<span class=\"ruby-identifier\">:backgroundrb</span>][<span class=\"ruby-identifier\">:persistent_delay</span>] <span class=\"ruby-operator\">||</span> <span class=\"ruby-value\">5</span>\n\
133: <span class=\"ruby-identifier\">add_periodic_timer</span>(<span class=\"ruby-identifier\">delay</span>.<span class=\"ruby-identifier\">to_i</span>) { <span class=\"ruby-identifier\">check_for_enqueued_tasks</span> }\n\
134: <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
does initialization of worker stuff and invokes create method in user
defined worker class
</p>
params: ()
- visibility: public
aref: M000068
name: worker_key
sourcecode: " <span class=\"ruby-comment cmt\"># File server/lib/meta_worker.rb, line 140</span>\n\
140: <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">worker_key</span>; <span class=\"ruby-identifier\">worker_options</span> <span class=\"ruby-operator\">&&</span> <span class=\"ruby-identifier\">worker_options</span>[<span class=\"ruby-identifier\">:worker_key</span>]; <span class=\"ruby-keyword kw\">end</span>"
m_desc: |-
<p>
if worker is running using a worker key, return it
</p>
params: ()
category: Instance
type: Public
---
Generated with the Darkfish Rdoc Generator.