Class: LogStash::PluginMixins::Scheduler::RufusImpl::SchedulerAdapter
- Inherits:
-
Object
- Object
- LogStash::PluginMixins::Scheduler::RufusImpl::SchedulerAdapter
- Includes:
- SchedulerInterface, Util::Loggable
- Defined in:
- lib/logstash/plugin_mixins/scheduler/rufus_impl.rb
Instance Attribute Summary collapse
- #impl ⇒ Object readonly
Instance Method Summary collapse
- #at(timestamp, opts = {}, &task) ⇒ Object
- #cron(schedule, opts = {}, &task) ⇒ Object
- #every(period, opts = {}, &task) ⇒ Object
- #in(delay, opts = {}, &task) ⇒ Object
-
#initialize(name, opts) ⇒ SchedulerAdapter
constructor
A new instance of SchedulerAdapter.
- #interval(interval, opts = {}, &task) ⇒ Object
- #join ⇒ Object
- #release ⇒ Object
- #release! ⇒ Object
- #running? ⇒ Object
- #terminate! ⇒ Object
Constructor Details
#initialize(name, opts) ⇒ SchedulerAdapter
Returns a new instance of SchedulerAdapter.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 21 def initialize(name, opts) if name && !opts.key?(:thread_name) opts[:thread_name] = name end opts[:max_work_threads] ||= 1 # amount the scheduler thread sleeps between checking whether jobs # should trigger, default is 0.3 which is a bit too often ... # in theory the cron expression '* * * * * *' supports running jobs # every second but this is very rare, we could potentially go higher opts[:frequency] ||= 1.0 logger = opts.delete(:logger) || self.logger @impl = SchedulerImpl.new(opts, logger) end |
Instance Attribute Details
#impl ⇒ Object (readonly)
19 20 21 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 19 def impl @impl end |
Instance Method Details
#at(timestamp, opts = {}, &task) ⇒ Object
41 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 41 def at(, opts = {}, &task); __schedule(:at, , opts, &task); end |
#cron(schedule, opts = {}, &task) ⇒ Object
37 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 37 def cron(schedule, opts = {}, &task); __schedule(:cron, schedule, opts, &task); end |
#every(period, opts = {}, &task) ⇒ Object
39 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 39 def every(period, opts = {}, &task); __schedule(:every, period, opts, &task); end |
#in(delay, opts = {}, &task) ⇒ Object
43 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 43 def in(delay, opts = {}, &task); __schedule(:in, delay, opts, &task); end |
#interval(interval, opts = {}, &task) ⇒ Object
45 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 45 def interval(interval, opts = {}, &task); __schedule(:interval, interval, opts, &task); end |
#join ⇒ Object
57 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 57 def join; @impl.join end |
#release ⇒ Object
48 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 48 def release; @impl.shutdown end |
#release! ⇒ Object
50 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 50 def release!; @impl.shutdown(:wait) end |
#running? ⇒ Object
54 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 54 def running?; !@impl.down? end |
#terminate! ⇒ Object
52 |
# File 'lib/logstash/plugin_mixins/scheduler/rufus_impl.rb', line 52 def terminate!; @impl.shutdown(:kill) end |