Class: Temporalio::SimplePlugin
- Inherits:
-
Object
- Object
- Temporalio::SimplePlugin
- Includes:
- Client::Plugin, Worker::Plugin
- Defined in:
- lib/temporalio/simple_plugin.rb
Overview
Plugin that implements both Client::Plugin and Worker::Plugin and provides a simplified common set of settings for configuring both.
WARNING: Plugins are experimental.
Defined Under Namespace
Classes: Options
Instance Attribute Summary collapse
-
#options ⇒ Options
readonly
Frozen options for this plugin which has the same attributes as #initialize.
Instance Method Summary collapse
-
#configure_client(options) ⇒ Object
Implements Client::Plugin#configure_client.
-
#configure_worker(options) ⇒ Object
Implements Worker::Plugin#configure_worker.
-
#configure_workflow_replayer(options) ⇒ Object
Implements Worker::Plugin#configure_workflow_replayer.
-
#connect_client(options, next_call) ⇒ Object
Implements Client::Plugin#connect_client.
-
#initialize(name:, data_converter: nil, client_interceptors: nil, activities: nil, workflows: nil, worker_interceptors: nil, workflow_failure_exception_types: nil, run_context: nil) ⇒ SimplePlugin
constructor
Create a simple plugin.
-
#name ⇒ Object
Implements Client::Plugin#name and Worker::Plugin#name.
-
#run_worker(options, next_call) ⇒ Object
Implements Worker::Plugin#run_worker.
-
#with_workflow_replay_worker(options, next_call) ⇒ Object
Implements Worker::Plugin#with_workflow_replay_worker.
Constructor Details
#initialize(name:, data_converter: nil, client_interceptors: nil, activities: nil, workflows: nil, worker_interceptors: nil, workflow_failure_exception_types: nil, run_context: nil) ⇒ SimplePlugin
Create a simple plugin.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/temporalio/simple_plugin.rb', line 56 def initialize( name:, data_converter: nil, client_interceptors: nil, activities: nil, workflows: nil, worker_interceptors: nil, workflow_failure_exception_types: nil, run_context: nil ) @options = Options.new( name:, data_converter:, client_interceptors:, activities:, workflows:, worker_interceptors:, workflow_failure_exception_types:, run_context: ).freeze end |
Instance Attribute Details
#options ⇒ Options (readonly)
Returns Frozen options for this plugin which has the same attributes as #initialize.
30 31 32 |
# File 'lib/temporalio/simple_plugin.rb', line 30 def @options end |
Instance Method Details
#configure_client(options) ⇒ Object
Implements Client::Plugin#configure_client.
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/temporalio/simple_plugin.rb', line 84 def configure_client() if (data_converter = _single_option(new: @options.data_converter, existing: .data_converter, type: Converters::DataConverter, name: 'data converter')) = .with(data_converter:) end if (interceptors = _array_option(new: @options.client_interceptors, existing: .interceptors, name: 'client interceptor')) = .with(interceptors:) end end |
#configure_worker(options) ⇒ Object
Implements Worker::Plugin#configure_worker.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/temporalio/simple_plugin.rb', line 102 def configure_worker() if (activities = _array_option(new: @options.activities, existing: .activities, name: 'activity')) = .with(activities:) end if (workflows = _array_option(new: @options.workflows, existing: .workflows, name: 'workflow')) = .with(workflows:) end if (interceptors = _array_option(new: @options.worker_interceptors, existing: .interceptors, name: 'worker interceptor')) = .with(interceptors:) end if (workflow_failure_exception_types = _array_option(new: @options.workflow_failure_exception_types, existing: .workflow_failure_exception_types, name: 'workflow failure exception types')) = .with(workflow_failure_exception_types:) end end |
#configure_workflow_replayer(options) ⇒ Object
Implements Worker::Plugin#configure_workflow_replayer.
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/temporalio/simple_plugin.rb', line 131 def configure_workflow_replayer() if (data_converter = _single_option(new: @options.data_converter, existing: .data_converter, type: Converters::DataConverter, name: 'data converter')) = .with(data_converter:) end if (workflows = _array_option(new: @options.workflows, existing: .workflows, name: 'workflow')) = .with(workflows:) end if (interceptors = _array_option(new: @options.worker_interceptors, existing: .interceptors, name: 'worker interceptor')) = .with(interceptors:) end if (workflow_failure_exception_types = _array_option(new: @options.workflow_failure_exception_types, existing: .workflow_failure_exception_types, name: 'workflow failure exception types')) = .with(workflow_failure_exception_types:) end end |
#connect_client(options, next_call) ⇒ Object
Implements Client::Plugin#connect_client.
97 98 99 |
# File 'lib/temporalio/simple_plugin.rb', line 97 def connect_client(, next_call) next_call.call() end |
#name ⇒ Object
Implements Client::Plugin#name and Worker::Plugin#name.
79 80 81 |
# File 'lib/temporalio/simple_plugin.rb', line 79 def name @options.name end |
#run_worker(options, next_call) ⇒ Object
Implements Worker::Plugin#run_worker.
122 123 124 125 126 127 128 |
# File 'lib/temporalio/simple_plugin.rb', line 122 def run_worker(, next_call) if @options.run_context @options.run_context.call(, next_call) # steep:ignore NoMethod else next_call.call() end end |
#with_workflow_replay_worker(options, next_call) ⇒ Object
Implements Worker::Plugin#with_workflow_replay_worker.
152 153 154 155 156 157 158 |
# File 'lib/temporalio/simple_plugin.rb', line 152 def with_workflow_replay_worker(, next_call) if @options.run_context @options.run_context.call(, next_call) # steep:ignore NoMethod else next_call.call() end end |