Class: ActiveJob::Temporal::ScheduleOptions
- Inherits:
-
Object
- Object
- ActiveJob::Temporal::ScheduleOptions
- Defined in:
- lib/activejob/temporal/schedule_options.rb
Constant Summary collapse
- OVERLAP_POLICIES =
{ skip: Temporalio::Client::Schedule::OverlapPolicy::SKIP, buffer: Temporalio::Client::Schedule::OverlapPolicy::BUFFER_ONE, buffer_one: Temporalio::Client::Schedule::OverlapPolicy::BUFFER_ONE, buffer_all: Temporalio::Client::Schedule::OverlapPolicy::BUFFER_ALL, allow_all: Temporalio::Client::Schedule::OverlapPolicy::ALLOW_ALL, cancel_other: Temporalio::Client::Schedule::OverlapPolicy::CANCEL_OTHER, terminate_other: Temporalio::Client::Schedule::OverlapPolicy::TERMINATE_OTHER }.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#cron_expressions ⇒ Object
readonly
Returns the value of attribute cron_expressions.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
-
#overlap_policy ⇒ Object
readonly
Returns the value of attribute overlap_policy.
-
#paused ⇒ Object
readonly
Returns the value of attribute paused.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#timezone ⇒ Object
readonly
Returns the value of attribute timezone.
-
#trigger_immediately ⇒ Object
readonly
Returns the value of attribute trigger_immediately.
Instance Method Summary collapse
- #cron ⇒ Object
-
#initialize(job_class, options) ⇒ ScheduleOptions
constructor
A new instance of ScheduleOptions.
- #temporal_overlap_policy ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(job_class, options) ⇒ ScheduleOptions
Returns a new instance of ScheduleOptions.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/activejob/temporal/schedule_options.rb', line 21 def initialize(job_class, ) = .transform_keys(&:to_sym) @job_class = job_class @id = normalize_id(.fetch(:id, default_id)) @cron_expressions = normalize_cron(.fetch(:cron)) @timezone = normalize_timezone(.fetch(:timezone, "UTC")) @overlap_policy = normalize_overlap_policy(.fetch(:overlap_policy, :skip)) @args = normalize_args(.fetch(:args, [])) @queue = [:queue]&.to_s @paused = .fetch(:paused, false) @trigger_immediately = .fetch(:trigger_immediately, false) end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def args @args end |
#cron_expressions ⇒ Object (readonly)
Returns the value of attribute cron_expressions.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def cron_expressions @cron_expressions end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def id @id end |
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def job_class @job_class end |
#overlap_policy ⇒ Object (readonly)
Returns the value of attribute overlap_policy.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def overlap_policy @overlap_policy end |
#paused ⇒ Object (readonly)
Returns the value of attribute paused.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def paused @paused end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def queue @queue end |
#timezone ⇒ Object (readonly)
Returns the value of attribute timezone.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def timezone @timezone end |
#trigger_immediately ⇒ Object (readonly)
Returns the value of attribute trigger_immediately.
18 19 20 |
# File 'lib/activejob/temporal/schedule_options.rb', line 18 def trigger_immediately @trigger_immediately end |
Instance Method Details
#cron ⇒ Object
35 36 37 38 39 |
# File 'lib/activejob/temporal/schedule_options.rb', line 35 def cron return cron_expressions.first if cron_expressions.one? cron_expressions end |
#temporal_overlap_policy ⇒ Object
41 42 43 |
# File 'lib/activejob/temporal/schedule_options.rb', line 41 def temporal_overlap_policy OVERLAP_POLICIES.fetch(overlap_policy) end |
#to_h ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/activejob/temporal/schedule_options.rb', line 45 def to_h { id: id, cron: cron, timezone: timezone, overlap_policy: overlap_policy, args: args, queue: queue, paused: paused, trigger_immediately: trigger_immediately } end |