Class: ActiveJob::Temporal::Schedule
- Inherits:
-
Object
- Object
- ActiveJob::Temporal::Schedule
- Defined in:
- lib/activejob/temporal/schedule.rb
Instance Attribute Summary collapse
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
Instance Method Summary collapse
- #args ⇒ Object
- #create ⇒ Object
- #cron ⇒ Object
- #cron_expressions ⇒ Object
- #handle ⇒ Object
- #id ⇒ Object
-
#initialize(job_class, options = {}) ⇒ Schedule
constructor
A new instance of Schedule.
- #options ⇒ Object
- #overlap_policy ⇒ Object
- #paused ⇒ Object
- #queue ⇒ Object
- #timezone ⇒ Object
- #to_temporal_schedule ⇒ Object
- #trigger_immediately ⇒ Object
Constructor Details
#initialize(job_class, options = {}) ⇒ Schedule
Returns a new instance of Schedule.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/activejob/temporal/schedule.rb', line 19 def initialize(job_class, = {}) = .transform_keys(&:to_sym) client = .delete(:client) config = .delete(:config) || ActiveJob::Temporal.config payload_builder = .delete(:payload_builder) @job_class = job_class @options = ScheduleOptions.new(job_class, ) @client = client @config = config @payload_builder = payload_builder || JobPayloadBuilder.new(config) end |
Instance Attribute Details
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
17 18 19 |
# File 'lib/activejob/temporal/schedule.rb', line 17 def job_class @job_class end |
Instance Method Details
#args ⇒ Object
40 |
# File 'lib/activejob/temporal/schedule.rb', line 40 def args = @options.args |
#create ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/activejob/temporal/schedule.rb', line 52 def create temporal_schedule = to_temporal_schedule handle = client.create_schedule( id, temporal_schedule, trigger_immediately: trigger_immediately, memo: nil, search_attributes: nil ) log_created(task_queue: temporal_schedule.action.task_queue, duplicate: false) handle rescue StandardError => e raise unless schedule_already_running?(e) handle_existing_schedule end |
#cron ⇒ Object
48 49 50 |
# File 'lib/activejob/temporal/schedule.rb', line 48 def cron @options.cron end |
#cron_expressions ⇒ Object
34 |
# File 'lib/activejob/temporal/schedule.rb', line 34 def cron_expressions = @options.cron_expressions |
#handle ⇒ Object
69 70 71 |
# File 'lib/activejob/temporal/schedule.rb', line 69 def handle client.schedule_handle(id) end |
#id ⇒ Object
32 |
# File 'lib/activejob/temporal/schedule.rb', line 32 def id = @options.id |
#options ⇒ Object
73 74 75 |
# File 'lib/activejob/temporal/schedule.rb', line 73 def @options.to_h end |
#overlap_policy ⇒ Object
38 |
# File 'lib/activejob/temporal/schedule.rb', line 38 def overlap_policy = @options.overlap_policy |
#paused ⇒ Object
44 |
# File 'lib/activejob/temporal/schedule.rb', line 44 def paused = @options.paused |
#queue ⇒ Object
42 |
# File 'lib/activejob/temporal/schedule.rb', line 42 def queue = @options.queue |
#timezone ⇒ Object
36 |
# File 'lib/activejob/temporal/schedule.rb', line 36 def timezone = @options.timezone |
#to_temporal_schedule ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/activejob/temporal/schedule.rb', line 77 def to_temporal_schedule Temporalio::Client::Schedule.new( action: schedule_action, spec: schedule_spec, policy: schedule_policy, state: schedule_state ) end |
#trigger_immediately ⇒ Object
46 |
# File 'lib/activejob/temporal/schedule.rb', line 46 def trigger_immediately = @options.trigger_immediately |