temporalio 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +180 -7
- data/bridge/Cargo.lock +208 -76
- data/bridge/Cargo.toml +5 -2
- data/bridge/sdk-core/Cargo.toml +1 -1
- data/bridge/sdk-core/README.md +20 -10
- data/bridge/sdk-core/client/Cargo.toml +1 -1
- data/bridge/sdk-core/client/src/lib.rs +227 -59
- data/bridge/sdk-core/client/src/metrics.rs +17 -8
- data/bridge/sdk-core/client/src/raw.rs +13 -12
- data/bridge/sdk-core/client/src/retry.rs +132 -43
- data/bridge/sdk-core/core/Cargo.toml +28 -15
- data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
- data/bridge/sdk-core/core/src/abstractions.rs +225 -36
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +217 -79
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +165 -2
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +565 -34
- data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -90
- data/bridge/sdk-core/core/src/core_tests/workers.rs +3 -5
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +430 -67
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +106 -12
- data/bridge/sdk-core/core/src/internal_flags.rs +136 -0
- data/bridge/sdk-core/core/src/lib.rs +148 -34
- data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
- data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +219 -140
- data/bridge/sdk-core/core/src/telemetry/mod.rs +326 -315
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +20 -14
- data/bridge/sdk-core/core/src/test_help/mod.rs +85 -21
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +112 -156
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +364 -128
- data/bridge/sdk-core/core/src/worker/activities.rs +263 -170
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +23 -3
- data/bridge/sdk-core/core/src/worker/client.rs +48 -6
- data/bridge/sdk-core/core/src/worker/mod.rs +186 -75
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +13 -24
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +879 -226
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +101 -48
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +90 -32
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -10
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +160 -83
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +36 -54
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +179 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +104 -157
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +9 -13
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +10 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +14 -11
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +395 -299
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +12 -20
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +33 -18
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +1032 -374
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +525 -392
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +125 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -6
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +456 -681
- data/bridge/sdk-core/core-api/Cargo.toml +6 -4
- data/bridge/sdk-core/core-api/src/errors.rs +1 -34
- data/bridge/sdk-core/core-api/src/lib.rs +7 -45
- data/bridge/sdk-core/core-api/src/telemetry.rs +141 -0
- data/bridge/sdk-core/core-api/src/worker.rs +27 -1
- data/bridge/sdk-core/etc/deps.svg +115 -140
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +18 -15
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +8 -3
- 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/protos/api_upstream/buf.yaml +0 -3
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
- data/bridge/sdk-core/protos/api_upstream/{temporal/api/enums/v1/cluster.proto → build/tools.go} +7 -18
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +15 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +10 -8
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +28 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +24 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +62 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +4 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +24 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
- data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +71 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +111 -36
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +19 -5
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +9 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +9 -1
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +6 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- data/bridge/sdk-core/sdk/Cargo.toml +4 -3
- data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
- data/bridge/sdk-core/sdk/src/lib.rs +94 -25
- data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
- data/bridge/sdk-core/sdk/src/workflow_future.rs +10 -13
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +5 -2
- data/bridge/sdk-core/sdk-core-protos/build.rs +36 -2
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +164 -104
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +27 -23
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +252 -74
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
- data/bridge/sdk-core/test-utils/Cargo.toml +4 -1
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +106 -296
- data/bridge/sdk-core/test-utils/src/histfetch.rs +1 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +161 -50
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
- data/bridge/sdk-core/test-utils/src/workflows.rs +29 -0
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +130 -0
- data/bridge/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +10 -5
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +239 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +4 -60
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +93 -69
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +151 -116
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +7 -28
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +115 -24
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -4
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +27 -18
- data/bridge/sdk-core/tests/main.rs +8 -16
- data/bridge/sdk-core/tests/runner.rs +75 -36
- data/bridge/sdk-core/tests/wf_input_replay.rs +32 -0
- data/bridge/src/connection.rs +117 -82
- data/bridge/src/lib.rs +356 -42
- data/bridge/src/runtime.rs +10 -3
- data/bridge/src/test_server.rs +153 -0
- data/bridge/src/worker.rs +133 -9
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
- data/lib/gen/temporal/api/command/v1/message_pb.rb +10 -16
- data/lib/gen/temporal/api/common/v1/message_pb.rb +5 -1
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -3
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +5 -4
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +9 -1
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +7 -10
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/history/v1/message_pb.rb +34 -25
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +14 -51
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +30 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +23 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +49 -0
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +21 -0
- data/lib/gen/temporal/api/update/v1/message_pb.rb +49 -3
- data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +47 -20
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +10 -6
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +9 -3
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +28 -21
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +32 -24
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +12 -5
- data/lib/temporalio/activity/context.rb +102 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/connect_options.rb +15 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge/retry_config.rb +24 -0
- data/lib/temporalio/bridge/tls_options.rb +19 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/{temporal → temporalio}/client/implementation.rb +57 -56
- data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
- data/lib/{temporal → temporalio}/client.rb +19 -32
- data/lib/temporalio/connection/retry_config.rb +44 -0
- data/lib/temporalio/connection/service.rb +20 -0
- data/lib/temporalio/connection/test_service.rb +92 -0
- data/lib/temporalio/connection/tls_options.rb +51 -0
- data/lib/temporalio/connection/workflow_service.rb +731 -0
- data/lib/temporalio/connection.rb +86 -0
- data/lib/{temporal → temporalio}/data_converter.rb +76 -35
- data/lib/{temporal → temporalio}/error/failure.rb +6 -6
- data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
- data/lib/{temporal → temporalio}/errors.rb +19 -1
- data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
- data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/activity_inbound.rb +22 -0
- data/lib/temporalio/interceptor/activity_outbound.rb +24 -0
- data/lib/{temporal → temporalio}/interceptor/chain.rb +7 -6
- data/lib/{temporal → temporalio}/interceptor/client.rb +27 -2
- data/lib/temporalio/interceptor.rb +22 -0
- data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
- data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
- data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
- data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
- data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/{temporal → temporalio}/retry_policy.rb +17 -7
- data/lib/{temporal → temporalio}/retry_state.rb +1 -1
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/testing/time_skipping_handle.rb +32 -0
- data/lib/temporalio/testing/time_skipping_interceptor.rb +23 -0
- data/lib/temporalio/testing/workflow_environment.rb +112 -0
- data/lib/temporalio/testing.rb +175 -0
- data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +114 -0
- data/lib/temporalio/worker/activity_worker.rb +164 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +124 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +204 -0
- data/lib/temporalio/workflow/async.rb +46 -0
- data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
- data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
- data/lib/temporalio/workflow/future.rb +138 -0
- data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
- data/lib/temporalio/workflow/info.rb +76 -0
- data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
- data/lib/temporalio.rb +12 -3
- data/temporalio.gemspec +11 -6
- metadata +137 -64
- data/bridge/sdk-core/Cargo.lock +0 -2606
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
- data/bridge/sdk-core/core/src/log_export.rs +0 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +0 -222
- data/lib/temporal/bridge.rb +0 -14
- data/lib/temporal/connection.rb +0 -736
- data/lib/temporal/failure_converter.rb +0 -8
- data/lib/temporal/payload_converter.rb +0 -14
- data/lib/temporal/runtime.rb +0 -22
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -8
@@ -13,14 +13,17 @@ mod retry;
|
|
13
13
|
mod workflow_handle;
|
14
14
|
|
15
15
|
pub use crate::retry::{CallType, RetryClient, RETRYABLE_ERROR_CODES};
|
16
|
+
pub use metrics::ClientMetricProvider;
|
16
17
|
pub use raw::{HealthService, OperatorService, TestService, WorkflowService};
|
17
18
|
pub use temporal_sdk_core_protos::temporal::api::{
|
19
|
+
enums::v1::ArchivalState,
|
18
20
|
filter::v1::{StartTimeFilter, StatusFilter, WorkflowExecutionFilter, WorkflowTypeFilter},
|
19
21
|
workflowservice::v1::{
|
20
22
|
list_closed_workflow_executions_request::Filters as ListClosedFilters,
|
21
23
|
list_open_workflow_executions_request::Filters as ListOpenFilters,
|
22
24
|
},
|
23
25
|
};
|
26
|
+
pub use tonic;
|
24
27
|
pub use workflow_handle::{WorkflowExecutionInfo, WorkflowExecutionResult};
|
25
28
|
|
26
29
|
use crate::{
|
@@ -32,7 +35,6 @@ use crate::{
|
|
32
35
|
use backoff::{exponential, ExponentialBackoff, SystemClock};
|
33
36
|
use http::uri::InvalidUri;
|
34
37
|
use once_cell::sync::OnceCell;
|
35
|
-
use opentelemetry::metrics::Meter;
|
36
38
|
use parking_lot::RwLock;
|
37
39
|
use std::{
|
38
40
|
collections::HashMap,
|
@@ -46,13 +48,13 @@ use temporal_sdk_core_protos::{
|
|
46
48
|
coresdk::{workflow_commands::QueryResult, IntoPayloadsExt},
|
47
49
|
grpc::health::v1::health_client::HealthClient,
|
48
50
|
temporal::api::{
|
49
|
-
command::v1::Command,
|
50
51
|
common::v1::{Header, Payload, Payloads, WorkflowExecution, WorkflowType},
|
51
52
|
enums::v1::{TaskQueueKind, WorkflowIdReusePolicy, WorkflowTaskFailedCause},
|
52
53
|
failure::v1::Failure,
|
53
54
|
operatorservice::v1::operator_service_client::OperatorServiceClient,
|
54
55
|
query::v1::WorkflowQuery,
|
55
|
-
|
56
|
+
replication::v1::ClusterReplicationConfig,
|
57
|
+
taskqueue::v1::TaskQueue,
|
56
58
|
testservice::v1::test_service_client::TestServiceClient,
|
57
59
|
workflowservice::v1::{workflow_service_client::WorkflowServiceClient, *},
|
58
60
|
},
|
@@ -181,6 +183,17 @@ impl RetryConfig {
|
|
181
183
|
}
|
182
184
|
}
|
183
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
|
+
|
184
197
|
pub(crate) fn into_exp_backoff<C>(self, clock: C) -> exponential::ExponentialBackoff<C> {
|
185
198
|
exponential::ExponentialBackoff {
|
186
199
|
current_interval: self.initial_interval,
|
@@ -273,7 +286,7 @@ impl ClientOptions {
|
|
273
286
|
pub async fn connect(
|
274
287
|
&self,
|
275
288
|
namespace: impl Into<String>,
|
276
|
-
metrics_meter: Option<&
|
289
|
+
metrics_meter: Option<&dyn ClientMetricProvider>,
|
277
290
|
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
278
291
|
) -> Result<RetryClient<Client>, ClientInitError> {
|
279
292
|
let client = self
|
@@ -291,7 +304,7 @@ impl ClientOptions {
|
|
291
304
|
/// See [RetryClient] for more
|
292
305
|
pub async fn connect_no_namespace(
|
293
306
|
&self,
|
294
|
-
metrics_meter: Option<&
|
307
|
+
metrics_meter: Option<&dyn ClientMetricProvider>,
|
295
308
|
headers: Option<Arc<RwLock<HashMap<String, String>>>>,
|
296
309
|
) -> Result<RetryClient<ConfiguredClient<TemporalServiceClientWithMetrics>>, ClientInitError>
|
297
310
|
{
|
@@ -362,24 +375,6 @@ impl ClientOptions {
|
|
362
375
|
}
|
363
376
|
}
|
364
377
|
|
365
|
-
/// A version of [RespondWorkflowTaskCompletedRequest] that will finish being filled out by the
|
366
|
-
/// server client
|
367
|
-
#[derive(Debug, Clone, PartialEq)]
|
368
|
-
pub struct WorkflowTaskCompletion {
|
369
|
-
/// The task token that would've been received from polling for a workflow activation
|
370
|
-
pub task_token: TaskToken,
|
371
|
-
/// A list of new commands to send to the server, such as starting a timer.
|
372
|
-
pub commands: Vec<Command>,
|
373
|
-
/// If set, indicate that next task should be queued on sticky queue with given attributes.
|
374
|
-
pub sticky_attributes: Option<StickyExecutionAttributes>,
|
375
|
-
/// Responses to queries in the `queries` field of the workflow task.
|
376
|
-
pub query_responses: Vec<QueryResult>,
|
377
|
-
/// Indicate that the task completion should return a new WFT if one is available
|
378
|
-
pub return_new_workflow_task: bool,
|
379
|
-
/// Force a new WFT to be created after this completion
|
380
|
-
pub force_create_new_workflow_task: bool,
|
381
|
-
}
|
382
|
-
|
383
378
|
/// Interceptor which attaches common metadata (like "client-name") to every outgoing call
|
384
379
|
#[derive(Clone)]
|
385
380
|
pub struct ServiceCallInterceptor {
|
@@ -600,6 +595,133 @@ impl Namespace {
|
|
600
595
|
}
|
601
596
|
}
|
602
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
|
+
|
603
725
|
/// This trait provides higher-level friendlier interaction with the server.
|
604
726
|
/// See the [WorkflowService] trait for a lower-level client.
|
605
727
|
#[cfg_attr(test, mockall::automock)]
|
@@ -685,15 +807,8 @@ pub trait WorkflowClientTrait {
|
|
685
807
|
#[allow(clippy::too_many_arguments)]
|
686
808
|
async fn signal_with_start_workflow_execution(
|
687
809
|
&self,
|
688
|
-
|
689
|
-
|
690
|
-
workflow_id: String,
|
691
|
-
workflow_type: String,
|
692
|
-
request_id: Option<String>,
|
693
|
-
options: WorkflowOptions,
|
694
|
-
signal_name: String,
|
695
|
-
signal_input: Option<Payloads>,
|
696
|
-
signal_header: Option<Header>,
|
810
|
+
options: SignalWithStartOptions,
|
811
|
+
workflow_options: WorkflowOptions,
|
697
812
|
) -> Result<SignalWithStartWorkflowExecutionResponse>;
|
698
813
|
|
699
814
|
/// Request a query of a certain workflow instance
|
@@ -742,13 +857,19 @@ pub trait WorkflowClientTrait {
|
|
742
857
|
run_id: Option<String>,
|
743
858
|
) -> Result<TerminateWorkflowExecutionResponse>;
|
744
859
|
|
860
|
+
/// Register a new namespace
|
861
|
+
async fn register_namespace(
|
862
|
+
&self,
|
863
|
+
options: RegisterNamespaceOptions,
|
864
|
+
) -> Result<RegisterNamespaceResponse>;
|
865
|
+
|
745
866
|
/// Lists all available namespaces
|
746
867
|
async fn list_namespaces(&self) -> Result<ListNamespacesResponse>;
|
747
868
|
|
748
869
|
/// Query namespace details
|
749
870
|
async fn describe_namespace(&self, namespace: Namespace) -> Result<DescribeNamespaceResponse>;
|
750
871
|
|
751
|
-
/// List open
|
872
|
+
/// List open workflow executions with Standard Visibility filtering
|
752
873
|
async fn list_open_workflow_executions(
|
753
874
|
&self,
|
754
875
|
max_page_size: i32,
|
@@ -757,7 +878,7 @@ pub trait WorkflowClientTrait {
|
|
757
878
|
filters: Option<ListOpenFilters>,
|
758
879
|
) -> Result<ListOpenWorkflowExecutionsResponse>;
|
759
880
|
|
760
|
-
/// List closed
|
881
|
+
/// List closed workflow executions Standard Visibility filtering
|
761
882
|
async fn list_closed_workflow_executions(
|
762
883
|
&self,
|
763
884
|
max_page_size: i32,
|
@@ -766,14 +887,25 @@ pub trait WorkflowClientTrait {
|
|
766
887
|
filters: Option<ListClosedFilters>,
|
767
888
|
) -> Result<ListClosedWorkflowExecutionsResponse>;
|
768
889
|
|
769
|
-
/// List
|
890
|
+
/// List workflow executions with Advanced Visibility filtering
|
770
891
|
async fn list_workflow_executions(
|
771
892
|
&self,
|
772
|
-
|
893
|
+
page_size: i32,
|
773
894
|
next_page_token: Vec<u8>,
|
774
895
|
query: String,
|
775
896
|
) -> Result<ListWorkflowExecutionsResponse>;
|
776
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
|
+
|
777
909
|
/// Returns options that were used to initialize the client
|
778
910
|
fn get_options(&self) -> &ClientOptions;
|
779
911
|
|
@@ -945,6 +1077,7 @@ impl WorkflowClientTrait for Client {
|
|
945
1077
|
identity: self.inner.options.identity.clone(),
|
946
1078
|
binary_checksum: self.bound_worker_build_id.clone().unwrap_or_default(),
|
947
1079
|
namespace: self.namespace.clone(),
|
1080
|
+
messages: vec![],
|
948
1081
|
};
|
949
1082
|
Ok(self
|
950
1083
|
.wf_svc()
|
@@ -981,42 +1114,43 @@ impl WorkflowClientTrait for Client {
|
|
981
1114
|
|
982
1115
|
async fn signal_with_start_workflow_execution(
|
983
1116
|
&self,
|
984
|
-
|
985
|
-
|
986
|
-
workflow_id: String,
|
987
|
-
workflow_type: String,
|
988
|
-
request_id: Option<String>,
|
989
|
-
options: WorkflowOptions,
|
990
|
-
signal_name: String,
|
991
|
-
signal_input: Option<Payloads>,
|
992
|
-
signal_header: Option<Header>,
|
1117
|
+
options: SignalWithStartOptions,
|
1118
|
+
workflow_options: WorkflowOptions,
|
993
1119
|
) -> Result<SignalWithStartWorkflowExecutionResponse> {
|
994
1120
|
Ok(self
|
995
1121
|
.wf_svc()
|
996
1122
|
.signal_with_start_workflow_execution(SignalWithStartWorkflowExecutionRequest {
|
997
1123
|
namespace: self.namespace.clone(),
|
998
|
-
workflow_id,
|
1124
|
+
workflow_id: options.workflow_id,
|
999
1125
|
workflow_type: Some(WorkflowType {
|
1000
|
-
name: workflow_type,
|
1126
|
+
name: options.workflow_type,
|
1001
1127
|
}),
|
1002
1128
|
task_queue: Some(TaskQueue {
|
1003
|
-
name: task_queue,
|
1129
|
+
name: options.task_queue,
|
1004
1130
|
kind: TaskQueueKind::Normal as i32,
|
1005
1131
|
}),
|
1006
|
-
input,
|
1007
|
-
signal_name,
|
1008
|
-
signal_input,
|
1132
|
+
input: options.input,
|
1133
|
+
signal_name: options.signal_name,
|
1134
|
+
signal_input: options.signal_input,
|
1009
1135
|
identity: self.inner.options.identity.clone(),
|
1010
|
-
request_id:
|
1011
|
-
|
1012
|
-
|
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
|
1013
1141
|
.execution_timeout
|
1014
1142
|
.and_then(|d| d.try_into().ok()),
|
1015
|
-
workflow_run_timeout:
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
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,
|
1020
1154
|
..Default::default()
|
1021
1155
|
})
|
1022
1156
|
.await?
|
@@ -1148,6 +1282,14 @@ impl WorkflowClientTrait for Client {
|
|
1148
1282
|
.into_inner())
|
1149
1283
|
}
|
1150
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
|
+
|
1151
1293
|
async fn list_namespaces(&self) -> Result<ListNamespacesResponse> {
|
1152
1294
|
Ok(self
|
1153
1295
|
.wf_svc()
|
@@ -1222,6 +1364,32 @@ impl WorkflowClientTrait for Client {
|
|
1222
1364
|
.into_inner())
|
1223
1365
|
}
|
1224
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
|
+
|
1225
1393
|
fn get_options(&self) -> &ClientOptions {
|
1226
1394
|
&self.inner.options
|
1227
1395
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
use crate::{AttachMetricLabels, LONG_POLL_METHOD_NAMES};
|
2
2
|
use futures::{future::BoxFuture, FutureExt};
|
3
3
|
use opentelemetry::{
|
4
|
-
metrics::{Counter, Histogram
|
4
|
+
metrics::{Counter, Histogram},
|
5
5
|
KeyValue,
|
6
6
|
};
|
7
7
|
use std::{
|
@@ -30,18 +30,27 @@ pub struct MetricsContext {
|
|
30
30
|
long_svc_request_latency: Histogram<u64>,
|
31
31
|
}
|
32
32
|
|
33
|
+
/// Things that can provide metrics for the client implement this. Trait exists to avoid having
|
34
|
+
/// to make a whole new lower-level crate just for a tiny shared wrapper around OTel meters.
|
35
|
+
pub trait ClientMetricProvider {
|
36
|
+
/// Construct a counter metric
|
37
|
+
fn counter(&self, name: &'static str) -> Counter<u64>;
|
38
|
+
/// Construct a histogram metric
|
39
|
+
fn histogram(&self, name: &'static str) -> Histogram<u64>;
|
40
|
+
}
|
41
|
+
|
33
42
|
impl MetricsContext {
|
34
|
-
pub(crate) fn new(kvs: Vec<KeyValue>,
|
43
|
+
pub(crate) fn new(kvs: Vec<KeyValue>, metric_provider: &dyn ClientMetricProvider) -> Self {
|
35
44
|
Self {
|
36
45
|
ctx: opentelemetry::Context::current(),
|
37
46
|
kvs: Arc::new(kvs),
|
38
47
|
poll_is_long: false,
|
39
|
-
svc_request:
|
40
|
-
svc_request_failed:
|
41
|
-
long_svc_request:
|
42
|
-
long_svc_request_failed:
|
43
|
-
svc_request_latency:
|
44
|
-
long_svc_request_latency:
|
48
|
+
svc_request: metric_provider.counter("request"),
|
49
|
+
svc_request_failed: metric_provider.counter("request_failure"),
|
50
|
+
long_svc_request: metric_provider.counter("long_request"),
|
51
|
+
long_svc_request_failed: metric_provider.counter("long_request_failure"),
|
52
|
+
svc_request_latency: metric_provider.histogram("request_latency"),
|
53
|
+
long_svc_request_latency: metric_provider.histogram("long_request_latency"),
|
45
54
|
}
|
46
55
|
}
|
47
56
|
|
@@ -542,6 +542,15 @@ proxier! {
|
|
542
542
|
r.extensions_mut().insert(labels);
|
543
543
|
}
|
544
544
|
);
|
545
|
+
(
|
546
|
+
delete_workflow_execution,
|
547
|
+
DeleteWorkflowExecutionRequest,
|
548
|
+
DeleteWorkflowExecutionResponse,
|
549
|
+
|r| {
|
550
|
+
let labels = AttachMetricLabels::namespace(r.get_ref().namespace.clone());
|
551
|
+
r.extensions_mut().insert(labels);
|
552
|
+
}
|
553
|
+
);
|
545
554
|
(
|
546
555
|
list_open_workflow_executions,
|
547
556
|
ListOpenWorkflowExecutionsRequest,
|
@@ -751,9 +760,9 @@ proxier! {
|
|
751
760
|
}
|
752
761
|
);
|
753
762
|
(
|
754
|
-
|
755
|
-
|
756
|
-
|
763
|
+
update_workflow_execution,
|
764
|
+
UpdateWorkflowExecutionRequest,
|
765
|
+
UpdateWorkflowExecutionResponse,
|
757
766
|
|r| {
|
758
767
|
let labels = AttachMetricLabels::namespace(r.get_ref().namespace.clone());
|
759
768
|
r.extensions_mut().insert(labels);
|
@@ -808,17 +817,9 @@ proxier! {
|
|
808
817
|
r.extensions_mut().insert(labels);
|
809
818
|
}
|
810
819
|
);
|
811
|
-
(delete_workflow_execution, DeleteWorkflowExecutionRequest, DeleteWorkflowExecutionResponse,
|
812
|
-
|r| {
|
813
|
-
let labels = AttachMetricLabels::namespace(r.get_ref().namespace.clone());
|
814
|
-
r.extensions_mut().insert(labels);
|
815
|
-
}
|
816
|
-
);
|
817
820
|
(add_or_update_remote_cluster, AddOrUpdateRemoteClusterRequest, AddOrUpdateRemoteClusterResponse);
|
818
821
|
(remove_remote_cluster, RemoveRemoteClusterRequest, RemoveRemoteClusterResponse);
|
819
|
-
(describe_cluster, DescribeClusterRequest, DescribeClusterResponse);
|
820
822
|
(list_clusters, ListClustersRequest, ListClustersResponse);
|
821
|
-
(list_cluster_members, ListClusterMembersRequest, ListClusterMembersResponse);
|
822
823
|
}
|
823
824
|
|
824
825
|
proxier! {
|
@@ -897,7 +898,7 @@ mod tests {
|
|
897
898
|
let no_underscores: HashSet<_> = impl_list.iter().map(|x| x.replace('_', "")).collect();
|
898
899
|
for method in methods {
|
899
900
|
if !no_underscores.contains(&method.to_lowercase()) {
|
900
|
-
panic!("RPC method {} is not implemented by raw client"
|
901
|
+
panic!("RPC method {method} is not implemented by raw client")
|
901
902
|
}
|
902
903
|
}
|
903
904
|
}
|