Class: Temporalio::Worker::SyncWorker Private
- Inherits:
-
Object
- Object
- Temporalio::Worker::SyncWorker
- Defined in:
- lib/temporalio/worker/sync_worker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
This is a wrapper class for the Core Worker (provided via the Bridge) to abstract away its async nature allowing other modules/classes to interact with it without any callbacks (simplifying the code).
CAUTION: This class will block the thread its running in unless it is used from
within an Async reactor.
Instance Method Summary collapse
- #complete_activity_task_with_cancellation(task_token, failure) ⇒ Object private
- #complete_activity_task_with_failure(task_token, failure) ⇒ Object private
- #complete_activity_task_with_success(task_token, payload) ⇒ Object private
- #complete_workflow_activation_with_failure(run_id, failure) ⇒ Object private
- #complete_workflow_activation_with_success(run_id, commands) ⇒ Object private
-
#initialize(core_worker) ⇒ SyncWorker
constructor
private
A new instance of SyncWorker.
- #poll_activity_task ⇒ Object private
- #poll_workflow_activation ⇒ Object private
- #record_activity_heartbeat(task_token, payloads) ⇒ Object private
Constructor Details
#initialize(core_worker) ⇒ SyncWorker
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SyncWorker.
17 18 19 |
# File 'lib/temporalio/worker/sync_worker.rb', line 17 def initialize(core_worker) @core_worker = core_worker end |
Instance Method Details
#complete_activity_task_with_cancellation(task_token, failure) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 |
# File 'lib/temporalio/worker/sync_worker.rb', line 45 def complete_activity_task_with_cancellation(task_token, failure) result = Temporalio::Bridge::Api::ActivityResult::ActivityExecutionResult.new( cancelled: Temporalio::Bridge::Api::ActivityResult::Cancellation.new(failure: failure), ) complete_activity_task(task_token, result) end |
#complete_activity_task_with_failure(task_token, failure) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 |
# File 'lib/temporalio/worker/sync_worker.rb', line 37 def complete_activity_task_with_failure(task_token, failure) result = Temporalio::Bridge::Api::ActivityResult::ActivityExecutionResult.new( failed: Temporalio::Bridge::Api::ActivityResult::Failure.new(failure: failure), ) complete_activity_task(task_token, result) end |
#complete_activity_task_with_success(task_token, payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 32 33 34 35 |
# File 'lib/temporalio/worker/sync_worker.rb', line 29 def complete_activity_task_with_success(task_token, payload) result = Temporalio::Bridge::Api::ActivityResult::ActivityExecutionResult.new( completed: Temporalio::Bridge::Api::ActivityResult::Success.new(result: payload), ) complete_activity_task(task_token, result) end |
#complete_workflow_activation_with_failure(run_id, failure) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
80 81 82 83 84 85 86 87 |
# File 'lib/temporalio/worker/sync_worker.rb', line 80 def complete_workflow_activation_with_failure(run_id, failure) proto = Temporalio::Bridge::Api::WorkflowCompletion::WorkflowActivationCompletion.new( run_id: run_id, failed: Temporalio::Bridge::Api::WorkflowCompletion::Failure.new(failure: failure), ) complete_workflow_activation(proto) end |
#complete_workflow_activation_with_success(run_id, commands) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 74 75 76 77 78 |
# File 'lib/temporalio/worker/sync_worker.rb', line 71 def complete_workflow_activation_with_success(run_id, commands) proto = Temporalio::Bridge::Api::WorkflowCompletion::WorkflowActivationCompletion.new( run_id: run_id, successful: Temporalio::Bridge::Api::WorkflowCompletion::Success.new(commands: commands), ) complete_workflow_activation(proto) end |
#poll_activity_task ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
21 22 23 24 25 26 27 |
# File 'lib/temporalio/worker/sync_worker.rb', line 21 def poll_activity_task with_queue do |done| core_worker.poll_activity_task do |task, error| done.call(task && Temporalio::Bridge::Api::ActivityTask::ActivityTask.decode(task), error) end end end |
#poll_workflow_activation ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 66 67 68 69 |
# File 'lib/temporalio/worker/sync_worker.rb', line 63 def poll_workflow_activation with_queue do |done| core_worker.poll_workflow_activation do |task, error| done.call(task && Temporalio::Bridge::Api::WorkflowActivation::WorkflowActivation.decode(task), error) end end end |
#record_activity_heartbeat(task_token, payloads) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 56 57 58 59 60 61 |
# File 'lib/temporalio/worker/sync_worker.rb', line 53 def record_activity_heartbeat(task_token, payloads) proto = Temporalio::Bridge::Api::CoreInterface::ActivityHeartbeat.new( task_token: task_token, details: payloads, ) encoded_proto = Temporalio::Bridge::Api::CoreInterface::ActivityHeartbeat.encode(proto) core_worker.record_activity_heartbeat(encoded_proto) end |