temporalio 0.4.0-aarch64-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 +27 -0
- data/Rakefile +101 -0
- data/lib/temporalio/activity/complete_async_error.rb +11 -0
- data/lib/temporalio/activity/context.rb +123 -0
- data/lib/temporalio/activity/definition.rb +192 -0
- data/lib/temporalio/activity/info.rb +67 -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 +36 -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 +48 -0
- data/lib/temporalio/api/deployment/v1/message.rb +38 -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/deployment.rb +23 -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/nexus.rb +21 -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 +31 -0
- data/lib/temporalio/api/errordetails/v1/message.rb +44 -0
- data/lib/temporalio/api/export/v1/message.rb +24 -0
- data/lib/temporalio/api/failure/v1/message.rb +37 -0
- data/lib/temporalio/api/filter/v1/message.rb +27 -0
- data/lib/temporalio/api/history/v1/message.rb +92 -0
- data/lib/temporalio/api/namespace/v1/message.rb +31 -0
- data/lib/temporalio/api/nexus/v1/message.rb +41 -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 +1581 -0
- data/lib/temporalio/api/protocol/v1/message.rb +23 -0
- data/lib/temporalio/api/query/v1/message.rb +28 -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 +48 -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 +51 -0
- data/lib/temporalio/api/workflowservice/v1/request_response.rb +233 -0
- data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
- data/lib/temporalio/api/workflowservice.rb +3 -0
- data/lib/temporalio/api.rb +15 -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 +1251 -0
- data/lib/temporalio/client/connection.rb +316 -0
- data/lib/temporalio/client/interceptor.rb +455 -0
- data/lib/temporalio/client/schedule.rb +991 -0
- data/lib/temporalio/client/schedule_handle.rb +126 -0
- data/lib/temporalio/client/with_start_workflow_operation.rb +115 -0
- data/lib/temporalio/client/workflow_execution.rb +119 -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 +607 -0
- data/lib/temporalio/common_enums.rb +41 -0
- data/lib/temporalio/contrib/open_telemetry.rb +470 -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 +156 -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 +27 -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 +31 -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 +56 -0
- data/lib/temporalio/internal/bridge/testing.rb +69 -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 +922 -0
- data/lib/temporalio/internal/metric.rb +122 -0
- data/lib/temporalio/internal/proto_utils.rb +165 -0
- data/lib/temporalio/internal/worker/activity_worker.rb +385 -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 +383 -0
- data/lib/temporalio/internal/worker/workflow_instance/details.rb +46 -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 +400 -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 +183 -0
- data/lib/temporalio/internal/worker/workflow_instance.rb +774 -0
- data/lib/temporalio/internal/worker/workflow_worker.rb +239 -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/metric_buffer.rb +94 -0
- data/lib/temporalio/runtime.rb +352 -0
- data/lib/temporalio/scoped_logger.rb +96 -0
- data/lib/temporalio/search_attributes.rb +356 -0
- data/lib/temporalio/testing/activity_environment.rb +160 -0
- data/lib/temporalio/testing/workflow_environment.rb +406 -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 +365 -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 +235 -0
- data/lib/temporalio/worker/workflow_executor.rb +26 -0
- data/lib/temporalio/worker/workflow_replayer.rb +350 -0
- data/lib/temporalio/worker.rb +603 -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 +598 -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 +104 -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 +575 -0
- data/lib/temporalio/workflow_history.rb +47 -0
- data/lib/temporalio.rb +11 -0
- data/temporalio.gemspec +29 -0
- metadata +258 -0
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/client/interceptor'
|
4
|
+
require 'temporalio/client/schedule'
|
5
|
+
|
6
|
+
module Temporalio
|
7
|
+
class Client
|
8
|
+
# Handle for interacting with a schedule. This is usually created via {Client.create_schedule} or
|
9
|
+
# {Client.schedule_handle}.
|
10
|
+
class ScheduleHandle
|
11
|
+
# @return [String] ID of the schedule.
|
12
|
+
attr_reader :id
|
13
|
+
|
14
|
+
# @!visibility private
|
15
|
+
def initialize(client:, id:)
|
16
|
+
@client = client
|
17
|
+
@id = id
|
18
|
+
end
|
19
|
+
|
20
|
+
# Backfill the schedule by going through the specified time periods as if they passed right now.
|
21
|
+
#
|
22
|
+
# @param backfills [Array<Schedule::Backfill>] Backfill periods.
|
23
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
24
|
+
#
|
25
|
+
# @raise [Error::RPCError] RPC error from call.
|
26
|
+
def backfill(
|
27
|
+
*backfills,
|
28
|
+
rpc_options: nil
|
29
|
+
)
|
30
|
+
raise ArgumentError, 'At least one backfill required' if backfills.empty?
|
31
|
+
|
32
|
+
@client._impl.backfill_schedule(Interceptor::BackfillScheduleInput.new(
|
33
|
+
id:,
|
34
|
+
backfills:,
|
35
|
+
rpc_options:
|
36
|
+
))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Delete this schedule.
|
40
|
+
#
|
41
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
42
|
+
#
|
43
|
+
# @raise [Error::RPCError] RPC error from call.
|
44
|
+
def delete(rpc_options: nil)
|
45
|
+
@client._impl.delete_schedule(Interceptor::DeleteScheduleInput.new(
|
46
|
+
id:,
|
47
|
+
rpc_options:
|
48
|
+
))
|
49
|
+
end
|
50
|
+
|
51
|
+
# Fetch this schedule's description.
|
52
|
+
#
|
53
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
54
|
+
#
|
55
|
+
# @return [Schedule::Description] Schedule description.
|
56
|
+
# @raise [Error::RPCError] RPC error from call.
|
57
|
+
def describe(rpc_options: nil)
|
58
|
+
@client._impl.describe_schedule(Interceptor::DescribeScheduleInput.new(
|
59
|
+
id:,
|
60
|
+
rpc_options:
|
61
|
+
))
|
62
|
+
end
|
63
|
+
|
64
|
+
# Pause the schedule and set a note.
|
65
|
+
#
|
66
|
+
# @param note [String] Note to set on the schedule.
|
67
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
68
|
+
#
|
69
|
+
# @raise [Error::RPCError] RPC error from call.
|
70
|
+
def pause(note: 'Paused via Ruby SDK', rpc_options: nil)
|
71
|
+
@client._impl.pause_schedule(Interceptor::PauseScheduleInput.new(
|
72
|
+
id:,
|
73
|
+
note:,
|
74
|
+
rpc_options:
|
75
|
+
))
|
76
|
+
end
|
77
|
+
|
78
|
+
# Trigger an action on this schedule to happen immediately.
|
79
|
+
#
|
80
|
+
# @param overlap [Schedule::OverlapPolicy, nil] If set, overrides the schedule's overlap policy.
|
81
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
82
|
+
#
|
83
|
+
# @raise [Error::RPCError] RPC error from call.
|
84
|
+
def trigger(overlap: nil, rpc_options: nil)
|
85
|
+
@client._impl.trigger_schedule(Interceptor::TriggerScheduleInput.new(
|
86
|
+
id:,
|
87
|
+
overlap:,
|
88
|
+
rpc_options:
|
89
|
+
))
|
90
|
+
end
|
91
|
+
|
92
|
+
# Unpause the schedule and set a note.
|
93
|
+
#
|
94
|
+
# @param note [String] Note to set on the schedule.
|
95
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
96
|
+
#
|
97
|
+
# @raise [Error::RPCError] RPC error from call.
|
98
|
+
def unpause(note: 'Unpaused via Ruby SDK', rpc_options: nil)
|
99
|
+
@client._impl.unpause_schedule(Interceptor::UnpauseScheduleInput.new(
|
100
|
+
id:,
|
101
|
+
note:,
|
102
|
+
rpc_options:
|
103
|
+
))
|
104
|
+
end
|
105
|
+
|
106
|
+
# Update a schedule using a callback to build the update from the description.
|
107
|
+
#
|
108
|
+
# NOTE: In future versions, the callback may be invoked multiple times in a conflict-resolution loop.
|
109
|
+
#
|
110
|
+
# @param rpc_options [RPCOptions, nil] Advanced RPC options.
|
111
|
+
# @yield Block called to obtain the update.
|
112
|
+
# @yieldparam [Schedule::Update::Input] Parameter to the block that contains a description with the schedule to be
|
113
|
+
# updated.
|
114
|
+
# @yieldreturn [Schedule::Update, nil] The update to apply, or `nil` to not perform an update.
|
115
|
+
#
|
116
|
+
# @raise [Error::RPCError] RPC error from call.
|
117
|
+
def update(rpc_options: nil, &updater)
|
118
|
+
@client._impl.update_schedule(Interceptor::UpdateScheduleInput.new(
|
119
|
+
id:,
|
120
|
+
updater:,
|
121
|
+
rpc_options:
|
122
|
+
))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/common_enums'
|
4
|
+
|
5
|
+
module Temporalio
|
6
|
+
class Client
|
7
|
+
# Start operation used by {Client.start_update_with_start_workflow}, {Client.execute_update_with_start_workflow},
|
8
|
+
# and {Client.signal_with_start_workflow}.
|
9
|
+
class WithStartWorkflowOperation
|
10
|
+
Options = Data.define(
|
11
|
+
:workflow,
|
12
|
+
:args,
|
13
|
+
:id,
|
14
|
+
:task_queue,
|
15
|
+
:static_summary,
|
16
|
+
:static_details,
|
17
|
+
:execution_timeout,
|
18
|
+
:run_timeout,
|
19
|
+
:task_timeout,
|
20
|
+
:id_reuse_policy,
|
21
|
+
:id_conflict_policy,
|
22
|
+
:retry_policy,
|
23
|
+
:cron_schedule,
|
24
|
+
:memo,
|
25
|
+
:search_attributes,
|
26
|
+
:start_delay,
|
27
|
+
:headers
|
28
|
+
)
|
29
|
+
|
30
|
+
# Options the operation was created with.
|
31
|
+
class Options; end # rubocop:disable Lint/EmptyClass
|
32
|
+
|
33
|
+
# @return [Options] Options the operation was created with.
|
34
|
+
attr_accessor :options
|
35
|
+
|
36
|
+
# Create a with-start workflow operation. These are mostly the same options as {Client.start_workflow}, see that
|
37
|
+
# documentation for more details.
|
38
|
+
#
|
39
|
+
# Note, for {Client.start_update_with_start_workflow} and {Client.execute_update_with_start_workflow},
|
40
|
+
# `id_conflict_policy` is required.
|
41
|
+
def initialize(
|
42
|
+
workflow,
|
43
|
+
*args,
|
44
|
+
id:,
|
45
|
+
task_queue:,
|
46
|
+
static_summary: nil,
|
47
|
+
static_details: nil,
|
48
|
+
execution_timeout: nil,
|
49
|
+
run_timeout: nil,
|
50
|
+
task_timeout: nil,
|
51
|
+
id_reuse_policy: WorkflowIDReusePolicy::ALLOW_DUPLICATE,
|
52
|
+
id_conflict_policy: WorkflowIDConflictPolicy::UNSPECIFIED,
|
53
|
+
retry_policy: nil,
|
54
|
+
cron_schedule: nil,
|
55
|
+
memo: nil,
|
56
|
+
search_attributes: nil,
|
57
|
+
start_delay: nil,
|
58
|
+
headers: {}
|
59
|
+
)
|
60
|
+
@options = Options.new(
|
61
|
+
workflow: Workflow::Definition._workflow_type_from_workflow_parameter(workflow),
|
62
|
+
args:,
|
63
|
+
id:,
|
64
|
+
task_queue:,
|
65
|
+
static_summary:,
|
66
|
+
static_details:,
|
67
|
+
execution_timeout:,
|
68
|
+
run_timeout:,
|
69
|
+
task_timeout:,
|
70
|
+
id_reuse_policy:,
|
71
|
+
id_conflict_policy:,
|
72
|
+
retry_policy:,
|
73
|
+
cron_schedule:,
|
74
|
+
memo:,
|
75
|
+
search_attributes:,
|
76
|
+
start_delay:,
|
77
|
+
headers:
|
78
|
+
)
|
79
|
+
@workflow_handle_mutex = Mutex.new
|
80
|
+
@workflow_handle_cond_var = ConditionVariable.new
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get the workflow handle, possibly waiting until set, or raise an error if the workflow start was unsuccessful.
|
84
|
+
#
|
85
|
+
# @param wait [Boolean] True to wait until it is set, false to return immediately.
|
86
|
+
#
|
87
|
+
# @return [WorkflowHandle, nil] The workflow handle when available or `nil` if `wait` is false and it is not set
|
88
|
+
# yet.
|
89
|
+
# @raise [Error] Any error that occurred during the call before the workflow start returned.
|
90
|
+
def workflow_handle(wait: true)
|
91
|
+
@workflow_handle_mutex.synchronize do
|
92
|
+
@workflow_handle_cond_var.wait(@workflow_handle_mutex) unless @workflow_handle || !wait
|
93
|
+
raise @workflow_handle if @workflow_handle.is_a?(Exception)
|
94
|
+
|
95
|
+
@workflow_handle
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# @!visibility private
|
100
|
+
def _set_workflow_handle(value)
|
101
|
+
@workflow_handle_mutex.synchronize do
|
102
|
+
@workflow_handle ||= value
|
103
|
+
@workflow_handle_cond_var.broadcast
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# @!visibility private
|
108
|
+
def _mark_used
|
109
|
+
raise 'Start operation already used' if @in_use
|
110
|
+
|
111
|
+
@in_use = true
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/api'
|
4
|
+
require 'temporalio/client/workflow_execution_status'
|
5
|
+
require 'temporalio/internal/proto_utils'
|
6
|
+
require 'temporalio/search_attributes'
|
7
|
+
|
8
|
+
module Temporalio
|
9
|
+
class Client
|
10
|
+
# Info for a single workflow execution run.
|
11
|
+
class WorkflowExecution
|
12
|
+
# @return [Api::Workflow::V1::WorkflowExecutionInfo] Underlying protobuf info.
|
13
|
+
attr_reader :raw_info
|
14
|
+
|
15
|
+
# @!visibility private
|
16
|
+
def initialize(raw_info, data_converter)
|
17
|
+
@raw_info = raw_info
|
18
|
+
@memo = Internal::ProtoUtils::LazyMemo.new(raw_info.memo, data_converter)
|
19
|
+
@search_attributes = Internal::ProtoUtils::LazySearchAttributes.new(raw_info.search_attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @return [Time, nil] When the workflow was closed if closed.
|
23
|
+
def close_time
|
24
|
+
Internal::ProtoUtils.timestamp_to_time(@raw_info.close_time)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Time, nil] When this workflow run started or should start.
|
28
|
+
def execution_time
|
29
|
+
Internal::ProtoUtils.timestamp_to_time(@raw_info.execution_time)
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [Integer] Number of events in the history.
|
33
|
+
def history_length
|
34
|
+
@raw_info.history_length
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [String] ID for the workflow.
|
38
|
+
def id
|
39
|
+
@raw_info.execution.workflow_id
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Hash<String, Object>, nil] Memo for the workflow.
|
43
|
+
def memo
|
44
|
+
@memo.get
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [String, nil] ID for the parent workflow if this was started as a child.
|
48
|
+
def parent_id
|
49
|
+
@raw_info.parent_execution&.workflow_id
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [String, nil] Run ID for the parent workflow if this was started as a child.
|
53
|
+
def parent_run_id
|
54
|
+
@raw_info.parent_execution&.run_id
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [String] Run ID for this workflow run.
|
58
|
+
def run_id
|
59
|
+
@raw_info.execution.run_id
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [SearchAttributes, nil] Current set of search attributes if any.
|
63
|
+
def search_attributes
|
64
|
+
@search_attributes.get
|
65
|
+
end
|
66
|
+
|
67
|
+
# @return [Time] When the workflow was created.
|
68
|
+
def start_time
|
69
|
+
Internal::ProtoUtils.timestamp_to_time(@raw_info.start_time) || raise # Never nil
|
70
|
+
end
|
71
|
+
|
72
|
+
# @return [WorkflowExecutionStatus] Status for the workflow.
|
73
|
+
def status
|
74
|
+
Internal::ProtoUtils.enum_to_int(Api::Enums::V1::WorkflowExecutionStatus, @raw_info.status)
|
75
|
+
end
|
76
|
+
|
77
|
+
# @return [String] Task queue for the workflow.
|
78
|
+
def task_queue
|
79
|
+
@raw_info.task_queue
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [String] Type name for the workflow.
|
83
|
+
def workflow_type
|
84
|
+
@raw_info.type.name
|
85
|
+
end
|
86
|
+
|
87
|
+
# Description for a single workflow execution run.
|
88
|
+
class Description < WorkflowExecution
|
89
|
+
# @return [Api::WorkflowService::V1::DescribeWorkflowExecutionResponse] Underlying protobuf description.
|
90
|
+
attr_reader :raw_description
|
91
|
+
|
92
|
+
# @!visibility private
|
93
|
+
def initialize(raw_description, data_converter)
|
94
|
+
super(raw_description.workflow_execution_info, data_converter)
|
95
|
+
@raw_description = raw_description
|
96
|
+
@data_converter = data_converter
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [String, nil] Static summary configured on the workflow. This is currently experimental.
|
100
|
+
def static_summary
|
101
|
+
user_metadata.first
|
102
|
+
end
|
103
|
+
|
104
|
+
# @return [String, nil] Static details configured on the workflow. This is currently experimental.
|
105
|
+
def static_details
|
106
|
+
user_metadata.last
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def user_metadata
|
112
|
+
@user_metadata ||= Internal::ProtoUtils.from_user_metadata(
|
113
|
+
@raw_description.execution_config&.user_metadata, @data_converter
|
114
|
+
)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Temporalio
|
4
|
+
class Client
|
5
|
+
# Representation of a count from a count workflows call.
|
6
|
+
class WorkflowExecutionCount
|
7
|
+
# @return [Integer] Approximate number of workflows matching the original query. If the query had a group-by
|
8
|
+
# clause, this is simply the sum of all the counts in {groups}.
|
9
|
+
attr_reader :count
|
10
|
+
|
11
|
+
# @return [Array<AggregationGroup>] Groups if the query had a group-by clause, or empty if not.
|
12
|
+
attr_reader :groups
|
13
|
+
|
14
|
+
# @!visibility private
|
15
|
+
def initialize(count, groups)
|
16
|
+
@count = count
|
17
|
+
@groups = groups
|
18
|
+
end
|
19
|
+
|
20
|
+
# Aggregation group if the workflow count query had a group-by clause.
|
21
|
+
class AggregationGroup
|
22
|
+
# @return [Integer] Approximate number of workflows matching the original query for this group.
|
23
|
+
attr_reader :count
|
24
|
+
|
25
|
+
# @return [Array<Object>] Search attribute values for this group.
|
26
|
+
attr_reader :group_values
|
27
|
+
|
28
|
+
# @!visibility private
|
29
|
+
def initialize(count, group_values)
|
30
|
+
@count = count
|
31
|
+
@group_values = group_values
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'temporalio/api'
|
4
|
+
|
5
|
+
module Temporalio
|
6
|
+
class Client
|
7
|
+
# Status of a workflow execution.
|
8
|
+
module WorkflowExecutionStatus
|
9
|
+
RUNNING = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_RUNNING
|
10
|
+
COMPLETED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_COMPLETED
|
11
|
+
FAILED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_FAILED
|
12
|
+
CANCELED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_CANCELED
|
13
|
+
TERMINATED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_TERMINATED
|
14
|
+
CONTINUED_AS_NEW = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_CONTINUED_AS_NEW
|
15
|
+
TIMED_OUT = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_TIMED_OUT
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|