Class: Temporalio::Worker::ActivityRunner Private
- Inherits:
-
Object
- Object
- Temporalio::Worker::ActivityRunner
- Defined in:
- lib/temporalio/worker/activity_runner.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.
The main class for handling activity processing. It is expected to be executed from some threaded or async executor’s context since methods called here might be blocking and this should not affect the main worker reactor.
Instance Method Summary collapse
- #cancel(reason, by_request:) ⇒ Object private
-
#initialize(activity_class, start, task_queue, task_token, worker, converter, inbound_interceptors, outbound_interceptors) ⇒ ActivityRunner
constructor
private
A new instance of ActivityRunner.
- #run ⇒ Object private
Constructor Details
#initialize(activity_class, start, task_queue, task_token, worker, converter, inbound_interceptors, outbound_interceptors) ⇒ ActivityRunner
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 ActivityRunner.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/temporalio/worker/activity_runner.rb', line 16 def initialize( activity_class, start, task_queue, task_token, worker, converter, inbound_interceptors, outbound_interceptors ) @activity_class = activity_class @start = start @task_queue = task_queue @task_token = task_token @worker = worker @converter = converter @inbound_interceptors = inbound_interceptors @outbound_interceptors = outbound_interceptors end |
Instance Method Details
#cancel(reason, by_request:) ⇒ 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.
65 66 67 |
# File 'lib/temporalio/worker/activity_runner.rb', line 65 def cancel(reason, by_request:) context.cancel(reason, by_request: by_request) end |
#run ⇒ 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.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/temporalio/worker/activity_runner.rb', line 36 def run activity = activity_class.new(context) args = converter.from_payload_array(start.input.to_a) headers = converter.from_payload_map(start.header_fields) input = Temporalio::Interceptor::ActivityInbound::ExecuteActivityInput.new( activity: activity_class, args: args, headers: headers || {}, ) result = inbound_interceptors.invoke(:execute_activity, input) do |i| activity.execute(*i.args) end converter.to_payload(result) rescue StandardError => e # Temporal server ignores cancellation failures that were not requested by the server. # However within the SDK cancellations are also used during the worker shutdown. In order # to provide a seamless handling experience (same error raised within the Activity) we are # using the ActivityCancelled error and then swapping it with a CancelledError here. # # In the future this will be handled by the SDK Core — https://github.com/temporalio/sdk-core/issues/461 if e.is_a?(Temporalio::Error::ActivityCancelled) && e.by_request? e = Temporalio::Error::CancelledError.new(e.) end converter.to_failure(e) end |