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
@@ -12,7 +12,10 @@ mod history_info;
|
|
12
12
|
mod task_token;
|
13
13
|
|
14
14
|
#[cfg(feature = "history_builders")]
|
15
|
-
pub use history_builder::{
|
15
|
+
pub use history_builder::{
|
16
|
+
default_act_sched, default_wes_attribs, TestHistoryBuilder, DEFAULT_ACTIVITY_TYPE,
|
17
|
+
DEFAULT_WORKFLOW_TYPE,
|
18
|
+
};
|
16
19
|
#[cfg(feature = "history_builders")]
|
17
20
|
pub use history_info::HistoryInfo;
|
18
21
|
pub use task_token::TaskToken;
|
@@ -26,7 +29,8 @@ pub mod coresdk {
|
|
26
29
|
tonic::include_proto!("coresdk");
|
27
30
|
|
28
31
|
use crate::temporal::api::{
|
29
|
-
common::v1::{
|
32
|
+
common::v1::{Payload, Payloads, WorkflowExecution},
|
33
|
+
enums::v1::WorkflowTaskFailedCause,
|
30
34
|
failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
|
31
35
|
workflowservice::v1::PollActivityTaskQueueResponse,
|
32
36
|
};
|
@@ -66,8 +70,8 @@ pub mod coresdk {
|
|
66
70
|
"ActivityTaskCompletion(token: {}",
|
67
71
|
fmt_tt(&self.task_token),
|
68
72
|
)?;
|
69
|
-
if let Some(r) = self.result.as_ref() {
|
70
|
-
write!(f, ", {}"
|
73
|
+
if let Some(r) = self.result.as_ref().and_then(|r| r.status.as_ref()) {
|
74
|
+
write!(f, ", {r}")?;
|
71
75
|
} else {
|
72
76
|
write!(f, ", missing result")?;
|
73
77
|
}
|
@@ -120,21 +124,20 @@ pub mod coresdk {
|
|
120
124
|
}
|
121
125
|
}
|
122
126
|
|
123
|
-
impl Display for
|
127
|
+
impl Display for aer::Status {
|
124
128
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
125
129
|
write!(f, "ActivityExecutionResult(")?;
|
126
|
-
match self
|
127
|
-
|
128
|
-
|
129
|
-
write!(f, "{})", v)
|
130
|
+
match self {
|
131
|
+
aer::Status::Completed(v) => {
|
132
|
+
write!(f, "{v})")
|
130
133
|
}
|
131
|
-
|
132
|
-
write!(f, "{})"
|
134
|
+
aer::Status::Failed(v) => {
|
135
|
+
write!(f, "{v})")
|
133
136
|
}
|
134
|
-
|
135
|
-
write!(f, "{})"
|
137
|
+
aer::Status::Cancelled(v) => {
|
138
|
+
write!(f, "{v})")
|
136
139
|
}
|
137
|
-
|
140
|
+
aer::Status::WillCompleteAsync(_) => {
|
138
141
|
write!(f, "Will complete async)")
|
139
142
|
}
|
140
143
|
}
|
@@ -145,7 +148,7 @@ pub mod coresdk {
|
|
145
148
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
146
149
|
write!(f, "Success(")?;
|
147
150
|
if let Some(ref v) = self.result {
|
148
|
-
write!(f, "{}"
|
151
|
+
write!(f, "{v}")?;
|
149
152
|
}
|
150
153
|
write!(f, ")")
|
151
154
|
}
|
@@ -155,7 +158,7 @@ pub mod coresdk {
|
|
155
158
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
156
159
|
write!(f, "Failure(")?;
|
157
160
|
if let Some(ref v) = self.failure {
|
158
|
-
write!(f, "{}"
|
161
|
+
write!(f, "{v}")?;
|
159
162
|
}
|
160
163
|
write!(f, ")")
|
161
164
|
}
|
@@ -165,7 +168,7 @@ pub mod coresdk {
|
|
165
168
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
166
169
|
write!(f, "Cancellation(")?;
|
167
170
|
if let Some(ref v) = self.failure {
|
168
|
-
write!(f, "{}"
|
171
|
+
write!(f, "{v}")?;
|
169
172
|
}
|
170
173
|
write!(f, ")")
|
171
174
|
}
|
@@ -186,7 +189,7 @@ pub mod coresdk {
|
|
186
189
|
pub fn unwrap_ok_payload(self) -> Payload {
|
187
190
|
match self.status.unwrap() {
|
188
191
|
activity_resolution::Status::Completed(c) => c.result.unwrap(),
|
189
|
-
|
192
|
+
e => panic!("Activity was not successful: {e:?}"),
|
190
193
|
}
|
191
194
|
}
|
192
195
|
|
@@ -198,11 +201,15 @@ pub mod coresdk {
|
|
198
201
|
matches!(self.status, Some(activity_resolution::Status::Failed(_)))
|
199
202
|
}
|
200
203
|
|
201
|
-
pub fn timed_out(&self) ->
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
204
|
+
pub fn timed_out(&self) -> Option<crate::temporal::api::enums::v1::TimeoutType> {
|
205
|
+
match self.status {
|
206
|
+
Some(activity_resolution::Status::Failed(Failure {
|
207
|
+
failure: Some(ref f),
|
208
|
+
})) => f
|
209
|
+
.is_timeout()
|
210
|
+
.or_else(|| f.cause.as_ref().and_then(|c| c.is_timeout())),
|
211
|
+
_ => None,
|
212
|
+
}
|
206
213
|
}
|
207
214
|
|
208
215
|
pub fn cancelled(&self) -> bool {
|
@@ -244,10 +251,6 @@ pub mod coresdk {
|
|
244
251
|
}
|
245
252
|
}
|
246
253
|
|
247
|
-
pub mod bridge {
|
248
|
-
tonic::include_proto!("coresdk.bridge");
|
249
|
-
}
|
250
|
-
|
251
254
|
pub mod common {
|
252
255
|
tonic::include_proto!("coresdk.common");
|
253
256
|
use super::external_data::LocalActivityMarkerData;
|
@@ -318,7 +321,7 @@ pub mod coresdk {
|
|
318
321
|
}
|
319
322
|
|
320
323
|
pub mod external_data {
|
321
|
-
use
|
324
|
+
use prost_wkt_types::{Duration, Timestamp};
|
322
325
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
323
326
|
tonic::include_proto!("coresdk.external_data");
|
324
327
|
|
@@ -397,6 +400,7 @@ pub mod coresdk {
|
|
397
400
|
},
|
398
401
|
temporal::api::{
|
399
402
|
common::v1::Header,
|
403
|
+
enums::v1::WorkflowTaskFailedCause,
|
400
404
|
history::v1::{
|
401
405
|
WorkflowExecutionCancelRequestedEventAttributes,
|
402
406
|
WorkflowExecutionSignaledEventAttributes,
|
@@ -405,6 +409,7 @@ pub mod coresdk {
|
|
405
409
|
query::v1::WorkflowQuery,
|
406
410
|
},
|
407
411
|
};
|
412
|
+
use prost_wkt_types::Timestamp;
|
408
413
|
use std::{
|
409
414
|
collections::HashMap,
|
410
415
|
fmt::{Display, Formatter},
|
@@ -428,6 +433,7 @@ pub mod coresdk {
|
|
428
433
|
reason: reason as i32,
|
429
434
|
}),
|
430
435
|
)],
|
436
|
+
available_internal_flags: vec![],
|
431
437
|
}
|
432
438
|
}
|
433
439
|
|
@@ -491,7 +497,18 @@ pub mod coresdk {
|
|
491
497
|
|
492
498
|
impl Display for EvictionReason {
|
493
499
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
494
|
-
write!(f, "{:?}"
|
500
|
+
write!(f, "{self:?}")
|
501
|
+
}
|
502
|
+
}
|
503
|
+
|
504
|
+
impl From<EvictionReason> for WorkflowTaskFailedCause {
|
505
|
+
fn from(value: EvictionReason) -> Self {
|
506
|
+
match value {
|
507
|
+
EvictionReason::Nondeterminism => {
|
508
|
+
WorkflowTaskFailedCause::NonDeterministicError
|
509
|
+
}
|
510
|
+
_ => WorkflowTaskFailedCause::Unspecified,
|
511
|
+
}
|
495
512
|
}
|
496
513
|
}
|
497
514
|
|
@@ -517,7 +534,7 @@ pub mod coresdk {
|
|
517
534
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
518
535
|
match &self.variant {
|
519
536
|
None => write!(f, "empty"),
|
520
|
-
Some(v) => write!(f, "{}"
|
537
|
+
Some(v) => write!(f, "{v}"),
|
521
538
|
}
|
522
539
|
}
|
523
540
|
}
|
@@ -600,6 +617,7 @@ pub mod coresdk {
|
|
600
617
|
attrs: WorkflowExecutionStartedEventAttributes,
|
601
618
|
workflow_id: String,
|
602
619
|
randomness_seed: u64,
|
620
|
+
start_time: Timestamp,
|
603
621
|
) -> StartWorkflow {
|
604
622
|
StartWorkflow {
|
605
623
|
workflow_type: attrs.workflow_type.map(|wt| wt.name).unwrap_or_default(),
|
@@ -633,12 +651,13 @@ pub mod coresdk {
|
|
633
651
|
cron_schedule_to_schedule_interval: attrs.first_workflow_task_backoff,
|
634
652
|
memo: attrs.memo,
|
635
653
|
search_attributes: attrs.search_attributes,
|
654
|
+
start_time: Some(start_time),
|
636
655
|
}
|
637
656
|
}
|
638
657
|
}
|
639
658
|
|
640
659
|
pub mod workflow_completion {
|
641
|
-
use crate::temporal::api::failure;
|
660
|
+
use crate::temporal::api::{enums::v1::WorkflowTaskFailedCause, failure};
|
642
661
|
tonic::include_proto!("coresdk.workflow_completion");
|
643
662
|
|
644
663
|
impl workflow_activation_completion::Status {
|
@@ -652,7 +671,10 @@ pub mod coresdk {
|
|
652
671
|
|
653
672
|
impl From<failure::v1::Failure> for Failure {
|
654
673
|
fn from(f: failure::v1::Failure) -> Self {
|
655
|
-
Failure {
|
674
|
+
Failure {
|
675
|
+
failure: Some(f),
|
676
|
+
force_cause: WorkflowTaskFailedCause::Unspecified as i32,
|
677
|
+
}
|
656
678
|
}
|
657
679
|
}
|
658
680
|
}
|
@@ -671,7 +693,7 @@ pub mod coresdk {
|
|
671
693
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
672
694
|
match &self.variant {
|
673
695
|
None => write!(f, "Empty"),
|
674
|
-
Some(v) => write!(f, "{}"
|
696
|
+
Some(v) => write!(f, "{v}"),
|
675
697
|
}
|
676
698
|
}
|
677
699
|
}
|
@@ -800,6 +822,16 @@ pub mod coresdk {
|
|
800
822
|
}
|
801
823
|
}
|
802
824
|
|
825
|
+
impl Display for ModifyWorkflowProperties {
|
826
|
+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
827
|
+
write!(
|
828
|
+
f,
|
829
|
+
"ModifyWorkflowProperties(upserted memo keys: {:?})",
|
830
|
+
self.upserted_memo.as_ref().map(|m| m.fields.keys())
|
831
|
+
)
|
832
|
+
}
|
833
|
+
}
|
834
|
+
|
803
835
|
impl QueryResult {
|
804
836
|
/// Helper to construct the Temporal API query result types.
|
805
837
|
pub fn into_components(self) -> (String, QueryResultType, Option<Payloads>, String) {
|
@@ -841,7 +873,10 @@ pub mod coresdk {
|
|
841
873
|
|
842
874
|
impl From<Vec<WorkflowCommand>> for workflow_completion::Success {
|
843
875
|
fn from(v: Vec<WorkflowCommand>) -> Self {
|
844
|
-
Self {
|
876
|
+
Self {
|
877
|
+
commands: v,
|
878
|
+
used_internal_flags: vec![],
|
879
|
+
}
|
845
880
|
}
|
846
881
|
}
|
847
882
|
|
@@ -895,6 +930,7 @@ pub mod coresdk {
|
|
895
930
|
status: Some(workflow_activation_completion::Status::Failed(
|
896
931
|
workflow_completion::Failure {
|
897
932
|
failure: Some(failure),
|
933
|
+
force_cause: WorkflowTaskFailedCause::Unspecified as i32,
|
898
934
|
},
|
899
935
|
)),
|
900
936
|
}
|
@@ -978,6 +1014,12 @@ pub mod coresdk {
|
|
978
1014
|
}
|
979
1015
|
false
|
980
1016
|
}
|
1017
|
+
|
1018
|
+
pub fn add_internal_flags(&mut self, patch: u32) {
|
1019
|
+
if let Some(workflow_activation_completion::Status::Successful(s)) = &mut self.status {
|
1020
|
+
s.used_internal_flags.push(patch);
|
1021
|
+
}
|
1022
|
+
}
|
981
1023
|
}
|
982
1024
|
|
983
1025
|
/// Makes converting outgoing lang commands into [WorkflowActivationCompletion]s easier
|
@@ -1015,7 +1057,7 @@ pub mod coresdk {
|
|
1015
1057
|
)?;
|
1016
1058
|
match &self.status {
|
1017
1059
|
None => write!(f, "empty")?,
|
1018
|
-
Some(s) => write!(f, "{}"
|
1060
|
+
Some(s) => write!(f, "{s}")?,
|
1019
1061
|
};
|
1020
1062
|
write!(f, ")")
|
1021
1063
|
}
|
@@ -1025,12 +1067,12 @@ pub mod coresdk {
|
|
1025
1067
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1026
1068
|
match self {
|
1027
1069
|
workflow_activation_completion::Status::Successful(
|
1028
|
-
workflow_completion::Success { commands },
|
1070
|
+
workflow_completion::Success { commands, .. },
|
1029
1071
|
) => {
|
1030
1072
|
write!(f, "Success(")?;
|
1031
1073
|
let mut written = 0;
|
1032
1074
|
for c in commands {
|
1033
|
-
write!(f, "{} "
|
1075
|
+
write!(f, "{c} ")?;
|
1034
1076
|
written += 1;
|
1035
1077
|
if written >= 10 && written < commands.len() {
|
1036
1078
|
write!(f, "... {} more", commands.len() - written)?;
|
@@ -1082,21 +1124,12 @@ pub mod coresdk {
|
|
1082
1124
|
}
|
1083
1125
|
}
|
1084
1126
|
|
1085
|
-
impl From<String> for ActivityType {
|
1086
|
-
fn from(name: String) -> Self {
|
1087
|
-
Self { name }
|
1088
|
-
}
|
1089
|
-
}
|
1090
|
-
|
1091
|
-
impl From<ActivityType> for String {
|
1092
|
-
fn from(at: ActivityType) -> Self {
|
1093
|
-
at.name
|
1094
|
-
}
|
1095
|
-
}
|
1096
|
-
|
1097
1127
|
impl Failure {
|
1098
|
-
pub fn is_timeout(&self) ->
|
1099
|
-
|
1128
|
+
pub fn is_timeout(&self) -> Option<crate::temporal::api::enums::v1::TimeoutType> {
|
1129
|
+
match &self.failure_info {
|
1130
|
+
Some(FailureInfo::TimeoutFailureInfo(ti)) => Some(ti.timeout_type()),
|
1131
|
+
_ => None,
|
1132
|
+
}
|
1100
1133
|
}
|
1101
1134
|
|
1102
1135
|
pub fn application_failure(message: String, non_retryable: bool) -> Self {
|
@@ -1112,6 +1145,26 @@ pub mod coresdk {
|
|
1112
1145
|
}
|
1113
1146
|
}
|
1114
1147
|
|
1148
|
+
pub fn application_failure_from_error(ae: anyhow::Error, non_retryable: bool) -> Self {
|
1149
|
+
Self {
|
1150
|
+
failure_info: Some(FailureInfo::ApplicationFailureInfo(
|
1151
|
+
ApplicationFailureInfo {
|
1152
|
+
non_retryable,
|
1153
|
+
..Default::default()
|
1154
|
+
},
|
1155
|
+
)),
|
1156
|
+
..ae.chain()
|
1157
|
+
.rfold(None, |cause, e| {
|
1158
|
+
Some(Self {
|
1159
|
+
message: e.to_string(),
|
1160
|
+
cause: cause.map(Box::new),
|
1161
|
+
..Default::default()
|
1162
|
+
})
|
1163
|
+
})
|
1164
|
+
.unwrap_or_default()
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
|
1115
1168
|
/// Extracts an ApplicationFailureInfo from a Failure instance if it exists
|
1116
1169
|
pub fn maybe_application_failure(&self) -> Option<&ApplicationFailureInfo> {
|
1117
1170
|
if let Failure {
|
@@ -1182,7 +1235,7 @@ pub mod coresdk {
|
|
1182
1235
|
|
1183
1236
|
impl From<anyhow::Error> for Failure {
|
1184
1237
|
fn from(ae: anyhow::Error) -> Self {
|
1185
|
-
Failure::
|
1238
|
+
Failure::application_failure_from_error(ae, false)
|
1186
1239
|
}
|
1187
1240
|
}
|
1188
1241
|
|
@@ -1320,11 +1373,6 @@ pub mod coresdk {
|
|
1320
1373
|
// This is disgusting, but unclear to me how to avoid it. TODO: Discuss w/ prost maintainer
|
1321
1374
|
pub mod temporal {
|
1322
1375
|
pub mod api {
|
1323
|
-
pub mod cluster {
|
1324
|
-
pub mod v1 {
|
1325
|
-
tonic::include_proto!("temporal.api.cluster.v1");
|
1326
|
-
}
|
1327
|
-
}
|
1328
1376
|
pub mod batch {
|
1329
1377
|
pub mod v1 {
|
1330
1378
|
tonic::include_proto!("temporal.api.batch.v1");
|
@@ -1414,6 +1462,16 @@ pub mod temporal {
|
|
1414
1462
|
}
|
1415
1463
|
}
|
1416
1464
|
|
1465
|
+
impl From<workflow_commands::ModifyWorkflowProperties> for command::Attributes {
|
1466
|
+
fn from(s: workflow_commands::ModifyWorkflowProperties) -> Self {
|
1467
|
+
Self::ModifyWorkflowPropertiesCommandAttributes(
|
1468
|
+
ModifyWorkflowPropertiesCommandAttributes {
|
1469
|
+
upserted_memo: s.upserted_memo.map(Into::into),
|
1470
|
+
},
|
1471
|
+
)
|
1472
|
+
}
|
1473
|
+
}
|
1474
|
+
|
1417
1475
|
impl From<workflow_commands::CancelTimer> for command::Attributes {
|
1418
1476
|
fn from(s: workflow_commands::CancelTimer) -> Self {
|
1419
1477
|
Self::CancelTimerCommandAttributes(CancelTimerCommandAttributes {
|
@@ -1533,6 +1591,7 @@ pub mod temporal {
|
|
1533
1591
|
}
|
1534
1592
|
pub mod common {
|
1535
1593
|
pub mod v1 {
|
1594
|
+
use base64::{prelude::BASE64_STANDARD, Engine};
|
1536
1595
|
use std::{
|
1537
1596
|
collections::HashMap,
|
1538
1597
|
fmt::{Display, Formatter},
|
@@ -1569,11 +1628,11 @@ pub mod temporal {
|
|
1569
1628
|
write!(
|
1570
1629
|
f,
|
1571
1630
|
"[{}..{}]",
|
1572
|
-
|
1573
|
-
|
1631
|
+
BASE64_STANDARD.encode(windows.next().unwrap_or_default()),
|
1632
|
+
BASE64_STANDARD.encode(windows.next_back().unwrap_or_default())
|
1574
1633
|
)
|
1575
1634
|
} else {
|
1576
|
-
write!(f, "[{}]",
|
1635
|
+
write!(f, "[{}]", BASE64_STANDARD.encode(&self.data))
|
1577
1636
|
}
|
1578
1637
|
}
|
1579
1638
|
}
|
@@ -1617,6 +1676,26 @@ pub mod temporal {
|
|
1617
1676
|
}
|
1618
1677
|
}
|
1619
1678
|
}
|
1679
|
+
|
1680
|
+
impl From<String> for ActivityType {
|
1681
|
+
fn from(name: String) -> Self {
|
1682
|
+
Self { name }
|
1683
|
+
}
|
1684
|
+
}
|
1685
|
+
|
1686
|
+
impl From<&str> for ActivityType {
|
1687
|
+
fn from(name: &str) -> Self {
|
1688
|
+
Self {
|
1689
|
+
name: name.to_string(),
|
1690
|
+
}
|
1691
|
+
}
|
1692
|
+
}
|
1693
|
+
|
1694
|
+
impl From<ActivityType> for String {
|
1695
|
+
fn from(at: ActivityType) -> Self {
|
1696
|
+
at.name
|
1697
|
+
}
|
1698
|
+
}
|
1620
1699
|
}
|
1621
1700
|
}
|
1622
1701
|
pub mod enums {
|
@@ -1647,14 +1726,7 @@ pub mod temporal {
|
|
1647
1726
|
|
1648
1727
|
impl History {
|
1649
1728
|
pub fn extract_run_id_from_start(&self) -> Result<&str, anyhow::Error> {
|
1650
|
-
|
1651
|
-
history_event::Attributes::WorkflowExecutionStartedEventAttributes(wes),
|
1652
|
-
) = self.events.get(0).and_then(|x| x.attributes.as_ref())
|
1653
|
-
{
|
1654
|
-
Ok(&wes.original_execution_run_id)
|
1655
|
-
} else {
|
1656
|
-
bail!("First event is not WorkflowExecutionStarted?!?")
|
1657
|
-
}
|
1729
|
+
extract_original_run_id_from_events(&self.events)
|
1658
1730
|
}
|
1659
1731
|
|
1660
1732
|
/// Returns the event id of the final event in the history. Will return 0 if
|
@@ -1664,6 +1736,18 @@ pub mod temporal {
|
|
1664
1736
|
}
|
1665
1737
|
}
|
1666
1738
|
|
1739
|
+
pub fn extract_original_run_id_from_events(
|
1740
|
+
events: &[HistoryEvent],
|
1741
|
+
) -> Result<&str, anyhow::Error> {
|
1742
|
+
if let Some(Attributes::WorkflowExecutionStartedEventAttributes(wes)) =
|
1743
|
+
events.get(0).and_then(|x| x.attributes.as_ref())
|
1744
|
+
{
|
1745
|
+
Ok(&wes.original_execution_run_id)
|
1746
|
+
} else {
|
1747
|
+
bail!("First event is not WorkflowExecutionStarted?!?")
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
|
1667
1751
|
impl HistoryEvent {
|
1668
1752
|
/// Returns true if this is an event created to mirror a command
|
1669
1753
|
pub fn is_command_event(&self) -> bool {
|
@@ -1677,6 +1761,7 @@ pub mod temporal {
|
|
1677
1761
|
| EventType::TimerCanceled
|
1678
1762
|
| EventType::TimerStarted
|
1679
1763
|
| EventType::UpsertWorkflowSearchAttributes
|
1764
|
+
| EventType::WorkflowPropertiesModified
|
1680
1765
|
| EventType::WorkflowExecutionCanceled
|
1681
1766
|
| EventType::WorkflowExecutionCompleted
|
1682
1767
|
| EventType::WorkflowExecutionContinuedAsNew
|
@@ -1735,6 +1820,15 @@ pub mod temporal {
|
|
1735
1820
|
_ => false,
|
1736
1821
|
}
|
1737
1822
|
}
|
1823
|
+
|
1824
|
+
pub fn is_wft_closed_event(&self) -> bool {
|
1825
|
+
match self.event_type() {
|
1826
|
+
EventType::WorkflowTaskCompleted => true,
|
1827
|
+
EventType::WorkflowTaskFailed => true,
|
1828
|
+
EventType::WorkflowTaskTimedOut => true,
|
1829
|
+
_ => false,
|
1830
|
+
}
|
1831
|
+
}
|
1738
1832
|
}
|
1739
1833
|
|
1740
1834
|
impl Display for HistoryEvent {
|
@@ -1747,6 +1841,60 @@ pub mod temporal {
|
|
1747
1841
|
)
|
1748
1842
|
}
|
1749
1843
|
}
|
1844
|
+
|
1845
|
+
impl Attributes {
|
1846
|
+
pub fn event_type(&self) -> EventType {
|
1847
|
+
// I just absolutely _love_ this
|
1848
|
+
match self {
|
1849
|
+
Attributes::WorkflowExecutionStartedEventAttributes(_) => {EventType::WorkflowExecutionStarted}
|
1850
|
+
Attributes::WorkflowExecutionCompletedEventAttributes(_) => {EventType::WorkflowExecutionCompleted}
|
1851
|
+
Attributes::WorkflowExecutionFailedEventAttributes(_) => {EventType::WorkflowExecutionFailed}
|
1852
|
+
Attributes::WorkflowExecutionTimedOutEventAttributes(_) => {EventType::WorkflowExecutionTimedOut}
|
1853
|
+
Attributes::WorkflowTaskScheduledEventAttributes(_) => {EventType::WorkflowTaskScheduled}
|
1854
|
+
Attributes::WorkflowTaskStartedEventAttributes(_) => {EventType::WorkflowTaskStarted}
|
1855
|
+
Attributes::WorkflowTaskCompletedEventAttributes(_) => {EventType::WorkflowTaskCompleted}
|
1856
|
+
Attributes::WorkflowTaskTimedOutEventAttributes(_) => {EventType::WorkflowTaskTimedOut}
|
1857
|
+
Attributes::WorkflowTaskFailedEventAttributes(_) => {EventType::WorkflowTaskFailed}
|
1858
|
+
Attributes::ActivityTaskScheduledEventAttributes(_) => {EventType::ActivityTaskScheduled}
|
1859
|
+
Attributes::ActivityTaskStartedEventAttributes(_) => {EventType::ActivityTaskStarted}
|
1860
|
+
Attributes::ActivityTaskCompletedEventAttributes(_) => {EventType::ActivityTaskCompleted}
|
1861
|
+
Attributes::ActivityTaskFailedEventAttributes(_) => {EventType::ActivityTaskFailed}
|
1862
|
+
Attributes::ActivityTaskTimedOutEventAttributes(_) => {EventType::ActivityTaskTimedOut}
|
1863
|
+
Attributes::TimerStartedEventAttributes(_) => {EventType::TimerStarted}
|
1864
|
+
Attributes::TimerFiredEventAttributes(_) => {EventType::TimerFired}
|
1865
|
+
Attributes::ActivityTaskCancelRequestedEventAttributes(_) => {EventType::ActivityTaskCancelRequested}
|
1866
|
+
Attributes::ActivityTaskCanceledEventAttributes(_) => {EventType::ActivityTaskCanceled}
|
1867
|
+
Attributes::TimerCanceledEventAttributes(_) => {EventType::TimerCanceled}
|
1868
|
+
Attributes::MarkerRecordedEventAttributes(_) => {EventType::MarkerRecorded}
|
1869
|
+
Attributes::WorkflowExecutionSignaledEventAttributes(_) => {EventType::WorkflowExecutionSignaled}
|
1870
|
+
Attributes::WorkflowExecutionTerminatedEventAttributes(_) => {EventType::WorkflowExecutionTerminated}
|
1871
|
+
Attributes::WorkflowExecutionCancelRequestedEventAttributes(_) => {EventType::WorkflowExecutionCancelRequested}
|
1872
|
+
Attributes::WorkflowExecutionCanceledEventAttributes(_) => {EventType::WorkflowExecutionCanceled}
|
1873
|
+
Attributes::RequestCancelExternalWorkflowExecutionInitiatedEventAttributes(_) => {EventType::RequestCancelExternalWorkflowExecutionInitiated}
|
1874
|
+
Attributes::RequestCancelExternalWorkflowExecutionFailedEventAttributes(_) => {EventType::RequestCancelExternalWorkflowExecutionFailed}
|
1875
|
+
Attributes::ExternalWorkflowExecutionCancelRequestedEventAttributes(_) => {EventType::ExternalWorkflowExecutionCancelRequested}
|
1876
|
+
Attributes::WorkflowExecutionContinuedAsNewEventAttributes(_) => {EventType::WorkflowExecutionContinuedAsNew}
|
1877
|
+
Attributes::StartChildWorkflowExecutionInitiatedEventAttributes(_) => {EventType::StartChildWorkflowExecutionInitiated}
|
1878
|
+
Attributes::StartChildWorkflowExecutionFailedEventAttributes(_) => {EventType::StartChildWorkflowExecutionFailed}
|
1879
|
+
Attributes::ChildWorkflowExecutionStartedEventAttributes(_) => {EventType::ChildWorkflowExecutionStarted}
|
1880
|
+
Attributes::ChildWorkflowExecutionCompletedEventAttributes(_) => {EventType::ChildWorkflowExecutionCompleted}
|
1881
|
+
Attributes::ChildWorkflowExecutionFailedEventAttributes(_) => {EventType::ChildWorkflowExecutionFailed}
|
1882
|
+
Attributes::ChildWorkflowExecutionCanceledEventAttributes(_) => {EventType::ChildWorkflowExecutionCanceled}
|
1883
|
+
Attributes::ChildWorkflowExecutionTimedOutEventAttributes(_) => {EventType::ChildWorkflowExecutionTimedOut}
|
1884
|
+
Attributes::ChildWorkflowExecutionTerminatedEventAttributes(_) => {EventType::ChildWorkflowExecutionTerminated}
|
1885
|
+
Attributes::SignalExternalWorkflowExecutionInitiatedEventAttributes(_) => {EventType::SignalExternalWorkflowExecutionInitiated}
|
1886
|
+
Attributes::SignalExternalWorkflowExecutionFailedEventAttributes(_) => {EventType::SignalExternalWorkflowExecutionFailed}
|
1887
|
+
Attributes::ExternalWorkflowExecutionSignaledEventAttributes(_) => {EventType::ExternalWorkflowExecutionSignaled}
|
1888
|
+
Attributes::UpsertWorkflowSearchAttributesEventAttributes(_) => {EventType::UpsertWorkflowSearchAttributes}
|
1889
|
+
Attributes::WorkflowExecutionUpdateRejectedEventAttributes(_) => {EventType::WorkflowExecutionUpdateRejected}
|
1890
|
+
Attributes::WorkflowExecutionUpdateAcceptedEventAttributes(_) => {EventType::WorkflowExecutionUpdateAccepted}
|
1891
|
+
Attributes::WorkflowExecutionUpdateCompletedEventAttributes(_) => {EventType::WorkflowExecutionUpdateCompleted}
|
1892
|
+
Attributes::WorkflowPropertiesModifiedExternallyEventAttributes(_) => {EventType::WorkflowPropertiesModifiedExternally}
|
1893
|
+
Attributes::ActivityPropertiesModifiedExternallyEventAttributes(_) => {EventType::ActivityPropertiesModifiedExternally}
|
1894
|
+
Attributes::WorkflowPropertiesModifiedEventAttributes(_) => {EventType::WorkflowPropertiesModified}
|
1895
|
+
}
|
1896
|
+
}
|
1897
|
+
}
|
1750
1898
|
}
|
1751
1899
|
}
|
1752
1900
|
pub mod namespace {
|
@@ -1759,6 +1907,11 @@ pub mod temporal {
|
|
1759
1907
|
tonic::include_proto!("temporal.api.operatorservice.v1");
|
1760
1908
|
}
|
1761
1909
|
}
|
1910
|
+
pub mod protocol {
|
1911
|
+
pub mod v1 {
|
1912
|
+
tonic::include_proto!("temporal.api.protocol.v1");
|
1913
|
+
}
|
1914
|
+
}
|
1762
1915
|
pub mod query {
|
1763
1916
|
pub mod v1 {
|
1764
1917
|
tonic::include_proto!("temporal.api.query.v1");
|
@@ -1774,6 +1927,11 @@ pub mod temporal {
|
|
1774
1927
|
tonic::include_proto!("temporal.api.schedule.v1");
|
1775
1928
|
}
|
1776
1929
|
}
|
1930
|
+
pub mod sdk {
|
1931
|
+
pub mod v1 {
|
1932
|
+
tonic::include_proto!("temporal.api.sdk.v1");
|
1933
|
+
}
|
1934
|
+
}
|
1777
1935
|
pub mod taskqueue {
|
1778
1936
|
pub mod v1 {
|
1779
1937
|
use crate::temporal::api::enums::v1::TaskQueueKind;
|
@@ -1820,12 +1978,12 @@ pub mod temporal {
|
|
1820
1978
|
tonic::include_proto!("temporal.api.workflowservice.v1");
|
1821
1979
|
|
1822
1980
|
macro_rules! sched_to_start_impl {
|
1823
|
-
() => {
|
1824
|
-
/// Return the duration of the task schedule time to its
|
1825
|
-
/// are set and time went forward.
|
1981
|
+
($sched_field:ident) => {
|
1982
|
+
/// Return the duration of the task schedule time (current attempt) to its
|
1983
|
+
/// start time if both are set and time went forward.
|
1826
1984
|
pub fn sched_to_start(&self) -> Option<Duration> {
|
1827
1985
|
if let Some((sch, st)) =
|
1828
|
-
self.
|
1986
|
+
self.$sched_field.clone().zip(self.started_time.clone())
|
1829
1987
|
{
|
1830
1988
|
let sch: Result<SystemTime, _> = sch.try_into();
|
1831
1989
|
let st: Result<SystemTime, _> = st.try_into();
|
@@ -1839,7 +1997,7 @@ pub mod temporal {
|
|
1839
1997
|
}
|
1840
1998
|
|
1841
1999
|
impl PollWorkflowTaskQueueResponse {
|
1842
|
-
sched_to_start_impl!();
|
2000
|
+
sched_to_start_impl!(scheduled_time);
|
1843
2001
|
}
|
1844
2002
|
|
1845
2003
|
impl Display for PollWorkflowTaskQueueResponse {
|
@@ -1881,7 +2039,7 @@ pub mod temporal {
|
|
1881
2039
|
}
|
1882
2040
|
|
1883
2041
|
impl PollActivityTaskQueueResponse {
|
1884
|
-
sched_to_start_impl!();
|
2042
|
+
sched_to_start_impl!(current_attempt_scheduled_time);
|
1885
2043
|
}
|
1886
2044
|
|
1887
2045
|
impl QueryWorkflowResponse {
|
@@ -1908,3 +2066,23 @@ pub mod grpc {
|
|
1908
2066
|
}
|
1909
2067
|
}
|
1910
2068
|
}
|
2069
|
+
|
2070
|
+
#[cfg(test)]
|
2071
|
+
mod tests {
|
2072
|
+
use crate::temporal::api::failure::v1::Failure;
|
2073
|
+
use anyhow::anyhow;
|
2074
|
+
|
2075
|
+
#[test]
|
2076
|
+
fn anyhow_to_failure_conversion() {
|
2077
|
+
let no_causes: Failure = anyhow!("no causes").into();
|
2078
|
+
assert_eq!(no_causes.cause, None);
|
2079
|
+
assert_eq!(no_causes.message, "no causes");
|
2080
|
+
let orig = anyhow!("fail 1");
|
2081
|
+
let mid = orig.context("fail 2");
|
2082
|
+
let top = mid.context("fail 3");
|
2083
|
+
let as_fail: Failure = top.into();
|
2084
|
+
assert_eq!(as_fail.message, "fail 3");
|
2085
|
+
assert_eq!(as_fail.cause.as_ref().unwrap().message, "fail 2");
|
2086
|
+
assert_eq!(as_fail.cause.unwrap().cause.unwrap().message, "fail 1");
|
2087
|
+
}
|
2088
|
+
}
|
@@ -1,8 +1,18 @@
|
|
1
|
+
use base64::{prelude::BASE64_STANDARD, Engine};
|
1
2
|
use std::fmt::{Debug, Display, Formatter};
|
2
3
|
|
3
4
|
static LOCAL_ACT_TASK_TOKEN_PREFIX: &[u8] = b"local_act_";
|
4
5
|
|
5
|
-
#[derive(
|
6
|
+
#[derive(
|
7
|
+
Hash,
|
8
|
+
Eq,
|
9
|
+
PartialEq,
|
10
|
+
Clone,
|
11
|
+
derive_more::From,
|
12
|
+
derive_more::Into,
|
13
|
+
serde::Serialize,
|
14
|
+
serde::Deserialize,
|
15
|
+
)]
|
6
16
|
/// Type-safe wrapper for task token bytes
|
7
17
|
pub struct TaskToken(pub Vec<u8>);
|
8
18
|
|
@@ -34,5 +44,5 @@ impl Debug for TaskToken {
|
|
34
44
|
}
|
35
45
|
|
36
46
|
pub fn fmt_tt(tt: &[u8]) -> String {
|
37
|
-
|
47
|
+
BASE64_STANDARD.encode(tt)
|
38
48
|
}
|