temporalio 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +4035 -0
- data/Cargo.toml +25 -0
- data/Gemfile +20 -0
- data/LICENSE +16 -15
- data/README.md +455 -195
- data/Rakefile +387 -0
- data/ext/Cargo.toml +25 -0
- data/lib/temporalio/activity/complete_async_error.rb +11 -0
- data/lib/temporalio/activity/context.rb +82 -77
- data/lib/temporalio/activity/definition.rb +77 -0
- data/lib/temporalio/activity/info.rb +42 -46
- data/lib/temporalio/activity.rb +49 -65
- data/lib/temporalio/api/batch/v1/message.rb +31 -0
- data/lib/temporalio/api/cloud/cloudservice/v1/request_response.rb +93 -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 +36 -0
- data/lib/temporalio/api/cloud/namespace/v1/message.rb +35 -0
- data/lib/temporalio/api/cloud/operation/v1/message.rb +27 -0
- data/lib/temporalio/api/cloud/region/v1/message.rb +23 -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 +41 -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/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 +42 -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/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 +189 -0
- data/lib/temporalio/api/workflowservice/v1/service.rb +23 -0
- data/lib/temporalio/api/workflowservice.rb +3 -0
- data/lib/temporalio/api.rb +13 -0
- data/lib/temporalio/cancellation.rb +150 -0
- data/lib/temporalio/client/activity_id_reference.rb +32 -0
- data/lib/temporalio/client/async_activity_handle.rb +110 -0
- data/lib/temporalio/client/connection/cloud_service.rb +648 -0
- data/lib/temporalio/client/connection/operator_service.rb +249 -0
- data/lib/temporalio/client/connection/service.rb +41 -0
- data/lib/temporalio/client/connection/workflow_service.rb +1218 -0
- data/lib/temporalio/client/connection.rb +270 -0
- data/lib/temporalio/client/interceptor.rb +316 -0
- data/lib/temporalio/client/workflow_execution.rb +103 -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 +380 -177
- data/lib/temporalio/client/workflow_query_reject_condition.rb +14 -0
- data/lib/temporalio/client/workflow_update_handle.rb +67 -0
- data/lib/temporalio/client/workflow_update_wait_stage.rb +17 -0
- data/lib/temporalio/client.rb +366 -93
- data/lib/temporalio/common_enums.rb +24 -0
- data/lib/temporalio/converters/data_converter.rb +102 -0
- data/lib/temporalio/converters/failure_converter.rb +200 -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 +62 -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 +73 -0
- data/lib/temporalio/converters.rb +9 -0
- data/lib/temporalio/error/failure.rb +119 -94
- data/lib/temporalio/error.rb +147 -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 +36 -0
- data/lib/temporalio/internal/bridge/api/external_data/external_data.rb +27 -0
- data/lib/temporalio/internal/bridge/api/workflow_activation/workflow_activation.rb +52 -0
- data/lib/temporalio/internal/bridge/api/workflow_commands/workflow_commands.rb +54 -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 +90 -0
- data/lib/temporalio/internal/bridge/runtime.rb +53 -0
- data/lib/temporalio/internal/bridge/testing.rb +46 -0
- data/lib/temporalio/internal/bridge/worker.rb +83 -0
- data/lib/temporalio/internal/bridge.rb +36 -0
- data/lib/temporalio/internal/client/implementation.rb +525 -0
- data/lib/temporalio/internal/proto_utils.rb +54 -0
- data/lib/temporalio/internal/worker/activity_worker.rb +345 -0
- data/lib/temporalio/internal/worker/multi_runner.rb +169 -0
- data/lib/temporalio/internal.rb +7 -0
- data/lib/temporalio/retry_policy.rb +39 -80
- data/lib/temporalio/runtime.rb +259 -13
- data/lib/temporalio/scoped_logger.rb +96 -0
- data/lib/temporalio/search_attributes.rb +300 -0
- data/lib/temporalio/testing/activity_environment.rb +132 -0
- data/lib/temporalio/testing/workflow_environment.rb +113 -88
- data/lib/temporalio/testing.rb +4 -169
- data/lib/temporalio/version.rb +3 -1
- data/lib/temporalio/worker/activity_executor/fiber.rb +49 -0
- data/lib/temporalio/worker/activity_executor/thread_pool.rb +254 -0
- data/lib/temporalio/worker/activity_executor.rb +55 -0
- data/lib/temporalio/worker/interceptor.rb +88 -0
- data/lib/temporalio/worker/tuner.rb +151 -0
- data/lib/temporalio/worker.rb +385 -163
- data/lib/temporalio/workflow_history.rb +22 -0
- data/lib/temporalio.rb +2 -7
- data/temporalio.gemspec +20 -38
- metadata +131 -596
- data/bridge/Cargo.lock +0 -2997
- data/bridge/Cargo.toml +0 -29
- data/bridge/sdk-core/ARCHITECTURE.md +0 -76
- data/bridge/sdk-core/Cargo.toml +0 -2
- data/bridge/sdk-core/LICENSE.txt +0 -23
- data/bridge/sdk-core/README.md +0 -117
- data/bridge/sdk-core/arch_docs/diagrams/README.md +0 -10
- data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +0 -40
- data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +0 -1
- data/bridge/sdk-core/arch_docs/sticky_queues.md +0 -51
- data/bridge/sdk-core/client/Cargo.toml +0 -40
- data/bridge/sdk-core/client/LICENSE.txt +0 -23
- data/bridge/sdk-core/client/src/lib.rs +0 -1462
- data/bridge/sdk-core/client/src/metrics.rs +0 -174
- data/bridge/sdk-core/client/src/raw.rs +0 -932
- data/bridge/sdk-core/client/src/retry.rs +0 -763
- data/bridge/sdk-core/client/src/workflow_handle/mod.rs +0 -185
- data/bridge/sdk-core/core/Cargo.toml +0 -129
- data/bridge/sdk-core/core/LICENSE.txt +0 -23
- data/bridge/sdk-core/core/benches/workflow_replay.rs +0 -76
- data/bridge/sdk-core/core/src/abstractions.rs +0 -355
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +0 -1049
- data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +0 -221
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +0 -270
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +0 -1046
- data/bridge/sdk-core/core/src/core_tests/mod.rs +0 -100
- data/bridge/sdk-core/core/src/core_tests/queries.rs +0 -893
- data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +0 -65
- data/bridge/sdk-core/core/src/core_tests/workers.rs +0 -257
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +0 -124
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +0 -2433
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +0 -609
- data/bridge/sdk-core/core/src/internal_flags.rs +0 -136
- data/bridge/sdk-core/core/src/lib.rs +0 -289
- data/bridge/sdk-core/core/src/pollers/mod.rs +0 -54
- data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +0 -297
- data/bridge/sdk-core/core/src/protosext/mod.rs +0 -428
- data/bridge/sdk-core/core/src/replay/mod.rs +0 -215
- data/bridge/sdk-core/core/src/retry_logic.rs +0 -202
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +0 -190
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +0 -462
- data/bridge/sdk-core/core/src/telemetry/mod.rs +0 -423
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +0 -83
- data/bridge/sdk-core/core/src/test_help/mod.rs +0 -939
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +0 -536
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +0 -89
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +0 -1278
- data/bridge/sdk-core/core/src/worker/activities.rs +0 -557
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +0 -107
- data/bridge/sdk-core/core/src/worker/client.rs +0 -389
- data/bridge/sdk-core/core/src/worker/mod.rs +0 -677
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +0 -35
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +0 -99
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +0 -1111
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +0 -964
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +0 -294
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +0 -168
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +0 -918
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +0 -137
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +0 -158
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +0 -130
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +0 -1525
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +0 -324
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +0 -179
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +0 -659
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +0 -439
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +0 -435
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +0 -175
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +0 -249
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +0 -85
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +0 -1280
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +0 -269
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +0 -213
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +0 -1305
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +0 -1276
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +0 -128
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +0 -125
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +0 -85
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +0 -117
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +0 -24
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +0 -715
- data/bridge/sdk-core/core-api/Cargo.toml +0 -33
- data/bridge/sdk-core/core-api/LICENSE.txt +0 -23
- data/bridge/sdk-core/core-api/src/errors.rs +0 -62
- data/bridge/sdk-core/core-api/src/lib.rs +0 -113
- data/bridge/sdk-core/core-api/src/telemetry.rs +0 -141
- data/bridge/sdk-core/core-api/src/worker.rs +0 -161
- data/bridge/sdk-core/etc/deps.svg +0 -162
- data/bridge/sdk-core/etc/dynamic-config.yaml +0 -2
- data/bridge/sdk-core/etc/otel-collector-config.yaml +0 -36
- data/bridge/sdk-core/etc/prometheus.yaml +0 -6
- data/bridge/sdk-core/etc/regen-depgraph.sh +0 -5
- data/bridge/sdk-core/fsm/Cargo.toml +0 -18
- data/bridge/sdk-core/fsm/LICENSE.txt +0 -23
- data/bridge/sdk-core/fsm/README.md +0 -3
- data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +0 -27
- data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +0 -23
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +0 -650
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +0 -8
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +0 -18
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +0 -12
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +0 -41
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +0 -14
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +0 -11
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +0 -32
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +0 -31
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +0 -46
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +0 -29
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +0 -12
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +0 -32
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +0 -18
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +0 -5
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +0 -11
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +0 -5
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +0 -11
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +0 -5
- data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +0 -14
- data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +0 -23
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +0 -254
- data/bridge/sdk-core/fsm/src/lib.rs +0 -2
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
- data/bridge/sdk-core/histories/fail_wf_task.bin +0 -0
- data/bridge/sdk-core/histories/timer_workflow_history.bin +0 -0
- data/bridge/sdk-core/integ-with-otel.sh +0 -7
- data/bridge/sdk-core/protos/api_upstream/README.md +0 -9
- data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +0 -40
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -9
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +0 -7
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +0 -5
- data/bridge/sdk-core/protos/api_upstream/build/tools.go +0 -29
- data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +0 -141
- data/bridge/sdk-core/protos/api_upstream/go.mod +0 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +0 -89
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +0 -248
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +0 -123
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +0 -47
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +0 -52
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +0 -56
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +0 -170
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +0 -123
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +0 -51
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +0 -50
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +0 -41
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +0 -60
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +0 -59
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +0 -56
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +0 -122
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +0 -108
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +0 -114
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +0 -56
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +0 -787
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +0 -99
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +0 -124
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +0 -80
- data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +0 -57
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +0 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +0 -55
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +0 -379
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +0 -63
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +0 -108
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +0 -111
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +0 -59
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +0 -146
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +0 -1199
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +0 -415
- data/bridge/sdk-core/protos/grpc/health/v1/health.proto +0 -63
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +0 -79
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +0 -80
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +0 -78
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +0 -16
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +0 -31
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +0 -31
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +0 -270
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +0 -305
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +0 -35
- data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +0 -38
- data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +0 -13
- data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +0 -141
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +0 -63
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +0 -90
- data/bridge/sdk-core/rustfmt.toml +0 -1
- data/bridge/sdk-core/sdk/Cargo.toml +0 -48
- data/bridge/sdk-core/sdk/LICENSE.txt +0 -23
- data/bridge/sdk-core/sdk/src/activity_context.rs +0 -230
- data/bridge/sdk-core/sdk/src/app_data.rs +0 -37
- data/bridge/sdk-core/sdk/src/interceptors.rs +0 -50
- data/bridge/sdk-core/sdk/src/lib.rs +0 -861
- data/bridge/sdk-core/sdk/src/payload_converter.rs +0 -11
- data/bridge/sdk-core/sdk/src/workflow_context/options.rs +0 -295
- data/bridge/sdk-core/sdk/src/workflow_context.rs +0 -694
- data/bridge/sdk-core/sdk/src/workflow_future.rs +0 -500
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +0 -33
- data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +0 -23
- data/bridge/sdk-core/sdk-core-protos/build.rs +0 -142
- data/bridge/sdk-core/sdk-core-protos/src/constants.rs +0 -7
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +0 -557
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +0 -234
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +0 -2088
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +0 -48
- data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +0 -14
- data/bridge/sdk-core/test-utils/Cargo.toml +0 -38
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +0 -1389
- data/bridge/sdk-core/test-utils/src/histfetch.rs +0 -28
- data/bridge/sdk-core/test-utils/src/lib.rs +0 -709
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +0 -50
- data/bridge/sdk-core/test-utils/src/workflows.rs +0 -29
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +0 -130
- data/bridge/sdk-core/tests/heavy_tests.rs +0 -265
- data/bridge/sdk-core/tests/integ_tests/client_tests.rs +0 -36
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +0 -150
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +0 -223
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +0 -239
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +0 -90
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +0 -314
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +0 -151
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +0 -902
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +0 -61
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +0 -60
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +0 -51
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +0 -51
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +0 -64
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +0 -47
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +0 -669
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +0 -54
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +0 -92
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +0 -228
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +0 -94
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +0 -171
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +0 -85
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +0 -120
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +0 -77
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +0 -596
- data/bridge/sdk-core/tests/main.rs +0 -103
- data/bridge/sdk-core/tests/runner.rs +0 -132
- data/bridge/sdk-core/tests/wf_input_replay.rs +0 -32
- data/bridge/src/connection.rs +0 -202
- data/bridge/src/lib.rs +0 -494
- data/bridge/src/runtime.rs +0 -54
- data/bridge/src/test_server.rs +0 -153
- data/bridge/src/worker.rs +0 -197
- data/ext/Rakefile +0 -9
- data/lib/gen/dependencies/gogoproto/gogo_pb.rb +0 -14
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +0 -50
- data/lib/gen/temporal/api/command/v1/message_pb.rb +0 -160
- data/lib/gen/temporal/api/common/v1/message_pb.rb +0 -73
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +0 -33
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +0 -37
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +0 -42
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +0 -68
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +0 -79
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +0 -37
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +0 -31
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +0 -24
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +0 -28
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +0 -30
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +0 -25
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +0 -89
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +0 -84
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +0 -83
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +0 -40
- data/lib/gen/temporal/api/history/v1/message_pb.rb +0 -498
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +0 -64
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +0 -88
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +0 -20
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +0 -30
- data/lib/gen/temporal/api/query/v1/message_pb.rb +0 -38
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +0 -37
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +0 -149
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +0 -23
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +0 -73
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +0 -49
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +0 -21
- data/lib/gen/temporal/api/update/v1/message_pb.rb +0 -72
- data/lib/gen/temporal/api/version/v1/message_pb.rb +0 -41
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +0 -111
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +0 -798
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +0 -20
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +0 -62
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +0 -61
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +0 -61
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +0 -26
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +0 -40
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +0 -31
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +0 -171
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +0 -200
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +0 -41
- data/lib/temporalio/bridge/connect_options.rb +0 -15
- data/lib/temporalio/bridge/error.rb +0 -8
- data/lib/temporalio/bridge/retry_config.rb +0 -24
- data/lib/temporalio/bridge/tls_options.rb +0 -19
- data/lib/temporalio/bridge.rb +0 -14
- data/lib/temporalio/client/implementation.rb +0 -340
- data/lib/temporalio/connection/retry_config.rb +0 -44
- data/lib/temporalio/connection/service.rb +0 -20
- data/lib/temporalio/connection/test_service.rb +0 -92
- data/lib/temporalio/connection/tls_options.rb +0 -51
- data/lib/temporalio/connection/workflow_service.rb +0 -731
- data/lib/temporalio/connection.rb +0 -86
- data/lib/temporalio/data_converter.rb +0 -191
- data/lib/temporalio/error/workflow_failure.rb +0 -19
- data/lib/temporalio/errors.rb +0 -40
- data/lib/temporalio/failure_converter/base.rb +0 -26
- data/lib/temporalio/failure_converter/basic.rb +0 -319
- data/lib/temporalio/failure_converter.rb +0 -7
- data/lib/temporalio/interceptor/activity_inbound.rb +0 -22
- data/lib/temporalio/interceptor/activity_outbound.rb +0 -24
- data/lib/temporalio/interceptor/chain.rb +0 -28
- data/lib/temporalio/interceptor/client.rb +0 -127
- data/lib/temporalio/interceptor.rb +0 -22
- data/lib/temporalio/payload_codec/base.rb +0 -32
- data/lib/temporalio/payload_converter/base.rb +0 -24
- data/lib/temporalio/payload_converter/bytes.rb +0 -27
- data/lib/temporalio/payload_converter/composite.rb +0 -49
- data/lib/temporalio/payload_converter/encoding_base.rb +0 -35
- data/lib/temporalio/payload_converter/json.rb +0 -26
- data/lib/temporalio/payload_converter/nil.rb +0 -26
- data/lib/temporalio/payload_converter.rb +0 -14
- data/lib/temporalio/retry_state.rb +0 -35
- data/lib/temporalio/testing/time_skipping_handle.rb +0 -32
- data/lib/temporalio/testing/time_skipping_interceptor.rb +0 -23
- data/lib/temporalio/timeout_type.rb +0 -29
- data/lib/temporalio/worker/activity_runner.rb +0 -114
- data/lib/temporalio/worker/activity_worker.rb +0 -164
- data/lib/temporalio/worker/reactor.rb +0 -46
- data/lib/temporalio/worker/runner.rb +0 -63
- data/lib/temporalio/worker/sync_worker.rb +0 -124
- data/lib/temporalio/worker/thread_pool_executor.rb +0 -51
- data/lib/temporalio/workflow/async.rb +0 -46
- data/lib/temporalio/workflow/execution_info.rb +0 -54
- data/lib/temporalio/workflow/execution_status.rb +0 -36
- data/lib/temporalio/workflow/future.rb +0 -138
- data/lib/temporalio/workflow/id_reuse_policy.rb +0 -36
- data/lib/temporalio/workflow/info.rb +0 -76
- data/lib/temporalio/workflow/query_reject_condition.rb +0 -33
- data/lib/thermite_patch.rb +0 -23
@@ -1,1462 +0,0 @@
|
|
1
|
-
#![warn(missing_docs)] // error if there are missing docs
|
2
|
-
|
3
|
-
//! This crate contains client implementations that can be used to contact the Temporal service.
|
4
|
-
//!
|
5
|
-
//! It implements auto-retry behavior and metrics collection.
|
6
|
-
|
7
|
-
#[macro_use]
|
8
|
-
extern crate tracing;
|
9
|
-
|
10
|
-
mod metrics;
|
11
|
-
mod raw;
|
12
|
-
mod retry;
|
13
|
-
mod workflow_handle;
|
14
|
-
|
15
|
-
pub use crate::retry::{CallType, RetryClient, RETRYABLE_ERROR_CODES};
|
16
|
-
pub use metrics::ClientMetricProvider;
|
17
|
-
pub use raw::{HealthService, OperatorService, TestService, WorkflowService};
|
18
|
-
pub use temporal_sdk_core_protos::temporal::api::{
|
19
|
-
enums::v1::ArchivalState,
|
20
|
-
filter::v1::{StartTimeFilter, StatusFilter, WorkflowExecutionFilter, WorkflowTypeFilter},
|
21
|
-
workflowservice::v1::{
|
22
|
-
list_closed_workflow_executions_request::Filters as ListClosedFilters,
|
23
|
-
list_open_workflow_executions_request::Filters as ListOpenFilters,
|
24
|
-
},
|
25
|
-
};
|
26
|
-
pub use tonic;
|
27
|
-
pub use workflow_handle::{WorkflowExecutionInfo, WorkflowExecutionResult};
|
28
|
-
|
29
|
-
use crate::{
|
30
|
-
metrics::{GrpcMetricSvc, MetricsContext},
|
31
|
-
raw::{sealed::RawClientLike, AttachMetricLabels},
|
32
|
-
sealed::WfHandleClient,
|
33
|
-
workflow_handle::UntypedWorkflowHandle,
|
34
|
-
};
|
35
|
-
use backoff::{exponential, ExponentialBackoff, SystemClock};
|
36
|
-
use http::uri::InvalidUri;
|
37
|
-
use once_cell::sync::OnceCell;
|
38
|
-
use parking_lot::RwLock;
|
39
|
-
use std::{
|
40
|
-
collections::HashMap,
|
41
|
-
fmt::{Debug, Formatter},
|
42
|
-
ops::{Deref, DerefMut},
|
43
|
-
str::FromStr,
|
44
|
-
sync::Arc,
|
45
|
-
time::{Duration, Instant},
|
46
|
-
};
|
47
|
-
use temporal_sdk_core_protos::{
|
48
|
-
coresdk::{workflow_commands::QueryResult, IntoPayloadsExt},
|
49
|
-
grpc::health::v1::health_client::HealthClient,
|
50
|
-
temporal::api::{
|
51
|
-
common::v1::{Header, Payload, Payloads, WorkflowExecution, WorkflowType},
|
52
|
-
enums::v1::{TaskQueueKind, WorkflowIdReusePolicy, WorkflowTaskFailedCause},
|
53
|
-
failure::v1::Failure,
|
54
|
-
operatorservice::v1::operator_service_client::OperatorServiceClient,
|
55
|
-
query::v1::WorkflowQuery,
|
56
|
-
replication::v1::ClusterReplicationConfig,
|
57
|
-
taskqueue::v1::TaskQueue,
|
58
|
-
testservice::v1::test_service_client::TestServiceClient,
|
59
|
-
workflowservice::v1::{workflow_service_client::WorkflowServiceClient, *},
|
60
|
-
},
|
61
|
-
TaskToken,
|
62
|
-
};
|
63
|
-
use tonic::{
|
64
|
-
body::BoxBody,
|
65
|
-
client::GrpcService,
|
66
|
-
codegen::InterceptedService,
|
67
|
-
metadata::{MetadataKey, MetadataValue},
|
68
|
-
service::Interceptor,
|
69
|
-
transport::{Certificate, Channel, Endpoint, Identity},
|
70
|
-
Code, Status,
|
71
|
-
};
|
72
|
-
use tower::ServiceBuilder;
|
73
|
-
use url::Url;
|
74
|
-
use uuid::Uuid;
|
75
|
-
|
76
|
-
static CLIENT_NAME_HEADER_KEY: &str = "client-name";
|
77
|
-
static CLIENT_VERSION_HEADER_KEY: &str = "client-version";
|
78
|
-
/// These must match the gRPC method names, not the snake case versions that exist in the Rust code.
|
79
|
-
static LONG_POLL_METHOD_NAMES: [&str; 2] = ["PollWorkflowTaskQueue", "PollActivityTaskQueue"];
|
80
|
-
/// The server times out polls after 60 seconds. Set our timeout to be slightly beyond that.
|
81
|
-
const LONG_POLL_TIMEOUT: Duration = Duration::from_secs(70);
|
82
|
-
const OTHER_CALL_TIMEOUT: Duration = Duration::from_secs(30);
|
83
|
-
|
84
|
-
type Result<T, E = tonic::Status> = std::result::Result<T, E>;
|
85
|
-
|
86
|
-
/// Options for the connection to the temporal server. Construct with [ClientOptionsBuilder]
|
87
|
-
#[derive(Clone, Debug, derive_builder::Builder)]
|
88
|
-
#[non_exhaustive]
|
89
|
-
pub struct ClientOptions {
|
90
|
-
/// The URL of the Temporal server to connect to
|
91
|
-
#[builder(setter(into))]
|
92
|
-
pub target_url: Url,
|
93
|
-
|
94
|
-
/// The name of the SDK being implemented on top of core. Is set as `client-name` header in
|
95
|
-
/// all RPC calls
|
96
|
-
#[builder(setter(into))]
|
97
|
-
pub client_name: String,
|
98
|
-
|
99
|
-
/// The version of the SDK being implemented on top of core. Is set as `client-version` header
|
100
|
-
/// in all RPC calls. The server decides if the client is supported based on this.
|
101
|
-
#[builder(setter(into))]
|
102
|
-
pub client_version: String,
|
103
|
-
|
104
|
-
/// A human-readable string that can identify this process. Defaults to empty string.
|
105
|
-
#[builder(default)]
|
106
|
-
pub identity: String,
|
107
|
-
|
108
|
-
/// If specified, use TLS as configured by the [TlsConfig] struct. If this is set core will
|
109
|
-
/// attempt to use TLS when connecting to the Temporal server. Lang SDK is expected to pass any
|
110
|
-
/// certs or keys as bytes, loading them from disk itself if needed.
|
111
|
-
#[builder(setter(strip_option), default)]
|
112
|
-
pub tls_cfg: Option<TlsConfig>,
|
113
|
-
|
114
|
-
/// Retry configuration for the server client. Default is [RetryConfig::default]
|
115
|
-
#[builder(default)]
|
116
|
-
pub retry_config: RetryConfig,
|
117
|
-
}
|
118
|
-
|
119
|
-
/// Configuration options for TLS
|
120
|
-
#[derive(Clone, Debug, Default)]
|
121
|
-
pub struct TlsConfig {
|
122
|
-
/// Bytes representing the root CA certificate used by the server. If not set, and the server's
|
123
|
-
/// cert is issued by someone the operating system trusts, verification will still work (ex:
|
124
|
-
/// Cloud offering).
|
125
|
-
pub server_root_ca_cert: Option<Vec<u8>>,
|
126
|
-
/// Sets the domain name against which to verify the server's TLS certificate. If not provided,
|
127
|
-
/// the domain name will be extracted from the URL used to connect.
|
128
|
-
pub domain: Option<String>,
|
129
|
-
/// TLS info for the client. If specified, core will attempt to use mTLS.
|
130
|
-
pub client_tls_config: Option<ClientTlsConfig>,
|
131
|
-
}
|
132
|
-
|
133
|
-
/// If using mTLS, both the client cert and private key must be specified, this contains them.
|
134
|
-
#[derive(Clone)]
|
135
|
-
pub struct ClientTlsConfig {
|
136
|
-
/// The certificate for this client
|
137
|
-
pub client_cert: Vec<u8>,
|
138
|
-
/// The private key for this client
|
139
|
-
pub client_private_key: Vec<u8>,
|
140
|
-
}
|
141
|
-
|
142
|
-
/// Configuration for retrying requests to the server
|
143
|
-
#[derive(Clone, Debug)]
|
144
|
-
pub struct RetryConfig {
|
145
|
-
/// initial wait time before the first retry.
|
146
|
-
pub initial_interval: Duration,
|
147
|
-
/// randomization jitter that is used as a multiplier for the current retry interval
|
148
|
-
/// and is added or subtracted from the interval length.
|
149
|
-
pub randomization_factor: f64,
|
150
|
-
/// rate at which retry time should be increased, until it reaches max_interval.
|
151
|
-
pub multiplier: f64,
|
152
|
-
/// maximum amount of time to wait between retries.
|
153
|
-
pub max_interval: Duration,
|
154
|
-
/// maximum total amount of time requests should be retried for, if None is set then no limit
|
155
|
-
/// will be used.
|
156
|
-
pub max_elapsed_time: Option<Duration>,
|
157
|
-
/// maximum number of retry attempts.
|
158
|
-
pub max_retries: usize,
|
159
|
-
}
|
160
|
-
|
161
|
-
impl Default for RetryConfig {
|
162
|
-
fn default() -> Self {
|
163
|
-
Self {
|
164
|
-
initial_interval: Duration::from_millis(100), // 100 ms wait by default.
|
165
|
-
randomization_factor: 0.2, // +-20% jitter.
|
166
|
-
multiplier: 1.5, // each next retry delay will increase by 50%
|
167
|
-
max_interval: Duration::from_secs(5), // until it reaches 5 seconds.
|
168
|
-
max_elapsed_time: Some(Duration::from_secs(10)), // 10 seconds total allocated time for all retries.
|
169
|
-
max_retries: 10,
|
170
|
-
}
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
impl RetryConfig {
|
175
|
-
pub(crate) const fn poll_retry_policy() -> Self {
|
176
|
-
Self {
|
177
|
-
initial_interval: Duration::from_millis(200),
|
178
|
-
randomization_factor: 0.2,
|
179
|
-
multiplier: 2.0,
|
180
|
-
max_interval: Duration::from_secs(10),
|
181
|
-
max_elapsed_time: None,
|
182
|
-
max_retries: 0,
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
pub(crate) const fn throttle_retry_policy() -> Self {
|
187
|
-
Self {
|
188
|
-
initial_interval: Duration::from_secs(1),
|
189
|
-
randomization_factor: 0.2,
|
190
|
-
multiplier: 2.0,
|
191
|
-
max_interval: Duration::from_secs(10),
|
192
|
-
max_elapsed_time: None,
|
193
|
-
max_retries: 0,
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
pub(crate) fn into_exp_backoff<C>(self, clock: C) -> exponential::ExponentialBackoff<C> {
|
198
|
-
exponential::ExponentialBackoff {
|
199
|
-
current_interval: self.initial_interval,
|
200
|
-
initial_interval: self.initial_interval,
|
201
|
-
randomization_factor: self.randomization_factor,
|
202
|
-
multiplier: self.multiplier,
|
203
|
-
max_interval: self.max_interval,
|
204
|
-
max_elapsed_time: self.max_elapsed_time,
|
205
|
-
clock,
|
206
|
-
start_time: Instant::now(),
|
207
|
-
}
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
impl From<RetryConfig> for ExponentialBackoff {
|
212
|
-
fn from(c: RetryConfig) -> Self {
|
213
|
-
c.into_exp_backoff(SystemClock::default())
|
214
|
-
}
|
215
|
-
}
|
216
|
-
|
217
|
-
impl Debug for ClientTlsConfig {
|
218
|
-
// Intentionally omit details here since they could leak a key if ever printed
|
219
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
220
|
-
write!(f, "ClientTlsConfig(..)")
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
/// Errors thrown while attempting to establish a connection to the server
|
225
|
-
#[derive(thiserror::Error, Debug)]
|
226
|
-
pub enum ClientInitError {
|
227
|
-
/// Invalid URI. Configuration error, fatal.
|
228
|
-
#[error("Invalid URI: {0:?}")]
|
229
|
-
InvalidUri(#[from] InvalidUri),
|
230
|
-
/// Server connection error. Crashing and restarting the worker is likely best.
|
231
|
-
#[error("Server connection error: {0:?}")]
|
232
|
-
TonicTransportError(#[from] tonic::transport::Error),
|
233
|
-
/// We couldn't successfully make the `get_system_info` call at connection time to establish
|
234
|
-
/// server capabilities / verify server is responding.
|
235
|
-
#[error("`get_system_info` call error after connection: {0:?}")]
|
236
|
-
SystemInfoCallError(tonic::Status),
|
237
|
-
}
|
238
|
-
|
239
|
-
/// A client with [ClientOptions] attached, which can be passed to initialize workers,
|
240
|
-
/// or can be used directly. Is cheap to clone.
|
241
|
-
#[derive(Clone, Debug)]
|
242
|
-
pub struct ConfiguredClient<C> {
|
243
|
-
client: C,
|
244
|
-
options: Arc<ClientOptions>,
|
245
|
-
headers: Arc<RwLock<HashMap<String, String>>>,
|
246
|
-
/// Capabilities as read from the `get_system_info` RPC call made on client connection
|
247
|
-
capabilities: Option<get_system_info_response::Capabilities>,
|
248
|
-
}
|
249
|
-
|
250
|
-
impl<C> ConfiguredClient<C> {
|
251
|
-
/// Set HTTP request headers overwriting previous headers
|
252
|
-
pub fn set_headers(&self, headers: HashMap<String, String>) {
|
253
|
-
let mut guard = self.headers.write();
|
254
|
-
*guard = headers;
|
255
|
-
}
|
256
|
-
|
257
|
-
/// Returns the options the client is configured with
|
258
|
-
pub fn options(&self) -> &ClientOptions {
|
259
|
-
&self.options
|
260
|
-
}
|
261
|
-
|
262
|
-
/// Returns the server capabilities we (may have) learned about when establishing an initial
|
263
|
-
/// connection
|
264
|
-
pub fn capabilities(&self) -> Option<&get_system_info_response::Capabilities> {
|
265
|
-
self.capabilities.as_ref()
|
266
|
-
}
|
267
|
-
}
|
268
|
-
|
269
|
-
// The configured client is effectively a "smart" (dumb) pointer
|
270
|
-
impl<C> Deref for ConfiguredClient<C> {
|
271
|
-
type Target = C;
|
272
|
-
|
273
|
-
fn deref(&self) -> &Self::Target {
|
274
|
-
&self.client
|
275
|
-
}
|
276
|
-
}
|
277
|
-
impl<C> DerefMut for ConfiguredClient<C> {
|
278
|
-
fn deref_mut(&mut self) -> &mut Self::Target {
|
279
|
-
&mut self.client
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
|
-
impl ClientOptions {
|
284
|
-
/// Attempt to establish a connection to the Temporal server in a specific namespace. The
|
285
|
-
/// returned client is bound to that namespace.
|
286
|
-
pub async fn connect(
|
287
|
-
&self,
|
288
|
-
namespace: impl Into<String>,
|
289
|
-
metrics_meter: Option<&dyn ClientMetricProvider>,
|
290
|
-
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
291
|
-
) -> Result<RetryClient<Client>, ClientInitError> {
|
292
|
-
let client = self
|
293
|
-
.connect_no_namespace(metrics_meter, headers)
|
294
|
-
.await?
|
295
|
-
.into_inner();
|
296
|
-
let client = Client::new(client, namespace.into());
|
297
|
-
let retry_client = RetryClient::new(client, self.retry_config.clone());
|
298
|
-
Ok(retry_client)
|
299
|
-
}
|
300
|
-
|
301
|
-
/// Attempt to establish a connection to the Temporal server and return a gRPC client which is
|
302
|
-
/// intercepted with retry, default headers functionality, and metrics if provided.
|
303
|
-
///
|
304
|
-
/// See [RetryClient] for more
|
305
|
-
pub async fn connect_no_namespace(
|
306
|
-
&self,
|
307
|
-
metrics_meter: Option<&dyn ClientMetricProvider>,
|
308
|
-
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
309
|
-
) -> Result<RetryClient<ConfiguredClient<TemporalServiceClientWithMetrics>>, ClientInitError>
|
310
|
-
{
|
311
|
-
let channel = Channel::from_shared(self.target_url.to_string())?;
|
312
|
-
let channel = self.add_tls_to_channel(channel).await?;
|
313
|
-
let channel = channel.connect().await?;
|
314
|
-
let service = ServiceBuilder::new()
|
315
|
-
.layer_fn(|channel| GrpcMetricSvc {
|
316
|
-
inner: channel,
|
317
|
-
metrics: metrics_meter.map(|mm| MetricsContext::new(vec![], mm)),
|
318
|
-
})
|
319
|
-
.service(channel);
|
320
|
-
let headers = headers.unwrap_or_default();
|
321
|
-
let interceptor = ServiceCallInterceptor {
|
322
|
-
opts: self.clone(),
|
323
|
-
headers: headers.clone(),
|
324
|
-
};
|
325
|
-
let svc = InterceptedService::new(service, interceptor);
|
326
|
-
|
327
|
-
let mut client = ConfiguredClient {
|
328
|
-
headers,
|
329
|
-
client: TemporalServiceClient::new(svc),
|
330
|
-
options: Arc::new(self.clone()),
|
331
|
-
capabilities: None,
|
332
|
-
};
|
333
|
-
match client
|
334
|
-
.get_system_info(GetSystemInfoRequest::default())
|
335
|
-
.await
|
336
|
-
{
|
337
|
-
Ok(sysinfo) => {
|
338
|
-
client.capabilities = sysinfo.into_inner().capabilities;
|
339
|
-
}
|
340
|
-
Err(status) => match status.code() {
|
341
|
-
Code::Unimplemented => {}
|
342
|
-
_ => return Err(ClientInitError::SystemInfoCallError(status)),
|
343
|
-
},
|
344
|
-
};
|
345
|
-
Ok(RetryClient::new(client, self.retry_config.clone()))
|
346
|
-
}
|
347
|
-
|
348
|
-
/// If TLS is configured, set the appropriate options on the provided channel and return it.
|
349
|
-
/// Passes it through if TLS options not set.
|
350
|
-
async fn add_tls_to_channel(
|
351
|
-
&self,
|
352
|
-
channel: Endpoint,
|
353
|
-
) -> Result<Endpoint, tonic::transport::Error> {
|
354
|
-
if let Some(tls_cfg) = &self.tls_cfg {
|
355
|
-
let mut tls = tonic::transport::ClientTlsConfig::new();
|
356
|
-
|
357
|
-
if let Some(root_cert) = &tls_cfg.server_root_ca_cert {
|
358
|
-
let server_root_ca_cert = Certificate::from_pem(root_cert);
|
359
|
-
tls = tls.ca_certificate(server_root_ca_cert);
|
360
|
-
}
|
361
|
-
|
362
|
-
if let Some(domain) = &tls_cfg.domain {
|
363
|
-
tls = tls.domain_name(domain);
|
364
|
-
}
|
365
|
-
|
366
|
-
if let Some(client_opts) = &tls_cfg.client_tls_config {
|
367
|
-
let client_identity =
|
368
|
-
Identity::from_pem(&client_opts.client_cert, &client_opts.client_private_key);
|
369
|
-
tls = tls.identity(client_identity);
|
370
|
-
}
|
371
|
-
|
372
|
-
return channel.tls_config(tls);
|
373
|
-
}
|
374
|
-
Ok(channel)
|
375
|
-
}
|
376
|
-
}
|
377
|
-
|
378
|
-
/// Interceptor which attaches common metadata (like "client-name") to every outgoing call
|
379
|
-
#[derive(Clone)]
|
380
|
-
pub struct ServiceCallInterceptor {
|
381
|
-
opts: ClientOptions,
|
382
|
-
/// Only accessed as a reader
|
383
|
-
headers: Arc<RwLock<HashMap<String, String>>>,
|
384
|
-
}
|
385
|
-
|
386
|
-
impl Interceptor for ServiceCallInterceptor {
|
387
|
-
/// This function will get called on each outbound request. Returning a `Status` here will
|
388
|
-
/// cancel the request and have that status returned to the caller.
|
389
|
-
fn call(&mut self, mut request: tonic::Request<()>) -> Result<tonic::Request<()>, Status> {
|
390
|
-
let metadata = request.metadata_mut();
|
391
|
-
if !metadata.contains_key(CLIENT_NAME_HEADER_KEY) {
|
392
|
-
metadata.insert(
|
393
|
-
CLIENT_NAME_HEADER_KEY,
|
394
|
-
self.opts
|
395
|
-
.client_name
|
396
|
-
.parse()
|
397
|
-
.unwrap_or_else(|_| MetadataValue::from_static("")),
|
398
|
-
);
|
399
|
-
}
|
400
|
-
if !metadata.contains_key(CLIENT_VERSION_HEADER_KEY) {
|
401
|
-
metadata.insert(
|
402
|
-
CLIENT_VERSION_HEADER_KEY,
|
403
|
-
self.opts
|
404
|
-
.client_version
|
405
|
-
.parse()
|
406
|
-
.unwrap_or_else(|_| MetadataValue::from_static("")),
|
407
|
-
);
|
408
|
-
}
|
409
|
-
let headers = &*self.headers.read();
|
410
|
-
for (k, v) in headers {
|
411
|
-
if metadata.contains_key(k) {
|
412
|
-
// Don't overwrite per-request specified headers
|
413
|
-
continue;
|
414
|
-
}
|
415
|
-
if let (Ok(k), Ok(v)) = (MetadataKey::from_str(k), v.parse()) {
|
416
|
-
metadata.insert(k, v);
|
417
|
-
}
|
418
|
-
}
|
419
|
-
if !metadata.contains_key("grpc-timeout") {
|
420
|
-
request.set_timeout(OTHER_CALL_TIMEOUT);
|
421
|
-
}
|
422
|
-
|
423
|
-
Ok(request)
|
424
|
-
}
|
425
|
-
}
|
426
|
-
|
427
|
-
/// Aggregates various services exposed by the Temporal server
|
428
|
-
#[derive(Debug, Clone)]
|
429
|
-
pub struct TemporalServiceClient<T> {
|
430
|
-
svc: T,
|
431
|
-
workflow_svc_client: OnceCell<WorkflowServiceClient<T>>,
|
432
|
-
operator_svc_client: OnceCell<OperatorServiceClient<T>>,
|
433
|
-
test_svc_client: OnceCell<TestServiceClient<T>>,
|
434
|
-
health_svc_client: OnceCell<HealthClient<T>>,
|
435
|
-
}
|
436
|
-
impl<T> TemporalServiceClient<T>
|
437
|
-
where
|
438
|
-
T: Clone,
|
439
|
-
T: GrpcService<BoxBody> + Send + Clone + 'static,
|
440
|
-
T::ResponseBody: tonic::codegen::Body<Data = tonic::codegen::Bytes> + Send + 'static,
|
441
|
-
T::Error: Into<tonic::codegen::StdError>,
|
442
|
-
<T::ResponseBody as tonic::codegen::Body>::Error: Into<tonic::codegen::StdError> + Send,
|
443
|
-
{
|
444
|
-
fn new(svc: T) -> Self {
|
445
|
-
Self {
|
446
|
-
svc,
|
447
|
-
workflow_svc_client: OnceCell::new(),
|
448
|
-
operator_svc_client: OnceCell::new(),
|
449
|
-
test_svc_client: OnceCell::new(),
|
450
|
-
health_svc_client: OnceCell::new(),
|
451
|
-
}
|
452
|
-
}
|
453
|
-
/// Get the underlying workflow service client
|
454
|
-
pub fn workflow_svc(&self) -> &WorkflowServiceClient<T> {
|
455
|
-
self.workflow_svc_client
|
456
|
-
.get_or_init(|| WorkflowServiceClient::new(self.svc.clone()))
|
457
|
-
}
|
458
|
-
/// Get the underlying operator service client
|
459
|
-
pub fn operator_svc(&self) -> &OperatorServiceClient<T> {
|
460
|
-
self.operator_svc_client
|
461
|
-
.get_or_init(|| OperatorServiceClient::new(self.svc.clone()))
|
462
|
-
}
|
463
|
-
/// Get the underlying test service client
|
464
|
-
pub fn test_svc(&self) -> &TestServiceClient<T> {
|
465
|
-
self.test_svc_client
|
466
|
-
.get_or_init(|| TestServiceClient::new(self.svc.clone()))
|
467
|
-
}
|
468
|
-
/// Get the underlying health service client
|
469
|
-
pub fn health_svc(&self) -> &HealthClient<T> {
|
470
|
-
self.health_svc_client
|
471
|
-
.get_or_init(|| HealthClient::new(self.svc.clone()))
|
472
|
-
}
|
473
|
-
/// Get the underlying workflow service client mutably
|
474
|
-
pub fn workflow_svc_mut(&mut self) -> &mut WorkflowServiceClient<T> {
|
475
|
-
let _ = self.workflow_svc();
|
476
|
-
self.workflow_svc_client.get_mut().unwrap()
|
477
|
-
}
|
478
|
-
/// Get the underlying operator service client mutably
|
479
|
-
pub fn operator_svc_mut(&mut self) -> &mut OperatorServiceClient<T> {
|
480
|
-
let _ = self.operator_svc();
|
481
|
-
self.operator_svc_client.get_mut().unwrap()
|
482
|
-
}
|
483
|
-
/// Get the underlying test service client mutably
|
484
|
-
pub fn test_svc_mut(&mut self) -> &mut TestServiceClient<T> {
|
485
|
-
let _ = self.test_svc();
|
486
|
-
self.test_svc_client.get_mut().unwrap()
|
487
|
-
}
|
488
|
-
/// Get the underlying health service client mutably
|
489
|
-
pub fn health_svc_mut(&mut self) -> &mut HealthClient<T> {
|
490
|
-
let _ = self.health_svc();
|
491
|
-
self.health_svc_client.get_mut().unwrap()
|
492
|
-
}
|
493
|
-
}
|
494
|
-
/// A [WorkflowServiceClient] with the default interceptors attached.
|
495
|
-
pub type WorkflowServiceClientWithMetrics = WorkflowServiceClient<InterceptedMetricsSvc>;
|
496
|
-
/// An [OperatorServiceClient] with the default interceptors attached.
|
497
|
-
pub type OperatorServiceClientWithMetrics = OperatorServiceClient<InterceptedMetricsSvc>;
|
498
|
-
/// An [TestServiceClient] with the default interceptors attached.
|
499
|
-
pub type TestServiceClientWithMetrics = TestServiceClient<InterceptedMetricsSvc>;
|
500
|
-
/// A [TemporalServiceClient] with the default interceptors attached.
|
501
|
-
pub type TemporalServiceClientWithMetrics = TemporalServiceClient<InterceptedMetricsSvc>;
|
502
|
-
type InterceptedMetricsSvc = InterceptedService<GrpcMetricSvc, ServiceCallInterceptor>;
|
503
|
-
|
504
|
-
/// Contains an instance of a namespace-bound client for interacting with the Temporal server
|
505
|
-
#[derive(Debug, Clone)]
|
506
|
-
pub struct Client {
|
507
|
-
/// Client for interacting with workflow service
|
508
|
-
inner: ConfiguredClient<TemporalServiceClientWithMetrics>,
|
509
|
-
/// The namespace this client interacts with
|
510
|
-
namespace: String,
|
511
|
-
/// If set, attach as the worker build id to relevant calls
|
512
|
-
bound_worker_build_id: Option<String>,
|
513
|
-
}
|
514
|
-
|
515
|
-
impl Client {
|
516
|
-
/// Create a new client from an existing configured lower level client and a namespace
|
517
|
-
pub fn new(
|
518
|
-
client: ConfiguredClient<TemporalServiceClientWithMetrics>,
|
519
|
-
namespace: String,
|
520
|
-
) -> Self {
|
521
|
-
Client {
|
522
|
-
inner: client,
|
523
|
-
namespace,
|
524
|
-
bound_worker_build_id: None,
|
525
|
-
}
|
526
|
-
}
|
527
|
-
|
528
|
-
/// Return an auto-retrying version of the underling grpc client (instrumented with metrics
|
529
|
-
/// collection, if enabled).
|
530
|
-
///
|
531
|
-
/// Note that it is reasonably cheap to clone the returned type if you need to own it. Such
|
532
|
-
/// clones will keep re-using the same channel.
|
533
|
-
pub fn raw_retry_client(&self) -> RetryClient<WorkflowServiceClientWithMetrics> {
|
534
|
-
RetryClient::new(
|
535
|
-
self.raw_client().clone(),
|
536
|
-
self.inner.options.retry_config.clone(),
|
537
|
-
)
|
538
|
-
}
|
539
|
-
|
540
|
-
/// Access the underling grpc client. This raw client is not bound to a specific namespace.
|
541
|
-
///
|
542
|
-
/// Note that it is reasonably cheap to clone the returned type if you need to own it. Such
|
543
|
-
/// clones will keep re-using the same channel.
|
544
|
-
pub fn raw_client(&self) -> &WorkflowServiceClientWithMetrics {
|
545
|
-
self.inner.workflow_svc()
|
546
|
-
}
|
547
|
-
|
548
|
-
/// Return the options this client was initialized with
|
549
|
-
pub fn options(&self) -> &ClientOptions {
|
550
|
-
&self.inner.options
|
551
|
-
}
|
552
|
-
|
553
|
-
/// Return the options this client was initialized with mutably
|
554
|
-
pub fn options_mut(&mut self) -> &mut ClientOptions {
|
555
|
-
Arc::make_mut(&mut self.inner.options)
|
556
|
-
}
|
557
|
-
|
558
|
-
/// Set a worker build id to be attached to relevant requests. Unlikely to be useful outside
|
559
|
-
/// of core.
|
560
|
-
pub fn set_worker_build_id(&mut self, id: String) {
|
561
|
-
self.bound_worker_build_id = Some(id)
|
562
|
-
}
|
563
|
-
|
564
|
-
/// Returns a reference to the underlying client
|
565
|
-
pub fn inner(&self) -> &ConfiguredClient<TemporalServiceClientWithMetrics> {
|
566
|
-
&self.inner
|
567
|
-
}
|
568
|
-
|
569
|
-
/// Consumes self and returns the underlying client
|
570
|
-
pub fn into_inner(self) -> ConfiguredClient<TemporalServiceClientWithMetrics> {
|
571
|
-
self.inner
|
572
|
-
}
|
573
|
-
|
574
|
-
fn wf_svc(&self) -> WorkflowServiceClientWithMetrics {
|
575
|
-
self.inner.workflow_svc().clone()
|
576
|
-
}
|
577
|
-
}
|
578
|
-
|
579
|
-
/// Enum to help reference a namespace by either the namespace name or the namespace id
|
580
|
-
#[derive(Clone)]
|
581
|
-
pub enum Namespace {
|
582
|
-
/// Namespace name
|
583
|
-
Name(String),
|
584
|
-
/// Namespace id
|
585
|
-
Id(String),
|
586
|
-
}
|
587
|
-
|
588
|
-
impl Namespace {
|
589
|
-
fn into_describe_namespace_request(self) -> DescribeNamespaceRequest {
|
590
|
-
let (namespace, id) = match self {
|
591
|
-
Namespace::Name(n) => (n, "".to_owned()),
|
592
|
-
Namespace::Id(n) => ("".to_owned(), n),
|
593
|
-
};
|
594
|
-
DescribeNamespaceRequest { namespace, id }
|
595
|
-
}
|
596
|
-
}
|
597
|
-
|
598
|
-
/// Default workflow execution retention for a Namespace is 3 days
|
599
|
-
pub const DEFAULT_WORKFLOW_EXECUTION_RETENTION_PERIOD: Duration =
|
600
|
-
Duration::from_secs(60 * 60 * 24 * 3);
|
601
|
-
|
602
|
-
/// Helper struct for `register_namespace`.
|
603
|
-
#[derive(Clone, derive_builder::Builder)]
|
604
|
-
pub struct RegisterNamespaceOptions {
|
605
|
-
/// Name (required)
|
606
|
-
#[builder(setter(into))]
|
607
|
-
pub namespace: String,
|
608
|
-
/// Description (required)
|
609
|
-
#[builder(setter(into))]
|
610
|
-
pub description: String,
|
611
|
-
/// Owner's email
|
612
|
-
#[builder(setter(into), default)]
|
613
|
-
pub owner_email: String,
|
614
|
-
/// Workflow execution retention period
|
615
|
-
#[builder(default = "DEFAULT_WORKFLOW_EXECUTION_RETENTION_PERIOD")]
|
616
|
-
pub workflow_execution_retention_period: Duration,
|
617
|
-
/// Cluster settings
|
618
|
-
#[builder(setter(strip_option, custom), default)]
|
619
|
-
pub clusters: Vec<ClusterReplicationConfig>,
|
620
|
-
/// Active cluster name
|
621
|
-
#[builder(setter(into), default)]
|
622
|
-
pub active_cluster_name: String,
|
623
|
-
/// Custom Data
|
624
|
-
#[builder(default)]
|
625
|
-
pub data: HashMap<String, String>,
|
626
|
-
/// Security Token
|
627
|
-
#[builder(setter(into), default)]
|
628
|
-
pub security_token: String,
|
629
|
-
/// Global namespace
|
630
|
-
#[builder(default)]
|
631
|
-
pub is_global_namespace: bool,
|
632
|
-
/// History Archival setting
|
633
|
-
#[builder(setter(into), default = "ArchivalState::Unspecified")]
|
634
|
-
pub history_archival_state: ArchivalState,
|
635
|
-
/// History Archival uri
|
636
|
-
#[builder(setter(into), default)]
|
637
|
-
pub history_archival_uri: String,
|
638
|
-
/// Visibility Archival setting
|
639
|
-
#[builder(setter(into), default = "ArchivalState::Unspecified")]
|
640
|
-
pub visibility_archival_state: ArchivalState,
|
641
|
-
/// Visibility Archival uri
|
642
|
-
#[builder(setter(into), default)]
|
643
|
-
pub visibility_archival_uri: String,
|
644
|
-
}
|
645
|
-
|
646
|
-
impl RegisterNamespaceOptions {
|
647
|
-
/// Builder convenience. Less `use` imports
|
648
|
-
pub fn builder() -> RegisterNamespaceOptionsBuilder {
|
649
|
-
Default::default()
|
650
|
-
}
|
651
|
-
}
|
652
|
-
|
653
|
-
impl From<RegisterNamespaceOptions> for RegisterNamespaceRequest {
|
654
|
-
fn from(val: RegisterNamespaceOptions) -> Self {
|
655
|
-
RegisterNamespaceRequest {
|
656
|
-
namespace: val.namespace,
|
657
|
-
description: val.description,
|
658
|
-
owner_email: val.owner_email,
|
659
|
-
workflow_execution_retention_period: val
|
660
|
-
.workflow_execution_retention_period
|
661
|
-
.try_into()
|
662
|
-
.ok(),
|
663
|
-
clusters: val.clusters,
|
664
|
-
active_cluster_name: val.active_cluster_name,
|
665
|
-
data: val.data,
|
666
|
-
security_token: val.security_token,
|
667
|
-
is_global_namespace: val.is_global_namespace,
|
668
|
-
history_archival_state: val.history_archival_state as i32,
|
669
|
-
history_archival_uri: val.history_archival_uri,
|
670
|
-
visibility_archival_state: val.visibility_archival_state as i32,
|
671
|
-
visibility_archival_uri: val.visibility_archival_uri,
|
672
|
-
}
|
673
|
-
}
|
674
|
-
}
|
675
|
-
|
676
|
-
impl RegisterNamespaceOptionsBuilder {
|
677
|
-
/// Custum builder function for convenience
|
678
|
-
/// Warning: setting cluster_names could blow away any previously set cluster configs
|
679
|
-
pub fn cluster_names(&mut self, clusters: Vec<String>) {
|
680
|
-
self.clusters = Some(
|
681
|
-
clusters
|
682
|
-
.into_iter()
|
683
|
-
.map(|s| ClusterReplicationConfig { cluster_name: s })
|
684
|
-
.collect(),
|
685
|
-
);
|
686
|
-
}
|
687
|
-
}
|
688
|
-
|
689
|
-
/// Helper struct for `signal_with_start_workflow_execution`.
|
690
|
-
#[derive(Clone, derive_builder::Builder)]
|
691
|
-
pub struct SignalWithStartOptions {
|
692
|
-
/// Input payload for the workflow run
|
693
|
-
#[builder(setter(strip_option), default)]
|
694
|
-
pub input: Option<Payloads>,
|
695
|
-
/// Task Queue to target (required)
|
696
|
-
#[builder(setter(into))]
|
697
|
-
pub task_queue: String,
|
698
|
-
/// Workflow id for the workflow run
|
699
|
-
#[builder(setter(into))]
|
700
|
-
pub workflow_id: String,
|
701
|
-
/// Workflow type for the workflow run
|
702
|
-
#[builder(setter(into))]
|
703
|
-
pub workflow_type: String,
|
704
|
-
#[builder(setter(strip_option), default)]
|
705
|
-
/// Request id for idempotency/deduplication
|
706
|
-
pub request_id: Option<String>,
|
707
|
-
/// The signal name to send (required)
|
708
|
-
#[builder(setter(into))]
|
709
|
-
pub signal_name: String,
|
710
|
-
/// Payloads for the signal
|
711
|
-
#[builder(default)]
|
712
|
-
pub signal_input: Option<Payloads>,
|
713
|
-
#[builder(setter(strip_option), default)]
|
714
|
-
/// Headers for the signal
|
715
|
-
pub signal_header: Option<Header>,
|
716
|
-
}
|
717
|
-
|
718
|
-
impl SignalWithStartOptions {
|
719
|
-
/// Builder convenience. Less `use` imports
|
720
|
-
pub fn builder() -> SignalWithStartOptionsBuilder {
|
721
|
-
Default::default()
|
722
|
-
}
|
723
|
-
}
|
724
|
-
|
725
|
-
/// This trait provides higher-level friendlier interaction with the server.
|
726
|
-
/// See the [WorkflowService] trait for a lower-level client.
|
727
|
-
#[cfg_attr(test, mockall::automock)]
|
728
|
-
#[async_trait::async_trait]
|
729
|
-
pub trait WorkflowClientTrait {
|
730
|
-
/// Starts workflow execution.
|
731
|
-
async fn start_workflow(
|
732
|
-
&self,
|
733
|
-
input: Vec<Payload>,
|
734
|
-
task_queue: String,
|
735
|
-
workflow_id: String,
|
736
|
-
workflow_type: String,
|
737
|
-
request_id: Option<String>,
|
738
|
-
options: WorkflowOptions,
|
739
|
-
) -> Result<StartWorkflowExecutionResponse>;
|
740
|
-
|
741
|
-
/// Notifies the server that workflow tasks for a given workflow should be sent to the normal
|
742
|
-
/// non-sticky task queue. This normally happens when workflow has been evicted from the cache.
|
743
|
-
async fn reset_sticky_task_queue(
|
744
|
-
&self,
|
745
|
-
workflow_id: String,
|
746
|
-
run_id: String,
|
747
|
-
) -> Result<ResetStickyTaskQueueResponse>;
|
748
|
-
|
749
|
-
/// Complete activity task by sending response to the server. `task_token` contains activity
|
750
|
-
/// identifier that would've been received from polling for an activity task. `result` is a blob
|
751
|
-
/// that contains activity response.
|
752
|
-
async fn complete_activity_task(
|
753
|
-
&self,
|
754
|
-
task_token: TaskToken,
|
755
|
-
result: Option<Payloads>,
|
756
|
-
) -> Result<RespondActivityTaskCompletedResponse>;
|
757
|
-
|
758
|
-
/// Report activity task heartbeat by sending details to the server. `task_token` contains
|
759
|
-
/// activity identifier that would've been received from polling for an activity task. `result`
|
760
|
-
/// contains `cancel_requested` flag, which if set to true indicates that activity has been
|
761
|
-
/// cancelled.
|
762
|
-
async fn record_activity_heartbeat(
|
763
|
-
&self,
|
764
|
-
task_token: TaskToken,
|
765
|
-
details: Option<Payloads>,
|
766
|
-
) -> Result<RecordActivityTaskHeartbeatResponse>;
|
767
|
-
|
768
|
-
/// Cancel activity task by sending response to the server. `task_token` contains activity
|
769
|
-
/// identifier that would've been received from polling for an activity task. `details` is a
|
770
|
-
/// blob that provides arbitrary user defined cancellation info.
|
771
|
-
async fn cancel_activity_task(
|
772
|
-
&self,
|
773
|
-
task_token: TaskToken,
|
774
|
-
details: Option<Payloads>,
|
775
|
-
) -> Result<RespondActivityTaskCanceledResponse>;
|
776
|
-
|
777
|
-
/// Fail activity task by sending response to the server. `task_token` contains activity
|
778
|
-
/// identifier that would've been received from polling for an activity task. `failure` provides
|
779
|
-
/// failure details, such as message, cause and stack trace.
|
780
|
-
async fn fail_activity_task(
|
781
|
-
&self,
|
782
|
-
task_token: TaskToken,
|
783
|
-
failure: Option<Failure>,
|
784
|
-
) -> Result<RespondActivityTaskFailedResponse>;
|
785
|
-
|
786
|
-
/// Fail task by sending the failure to the server. `task_token` is the task token that would've
|
787
|
-
/// been received from polling for a workflow activation.
|
788
|
-
async fn fail_workflow_task(
|
789
|
-
&self,
|
790
|
-
task_token: TaskToken,
|
791
|
-
cause: WorkflowTaskFailedCause,
|
792
|
-
failure: Option<Failure>,
|
793
|
-
) -> Result<RespondWorkflowTaskFailedResponse>;
|
794
|
-
|
795
|
-
/// Send a signal to a certain workflow instance
|
796
|
-
async fn signal_workflow_execution(
|
797
|
-
&self,
|
798
|
-
workflow_id: String,
|
799
|
-
run_id: String,
|
800
|
-
signal_name: String,
|
801
|
-
payloads: Option<Payloads>,
|
802
|
-
request_id: Option<String>,
|
803
|
-
) -> Result<SignalWorkflowExecutionResponse>;
|
804
|
-
|
805
|
-
/// Send signal and start workflow transcationally
|
806
|
-
//#TODO maybe lift the Signal type from sdk::workflow_context::options
|
807
|
-
#[allow(clippy::too_many_arguments)]
|
808
|
-
async fn signal_with_start_workflow_execution(
|
809
|
-
&self,
|
810
|
-
options: SignalWithStartOptions,
|
811
|
-
workflow_options: WorkflowOptions,
|
812
|
-
) -> Result<SignalWithStartWorkflowExecutionResponse>;
|
813
|
-
|
814
|
-
/// Request a query of a certain workflow instance
|
815
|
-
async fn query_workflow_execution(
|
816
|
-
&self,
|
817
|
-
workflow_id: String,
|
818
|
-
run_id: String,
|
819
|
-
query: WorkflowQuery,
|
820
|
-
) -> Result<QueryWorkflowResponse>;
|
821
|
-
|
822
|
-
/// Get information about a workflow run
|
823
|
-
async fn describe_workflow_execution(
|
824
|
-
&self,
|
825
|
-
workflow_id: String,
|
826
|
-
run_id: Option<String>,
|
827
|
-
) -> Result<DescribeWorkflowExecutionResponse>;
|
828
|
-
|
829
|
-
/// Get history for a particular workflow run
|
830
|
-
async fn get_workflow_execution_history(
|
831
|
-
&self,
|
832
|
-
workflow_id: String,
|
833
|
-
run_id: Option<String>,
|
834
|
-
page_token: Vec<u8>,
|
835
|
-
) -> Result<GetWorkflowExecutionHistoryResponse>;
|
836
|
-
|
837
|
-
/// Respond to a legacy query-only workflow task
|
838
|
-
async fn respond_legacy_query(
|
839
|
-
&self,
|
840
|
-
task_token: TaskToken,
|
841
|
-
query_result: QueryResult,
|
842
|
-
) -> Result<RespondQueryTaskCompletedResponse>;
|
843
|
-
|
844
|
-
/// Cancel a currently executing workflow
|
845
|
-
async fn cancel_workflow_execution(
|
846
|
-
&self,
|
847
|
-
workflow_id: String,
|
848
|
-
run_id: Option<String>,
|
849
|
-
reason: String,
|
850
|
-
request_id: Option<String>,
|
851
|
-
) -> Result<RequestCancelWorkflowExecutionResponse>;
|
852
|
-
|
853
|
-
/// Terminate a currently executing workflow
|
854
|
-
async fn terminate_workflow_execution(
|
855
|
-
&self,
|
856
|
-
workflow_id: String,
|
857
|
-
run_id: Option<String>,
|
858
|
-
) -> Result<TerminateWorkflowExecutionResponse>;
|
859
|
-
|
860
|
-
/// Register a new namespace
|
861
|
-
async fn register_namespace(
|
862
|
-
&self,
|
863
|
-
options: RegisterNamespaceOptions,
|
864
|
-
) -> Result<RegisterNamespaceResponse>;
|
865
|
-
|
866
|
-
/// Lists all available namespaces
|
867
|
-
async fn list_namespaces(&self) -> Result<ListNamespacesResponse>;
|
868
|
-
|
869
|
-
/// Query namespace details
|
870
|
-
async fn describe_namespace(&self, namespace: Namespace) -> Result<DescribeNamespaceResponse>;
|
871
|
-
|
872
|
-
/// List open workflow executions with Standard Visibility filtering
|
873
|
-
async fn list_open_workflow_executions(
|
874
|
-
&self,
|
875
|
-
max_page_size: i32,
|
876
|
-
next_page_token: Vec<u8>,
|
877
|
-
start_time_filter: Option<StartTimeFilter>,
|
878
|
-
filters: Option<ListOpenFilters>,
|
879
|
-
) -> Result<ListOpenWorkflowExecutionsResponse>;
|
880
|
-
|
881
|
-
/// List closed workflow executions Standard Visibility filtering
|
882
|
-
async fn list_closed_workflow_executions(
|
883
|
-
&self,
|
884
|
-
max_page_size: i32,
|
885
|
-
next_page_token: Vec<u8>,
|
886
|
-
start_time_filter: Option<StartTimeFilter>,
|
887
|
-
filters: Option<ListClosedFilters>,
|
888
|
-
) -> Result<ListClosedWorkflowExecutionsResponse>;
|
889
|
-
|
890
|
-
/// List workflow executions with Advanced Visibility filtering
|
891
|
-
async fn list_workflow_executions(
|
892
|
-
&self,
|
893
|
-
page_size: i32,
|
894
|
-
next_page_token: Vec<u8>,
|
895
|
-
query: String,
|
896
|
-
) -> Result<ListWorkflowExecutionsResponse>;
|
897
|
-
|
898
|
-
/// List archived workflow executions
|
899
|
-
async fn list_archived_workflow_executions(
|
900
|
-
&self,
|
901
|
-
page_size: i32,
|
902
|
-
next_page_token: Vec<u8>,
|
903
|
-
query: String,
|
904
|
-
) -> Result<ListArchivedWorkflowExecutionsResponse>;
|
905
|
-
|
906
|
-
/// Get Cluster Search Attributes
|
907
|
-
async fn get_search_attributes(&self) -> Result<GetSearchAttributesResponse>;
|
908
|
-
|
909
|
-
/// Returns options that were used to initialize the client
|
910
|
-
fn get_options(&self) -> &ClientOptions;
|
911
|
-
|
912
|
-
/// Returns the namespace this client is bound to
|
913
|
-
fn namespace(&self) -> &str;
|
914
|
-
}
|
915
|
-
|
916
|
-
/// Optional fields supplied at the start of workflow execution
|
917
|
-
#[derive(Debug, Clone, Default)]
|
918
|
-
pub struct WorkflowOptions {
|
919
|
-
/// Set the policy for reusing the workflow id
|
920
|
-
pub id_reuse_policy: WorkflowIdReusePolicy,
|
921
|
-
|
922
|
-
/// Optionally set the execution timeout for the workflow
|
923
|
-
/// <https://docs.temporal.io/workflows/#workflow-execution-timeout>
|
924
|
-
pub execution_timeout: Option<Duration>,
|
925
|
-
|
926
|
-
/// Optionally indicates the default run timeout for a workflow run
|
927
|
-
pub run_timeout: Option<Duration>,
|
928
|
-
|
929
|
-
/// Optionally indicates the default task timeout for a workflow run
|
930
|
-
pub task_timeout: Option<Duration>,
|
931
|
-
|
932
|
-
/// Optionally set a cron schedule for the workflow
|
933
|
-
pub cron_schedule: Option<String>,
|
934
|
-
|
935
|
-
/// Optionally associate extra search attributes with a workflow
|
936
|
-
pub search_attributes: Option<HashMap<String, Payload>>,
|
937
|
-
}
|
938
|
-
|
939
|
-
#[async_trait::async_trait]
|
940
|
-
impl WorkflowClientTrait for Client {
|
941
|
-
async fn start_workflow(
|
942
|
-
&self,
|
943
|
-
input: Vec<Payload>,
|
944
|
-
task_queue: String,
|
945
|
-
workflow_id: String,
|
946
|
-
workflow_type: String,
|
947
|
-
request_id: Option<String>,
|
948
|
-
options: WorkflowOptions,
|
949
|
-
) -> Result<StartWorkflowExecutionResponse> {
|
950
|
-
Ok(self
|
951
|
-
.wf_svc()
|
952
|
-
.start_workflow_execution(StartWorkflowExecutionRequest {
|
953
|
-
namespace: self.namespace.clone(),
|
954
|
-
input: input.into_payloads(),
|
955
|
-
workflow_id,
|
956
|
-
workflow_type: Some(WorkflowType {
|
957
|
-
name: workflow_type,
|
958
|
-
}),
|
959
|
-
task_queue: Some(TaskQueue {
|
960
|
-
name: task_queue,
|
961
|
-
kind: TaskQueueKind::Unspecified as i32,
|
962
|
-
}),
|
963
|
-
request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
964
|
-
workflow_id_reuse_policy: options.id_reuse_policy as i32,
|
965
|
-
workflow_execution_timeout: options
|
966
|
-
.execution_timeout
|
967
|
-
.and_then(|d| d.try_into().ok()),
|
968
|
-
workflow_run_timeout: options.execution_timeout.and_then(|d| d.try_into().ok()),
|
969
|
-
workflow_task_timeout: options.task_timeout.and_then(|d| d.try_into().ok()),
|
970
|
-
search_attributes: options.search_attributes.and_then(|d| d.try_into().ok()),
|
971
|
-
cron_schedule: options.cron_schedule.unwrap_or_default(),
|
972
|
-
..Default::default()
|
973
|
-
})
|
974
|
-
.await?
|
975
|
-
.into_inner())
|
976
|
-
}
|
977
|
-
|
978
|
-
async fn reset_sticky_task_queue(
|
979
|
-
&self,
|
980
|
-
workflow_id: String,
|
981
|
-
run_id: String,
|
982
|
-
) -> Result<ResetStickyTaskQueueResponse> {
|
983
|
-
let request = ResetStickyTaskQueueRequest {
|
984
|
-
namespace: self.namespace.clone(),
|
985
|
-
execution: Some(WorkflowExecution {
|
986
|
-
workflow_id,
|
987
|
-
run_id,
|
988
|
-
}),
|
989
|
-
};
|
990
|
-
Ok(self
|
991
|
-
.wf_svc()
|
992
|
-
.reset_sticky_task_queue(request)
|
993
|
-
.await?
|
994
|
-
.into_inner())
|
995
|
-
}
|
996
|
-
|
997
|
-
async fn complete_activity_task(
|
998
|
-
&self,
|
999
|
-
task_token: TaskToken,
|
1000
|
-
result: Option<Payloads>,
|
1001
|
-
) -> Result<RespondActivityTaskCompletedResponse> {
|
1002
|
-
Ok(self
|
1003
|
-
.wf_svc()
|
1004
|
-
.respond_activity_task_completed(RespondActivityTaskCompletedRequest {
|
1005
|
-
task_token: task_token.0,
|
1006
|
-
result,
|
1007
|
-
identity: self.inner.options.identity.clone(),
|
1008
|
-
namespace: self.namespace.clone(),
|
1009
|
-
})
|
1010
|
-
.await?
|
1011
|
-
.into_inner())
|
1012
|
-
}
|
1013
|
-
|
1014
|
-
async fn record_activity_heartbeat(
|
1015
|
-
&self,
|
1016
|
-
task_token: TaskToken,
|
1017
|
-
details: Option<Payloads>,
|
1018
|
-
) -> Result<RecordActivityTaskHeartbeatResponse> {
|
1019
|
-
Ok(self
|
1020
|
-
.wf_svc()
|
1021
|
-
.record_activity_task_heartbeat(RecordActivityTaskHeartbeatRequest {
|
1022
|
-
task_token: task_token.0,
|
1023
|
-
details,
|
1024
|
-
identity: self.inner.options.identity.clone(),
|
1025
|
-
namespace: self.namespace.clone(),
|
1026
|
-
})
|
1027
|
-
.await?
|
1028
|
-
.into_inner())
|
1029
|
-
}
|
1030
|
-
|
1031
|
-
async fn cancel_activity_task(
|
1032
|
-
&self,
|
1033
|
-
task_token: TaskToken,
|
1034
|
-
details: Option<Payloads>,
|
1035
|
-
) -> Result<RespondActivityTaskCanceledResponse> {
|
1036
|
-
Ok(self
|
1037
|
-
.wf_svc()
|
1038
|
-
.respond_activity_task_canceled(RespondActivityTaskCanceledRequest {
|
1039
|
-
task_token: task_token.0,
|
1040
|
-
details,
|
1041
|
-
identity: self.inner.options.identity.clone(),
|
1042
|
-
namespace: self.namespace.clone(),
|
1043
|
-
})
|
1044
|
-
.await?
|
1045
|
-
.into_inner())
|
1046
|
-
}
|
1047
|
-
|
1048
|
-
async fn fail_activity_task(
|
1049
|
-
&self,
|
1050
|
-
task_token: TaskToken,
|
1051
|
-
failure: Option<Failure>,
|
1052
|
-
) -> Result<RespondActivityTaskFailedResponse> {
|
1053
|
-
Ok(self
|
1054
|
-
.wf_svc()
|
1055
|
-
.respond_activity_task_failed(RespondActivityTaskFailedRequest {
|
1056
|
-
task_token: task_token.0,
|
1057
|
-
failure,
|
1058
|
-
identity: self.inner.options.identity.clone(),
|
1059
|
-
namespace: self.namespace.clone(),
|
1060
|
-
// TODO: Implement - https://github.com/temporalio/sdk-core/issues/293
|
1061
|
-
last_heartbeat_details: None,
|
1062
|
-
})
|
1063
|
-
.await?
|
1064
|
-
.into_inner())
|
1065
|
-
}
|
1066
|
-
|
1067
|
-
async fn fail_workflow_task(
|
1068
|
-
&self,
|
1069
|
-
task_token: TaskToken,
|
1070
|
-
cause: WorkflowTaskFailedCause,
|
1071
|
-
failure: Option<Failure>,
|
1072
|
-
) -> Result<RespondWorkflowTaskFailedResponse> {
|
1073
|
-
let request = RespondWorkflowTaskFailedRequest {
|
1074
|
-
task_token: task_token.0,
|
1075
|
-
cause: cause as i32,
|
1076
|
-
failure,
|
1077
|
-
identity: self.inner.options.identity.clone(),
|
1078
|
-
binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
|
1079
|
-
namespace: self.namespace.clone(),
|
1080
|
-
messages: vec![],
|
1081
|
-
};
|
1082
|
-
Ok(self
|
1083
|
-
.wf_svc()
|
1084
|
-
.respond_workflow_task_failed(request)
|
1085
|
-
.await?
|
1086
|
-
.into_inner())
|
1087
|
-
}
|
1088
|
-
|
1089
|
-
async fn signal_workflow_execution(
|
1090
|
-
&self,
|
1091
|
-
workflow_id: String,
|
1092
|
-
run_id: String,
|
1093
|
-
signal_name: String,
|
1094
|
-
payloads: Option<Payloads>,
|
1095
|
-
request_id: Option<String>,
|
1096
|
-
) -> Result<SignalWorkflowExecutionResponse> {
|
1097
|
-
Ok(self
|
1098
|
-
.wf_svc()
|
1099
|
-
.signal_workflow_execution(SignalWorkflowExecutionRequest {
|
1100
|
-
namespace: self.namespace.clone(),
|
1101
|
-
workflow_execution: Some(WorkflowExecution {
|
1102
|
-
workflow_id,
|
1103
|
-
run_id,
|
1104
|
-
}),
|
1105
|
-
signal_name,
|
1106
|
-
input: payloads,
|
1107
|
-
identity: self.inner.options.identity.clone(),
|
1108
|
-
request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
1109
|
-
..Default::default()
|
1110
|
-
})
|
1111
|
-
.await?
|
1112
|
-
.into_inner())
|
1113
|
-
}
|
1114
|
-
|
1115
|
-
async fn signal_with_start_workflow_execution(
|
1116
|
-
&self,
|
1117
|
-
options: SignalWithStartOptions,
|
1118
|
-
workflow_options: WorkflowOptions,
|
1119
|
-
) -> Result<SignalWithStartWorkflowExecutionResponse> {
|
1120
|
-
Ok(self
|
1121
|
-
.wf_svc()
|
1122
|
-
.signal_with_start_workflow_execution(SignalWithStartWorkflowExecutionRequest {
|
1123
|
-
namespace: self.namespace.clone(),
|
1124
|
-
workflow_id: options.workflow_id,
|
1125
|
-
workflow_type: Some(WorkflowType {
|
1126
|
-
name: options.workflow_type,
|
1127
|
-
}),
|
1128
|
-
task_queue: Some(TaskQueue {
|
1129
|
-
name: options.task_queue,
|
1130
|
-
kind: TaskQueueKind::Normal as i32,
|
1131
|
-
}),
|
1132
|
-
input: options.input,
|
1133
|
-
signal_name: options.signal_name,
|
1134
|
-
signal_input: options.signal_input,
|
1135
|
-
identity: self.inner.options.identity.clone(),
|
1136
|
-
request_id: options
|
1137
|
-
.request_id
|
1138
|
-
.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
1139
|
-
workflow_id_reuse_policy: workflow_options.id_reuse_policy as i32,
|
1140
|
-
workflow_execution_timeout: workflow_options
|
1141
|
-
.execution_timeout
|
1142
|
-
.and_then(|d| d.try_into().ok()),
|
1143
|
-
workflow_run_timeout: workflow_options
|
1144
|
-
.execution_timeout
|
1145
|
-
.and_then(|d| d.try_into().ok()),
|
1146
|
-
workflow_task_timeout: workflow_options
|
1147
|
-
.task_timeout
|
1148
|
-
.and_then(|d| d.try_into().ok()),
|
1149
|
-
search_attributes: workflow_options
|
1150
|
-
.search_attributes
|
1151
|
-
.and_then(|d| d.try_into().ok()),
|
1152
|
-
cron_schedule: workflow_options.cron_schedule.unwrap_or_default(),
|
1153
|
-
header: options.signal_header,
|
1154
|
-
..Default::default()
|
1155
|
-
})
|
1156
|
-
.await?
|
1157
|
-
.into_inner())
|
1158
|
-
}
|
1159
|
-
|
1160
|
-
async fn query_workflow_execution(
|
1161
|
-
&self,
|
1162
|
-
workflow_id: String,
|
1163
|
-
run_id: String,
|
1164
|
-
query: WorkflowQuery,
|
1165
|
-
) -> Result<QueryWorkflowResponse> {
|
1166
|
-
Ok(self
|
1167
|
-
.wf_svc()
|
1168
|
-
.query_workflow(QueryWorkflowRequest {
|
1169
|
-
namespace: self.namespace.clone(),
|
1170
|
-
execution: Some(WorkflowExecution {
|
1171
|
-
workflow_id,
|
1172
|
-
run_id,
|
1173
|
-
}),
|
1174
|
-
query: Some(query),
|
1175
|
-
query_reject_condition: 1,
|
1176
|
-
})
|
1177
|
-
.await?
|
1178
|
-
.into_inner())
|
1179
|
-
}
|
1180
|
-
|
1181
|
-
async fn describe_workflow_execution(
|
1182
|
-
&self,
|
1183
|
-
workflow_id: String,
|
1184
|
-
run_id: Option<String>,
|
1185
|
-
) -> Result<DescribeWorkflowExecutionResponse> {
|
1186
|
-
Ok(self
|
1187
|
-
.wf_svc()
|
1188
|
-
.describe_workflow_execution(DescribeWorkflowExecutionRequest {
|
1189
|
-
namespace: self.namespace.clone(),
|
1190
|
-
execution: Some(WorkflowExecution {
|
1191
|
-
workflow_id,
|
1192
|
-
run_id: run_id.unwrap_or_default(),
|
1193
|
-
}),
|
1194
|
-
})
|
1195
|
-
.await?
|
1196
|
-
.into_inner())
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
async fn get_workflow_execution_history(
|
1200
|
-
&self,
|
1201
|
-
workflow_id: String,
|
1202
|
-
run_id: Option<String>,
|
1203
|
-
page_token: Vec<u8>,
|
1204
|
-
) -> Result<GetWorkflowExecutionHistoryResponse> {
|
1205
|
-
Ok(self
|
1206
|
-
.wf_svc()
|
1207
|
-
.get_workflow_execution_history(GetWorkflowExecutionHistoryRequest {
|
1208
|
-
namespace: self.namespace.clone(),
|
1209
|
-
execution: Some(WorkflowExecution {
|
1210
|
-
workflow_id,
|
1211
|
-
run_id: run_id.unwrap_or_default(),
|
1212
|
-
}),
|
1213
|
-
next_page_token: page_token,
|
1214
|
-
..Default::default()
|
1215
|
-
})
|
1216
|
-
.await?
|
1217
|
-
.into_inner())
|
1218
|
-
}
|
1219
|
-
|
1220
|
-
async fn respond_legacy_query(
|
1221
|
-
&self,
|
1222
|
-
task_token: TaskToken,
|
1223
|
-
query_result: QueryResult,
|
1224
|
-
) -> Result<RespondQueryTaskCompletedResponse> {
|
1225
|
-
let (_, completed_type, query_result, error_message) = query_result.into_components();
|
1226
|
-
Ok(self
|
1227
|
-
.wf_svc()
|
1228
|
-
.respond_query_task_completed(RespondQueryTaskCompletedRequest {
|
1229
|
-
task_token: task_token.into(),
|
1230
|
-
completed_type: completed_type as i32,
|
1231
|
-
query_result,
|
1232
|
-
error_message,
|
1233
|
-
namespace: self.namespace.clone(),
|
1234
|
-
})
|
1235
|
-
.await?
|
1236
|
-
.into_inner())
|
1237
|
-
}
|
1238
|
-
|
1239
|
-
async fn cancel_workflow_execution(
|
1240
|
-
&self,
|
1241
|
-
workflow_id: String,
|
1242
|
-
run_id: Option<String>,
|
1243
|
-
reason: String,
|
1244
|
-
request_id: Option<String>,
|
1245
|
-
) -> Result<RequestCancelWorkflowExecutionResponse> {
|
1246
|
-
Ok(self
|
1247
|
-
.wf_svc()
|
1248
|
-
.request_cancel_workflow_execution(RequestCancelWorkflowExecutionRequest {
|
1249
|
-
namespace: self.namespace.clone(),
|
1250
|
-
workflow_execution: Some(WorkflowExecution {
|
1251
|
-
workflow_id,
|
1252
|
-
run_id: run_id.unwrap_or_default(),
|
1253
|
-
}),
|
1254
|
-
identity: self.inner.options.identity.clone(),
|
1255
|
-
request_id: request_id.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
1256
|
-
first_execution_run_id: "".to_string(),
|
1257
|
-
reason,
|
1258
|
-
})
|
1259
|
-
.await?
|
1260
|
-
.into_inner())
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
async fn terminate_workflow_execution(
|
1264
|
-
&self,
|
1265
|
-
workflow_id: String,
|
1266
|
-
run_id: Option<String>,
|
1267
|
-
) -> Result<TerminateWorkflowExecutionResponse> {
|
1268
|
-
Ok(self
|
1269
|
-
.wf_svc()
|
1270
|
-
.terminate_workflow_execution(TerminateWorkflowExecutionRequest {
|
1271
|
-
namespace: self.namespace.clone(),
|
1272
|
-
workflow_execution: Some(WorkflowExecution {
|
1273
|
-
workflow_id,
|
1274
|
-
run_id: run_id.unwrap_or_default(),
|
1275
|
-
}),
|
1276
|
-
reason: "".to_string(),
|
1277
|
-
details: None,
|
1278
|
-
identity: self.inner.options.identity.clone(),
|
1279
|
-
first_execution_run_id: "".to_string(),
|
1280
|
-
})
|
1281
|
-
.await?
|
1282
|
-
.into_inner())
|
1283
|
-
}
|
1284
|
-
|
1285
|
-
async fn register_namespace(
|
1286
|
-
&self,
|
1287
|
-
options: RegisterNamespaceOptions,
|
1288
|
-
) -> Result<RegisterNamespaceResponse> {
|
1289
|
-
let req = Into::<RegisterNamespaceRequest>::into(options);
|
1290
|
-
Ok(self.wf_svc().register_namespace(req).await?.into_inner())
|
1291
|
-
}
|
1292
|
-
|
1293
|
-
async fn list_namespaces(&self) -> Result<ListNamespacesResponse> {
|
1294
|
-
Ok(self
|
1295
|
-
.wf_svc()
|
1296
|
-
.list_namespaces(ListNamespacesRequest::default())
|
1297
|
-
.await?
|
1298
|
-
.into_inner())
|
1299
|
-
}
|
1300
|
-
|
1301
|
-
async fn describe_namespace(&self, namespace: Namespace) -> Result<DescribeNamespaceResponse> {
|
1302
|
-
Ok(self
|
1303
|
-
.wf_svc()
|
1304
|
-
.describe_namespace(namespace.into_describe_namespace_request())
|
1305
|
-
.await?
|
1306
|
-
.into_inner())
|
1307
|
-
}
|
1308
|
-
|
1309
|
-
async fn list_open_workflow_executions(
|
1310
|
-
&self,
|
1311
|
-
maximum_page_size: i32,
|
1312
|
-
next_page_token: Vec<u8>,
|
1313
|
-
start_time_filter: Option<StartTimeFilter>,
|
1314
|
-
filters: Option<ListOpenFilters>,
|
1315
|
-
) -> Result<ListOpenWorkflowExecutionsResponse> {
|
1316
|
-
Ok(self
|
1317
|
-
.wf_svc()
|
1318
|
-
.list_open_workflow_executions(ListOpenWorkflowExecutionsRequest {
|
1319
|
-
namespace: self.namespace.clone(),
|
1320
|
-
maximum_page_size,
|
1321
|
-
next_page_token,
|
1322
|
-
start_time_filter,
|
1323
|
-
filters,
|
1324
|
-
})
|
1325
|
-
.await?
|
1326
|
-
.into_inner())
|
1327
|
-
}
|
1328
|
-
|
1329
|
-
async fn list_closed_workflow_executions(
|
1330
|
-
&self,
|
1331
|
-
maximum_page_size: i32,
|
1332
|
-
next_page_token: Vec<u8>,
|
1333
|
-
start_time_filter: Option<StartTimeFilter>,
|
1334
|
-
filters: Option<ListClosedFilters>,
|
1335
|
-
) -> Result<ListClosedWorkflowExecutionsResponse> {
|
1336
|
-
Ok(self
|
1337
|
-
.wf_svc()
|
1338
|
-
.list_closed_workflow_executions(ListClosedWorkflowExecutionsRequest {
|
1339
|
-
namespace: self.namespace.clone(),
|
1340
|
-
maximum_page_size,
|
1341
|
-
next_page_token,
|
1342
|
-
start_time_filter,
|
1343
|
-
filters,
|
1344
|
-
})
|
1345
|
-
.await?
|
1346
|
-
.into_inner())
|
1347
|
-
}
|
1348
|
-
|
1349
|
-
async fn list_workflow_executions(
|
1350
|
-
&self,
|
1351
|
-
page_size: i32,
|
1352
|
-
next_page_token: Vec<u8>,
|
1353
|
-
query: String,
|
1354
|
-
) -> Result<ListWorkflowExecutionsResponse> {
|
1355
|
-
Ok(self
|
1356
|
-
.wf_svc()
|
1357
|
-
.list_workflow_executions(ListWorkflowExecutionsRequest {
|
1358
|
-
namespace: self.namespace.clone(),
|
1359
|
-
page_size,
|
1360
|
-
next_page_token,
|
1361
|
-
query,
|
1362
|
-
})
|
1363
|
-
.await?
|
1364
|
-
.into_inner())
|
1365
|
-
}
|
1366
|
-
|
1367
|
-
async fn list_archived_workflow_executions(
|
1368
|
-
&self,
|
1369
|
-
page_size: i32,
|
1370
|
-
next_page_token: Vec<u8>,
|
1371
|
-
query: String,
|
1372
|
-
) -> Result<ListArchivedWorkflowExecutionsResponse> {
|
1373
|
-
Ok(self
|
1374
|
-
.wf_svc()
|
1375
|
-
.list_archived_workflow_executions(ListArchivedWorkflowExecutionsRequest {
|
1376
|
-
namespace: self.namespace.clone(),
|
1377
|
-
page_size,
|
1378
|
-
next_page_token,
|
1379
|
-
query,
|
1380
|
-
})
|
1381
|
-
.await?
|
1382
|
-
.into_inner())
|
1383
|
-
}
|
1384
|
-
|
1385
|
-
async fn get_search_attributes(&self) -> Result<GetSearchAttributesResponse> {
|
1386
|
-
Ok(self
|
1387
|
-
.wf_svc()
|
1388
|
-
.get_search_attributes(GetSearchAttributesRequest {})
|
1389
|
-
.await?
|
1390
|
-
.into_inner())
|
1391
|
-
}
|
1392
|
-
|
1393
|
-
fn get_options(&self) -> &ClientOptions {
|
1394
|
-
&self.inner.options
|
1395
|
-
}
|
1396
|
-
|
1397
|
-
fn namespace(&self) -> &str {
|
1398
|
-
&self.namespace
|
1399
|
-
}
|
1400
|
-
}
|
1401
|
-
|
1402
|
-
mod sealed {
|
1403
|
-
use crate::{InterceptedMetricsSvc, RawClientLike, WorkflowClientTrait};
|
1404
|
-
|
1405
|
-
pub trait WfHandleClient:
|
1406
|
-
WorkflowClientTrait + RawClientLike<SvcType = InterceptedMetricsSvc>
|
1407
|
-
{
|
1408
|
-
}
|
1409
|
-
impl<T> WfHandleClient for T where
|
1410
|
-
T: WorkflowClientTrait + RawClientLike<SvcType = InterceptedMetricsSvc>
|
1411
|
-
{
|
1412
|
-
}
|
1413
|
-
}
|
1414
|
-
|
1415
|
-
/// Additional methods for workflow clients
|
1416
|
-
pub trait WfClientExt: WfHandleClient + Sized + Clone {
|
1417
|
-
/// Create an untyped handle for a workflow execution, which can be used to do things like
|
1418
|
-
/// wait for that workflow's result. `run_id` may be left blank to target the latest run.
|
1419
|
-
fn get_untyped_workflow_handle(
|
1420
|
-
&self,
|
1421
|
-
workflow_id: impl Into<String>,
|
1422
|
-
run_id: impl Into<String>,
|
1423
|
-
) -> UntypedWorkflowHandle<Self> {
|
1424
|
-
let rid = run_id.into();
|
1425
|
-
UntypedWorkflowHandle::new(
|
1426
|
-
self.clone(),
|
1427
|
-
WorkflowExecutionInfo {
|
1428
|
-
namespace: self.namespace().to_string(),
|
1429
|
-
workflow_id: workflow_id.into(),
|
1430
|
-
run_id: if rid.is_empty() { None } else { Some(rid) },
|
1431
|
-
},
|
1432
|
-
)
|
1433
|
-
}
|
1434
|
-
}
|
1435
|
-
impl<T> WfClientExt for T where T: WfHandleClient + Clone + Sized {}
|
1436
|
-
|
1437
|
-
#[cfg(test)]
|
1438
|
-
mod tests {
|
1439
|
-
use super::*;
|
1440
|
-
|
1441
|
-
#[test]
|
1442
|
-
fn respects_per_call_headers() {
|
1443
|
-
let opts = ClientOptionsBuilder::default()
|
1444
|
-
.identity("enchicat".to_string())
|
1445
|
-
.target_url(Url::parse("https://smolkitty").unwrap())
|
1446
|
-
.client_name("cute-kitty".to_string())
|
1447
|
-
.client_version("0.1.0".to_string())
|
1448
|
-
.build()
|
1449
|
-
.unwrap();
|
1450
|
-
|
1451
|
-
let mut static_headers = HashMap::new();
|
1452
|
-
static_headers.insert("enchi".to_string(), "kitty".to_string());
|
1453
|
-
let mut iceptor = ServiceCallInterceptor {
|
1454
|
-
opts,
|
1455
|
-
headers: Arc::new(RwLock::new(static_headers)),
|
1456
|
-
};
|
1457
|
-
let mut req = tonic::Request::new(());
|
1458
|
-
req.metadata_mut().insert("enchi", "cat".parse().unwrap());
|
1459
|
-
let next_req = iceptor.call(req).unwrap();
|
1460
|
-
assert_eq!(next_req.metadata().get("enchi").unwrap(), "cat");
|
1461
|
-
}
|
1462
|
-
}
|