Class: Schked::ScheduleDSL
- Inherits:
-
Object
- Object
- Schked::ScheduleDSL
- Defined in:
- lib/schked/schedule_dsl.rb
Overview
Wraps the rufus-scheduler DSL so deduplication mode (+job_run_store+ is
configured) makes every jobs grid-aligned (via injected first_at) and
rejects interval jobs (their phase drifts with job duration and cannot
be deduplicated).
In the default (non-dedup) mode the wrapper is transparent and forwards every call to the underlying scheduler.
Defined Under Namespace
Classes: IntervalNotSupportedError
Instance Attribute Summary collapse
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Instance Method Summary collapse
-
#initialize(scheduler:, dedup_enabled:, max_skew_seconds: 60, logger: Logger.new(File::NULL)) ⇒ ScheduleDSL
constructor
A new instance of ScheduleDSL.
- #method_missing(name, *args, **kwargs, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(scheduler:, dedup_enabled:, max_skew_seconds: 60, logger: Logger.new(File::NULL)) ⇒ ScheduleDSL
Returns a new instance of ScheduleDSL.
18 19 20 21 22 23 |
# File 'lib/schked/schedule_dsl.rb', line 18 def initialize(scheduler:, dedup_enabled:, max_skew_seconds: 60, logger: Logger.new(File::NULL)) @scheduler = scheduler @dedup_enabled = dedup_enabled @max_skew_seconds = Integer(max_skew_seconds) @logger = logger end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, **kwargs, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/schked/schedule_dsl.rb', line 29 def method_missing(name, *args, **kwargs, &block) case name when :every every_with_alignment(*args, **kwargs, &block) when :interval raise IntervalNotSupportedError, if @dedup_enabled @scheduler.interval(*args, **kwargs, &block) else @scheduler.public_send(name, *args, **kwargs, &block) end end |
Instance Attribute Details
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
16 17 18 |
# File 'lib/schked/schedule_dsl.rb', line 16 def scheduler @scheduler end |
Instance Method Details
#respond_to_missing?(name, include_private = false) ⇒ Boolean
25 26 27 |
# File 'lib/schked/schedule_dsl.rb', line 25 def respond_to_missing?(name, include_private = false) @scheduler.respond_to?(name, include_private) || super end |