Class: RubyJob::ThreadedServer
- Inherits:
-
Object
- Object
- RubyJob::ThreadedServer
- Defined in:
- lib/ruby_job/threaded_server.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #halt ⇒ Object
- #halt_at(time) ⇒ Object
-
#initialize(num_threads:, jobstore:) ⇒ ThreadedServer
constructor
A new instance of ThreadedServer.
- #resume ⇒ Object
- #resume_until(time) ⇒ Object
- #set(**options) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(num_threads:, jobstore:) ⇒ ThreadedServer
Returns a new instance of ThreadedServer.
7 8 9 10 11 |
# File 'lib/ruby_job/threaded_server.rb', line 7 def initialize(num_threads:, jobstore:) @num_threads = num_threads @jobstore = jobstore = { wait: true, wait_delay: 0.5 } end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/ruby_job/threaded_server.rb', line 5 def end |
Instance Method Details
#halt ⇒ Object
33 34 35 36 |
# File 'lib/ruby_job/threaded_server.rb', line 33 def halt halt_at(Time.now) self end |
#halt_at(time) ⇒ Object
28 29 30 31 |
# File 'lib/ruby_job/threaded_server.rb', line 28 def halt_at(time) @jobstore.pause_at(time) self end |
#resume ⇒ Object
38 39 40 41 |
# File 'lib/ruby_job/threaded_server.rb', line 38 def resume halt_at(nil) self end |
#resume_until(time) ⇒ Object
43 44 45 46 47 |
# File 'lib/ruby_job/threaded_server.rb', line 43 def resume_until(time) resume halt_at(time) self end |
#set(**options) ⇒ Object
13 14 15 16 |
# File 'lib/ruby_job/threaded_server.rb', line 13 def set(**) .merge!() self end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_job/threaded_server.rb', line 18 def start Thread.new do @num_threads.times.map do Thread.new do JobProcessor.new(@jobstore).run(**) end end.each(&:join) end end |