amit-temporalio 0.3.1-x86_64-linux-musl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +2 -0
- data/Gemfile +23 -0
- data/Rakefile +101 -0
- data/lib/temporalio/activity/complete_async_error.rb +11 -0
- data/lib/temporalio/activity/context.rb +116 -0
- data/lib/temporalio/activity/definition.rb +189 -0
- data/lib/temporalio/activity/info.rb +64 -0
- data/lib/temporalio/activity.rb +12 -0
- data/lib/temporalio/api/activity/v1/message.rb +25 -0
- data/lib/temporalio/api/batch/v1/message.rb +31 -0
- data/lib/temporalio/api/cloud/account/v1/message.rb +28 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +126 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/service.rb +25 -0
- data/lib/temporalio/api/cloud/cloudservice.rb +3 -0
- data/lib/temporalio/api/cloud/identity/v1/message.rb +41 -0
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +42 -0
- data/lib/temporalio/api/cloud/nexus/v1/message.rb +31 -0
- data/lib/temporalio/api/cloud/operation/v1/message.rb +28 -0
- data/lib/temporalio/api/cloud/region/v1/message.rb +24 -0
- data/lib/temporalio/api/cloud/resource/v1/message.rb +23 -0
- data/lib/temporalio/api/cloud/sink/v1/message.rb +24 -0
- data/lib/temporalio/api/cloud/usage/v1/message.rb +31 -0
- data/lib/temporalio/api/command/v1/message.rb +46 -0
- data/lib/temporalio/api/common/v1/grpc_status.rb +23 -0
- data/lib/temporalio/api/common/v1/message.rb +47 -0
- data/lib/temporalio/api/enums/v1/batch_operation.rb +22 -0
- data/lib/temporalio/api/enums/v1/command_type.rb +21 -0
- data/lib/temporalio/api/enums/v1/common.rb +26 -0
- data/lib/temporalio/api/enums/v1/event_type.rb +21 -0
- data/lib/temporalio/api/enums/v1/failed_cause.rb +26 -0
- data/lib/temporalio/api/enums/v1/namespace.rb +23 -0
- data/lib/temporalio/api/enums/v1/query.rb +22 -0
- data/lib/temporalio/api/enums/v1/reset.rb +23 -0
- data/lib/temporalio/api/enums/v1/schedule.rb +21 -0
- data/lib/temporalio/api/enums/v1/task_queue.rb +25 -0
- data/lib/temporalio/api/enums/v1/update.rb +22 -0
- data/lib/temporalio/api/enums/v1/workflow.rb +30 -0
- data/lib/temporalio/api/errordetails/v1/message.rb +42 -0
- data/lib/temporalio/api/export/v1/message.rb +24 -0
- data/lib/temporalio/api/failure/v1/message.rb +35 -0
- data/lib/temporalio/api/filter/v1/message.rb +27 -0
- data/lib/temporalio/api/history/v1/message.rb +90 -0
- data/lib/temporalio/api/namespace/v1/message.rb +31 -0
- data/lib/temporalio/api/nexus/v1/message.rb +40 -0
- data/lib/temporalio/api/operatorservice/v1/request_response.rb +49 -0
- data/lib/temporalio/api/operatorservice/v1/service.rb +23 -0
- data/lib/temporalio/api/operatorservice.rb +3 -0
- data/lib/temporalio/api/payload_visitor.rb +1513 -0
- data/lib/temporalio/api/protocol/v1/message.rb +23 -0
- data/lib/temporalio/api/query/v1/message.rb +27 -0
- data/lib/temporalio/api/replication/v1/message.rb +26 -0
- data/lib/temporalio/api/schedule/v1/message.rb +43 -0
- data/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb +25 -0
- data/lib/temporalio/api/sdk/v1/task_complete_metadata.rb +21 -0
- data/lib/temporalio/api/sdk/v1/user_metadata.rb +23 -0
- data/lib/temporalio/api/sdk/v1/workflow_metadata.rb +23 -0
- data/lib/temporalio/api/taskqueue/v1/message.rb +45 -0
- data/lib/temporalio/api/testservice/v1/request_response.rb +31 -0
- data/lib/temporalio/api/testservice/v1/service.rb +23 -0
- data/lib/temporalio/api/update/v1/message.rb +33 -0
- data/lib/temporalio/api/version/v1/message.rb +26 -0
- data/lib/temporalio/api/workflow/v1/message.rb +43 -0
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +204 -0
- data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
- data/lib/temporalio/api/workflowservice.rb +3 -0
- data/lib/temporalio/api.rb +14 -0
- data/lib/temporalio/cancellation.rb +170 -0
- data/lib/temporalio/client/activity_id_reference.rb +32 -0
- data/lib/temporalio/client/async_activity_handle.rb +85 -0
- data/lib/temporalio/client/connection/cloud_service.rb +726 -0
- data/lib/temporalio/client/connection/operator_service.rb +201 -0
- data/lib/temporalio/client/connection/service.rb +42 -0
- data/lib/temporalio/client/connection/test_service.rb +111 -0
- data/lib/temporalio/client/connection/workflow_service.rb +1041 -0
- data/lib/temporalio/client/connection.rb +316 -0
- data/lib/temporalio/client/interceptor.rb +416 -0
- data/lib/temporalio/client/schedule.rb +967 -0
- data/lib/temporalio/client/schedule_handle.rb +126 -0
- data/lib/temporalio/client/workflow_execution.rb +100 -0
- data/lib/temporalio/client/workflow_execution_count.rb +36 -0
- data/lib/temporalio/client/workflow_execution_status.rb +18 -0
- data/lib/temporalio/client/workflow_handle.rb +389 -0
- data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
- data/lib/temporalio/client/workflow_update_handle.rb +65 -0
- data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
- data/lib/temporalio/client.rb +484 -0
- data/lib/temporalio/common_enums.rb +41 -0
- data/lib/temporalio/converters/data_converter.rb +99 -0
- data/lib/temporalio/converters/failure_converter.rb +202 -0
- data/lib/temporalio/converters/payload_codec.rb +26 -0
- data/lib/temporalio/converters/payload_converter/binary_null.rb +34 -0
- data/lib/temporalio/converters/payload_converter/binary_plain.rb +35 -0
- data/lib/temporalio/converters/payload_converter/binary_protobuf.rb +42 -0
- data/lib/temporalio/converters/payload_converter/composite.rb +66 -0
- data/lib/temporalio/converters/payload_converter/encoding.rb +35 -0
- data/lib/temporalio/converters/payload_converter/json_plain.rb +44 -0
- data/lib/temporalio/converters/payload_converter/json_protobuf.rb +41 -0
- data/lib/temporalio/converters/payload_converter.rb +71 -0
- data/lib/temporalio/converters/raw_value.rb +20 -0
- data/lib/temporalio/converters.rb +9 -0
- data/lib/temporalio/error/failure.rb +219 -0
- data/lib/temporalio/error.rb +155 -0
- data/lib/temporalio/internal/bridge/3.2/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/3.3/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/3.4/temporalio_bridge.so +0 -0
- data/lib/temporalio/internal/bridge/api/activity_result/activity_result.rb +34 -0
- data/lib/temporalio/internal/bridge/api/activity_task/activity_task.rb +31 -0
- data/lib/temporalio/internal/bridge/api/child_workflow/child_workflow.rb +33 -0
- data/lib/temporalio/internal/bridge/api/common/common.rb +26 -0
- data/lib/temporalio/internal/bridge/api/core_interface.rb +40 -0
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
- data/lib/temporalio/internal/bridge/api/nexus/nexus.rb +33 -0
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +56 -0
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +57 -0
- data/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb +30 -0
- data/lib/temporalio/internal/bridge/api.rb +3 -0
- data/lib/temporalio/internal/bridge/client.rb +95 -0
- data/lib/temporalio/internal/bridge/runtime.rb +53 -0
- data/lib/temporalio/internal/bridge/testing.rb +66 -0
- data/lib/temporalio/internal/bridge/worker.rb +85 -0
- data/lib/temporalio/internal/bridge.rb +36 -0
- data/lib/temporalio/internal/client/implementation.rb +700 -0
- data/lib/temporalio/internal/metric.rb +122 -0
- data/lib/temporalio/internal/proto_utils.rb +133 -0
- data/lib/temporalio/internal/worker/activity_worker.rb +376 -0
- data/lib/temporalio/internal/worker/multi_runner.rb +213 -0
- data/lib/temporalio/internal/worker/workflow_instance/child_workflow_handle.rb +54 -0
- data/lib/temporalio/internal/worker/workflow_instance/context.rb +333 -0
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +44 -0
- data/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb +32 -0
- data/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb +22 -0
- data/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb +25 -0
- data/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb +41 -0
- data/lib/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rb +97 -0
- data/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb +62 -0
- data/lib/temporalio/internal/worker/workflow_instance/outbound_implementation.rb +415 -0
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb +37 -0
- data/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb +40 -0
- data/lib/temporalio/internal/worker/workflow_instance/scheduler.rb +163 -0
- data/lib/temporalio/internal/worker/workflow_instance.rb +730 -0
- data/lib/temporalio/internal/worker/workflow_worker.rb +236 -0
- data/lib/temporalio/internal.rb +7 -0
- data/lib/temporalio/metric.rb +109 -0
- data/lib/temporalio/retry_policy.rb +74 -0
- data/lib/temporalio/runtime.rb +314 -0
- data/lib/temporalio/scoped_logger.rb +96 -0
- data/lib/temporalio/search_attributes.rb +343 -0
- data/lib/temporalio/testing/activity_environment.rb +136 -0
- data/lib/temporalio/testing/workflow_environment.rb +383 -0
- data/lib/temporalio/testing.rb +10 -0
- data/lib/temporalio/version.rb +5 -0
- data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
- data/lib/temporalio/worker/activity_executor/thread_pool.rb +46 -0
- data/lib/temporalio/worker/activity_executor.rb +55 -0
- data/lib/temporalio/worker/interceptor.rb +362 -0
- data/lib/temporalio/worker/thread_pool.rb +237 -0
- data/lib/temporalio/worker/tuner.rb +189 -0
- data/lib/temporalio/worker/workflow_executor/thread_pool.rb +230 -0
- data/lib/temporalio/worker/workflow_executor.rb +26 -0
- data/lib/temporalio/worker/workflow_replayer.rb +343 -0
- data/lib/temporalio/worker.rb +569 -0
- data/lib/temporalio/workflow/activity_cancellation_type.rb +20 -0
- data/lib/temporalio/workflow/child_workflow_cancellation_type.rb +21 -0
- data/lib/temporalio/workflow/child_workflow_handle.rb +43 -0
- data/lib/temporalio/workflow/definition.rb +566 -0
- data/lib/temporalio/workflow/external_workflow_handle.rb +41 -0
- data/lib/temporalio/workflow/future.rb +151 -0
- data/lib/temporalio/workflow/handler_unfinished_policy.rb +13 -0
- data/lib/temporalio/workflow/info.rb +82 -0
- data/lib/temporalio/workflow/parent_close_policy.rb +19 -0
- data/lib/temporalio/workflow/update_info.rb +20 -0
- data/lib/temporalio/workflow.rb +529 -0
- data/lib/temporalio/workflow_history.rb +47 -0
- data/lib/temporalio.rb +11 -0
- data/temporalio.gemspec +28 -0
- metadata +238 -0
@@ -0,0 +1,316 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'socket'
|
4
|
+
require 'temporalio/client/connection/cloud_service'
|
5
|
+
require 'temporalio/client/connection/operator_service'
|
6
|
+
require 'temporalio/client/connection/workflow_service'
|
7
|
+
require 'temporalio/internal/bridge'
|
8
|
+
require 'temporalio/internal/bridge/client'
|
9
|
+
require 'temporalio/runtime'
|
10
|
+
require 'temporalio/version'
|
11
|
+
|
12
|
+
module Temporalio
|
13
|
+
class Client
|
14
|
+
# Connection to Temporal server that is not namespace specific. Most users will use {Client.connect} instead of this
|
15
|
+
# directly.
|
16
|
+
class Connection
|
17
|
+
Options = Data.define(
|
18
|
+
:target_host,
|
19
|
+
:api_key,
|
20
|
+
:tls,
|
21
|
+
:rpc_metadata,
|
22
|
+
:rpc_retry,
|
23
|
+
:identity,
|
24
|
+
:keep_alive,
|
25
|
+
:http_connect_proxy,
|
26
|
+
:runtime,
|
27
|
+
:lazy_connect
|
28
|
+
)
|
29
|
+
|
30
|
+
# Options as returned from {options} for +**to_h+ splat use in {initialize}. See {initialize} for details.
|
31
|
+
class Options; end # rubocop:disable Lint/EmptyClass
|
32
|
+
|
33
|
+
TLSOptions = Data.define(
|
34
|
+
:client_cert,
|
35
|
+
:client_private_key,
|
36
|
+
:server_root_ca_cert,
|
37
|
+
:domain
|
38
|
+
)
|
39
|
+
|
40
|
+
# TLS options. All attributes are optional, and an empty options set just enables default TLS.
|
41
|
+
#
|
42
|
+
# @!attribute client_cert
|
43
|
+
# @return [String, nil] Client certificate for mTLS. Must be combined with {client_private_key}.
|
44
|
+
# @!attribute client_private_key
|
45
|
+
# @return [String, nil] Client private key for mTLS. Must be combined with {client_cert}.
|
46
|
+
# @!attribute server_root_ca_cert
|
47
|
+
# @return [String, nil] Root CA certificate to validate the server certificate against. This is only needed for
|
48
|
+
# self-hosted servers with self-signed server certificates.
|
49
|
+
# @!attribute domain
|
50
|
+
# @return [String, nil] SNI override. This is only needed for self-hosted servers with certificates that do not
|
51
|
+
# match the hostname being connected to.
|
52
|
+
class TLSOptions
|
53
|
+
def initialize(
|
54
|
+
client_cert: nil,
|
55
|
+
client_private_key: nil,
|
56
|
+
server_root_ca_cert: nil,
|
57
|
+
domain: nil
|
58
|
+
)
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
RPCRetryOptions = Data.define(
|
64
|
+
:initial_interval,
|
65
|
+
:randomization_factor,
|
66
|
+
:multiplier,
|
67
|
+
:max_interval,
|
68
|
+
:max_elapsed_time,
|
69
|
+
:max_retries
|
70
|
+
)
|
71
|
+
|
72
|
+
# Retry options for server calls when retry is enabled (which it is by default on all high-level {Client} calls).
|
73
|
+
# For most users, the default is preferred.
|
74
|
+
#
|
75
|
+
# @!attribute initial_interval
|
76
|
+
# @return [Float] Initial backoff interval, default 0.1.
|
77
|
+
# @!attribute randomization_factor
|
78
|
+
# @return [Float] Randomization jitter to add, default 0.2.
|
79
|
+
# @!attribute multiplier
|
80
|
+
# @return [Float] Backoff multiplier, default 1.5.
|
81
|
+
# @!attribute max_interval
|
82
|
+
# @return [Float] Maximum backoff interval, default 5.0.
|
83
|
+
# @!attribute max_elapsed_time
|
84
|
+
# @return [Float] Maximum total time, default 10.0. Can use 0 for no max.
|
85
|
+
# @!attribute max_retries
|
86
|
+
# @return [Integer] Maximum number of retries, default 10.
|
87
|
+
class RPCRetryOptions
|
88
|
+
def initialize(
|
89
|
+
initial_interval: 0.1,
|
90
|
+
randomization_factor: 0.2,
|
91
|
+
multiplier: 1.5,
|
92
|
+
max_interval: 5.0,
|
93
|
+
max_elapsed_time: 10.0,
|
94
|
+
max_retries: 10
|
95
|
+
)
|
96
|
+
super
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
KeepAliveOptions = Data.define(
|
101
|
+
:interval,
|
102
|
+
:timeout
|
103
|
+
)
|
104
|
+
|
105
|
+
# Keep-alive options for client connections. For most users, the default is preferred.
|
106
|
+
#
|
107
|
+
# @!attribute interval
|
108
|
+
# @return [Float] Interval to send HTTP2 keep alive pings, default 30.0.
|
109
|
+
# @!attribute timeout
|
110
|
+
# @return [Float] Timeout that the keep alive must be responded to within or the connection will be closed,
|
111
|
+
# default 15.0.
|
112
|
+
class KeepAliveOptions
|
113
|
+
def initialize(interval: 30.0, timeout: 15.0)
|
114
|
+
super
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
HTTPConnectProxyOptions = Data.define(
|
119
|
+
:target_host,
|
120
|
+
:basic_auth_user,
|
121
|
+
:basic_auth_pass
|
122
|
+
)
|
123
|
+
|
124
|
+
# Options for HTTP CONNECT proxy for client connections.
|
125
|
+
#
|
126
|
+
# @!attribute target_host
|
127
|
+
# @return [String] Target host:port for the HTTP CONNECT proxy.
|
128
|
+
# @!attribute basic_auth_user
|
129
|
+
# @return [String, nil] User for HTTP basic auth for the proxy, must be combined with {basic_auth_pass}.
|
130
|
+
# @!attribute basic_auth_pass
|
131
|
+
# @return [String, nil] Pass for HTTP basic auth for the proxy, must be combined with {basic_auth_user}.
|
132
|
+
class HTTPConnectProxyOptions; end # rubocop:disable Lint/EmptyClass
|
133
|
+
|
134
|
+
# @return [Options] Frozen options for this client which has the same attributes as {initialize}. Note that if
|
135
|
+
# {api_key=} or {rpc_metadata=} are updated, the options object is replaced with those changes (it is not
|
136
|
+
# mutated in place).
|
137
|
+
attr_reader :options
|
138
|
+
|
139
|
+
# @return [WorkflowService] Raw gRPC workflow service.
|
140
|
+
attr_reader :workflow_service
|
141
|
+
|
142
|
+
# @return [OperatorService] Raw gRPC operator service.
|
143
|
+
attr_reader :operator_service
|
144
|
+
|
145
|
+
# @return [CloudService] Raw gRPC cloud service.
|
146
|
+
attr_reader :cloud_service
|
147
|
+
|
148
|
+
# Connect to Temporal server. Most users will use {Client.connect} instead of this directly. Parameters here match
|
149
|
+
# {Options} returned from {options} by intention so options can be dup'd, altered, splatted to create a new
|
150
|
+
# connection.
|
151
|
+
#
|
152
|
+
# @param target_host [String] +host:port+ for the Temporal server. For local development, this is often
|
153
|
+
# +localhost:7233+.
|
154
|
+
# @param api_key [String, nil] API key for Temporal. This becomes the +Authorization+ HTTP header with +"Bearer "+
|
155
|
+
# prepended. This is only set if RPC metadata doesn't already have an +authorization+ key.
|
156
|
+
# @param tls [Boolean, TLSOptions] If false, do not use TLS. If true, use system default TLS options. If TLS
|
157
|
+
# options are present, those TLS options will be used.
|
158
|
+
# @param rpc_metadata [Hash<String, String>] Headers to use for all calls to the server. Keys here can be
|
159
|
+
# overriden by per-call RPC metadata keys.
|
160
|
+
# @param rpc_retry [RPCRetryOptions] Retry options for direct service calls (when opted in) or all high-level
|
161
|
+
# calls made by this client (which all opt-in to retries by default).
|
162
|
+
# @param identity [String] Identity for this client.
|
163
|
+
# @param keep_alive [KeepAliveOptions] Keep-alive options for the client connection. Can be set to +nil+ to
|
164
|
+
# disable.
|
165
|
+
# @param http_connect_proxy [HTTPConnectProxyOptions, nil] Options for HTTP CONNECT proxy.
|
166
|
+
# @param runtime [Runtime] Runtime for this client.
|
167
|
+
# @param lazy_connect [Boolean] If true, there is no connection until the first call is attempted or a worker
|
168
|
+
# is created with it. Clients from lazy connections cannot be used for workers if they have not performed a
|
169
|
+
# connection.
|
170
|
+
#
|
171
|
+
# @see Client.connect
|
172
|
+
def initialize(
|
173
|
+
target_host:,
|
174
|
+
api_key: nil,
|
175
|
+
tls: false,
|
176
|
+
rpc_metadata: {},
|
177
|
+
rpc_retry: RPCRetryOptions.new,
|
178
|
+
identity: "#{Process.pid}@#{Socket.gethostname}",
|
179
|
+
keep_alive: KeepAliveOptions.new,
|
180
|
+
http_connect_proxy: nil,
|
181
|
+
runtime: Runtime.default,
|
182
|
+
lazy_connect: false
|
183
|
+
)
|
184
|
+
@options = Options.new(
|
185
|
+
target_host:,
|
186
|
+
api_key:,
|
187
|
+
tls:,
|
188
|
+
rpc_metadata:,
|
189
|
+
rpc_retry:,
|
190
|
+
identity:,
|
191
|
+
keep_alive:,
|
192
|
+
http_connect_proxy:,
|
193
|
+
runtime:,
|
194
|
+
lazy_connect:
|
195
|
+
).freeze
|
196
|
+
# Create core client now if not lazy
|
197
|
+
@core_client_mutex = Mutex.new
|
198
|
+
_core_client unless lazy_connect
|
199
|
+
# Create service instances
|
200
|
+
@workflow_service = WorkflowService.new(self)
|
201
|
+
@operator_service = OperatorService.new(self)
|
202
|
+
@cloud_service = CloudService.new(self)
|
203
|
+
end
|
204
|
+
|
205
|
+
# @return [String] Target host this connection is connected to.
|
206
|
+
def target_host
|
207
|
+
@options.target_host
|
208
|
+
end
|
209
|
+
|
210
|
+
# @return [String] Client identity.
|
211
|
+
def identity
|
212
|
+
@options.identity
|
213
|
+
end
|
214
|
+
|
215
|
+
# @return [Boolean] Whether this connection is connected. This is always `true` unless `lazy_connect` option was
|
216
|
+
# originally set, in which case this will be `false` until the first call is made.
|
217
|
+
def connected?
|
218
|
+
!@core_client.nil?
|
219
|
+
end
|
220
|
+
|
221
|
+
# @return [String, nil] API key. This is a shortcut for `options.api_key`.
|
222
|
+
def api_key
|
223
|
+
@options.api_key
|
224
|
+
end
|
225
|
+
|
226
|
+
# Set the API key for all future calls. This also makes a new object for {options} with the changes.
|
227
|
+
#
|
228
|
+
# @param new_key [String, nil] New API key.
|
229
|
+
def api_key=(new_key)
|
230
|
+
# Mutate the client if connected then mutate options
|
231
|
+
@core_client_mutex.synchronize do
|
232
|
+
@core_client&.update_api_key(new_key)
|
233
|
+
@options = @options.with(api_key: new_key)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# @return [Hash<String, String>] RPC metadata (aka HTTP headers). This is a shortcut for `options.rpc_metadata`.
|
238
|
+
def rpc_metadata
|
239
|
+
@options.rpc_metadata
|
240
|
+
end
|
241
|
+
|
242
|
+
# Set the RPC metadata (aka HTTP headers) for all future calls. This also makes a new object for {options} with
|
243
|
+
# the changes.
|
244
|
+
#
|
245
|
+
# @param rpc_metadata [Hash<String, String>] New API key.
|
246
|
+
def rpc_metadata=(rpc_metadata)
|
247
|
+
# Mutate the client if connected then mutate options
|
248
|
+
@core_client_mutex.synchronize do
|
249
|
+
@core_client&.update_metadata(rpc_metadata)
|
250
|
+
@options = @options.with(rpc_metadata: rpc_metadata)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# @!visibility private
|
255
|
+
def _core_client
|
256
|
+
# If lazy, this needs to be done under mutex
|
257
|
+
if @options.lazy_connect
|
258
|
+
@core_client_mutex.synchronize do
|
259
|
+
@core_client ||= new_core_client
|
260
|
+
end
|
261
|
+
else
|
262
|
+
@core_client ||= new_core_client
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
private
|
267
|
+
|
268
|
+
def new_core_client
|
269
|
+
Internal::Bridge.assert_fiber_compatibility!
|
270
|
+
|
271
|
+
options = Internal::Bridge::Client::Options.new(
|
272
|
+
target_host: @options.target_host,
|
273
|
+
client_name: 'temporal-ruby',
|
274
|
+
client_version: VERSION,
|
275
|
+
rpc_metadata: @options.rpc_metadata,
|
276
|
+
api_key: @options.api_key,
|
277
|
+
rpc_retry: Internal::Bridge::Client::RPCRetryOptions.new(
|
278
|
+
initial_interval: @options.rpc_retry.initial_interval,
|
279
|
+
randomization_factor: @options.rpc_retry.randomization_factor,
|
280
|
+
multiplier: @options.rpc_retry.multiplier,
|
281
|
+
max_interval: @options.rpc_retry.max_interval,
|
282
|
+
max_elapsed_time: @options.rpc_retry.max_elapsed_time,
|
283
|
+
max_retries: @options.rpc_retry.max_retries
|
284
|
+
),
|
285
|
+
identity: @options.identity || "#{Process.pid}@#{Socket.gethostname}"
|
286
|
+
)
|
287
|
+
if @options.tls
|
288
|
+
options.tls = if @options.tls.is_a?(TLSOptions)
|
289
|
+
Internal::Bridge::Client::TLSOptions.new(
|
290
|
+
client_cert: @options.tls.client_cert, # steep:ignore
|
291
|
+
client_private_key: @options.tls.client_private_key, # steep:ignore
|
292
|
+
server_root_ca_cert: @options.tls.server_root_ca_cert, # steep:ignore
|
293
|
+
domain: @options.tls.domain # steep:ignore
|
294
|
+
)
|
295
|
+
else
|
296
|
+
Internal::Bridge::Client::TLSOptions.new
|
297
|
+
end
|
298
|
+
end
|
299
|
+
if @options.keep_alive
|
300
|
+
options.keep_alive = Internal::Bridge::Client::KeepAliveOptions.new(
|
301
|
+
interval: @options.keep_alive.interval,
|
302
|
+
timeout: @options.keep_alive.timeout
|
303
|
+
)
|
304
|
+
end
|
305
|
+
if @options.http_connect_proxy
|
306
|
+
options.http_connect_proxy = Internal::Bridge::Client::HTTPConnectProxyOptions.new(
|
307
|
+
target_host: @options.http_connect_proxy.target_host,
|
308
|
+
basic_auth_user: @options.http_connect_proxy.basic_auth_user,
|
309
|
+
basic_auth_pass: @options.http_connect_proxy.basic_auth_pass
|
310
|
+
)
|
311
|
+
end
|
312
|
+
Internal::Bridge::Client.new(@options.runtime._core_runtime, options)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|