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,2088 +0,0 @@
|
|
1
|
-
//! Contains the protobuf definitions used as arguments to and return values from interactions with
|
2
|
-
//! the Temporal Core SDK. Language SDK authors can generate structs using the proto definitions
|
3
|
-
//! that will match the generated structs in this module.
|
4
|
-
|
5
|
-
pub mod constants;
|
6
|
-
pub mod utilities;
|
7
|
-
|
8
|
-
#[cfg(feature = "history_builders")]
|
9
|
-
mod history_builder;
|
10
|
-
#[cfg(feature = "history_builders")]
|
11
|
-
mod history_info;
|
12
|
-
mod task_token;
|
13
|
-
|
14
|
-
#[cfg(feature = "history_builders")]
|
15
|
-
pub use history_builder::{
|
16
|
-
default_act_sched, default_wes_attribs, TestHistoryBuilder, DEFAULT_ACTIVITY_TYPE,
|
17
|
-
DEFAULT_WORKFLOW_TYPE,
|
18
|
-
};
|
19
|
-
#[cfg(feature = "history_builders")]
|
20
|
-
pub use history_info::HistoryInfo;
|
21
|
-
pub use task_token::TaskToken;
|
22
|
-
|
23
|
-
#[allow(clippy::large_enum_variant, clippy::derive_partial_eq_without_eq)]
|
24
|
-
// I'd prefer not to do this, but there are some generated things that just don't need it.
|
25
|
-
#[allow(missing_docs)]
|
26
|
-
pub mod coresdk {
|
27
|
-
//! Contains all protobufs relating to communication between core and lang-specific SDKs
|
28
|
-
|
29
|
-
tonic::include_proto!("coresdk");
|
30
|
-
|
31
|
-
use crate::temporal::api::{
|
32
|
-
common::v1::{Payload, Payloads, WorkflowExecution},
|
33
|
-
enums::v1::WorkflowTaskFailedCause,
|
34
|
-
failure::v1::{failure::FailureInfo, ApplicationFailureInfo, Failure},
|
35
|
-
workflowservice::v1::PollActivityTaskQueueResponse,
|
36
|
-
};
|
37
|
-
use activity_task::ActivityTask;
|
38
|
-
use serde::{Deserialize, Serialize};
|
39
|
-
use std::{
|
40
|
-
collections::HashMap,
|
41
|
-
convert::TryFrom,
|
42
|
-
fmt::{Display, Formatter},
|
43
|
-
iter::FromIterator,
|
44
|
-
};
|
45
|
-
use workflow_activation::{workflow_activation_job, WorkflowActivationJob};
|
46
|
-
use workflow_commands::{workflow_command, workflow_command::Variant, WorkflowCommand};
|
47
|
-
use workflow_completion::{workflow_activation_completion, WorkflowActivationCompletion};
|
48
|
-
|
49
|
-
#[allow(clippy::module_inception)]
|
50
|
-
pub mod activity_task {
|
51
|
-
use crate::{coresdk::ActivityTaskCompletion, task_token::fmt_tt};
|
52
|
-
use std::fmt::{Display, Formatter};
|
53
|
-
tonic::include_proto!("coresdk.activity_task");
|
54
|
-
|
55
|
-
impl ActivityTask {
|
56
|
-
pub fn cancel_from_ids(task_token: Vec<u8>, reason: ActivityCancelReason) -> Self {
|
57
|
-
Self {
|
58
|
-
task_token,
|
59
|
-
variant: Some(activity_task::Variant::Cancel(Cancel {
|
60
|
-
reason: reason as i32,
|
61
|
-
})),
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
impl Display for ActivityTaskCompletion {
|
67
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
68
|
-
write!(
|
69
|
-
f,
|
70
|
-
"ActivityTaskCompletion(token: {}",
|
71
|
-
fmt_tt(&self.task_token),
|
72
|
-
)?;
|
73
|
-
if let Some(r) = self.result.as_ref().and_then(|r| r.status.as_ref()) {
|
74
|
-
write!(f, ", {r}")?;
|
75
|
-
} else {
|
76
|
-
write!(f, ", missing result")?;
|
77
|
-
}
|
78
|
-
write!(f, ")")
|
79
|
-
}
|
80
|
-
}
|
81
|
-
}
|
82
|
-
#[allow(clippy::module_inception)]
|
83
|
-
pub mod activity_result {
|
84
|
-
tonic::include_proto!("coresdk.activity_result");
|
85
|
-
use super::super::temporal::api::{
|
86
|
-
common::v1::Payload,
|
87
|
-
failure::v1::{failure, CanceledFailureInfo, Failure as APIFailure},
|
88
|
-
};
|
89
|
-
use crate::temporal::api::{enums::v1::TimeoutType, failure::v1::TimeoutFailureInfo};
|
90
|
-
use activity_execution_result as aer;
|
91
|
-
use std::fmt::{Display, Formatter};
|
92
|
-
|
93
|
-
impl ActivityExecutionResult {
|
94
|
-
pub const fn ok(result: Payload) -> Self {
|
95
|
-
Self {
|
96
|
-
status: Some(aer::Status::Completed(Success {
|
97
|
-
result: Some(result),
|
98
|
-
})),
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
pub fn fail(fail: APIFailure) -> Self {
|
103
|
-
Self {
|
104
|
-
status: Some(aer::Status::Failed(Failure {
|
105
|
-
failure: Some(fail),
|
106
|
-
})),
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
pub fn cancel_from_details(payload: Option<Payload>) -> Self {
|
111
|
-
Self {
|
112
|
-
status: Some(aer::Status::Cancelled(Cancellation::from_details(payload))),
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
pub const fn will_complete_async() -> Self {
|
117
|
-
Self {
|
118
|
-
status: Some(aer::Status::WillCompleteAsync(WillCompleteAsync {})),
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
pub fn is_cancelled(&self) -> bool {
|
123
|
-
matches!(self.status, Some(aer::Status::Cancelled(_)))
|
124
|
-
}
|
125
|
-
}
|
126
|
-
|
127
|
-
impl Display for aer::Status {
|
128
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
129
|
-
write!(f, "ActivityExecutionResult(")?;
|
130
|
-
match self {
|
131
|
-
aer::Status::Completed(v) => {
|
132
|
-
write!(f, "{v})")
|
133
|
-
}
|
134
|
-
aer::Status::Failed(v) => {
|
135
|
-
write!(f, "{v})")
|
136
|
-
}
|
137
|
-
aer::Status::Cancelled(v) => {
|
138
|
-
write!(f, "{v})")
|
139
|
-
}
|
140
|
-
aer::Status::WillCompleteAsync(_) => {
|
141
|
-
write!(f, "Will complete async)")
|
142
|
-
}
|
143
|
-
}
|
144
|
-
}
|
145
|
-
}
|
146
|
-
|
147
|
-
impl Display for Success {
|
148
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
149
|
-
write!(f, "Success(")?;
|
150
|
-
if let Some(ref v) = self.result {
|
151
|
-
write!(f, "{v}")?;
|
152
|
-
}
|
153
|
-
write!(f, ")")
|
154
|
-
}
|
155
|
-
}
|
156
|
-
|
157
|
-
impl Display for Failure {
|
158
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
159
|
-
write!(f, "Failure(")?;
|
160
|
-
if let Some(ref v) = self.failure {
|
161
|
-
write!(f, "{v}")?;
|
162
|
-
}
|
163
|
-
write!(f, ")")
|
164
|
-
}
|
165
|
-
}
|
166
|
-
|
167
|
-
impl Display for Cancellation {
|
168
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
169
|
-
write!(f, "Cancellation(")?;
|
170
|
-
if let Some(ref v) = self.failure {
|
171
|
-
write!(f, "{v}")?;
|
172
|
-
}
|
173
|
-
write!(f, ")")
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
impl From<Result<Payload, APIFailure>> for ActivityExecutionResult {
|
178
|
-
fn from(r: Result<Payload, APIFailure>) -> Self {
|
179
|
-
Self {
|
180
|
-
status: match r {
|
181
|
-
Ok(p) => Some(aer::Status::Completed(Success { result: Some(p) })),
|
182
|
-
Err(f) => Some(aer::Status::Failed(Failure { failure: Some(f) })),
|
183
|
-
},
|
184
|
-
}
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
impl ActivityResolution {
|
189
|
-
pub fn unwrap_ok_payload(self) -> Payload {
|
190
|
-
match self.status.unwrap() {
|
191
|
-
activity_resolution::Status::Completed(c) => c.result.unwrap(),
|
192
|
-
e => panic!("Activity was not successful: {e:?}"),
|
193
|
-
}
|
194
|
-
}
|
195
|
-
|
196
|
-
pub fn completed_ok(&self) -> bool {
|
197
|
-
matches!(self.status, Some(activity_resolution::Status::Completed(_)))
|
198
|
-
}
|
199
|
-
|
200
|
-
pub fn failed(&self) -> bool {
|
201
|
-
matches!(self.status, Some(activity_resolution::Status::Failed(_)))
|
202
|
-
}
|
203
|
-
|
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
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
pub fn cancelled(&self) -> bool {
|
216
|
-
matches!(self.status, Some(activity_resolution::Status::Cancelled(_)))
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
impl Cancellation {
|
221
|
-
pub fn from_details(payload: Option<Payload>) -> Self {
|
222
|
-
Cancellation {
|
223
|
-
failure: Some(APIFailure {
|
224
|
-
message: "Activity cancelled".to_string(),
|
225
|
-
failure_info: Some(failure::FailureInfo::CanceledFailureInfo(
|
226
|
-
CanceledFailureInfo {
|
227
|
-
details: payload.map(Into::into),
|
228
|
-
},
|
229
|
-
)),
|
230
|
-
..Default::default()
|
231
|
-
}),
|
232
|
-
}
|
233
|
-
}
|
234
|
-
}
|
235
|
-
|
236
|
-
impl Failure {
|
237
|
-
pub fn timeout(timeout_type: TimeoutType) -> Self {
|
238
|
-
Failure {
|
239
|
-
failure: Some(APIFailure {
|
240
|
-
message: "Activity timed out".to_string(),
|
241
|
-
failure_info: Some(failure::FailureInfo::TimeoutFailureInfo(
|
242
|
-
TimeoutFailureInfo {
|
243
|
-
timeout_type: timeout_type as i32,
|
244
|
-
last_heartbeat_details: None,
|
245
|
-
},
|
246
|
-
)),
|
247
|
-
..Default::default()
|
248
|
-
}),
|
249
|
-
}
|
250
|
-
}
|
251
|
-
}
|
252
|
-
}
|
253
|
-
|
254
|
-
pub mod common {
|
255
|
-
tonic::include_proto!("coresdk.common");
|
256
|
-
use super::external_data::LocalActivityMarkerData;
|
257
|
-
use crate::{
|
258
|
-
coresdk::{AsJsonPayloadExt, IntoPayloadsExt},
|
259
|
-
temporal::api::common::v1::{Payload, Payloads},
|
260
|
-
};
|
261
|
-
use std::collections::HashMap;
|
262
|
-
|
263
|
-
pub fn build_has_change_marker_details(
|
264
|
-
patch_id: &str,
|
265
|
-
deprecated: bool,
|
266
|
-
) -> HashMap<String, Payloads> {
|
267
|
-
let mut hm = HashMap::new();
|
268
|
-
hm.insert("patch_id".to_string(), patch_id.as_bytes().into());
|
269
|
-
let deprecated = deprecated as u8;
|
270
|
-
hm.insert("deprecated".to_string(), (&[deprecated]).into());
|
271
|
-
hm
|
272
|
-
}
|
273
|
-
|
274
|
-
pub fn decode_change_marker_details(
|
275
|
-
details: &HashMap<String, Payloads>,
|
276
|
-
) -> Option<(String, bool)> {
|
277
|
-
let name =
|
278
|
-
std::str::from_utf8(&details.get("patch_id")?.payloads.first()?.data).ok()?;
|
279
|
-
let deprecated = *details.get("deprecated")?.payloads.first()?.data.first()? != 0;
|
280
|
-
Some((name.to_string(), deprecated))
|
281
|
-
}
|
282
|
-
|
283
|
-
pub fn build_local_activity_marker_details(
|
284
|
-
metadata: LocalActivityMarkerData,
|
285
|
-
result: Option<Payload>,
|
286
|
-
) -> HashMap<String, Payloads> {
|
287
|
-
let mut hm = HashMap::new();
|
288
|
-
// It would be more efficient for this to be proto binary, but then it shows up as
|
289
|
-
// meaningless in the Temporal UI...
|
290
|
-
if let Some(jsonified) = metadata.as_json_payload().into_payloads() {
|
291
|
-
hm.insert("data".to_string(), jsonified);
|
292
|
-
}
|
293
|
-
if let Some(res) = result {
|
294
|
-
hm.insert("result".to_string(), res.into());
|
295
|
-
}
|
296
|
-
hm
|
297
|
-
}
|
298
|
-
|
299
|
-
/// Given a marker detail map, returns just the local activity info, but not the payload.
|
300
|
-
/// This is fairly inexpensive. Deserializing the whole payload may not be.
|
301
|
-
pub fn extract_local_activity_marker_data(
|
302
|
-
details: &HashMap<String, Payloads>,
|
303
|
-
) -> Option<LocalActivityMarkerData> {
|
304
|
-
details
|
305
|
-
.get("data")
|
306
|
-
.and_then(|p| p.payloads.get(0))
|
307
|
-
.and_then(|p| std::str::from_utf8(&p.data).ok())
|
308
|
-
.and_then(|s| serde_json::from_str(s).ok())
|
309
|
-
}
|
310
|
-
|
311
|
-
/// Given a marker detail map, returns the local activity info and the result payload
|
312
|
-
/// if they are found and the marker data is well-formed. This removes the data from the
|
313
|
-
/// map.
|
314
|
-
pub fn extract_local_activity_marker_details(
|
315
|
-
details: &mut HashMap<String, Payloads>,
|
316
|
-
) -> (Option<LocalActivityMarkerData>, Option<Payload>) {
|
317
|
-
let data = extract_local_activity_marker_data(details);
|
318
|
-
let result = details.remove("result").and_then(|mut p| p.payloads.pop());
|
319
|
-
(data, result)
|
320
|
-
}
|
321
|
-
}
|
322
|
-
|
323
|
-
pub mod external_data {
|
324
|
-
use prost_wkt_types::{Duration, Timestamp};
|
325
|
-
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
326
|
-
tonic::include_proto!("coresdk.external_data");
|
327
|
-
|
328
|
-
// Buncha hullaballoo because prost types aren't serde compat.
|
329
|
-
// See https://github.com/tokio-rs/prost/issues/75 which hilariously Chad opened ages ago
|
330
|
-
|
331
|
-
#[derive(Serialize, Deserialize)]
|
332
|
-
#[serde(remote = "Timestamp")]
|
333
|
-
struct TimestampDef {
|
334
|
-
pub seconds: i64,
|
335
|
-
pub nanos: i32,
|
336
|
-
}
|
337
|
-
mod opt_timestamp {
|
338
|
-
use super::*;
|
339
|
-
|
340
|
-
pub fn serialize<S>(value: &Option<Timestamp>, serializer: S) -> Result<S::Ok, S::Error>
|
341
|
-
where
|
342
|
-
S: Serializer,
|
343
|
-
{
|
344
|
-
#[derive(Serialize)]
|
345
|
-
struct Helper<'a>(#[serde(with = "TimestampDef")] &'a Timestamp);
|
346
|
-
|
347
|
-
value.as_ref().map(Helper).serialize(serializer)
|
348
|
-
}
|
349
|
-
|
350
|
-
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Timestamp>, D::Error>
|
351
|
-
where
|
352
|
-
D: Deserializer<'de>,
|
353
|
-
{
|
354
|
-
#[derive(Deserialize)]
|
355
|
-
struct Helper(#[serde(with = "TimestampDef")] Timestamp);
|
356
|
-
|
357
|
-
let helper = Option::deserialize(deserializer)?;
|
358
|
-
Ok(helper.map(|Helper(external)| external))
|
359
|
-
}
|
360
|
-
}
|
361
|
-
|
362
|
-
// Luckily Duration is also stored the exact same way
|
363
|
-
#[derive(Serialize, Deserialize)]
|
364
|
-
#[serde(remote = "Duration")]
|
365
|
-
struct DurationDef {
|
366
|
-
pub seconds: i64,
|
367
|
-
pub nanos: i32,
|
368
|
-
}
|
369
|
-
mod opt_duration {
|
370
|
-
use super::*;
|
371
|
-
|
372
|
-
pub fn serialize<S>(value: &Option<Duration>, serializer: S) -> Result<S::Ok, S::Error>
|
373
|
-
where
|
374
|
-
S: Serializer,
|
375
|
-
{
|
376
|
-
#[derive(Serialize)]
|
377
|
-
struct Helper<'a>(#[serde(with = "DurationDef")] &'a Duration);
|
378
|
-
|
379
|
-
value.as_ref().map(Helper).serialize(serializer)
|
380
|
-
}
|
381
|
-
|
382
|
-
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Duration>, D::Error>
|
383
|
-
where
|
384
|
-
D: Deserializer<'de>,
|
385
|
-
{
|
386
|
-
#[derive(Deserialize)]
|
387
|
-
struct Helper(#[serde(with = "DurationDef")] Duration);
|
388
|
-
|
389
|
-
let helper = Option::deserialize(deserializer)?;
|
390
|
-
Ok(helper.map(|Helper(external)| external))
|
391
|
-
}
|
392
|
-
}
|
393
|
-
}
|
394
|
-
|
395
|
-
pub mod workflow_activation {
|
396
|
-
use crate::{
|
397
|
-
coresdk::{
|
398
|
-
common::NamespacedWorkflowExecution,
|
399
|
-
workflow_activation::remove_from_cache::EvictionReason, FromPayloadsExt,
|
400
|
-
},
|
401
|
-
temporal::api::{
|
402
|
-
common::v1::Header,
|
403
|
-
enums::v1::WorkflowTaskFailedCause,
|
404
|
-
history::v1::{
|
405
|
-
WorkflowExecutionCancelRequestedEventAttributes,
|
406
|
-
WorkflowExecutionSignaledEventAttributes,
|
407
|
-
WorkflowExecutionStartedEventAttributes,
|
408
|
-
},
|
409
|
-
query::v1::WorkflowQuery,
|
410
|
-
},
|
411
|
-
};
|
412
|
-
use prost_wkt_types::Timestamp;
|
413
|
-
use std::{
|
414
|
-
collections::HashMap,
|
415
|
-
fmt::{Display, Formatter},
|
416
|
-
};
|
417
|
-
|
418
|
-
tonic::include_proto!("coresdk.workflow_activation");
|
419
|
-
|
420
|
-
pub fn create_evict_activation(
|
421
|
-
run_id: String,
|
422
|
-
message: String,
|
423
|
-
reason: EvictionReason,
|
424
|
-
) -> WorkflowActivation {
|
425
|
-
WorkflowActivation {
|
426
|
-
timestamp: None,
|
427
|
-
run_id,
|
428
|
-
is_replaying: false,
|
429
|
-
history_length: 0,
|
430
|
-
jobs: vec![WorkflowActivationJob::from(
|
431
|
-
workflow_activation_job::Variant::RemoveFromCache(RemoveFromCache {
|
432
|
-
message,
|
433
|
-
reason: reason as i32,
|
434
|
-
}),
|
435
|
-
)],
|
436
|
-
available_internal_flags: vec![],
|
437
|
-
}
|
438
|
-
}
|
439
|
-
|
440
|
-
pub fn query_to_job(id: String, q: WorkflowQuery) -> QueryWorkflow {
|
441
|
-
QueryWorkflow {
|
442
|
-
query_id: id,
|
443
|
-
query_type: q.query_type,
|
444
|
-
arguments: Vec::from_payloads(q.query_args),
|
445
|
-
headers: q.header.map(|h| h.into()).unwrap_or_default(),
|
446
|
-
}
|
447
|
-
}
|
448
|
-
|
449
|
-
impl WorkflowActivation {
|
450
|
-
/// Returns the index of the eviction job if this activation contains one. If present
|
451
|
-
/// it should always be the last job in the list.
|
452
|
-
pub fn eviction_index(&self) -> Option<usize> {
|
453
|
-
self.jobs.iter().position(|j| {
|
454
|
-
matches!(
|
455
|
-
j,
|
456
|
-
WorkflowActivationJob {
|
457
|
-
variant: Some(workflow_activation_job::Variant::RemoveFromCache(_))
|
458
|
-
}
|
459
|
-
)
|
460
|
-
})
|
461
|
-
}
|
462
|
-
|
463
|
-
/// Returns true if the only job is eviction
|
464
|
-
pub fn is_only_eviction(&self) -> bool {
|
465
|
-
self.jobs.len() == 1 && self.eviction_index().is_some()
|
466
|
-
}
|
467
|
-
|
468
|
-
/// Returns eviction reason if this activation has an evict job
|
469
|
-
pub fn eviction_reason(&self) -> Option<EvictionReason> {
|
470
|
-
self.jobs.iter().find_map(|j| {
|
471
|
-
if let Some(workflow_activation_job::Variant::RemoveFromCache(ref rj)) =
|
472
|
-
j.variant
|
473
|
-
{
|
474
|
-
EvictionReason::from_i32(rj.reason)
|
475
|
-
} else {
|
476
|
-
None
|
477
|
-
}
|
478
|
-
})
|
479
|
-
}
|
480
|
-
|
481
|
-
/// Append an eviction job to the joblist
|
482
|
-
pub fn append_evict_job(&mut self, evict_job: RemoveFromCache) {
|
483
|
-
if let Some(last_job) = self.jobs.last() {
|
484
|
-
if matches!(
|
485
|
-
last_job.variant,
|
486
|
-
Some(workflow_activation_job::Variant::RemoveFromCache(_))
|
487
|
-
) {
|
488
|
-
return;
|
489
|
-
}
|
490
|
-
}
|
491
|
-
let evict_job = WorkflowActivationJob::from(
|
492
|
-
workflow_activation_job::Variant::RemoveFromCache(evict_job),
|
493
|
-
);
|
494
|
-
self.jobs.push(evict_job);
|
495
|
-
}
|
496
|
-
}
|
497
|
-
|
498
|
-
impl Display for EvictionReason {
|
499
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
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
|
-
}
|
512
|
-
}
|
513
|
-
}
|
514
|
-
|
515
|
-
impl Display for WorkflowActivation {
|
516
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
517
|
-
write!(f, "WorkflowActivation(")?;
|
518
|
-
write!(f, "run_id: {}, ", self.run_id)?;
|
519
|
-
write!(f, "is_replaying: {}, ", self.is_replaying)?;
|
520
|
-
write!(
|
521
|
-
f,
|
522
|
-
"jobs: {})",
|
523
|
-
self.jobs
|
524
|
-
.iter()
|
525
|
-
.map(ToString::to_string)
|
526
|
-
.collect::<Vec<_>>()
|
527
|
-
.as_slice()
|
528
|
-
.join(", ")
|
529
|
-
)
|
530
|
-
}
|
531
|
-
}
|
532
|
-
|
533
|
-
impl Display for WorkflowActivationJob {
|
534
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
535
|
-
match &self.variant {
|
536
|
-
None => write!(f, "empty"),
|
537
|
-
Some(v) => write!(f, "{v}"),
|
538
|
-
}
|
539
|
-
}
|
540
|
-
}
|
541
|
-
|
542
|
-
impl Display for workflow_activation_job::Variant {
|
543
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
544
|
-
match self {
|
545
|
-
workflow_activation_job::Variant::StartWorkflow(_) => {
|
546
|
-
write!(f, "StartWorkflow")
|
547
|
-
}
|
548
|
-
workflow_activation_job::Variant::FireTimer(t) => {
|
549
|
-
write!(f, "FireTimer({})", t.seq)
|
550
|
-
}
|
551
|
-
workflow_activation_job::Variant::UpdateRandomSeed(_) => {
|
552
|
-
write!(f, "UpdateRandomSeed")
|
553
|
-
}
|
554
|
-
workflow_activation_job::Variant::QueryWorkflow(_) => {
|
555
|
-
write!(f, "QueryWorkflow")
|
556
|
-
}
|
557
|
-
workflow_activation_job::Variant::CancelWorkflow(_) => {
|
558
|
-
write!(f, "CancelWorkflow")
|
559
|
-
}
|
560
|
-
workflow_activation_job::Variant::SignalWorkflow(_) => {
|
561
|
-
write!(f, "SignalWorkflow")
|
562
|
-
}
|
563
|
-
workflow_activation_job::Variant::ResolveActivity(r) => {
|
564
|
-
write!(f, "ResolveActivity({})", r.seq)
|
565
|
-
}
|
566
|
-
workflow_activation_job::Variant::NotifyHasPatch(_) => {
|
567
|
-
write!(f, "NotifyHasPatch")
|
568
|
-
}
|
569
|
-
workflow_activation_job::Variant::ResolveChildWorkflowExecutionStart(_) => {
|
570
|
-
write!(f, "ResolveChildWorkflowExecutionStart")
|
571
|
-
}
|
572
|
-
workflow_activation_job::Variant::ResolveChildWorkflowExecution(_) => {
|
573
|
-
write!(f, "ResolveChildWorkflowExecution")
|
574
|
-
}
|
575
|
-
workflow_activation_job::Variant::ResolveSignalExternalWorkflow(_) => {
|
576
|
-
write!(f, "ResolveSignalExternalWorkflow")
|
577
|
-
}
|
578
|
-
workflow_activation_job::Variant::RemoveFromCache(_) => {
|
579
|
-
write!(f, "RemoveFromCache")
|
580
|
-
}
|
581
|
-
workflow_activation_job::Variant::ResolveRequestCancelExternalWorkflow(_) => {
|
582
|
-
write!(f, "ResolveRequestCancelExternalWorkflow")
|
583
|
-
}
|
584
|
-
}
|
585
|
-
}
|
586
|
-
}
|
587
|
-
|
588
|
-
impl Display for QueryWorkflow {
|
589
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
590
|
-
write!(
|
591
|
-
f,
|
592
|
-
"QueryWorkflow(id: {}, type: {})",
|
593
|
-
self.query_id, self.query_type
|
594
|
-
)
|
595
|
-
}
|
596
|
-
}
|
597
|
-
|
598
|
-
impl From<WorkflowExecutionSignaledEventAttributes> for SignalWorkflow {
|
599
|
-
fn from(a: WorkflowExecutionSignaledEventAttributes) -> Self {
|
600
|
-
Self {
|
601
|
-
signal_name: a.signal_name,
|
602
|
-
input: Vec::from_payloads(a.input),
|
603
|
-
identity: a.identity,
|
604
|
-
headers: a.header.map(Into::into).unwrap_or_default(),
|
605
|
-
}
|
606
|
-
}
|
607
|
-
}
|
608
|
-
|
609
|
-
impl From<WorkflowExecutionCancelRequestedEventAttributes> for CancelWorkflow {
|
610
|
-
fn from(_a: WorkflowExecutionCancelRequestedEventAttributes) -> Self {
|
611
|
-
Self { details: vec![] }
|
612
|
-
}
|
613
|
-
}
|
614
|
-
|
615
|
-
/// Create a [StartWorkflow] job from corresponding event attributes
|
616
|
-
pub fn start_workflow_from_attribs(
|
617
|
-
attrs: WorkflowExecutionStartedEventAttributes,
|
618
|
-
workflow_id: String,
|
619
|
-
randomness_seed: u64,
|
620
|
-
start_time: Timestamp,
|
621
|
-
) -> StartWorkflow {
|
622
|
-
StartWorkflow {
|
623
|
-
workflow_type: attrs.workflow_type.map(|wt| wt.name).unwrap_or_default(),
|
624
|
-
workflow_id,
|
625
|
-
arguments: Vec::from_payloads(attrs.input),
|
626
|
-
randomness_seed,
|
627
|
-
headers: match attrs.header {
|
628
|
-
None => HashMap::new(),
|
629
|
-
Some(Header { fields }) => fields,
|
630
|
-
},
|
631
|
-
identity: attrs.identity,
|
632
|
-
parent_workflow_info: attrs.parent_workflow_execution.map(|pe| {
|
633
|
-
NamespacedWorkflowExecution {
|
634
|
-
namespace: attrs.parent_workflow_namespace,
|
635
|
-
run_id: pe.run_id,
|
636
|
-
workflow_id: pe.workflow_id,
|
637
|
-
}
|
638
|
-
}),
|
639
|
-
workflow_execution_timeout: attrs.workflow_execution_timeout,
|
640
|
-
workflow_run_timeout: attrs.workflow_run_timeout,
|
641
|
-
workflow_task_timeout: attrs.workflow_task_timeout,
|
642
|
-
continued_from_execution_run_id: attrs.continued_execution_run_id,
|
643
|
-
continued_initiator: attrs.initiator,
|
644
|
-
continued_failure: attrs.continued_failure,
|
645
|
-
last_completion_result: attrs.last_completion_result,
|
646
|
-
first_execution_run_id: attrs.first_execution_run_id,
|
647
|
-
retry_policy: attrs.retry_policy,
|
648
|
-
attempt: attrs.attempt,
|
649
|
-
cron_schedule: attrs.cron_schedule,
|
650
|
-
workflow_execution_expiration_time: attrs.workflow_execution_expiration_time,
|
651
|
-
cron_schedule_to_schedule_interval: attrs.first_workflow_task_backoff,
|
652
|
-
memo: attrs.memo,
|
653
|
-
search_attributes: attrs.search_attributes,
|
654
|
-
start_time: Some(start_time),
|
655
|
-
}
|
656
|
-
}
|
657
|
-
}
|
658
|
-
|
659
|
-
pub mod workflow_completion {
|
660
|
-
use crate::temporal::api::{enums::v1::WorkflowTaskFailedCause, failure};
|
661
|
-
tonic::include_proto!("coresdk.workflow_completion");
|
662
|
-
|
663
|
-
impl workflow_activation_completion::Status {
|
664
|
-
pub const fn is_success(&self) -> bool {
|
665
|
-
match &self {
|
666
|
-
Self::Successful(_) => true,
|
667
|
-
Self::Failed(_) => false,
|
668
|
-
}
|
669
|
-
}
|
670
|
-
}
|
671
|
-
|
672
|
-
impl From<failure::v1::Failure> for Failure {
|
673
|
-
fn from(f: failure::v1::Failure) -> Self {
|
674
|
-
Failure {
|
675
|
-
failure: Some(f),
|
676
|
-
force_cause: WorkflowTaskFailedCause::Unspecified as i32,
|
677
|
-
}
|
678
|
-
}
|
679
|
-
}
|
680
|
-
}
|
681
|
-
|
682
|
-
pub mod child_workflow {
|
683
|
-
tonic::include_proto!("coresdk.child_workflow");
|
684
|
-
}
|
685
|
-
|
686
|
-
pub mod workflow_commands {
|
687
|
-
tonic::include_proto!("coresdk.workflow_commands");
|
688
|
-
|
689
|
-
use crate::temporal::api::{common::v1::Payloads, enums::v1::QueryResultType};
|
690
|
-
use std::fmt::{Display, Formatter};
|
691
|
-
|
692
|
-
impl Display for WorkflowCommand {
|
693
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
694
|
-
match &self.variant {
|
695
|
-
None => write!(f, "Empty"),
|
696
|
-
Some(v) => write!(f, "{v}"),
|
697
|
-
}
|
698
|
-
}
|
699
|
-
}
|
700
|
-
|
701
|
-
impl Display for StartTimer {
|
702
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
703
|
-
write!(f, "StartTimer({})", self.seq)
|
704
|
-
}
|
705
|
-
}
|
706
|
-
|
707
|
-
impl Display for ScheduleActivity {
|
708
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
709
|
-
write!(f, "ScheduleActivity({}, {})", self.seq, self.activity_type)
|
710
|
-
}
|
711
|
-
}
|
712
|
-
|
713
|
-
impl Display for ScheduleLocalActivity {
|
714
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
715
|
-
write!(
|
716
|
-
f,
|
717
|
-
"ScheduleLocalActivity({}, {})",
|
718
|
-
self.seq, self.activity_type
|
719
|
-
)
|
720
|
-
}
|
721
|
-
}
|
722
|
-
|
723
|
-
impl Display for QueryResult {
|
724
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
725
|
-
write!(f, "RespondToQuery({})", self.query_id)
|
726
|
-
}
|
727
|
-
}
|
728
|
-
|
729
|
-
impl Display for RequestCancelActivity {
|
730
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
731
|
-
write!(f, "RequestCancelActivity({})", self.seq)
|
732
|
-
}
|
733
|
-
}
|
734
|
-
|
735
|
-
impl Display for RequestCancelLocalActivity {
|
736
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
737
|
-
write!(f, "RequestCancelLocalActivity({})", self.seq)
|
738
|
-
}
|
739
|
-
}
|
740
|
-
|
741
|
-
impl Display for CancelTimer {
|
742
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
743
|
-
write!(f, "CancelTimer({})", self.seq)
|
744
|
-
}
|
745
|
-
}
|
746
|
-
|
747
|
-
impl Display for CompleteWorkflowExecution {
|
748
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
749
|
-
write!(f, "CompleteWorkflowExecution")
|
750
|
-
}
|
751
|
-
}
|
752
|
-
|
753
|
-
impl Display for FailWorkflowExecution {
|
754
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
755
|
-
write!(f, "FailWorkflowExecution")
|
756
|
-
}
|
757
|
-
}
|
758
|
-
|
759
|
-
impl Display for ContinueAsNewWorkflowExecution {
|
760
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
761
|
-
write!(f, "ContinueAsNewWorkflowExecution")
|
762
|
-
}
|
763
|
-
}
|
764
|
-
|
765
|
-
impl Display for CancelWorkflowExecution {
|
766
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
767
|
-
write!(f, "CancelWorkflowExecution")
|
768
|
-
}
|
769
|
-
}
|
770
|
-
|
771
|
-
impl Display for SetPatchMarker {
|
772
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
773
|
-
write!(f, "SetPatchMarker({})", self.patch_id)
|
774
|
-
}
|
775
|
-
}
|
776
|
-
|
777
|
-
impl Display for StartChildWorkflowExecution {
|
778
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
779
|
-
write!(
|
780
|
-
f,
|
781
|
-
"StartChildWorkflowExecution({}, {})",
|
782
|
-
self.seq, self.workflow_type
|
783
|
-
)
|
784
|
-
}
|
785
|
-
}
|
786
|
-
|
787
|
-
impl Display for RequestCancelExternalWorkflowExecution {
|
788
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
789
|
-
write!(f, "RequestCancelExternalWorkflowExecution({})", self.seq)
|
790
|
-
}
|
791
|
-
}
|
792
|
-
|
793
|
-
impl Display for UpsertWorkflowSearchAttributes {
|
794
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
795
|
-
write!(
|
796
|
-
f,
|
797
|
-
"UpsertWorkflowSearchAttributes({:?})",
|
798
|
-
self.search_attributes.keys()
|
799
|
-
)
|
800
|
-
}
|
801
|
-
}
|
802
|
-
|
803
|
-
impl Display for SignalExternalWorkflowExecution {
|
804
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
805
|
-
write!(f, "SignalExternalWorkflowExecution({})", self.seq)
|
806
|
-
}
|
807
|
-
}
|
808
|
-
|
809
|
-
impl Display for CancelSignalWorkflow {
|
810
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
811
|
-
write!(f, "CancelSignalWorkflow({})", self.seq)
|
812
|
-
}
|
813
|
-
}
|
814
|
-
|
815
|
-
impl Display for CancelChildWorkflowExecution {
|
816
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
817
|
-
write!(
|
818
|
-
f,
|
819
|
-
"CancelChildWorkflowExecution({})",
|
820
|
-
self.child_workflow_seq
|
821
|
-
)
|
822
|
-
}
|
823
|
-
}
|
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
|
-
|
835
|
-
impl QueryResult {
|
836
|
-
/// Helper to construct the Temporal API query result types.
|
837
|
-
pub fn into_components(self) -> (String, QueryResultType, Option<Payloads>, String) {
|
838
|
-
match self {
|
839
|
-
QueryResult {
|
840
|
-
variant: Some(query_result::Variant::Succeeded(qs)),
|
841
|
-
query_id,
|
842
|
-
} => (
|
843
|
-
query_id,
|
844
|
-
QueryResultType::Answered,
|
845
|
-
qs.response.map(Into::into),
|
846
|
-
"".to_string(),
|
847
|
-
),
|
848
|
-
QueryResult {
|
849
|
-
variant: Some(query_result::Variant::Failed(err)),
|
850
|
-
query_id,
|
851
|
-
} => (query_id, QueryResultType::Failed, None, err.message),
|
852
|
-
QueryResult {
|
853
|
-
variant: None,
|
854
|
-
query_id,
|
855
|
-
} => (
|
856
|
-
query_id,
|
857
|
-
QueryResultType::Failed,
|
858
|
-
None,
|
859
|
-
"Query response was empty".to_string(),
|
860
|
-
),
|
861
|
-
}
|
862
|
-
}
|
863
|
-
}
|
864
|
-
}
|
865
|
-
|
866
|
-
pub type HistoryEventId = i64;
|
867
|
-
|
868
|
-
impl From<workflow_activation_job::Variant> for WorkflowActivationJob {
|
869
|
-
fn from(a: workflow_activation_job::Variant) -> Self {
|
870
|
-
Self { variant: Some(a) }
|
871
|
-
}
|
872
|
-
}
|
873
|
-
|
874
|
-
impl From<Vec<WorkflowCommand>> for workflow_completion::Success {
|
875
|
-
fn from(v: Vec<WorkflowCommand>) -> Self {
|
876
|
-
Self {
|
877
|
-
commands: v,
|
878
|
-
used_internal_flags: vec![],
|
879
|
-
}
|
880
|
-
}
|
881
|
-
}
|
882
|
-
|
883
|
-
impl From<workflow_command::Variant> for WorkflowCommand {
|
884
|
-
fn from(v: workflow_command::Variant) -> Self {
|
885
|
-
Self { variant: Some(v) }
|
886
|
-
}
|
887
|
-
}
|
888
|
-
|
889
|
-
impl workflow_completion::Success {
|
890
|
-
pub fn from_variants(cmds: Vec<Variant>) -> Self {
|
891
|
-
let cmds: Vec<_> = cmds
|
892
|
-
.into_iter()
|
893
|
-
.map(|c| WorkflowCommand { variant: Some(c) })
|
894
|
-
.collect();
|
895
|
-
cmds.into()
|
896
|
-
}
|
897
|
-
}
|
898
|
-
|
899
|
-
impl WorkflowActivationCompletion {
|
900
|
-
/// Create a successful activation with no commands in it
|
901
|
-
pub fn empty(run_id: impl Into<String>) -> Self {
|
902
|
-
let success = workflow_completion::Success::from_variants(vec![]);
|
903
|
-
Self {
|
904
|
-
run_id: run_id.into(),
|
905
|
-
status: Some(workflow_activation_completion::Status::Successful(success)),
|
906
|
-
}
|
907
|
-
}
|
908
|
-
|
909
|
-
/// Create a successful activation from a list of commands
|
910
|
-
pub fn from_cmds(run_id: impl Into<String>, cmds: Vec<workflow_command::Variant>) -> Self {
|
911
|
-
let success = workflow_completion::Success::from_variants(cmds);
|
912
|
-
Self {
|
913
|
-
run_id: run_id.into(),
|
914
|
-
status: Some(workflow_activation_completion::Status::Successful(success)),
|
915
|
-
}
|
916
|
-
}
|
917
|
-
|
918
|
-
/// Create a successful activation from just one command
|
919
|
-
pub fn from_cmd(run_id: impl Into<String>, cmd: workflow_command::Variant) -> Self {
|
920
|
-
let success = workflow_completion::Success::from_variants(vec![cmd]);
|
921
|
-
Self {
|
922
|
-
run_id: run_id.into(),
|
923
|
-
status: Some(workflow_activation_completion::Status::Successful(success)),
|
924
|
-
}
|
925
|
-
}
|
926
|
-
|
927
|
-
pub fn fail(run_id: impl Into<String>, failure: Failure) -> Self {
|
928
|
-
Self {
|
929
|
-
run_id: run_id.into(),
|
930
|
-
status: Some(workflow_activation_completion::Status::Failed(
|
931
|
-
workflow_completion::Failure {
|
932
|
-
failure: Some(failure),
|
933
|
-
force_cause: WorkflowTaskFailedCause::Unspecified as i32,
|
934
|
-
},
|
935
|
-
)),
|
936
|
-
}
|
937
|
-
}
|
938
|
-
|
939
|
-
/// Returns true if the activation has either a fail, continue, cancel, or complete workflow
|
940
|
-
/// execution command in it.
|
941
|
-
pub fn has_execution_ending(&self) -> bool {
|
942
|
-
self.has_complete_workflow_execution()
|
943
|
-
|| self.has_fail_execution()
|
944
|
-
|| self.has_continue_as_new()
|
945
|
-
|| self.has_cancel_workflow_execution()
|
946
|
-
}
|
947
|
-
|
948
|
-
/// Returns true if the activation contains a fail workflow execution command
|
949
|
-
pub fn has_fail_execution(&self) -> bool {
|
950
|
-
if let Some(workflow_activation_completion::Status::Successful(s)) = &self.status {
|
951
|
-
return s.commands.iter().any(|wfc| {
|
952
|
-
matches!(
|
953
|
-
wfc,
|
954
|
-
WorkflowCommand {
|
955
|
-
variant: Some(workflow_command::Variant::FailWorkflowExecution(_)),
|
956
|
-
}
|
957
|
-
)
|
958
|
-
});
|
959
|
-
}
|
960
|
-
false
|
961
|
-
}
|
962
|
-
|
963
|
-
/// Returns true if the activation contains a cancel workflow execution command
|
964
|
-
pub fn has_cancel_workflow_execution(&self) -> bool {
|
965
|
-
if let Some(workflow_activation_completion::Status::Successful(s)) = &self.status {
|
966
|
-
return s.commands.iter().any(|wfc| {
|
967
|
-
matches!(
|
968
|
-
wfc,
|
969
|
-
WorkflowCommand {
|
970
|
-
variant: Some(workflow_command::Variant::CancelWorkflowExecution(_)),
|
971
|
-
}
|
972
|
-
)
|
973
|
-
});
|
974
|
-
}
|
975
|
-
false
|
976
|
-
}
|
977
|
-
|
978
|
-
/// Returns true if the activation contains a continue as new workflow execution command
|
979
|
-
pub fn has_continue_as_new(&self) -> bool {
|
980
|
-
if let Some(workflow_activation_completion::Status::Successful(s)) = &self.status {
|
981
|
-
return s.commands.iter().any(|wfc| {
|
982
|
-
matches!(
|
983
|
-
wfc,
|
984
|
-
WorkflowCommand {
|
985
|
-
variant: Some(
|
986
|
-
workflow_command::Variant::ContinueAsNewWorkflowExecution(_)
|
987
|
-
),
|
988
|
-
}
|
989
|
-
)
|
990
|
-
});
|
991
|
-
}
|
992
|
-
false
|
993
|
-
}
|
994
|
-
|
995
|
-
/// Returns true if the activation contains a complete workflow execution command
|
996
|
-
pub fn has_complete_workflow_execution(&self) -> bool {
|
997
|
-
if let Some(workflow_activation_completion::Status::Successful(s)) = &self.status {
|
998
|
-
return s.commands.iter().any(|wfc| {
|
999
|
-
matches!(
|
1000
|
-
wfc,
|
1001
|
-
WorkflowCommand {
|
1002
|
-
variant: Some(workflow_command::Variant::CompleteWorkflowExecution(_)),
|
1003
|
-
}
|
1004
|
-
)
|
1005
|
-
});
|
1006
|
-
}
|
1007
|
-
false
|
1008
|
-
}
|
1009
|
-
|
1010
|
-
/// Returns true if the activation completion is a success with no commands
|
1011
|
-
pub fn is_empty(&self) -> bool {
|
1012
|
-
if let Some(workflow_activation_completion::Status::Successful(s)) = &self.status {
|
1013
|
-
return s.commands.is_empty();
|
1014
|
-
}
|
1015
|
-
false
|
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
|
-
}
|
1023
|
-
}
|
1024
|
-
|
1025
|
-
/// Makes converting outgoing lang commands into [WorkflowActivationCompletion]s easier
|
1026
|
-
pub trait IntoCompletion {
|
1027
|
-
/// The conversion function
|
1028
|
-
fn into_completion(self, run_id: String) -> WorkflowActivationCompletion;
|
1029
|
-
}
|
1030
|
-
|
1031
|
-
impl IntoCompletion for workflow_command::Variant {
|
1032
|
-
fn into_completion(self, run_id: String) -> WorkflowActivationCompletion {
|
1033
|
-
WorkflowActivationCompletion::from_cmd(run_id, self)
|
1034
|
-
}
|
1035
|
-
}
|
1036
|
-
|
1037
|
-
impl<I, V> IntoCompletion for I
|
1038
|
-
where
|
1039
|
-
I: IntoIterator<Item = V>,
|
1040
|
-
V: Into<WorkflowCommand>,
|
1041
|
-
{
|
1042
|
-
fn into_completion(self, run_id: String) -> WorkflowActivationCompletion {
|
1043
|
-
let success = self.into_iter().map(Into::into).collect::<Vec<_>>().into();
|
1044
|
-
WorkflowActivationCompletion {
|
1045
|
-
run_id,
|
1046
|
-
status: Some(workflow_activation_completion::Status::Successful(success)),
|
1047
|
-
}
|
1048
|
-
}
|
1049
|
-
}
|
1050
|
-
|
1051
|
-
impl Display for WorkflowActivationCompletion {
|
1052
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1053
|
-
write!(
|
1054
|
-
f,
|
1055
|
-
"WorkflowActivationCompletion(run_id: {}, status: ",
|
1056
|
-
&self.run_id
|
1057
|
-
)?;
|
1058
|
-
match &self.status {
|
1059
|
-
None => write!(f, "empty")?,
|
1060
|
-
Some(s) => write!(f, "{s}")?,
|
1061
|
-
};
|
1062
|
-
write!(f, ")")
|
1063
|
-
}
|
1064
|
-
}
|
1065
|
-
|
1066
|
-
impl Display for workflow_activation_completion::Status {
|
1067
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1068
|
-
match self {
|
1069
|
-
workflow_activation_completion::Status::Successful(
|
1070
|
-
workflow_completion::Success { commands, .. },
|
1071
|
-
) => {
|
1072
|
-
write!(f, "Success(")?;
|
1073
|
-
let mut written = 0;
|
1074
|
-
for c in commands {
|
1075
|
-
write!(f, "{c} ")?;
|
1076
|
-
written += 1;
|
1077
|
-
if written >= 10 && written < commands.len() {
|
1078
|
-
write!(f, "... {} more", commands.len() - written)?;
|
1079
|
-
break;
|
1080
|
-
}
|
1081
|
-
}
|
1082
|
-
write!(f, ")")
|
1083
|
-
}
|
1084
|
-
workflow_activation_completion::Status::Failed(_) => {
|
1085
|
-
write!(f, "Failed")
|
1086
|
-
}
|
1087
|
-
}
|
1088
|
-
}
|
1089
|
-
}
|
1090
|
-
|
1091
|
-
impl ActivityTask {
|
1092
|
-
pub fn start_from_poll_resp(r: PollActivityTaskQueueResponse) -> Self {
|
1093
|
-
let (workflow_id, run_id) = r
|
1094
|
-
.workflow_execution
|
1095
|
-
.map(|we| (we.workflow_id, we.run_id))
|
1096
|
-
.unwrap_or_default();
|
1097
|
-
Self {
|
1098
|
-
task_token: r.task_token,
|
1099
|
-
variant: Some(activity_task::activity_task::Variant::Start(
|
1100
|
-
activity_task::Start {
|
1101
|
-
workflow_namespace: r.workflow_namespace,
|
1102
|
-
workflow_type: r.workflow_type.map_or_else(|| "".to_string(), |wt| wt.name),
|
1103
|
-
workflow_execution: Some(WorkflowExecution {
|
1104
|
-
workflow_id,
|
1105
|
-
run_id,
|
1106
|
-
}),
|
1107
|
-
activity_id: r.activity_id,
|
1108
|
-
activity_type: r.activity_type.map_or_else(|| "".to_string(), |at| at.name),
|
1109
|
-
header_fields: r.header.map(Into::into).unwrap_or_default(),
|
1110
|
-
input: Vec::from_payloads(r.input),
|
1111
|
-
heartbeat_details: Vec::from_payloads(r.heartbeat_details),
|
1112
|
-
scheduled_time: r.scheduled_time,
|
1113
|
-
current_attempt_scheduled_time: r.current_attempt_scheduled_time,
|
1114
|
-
started_time: r.started_time,
|
1115
|
-
attempt: r.attempt as u32,
|
1116
|
-
schedule_to_close_timeout: r.schedule_to_close_timeout,
|
1117
|
-
start_to_close_timeout: r.start_to_close_timeout,
|
1118
|
-
heartbeat_timeout: r.heartbeat_timeout,
|
1119
|
-
retry_policy: r.retry_policy.map(Into::into),
|
1120
|
-
is_local: false,
|
1121
|
-
},
|
1122
|
-
)),
|
1123
|
-
}
|
1124
|
-
}
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
impl Failure {
|
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
|
-
}
|
1133
|
-
}
|
1134
|
-
|
1135
|
-
pub fn application_failure(message: String, non_retryable: bool) -> Self {
|
1136
|
-
Self {
|
1137
|
-
message,
|
1138
|
-
failure_info: Some(FailureInfo::ApplicationFailureInfo(
|
1139
|
-
ApplicationFailureInfo {
|
1140
|
-
non_retryable,
|
1141
|
-
..Default::default()
|
1142
|
-
},
|
1143
|
-
)),
|
1144
|
-
..Default::default()
|
1145
|
-
}
|
1146
|
-
}
|
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
|
-
|
1168
|
-
/// Extracts an ApplicationFailureInfo from a Failure instance if it exists
|
1169
|
-
pub fn maybe_application_failure(&self) -> Option<&ApplicationFailureInfo> {
|
1170
|
-
if let Failure {
|
1171
|
-
failure_info: Some(FailureInfo::ApplicationFailureInfo(f)),
|
1172
|
-
..
|
1173
|
-
} = self
|
1174
|
-
{
|
1175
|
-
Some(f)
|
1176
|
-
} else {
|
1177
|
-
None
|
1178
|
-
}
|
1179
|
-
}
|
1180
|
-
}
|
1181
|
-
|
1182
|
-
impl Display for Failure {
|
1183
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1184
|
-
write!(f, "Failure({}, ", self.message)?;
|
1185
|
-
match self.failure_info.as_ref() {
|
1186
|
-
None => write!(f, "missing info")?,
|
1187
|
-
Some(FailureInfo::TimeoutFailureInfo(v)) => {
|
1188
|
-
write!(f, "Timeout: {:?}", v.timeout_type())?;
|
1189
|
-
}
|
1190
|
-
Some(FailureInfo::ApplicationFailureInfo(v)) => {
|
1191
|
-
write!(f, "Application Failure: {}", v.r#type)?;
|
1192
|
-
}
|
1193
|
-
Some(FailureInfo::CanceledFailureInfo(_)) => {
|
1194
|
-
write!(f, "Cancelled")?;
|
1195
|
-
}
|
1196
|
-
Some(FailureInfo::TerminatedFailureInfo(_)) => {
|
1197
|
-
write!(f, "Terminated")?;
|
1198
|
-
}
|
1199
|
-
Some(FailureInfo::ServerFailureInfo(_)) => {
|
1200
|
-
write!(f, "Server Failure")?;
|
1201
|
-
}
|
1202
|
-
Some(FailureInfo::ResetWorkflowFailureInfo(_)) => {
|
1203
|
-
write!(f, "Reset Workflow")?;
|
1204
|
-
}
|
1205
|
-
Some(FailureInfo::ActivityFailureInfo(v)) => {
|
1206
|
-
write!(
|
1207
|
-
f,
|
1208
|
-
"Activity Failure: scheduled_event_id: {}",
|
1209
|
-
v.scheduled_event_id
|
1210
|
-
)?;
|
1211
|
-
}
|
1212
|
-
Some(FailureInfo::ChildWorkflowExecutionFailureInfo(v)) => {
|
1213
|
-
write!(
|
1214
|
-
f,
|
1215
|
-
"Child Workflow: started_event_id: {}",
|
1216
|
-
v.started_event_id
|
1217
|
-
)?;
|
1218
|
-
}
|
1219
|
-
}
|
1220
|
-
write!(f, ")")
|
1221
|
-
}
|
1222
|
-
}
|
1223
|
-
|
1224
|
-
impl From<&str> for Failure {
|
1225
|
-
fn from(v: &str) -> Self {
|
1226
|
-
Failure::application_failure(v.to_string(), false)
|
1227
|
-
}
|
1228
|
-
}
|
1229
|
-
|
1230
|
-
impl From<String> for Failure {
|
1231
|
-
fn from(v: String) -> Self {
|
1232
|
-
Failure::application_failure(v, false)
|
1233
|
-
}
|
1234
|
-
}
|
1235
|
-
|
1236
|
-
impl From<anyhow::Error> for Failure {
|
1237
|
-
fn from(ae: anyhow::Error) -> Self {
|
1238
|
-
Failure::application_failure_from_error(ae, false)
|
1239
|
-
}
|
1240
|
-
}
|
1241
|
-
|
1242
|
-
pub trait FromPayloadsExt {
|
1243
|
-
fn from_payloads(p: Option<Payloads>) -> Self;
|
1244
|
-
}
|
1245
|
-
impl<T> FromPayloadsExt for T
|
1246
|
-
where
|
1247
|
-
T: FromIterator<Payload>,
|
1248
|
-
{
|
1249
|
-
fn from_payloads(p: Option<Payloads>) -> Self {
|
1250
|
-
match p {
|
1251
|
-
None => std::iter::empty().collect(),
|
1252
|
-
Some(p) => p.payloads.into_iter().map(Into::into).collect(),
|
1253
|
-
}
|
1254
|
-
}
|
1255
|
-
}
|
1256
|
-
|
1257
|
-
pub trait IntoPayloadsExt {
|
1258
|
-
fn into_payloads(self) -> Option<Payloads>;
|
1259
|
-
}
|
1260
|
-
impl<T> IntoPayloadsExt for T
|
1261
|
-
where
|
1262
|
-
T: IntoIterator<Item = Payload>,
|
1263
|
-
{
|
1264
|
-
fn into_payloads(self) -> Option<Payloads> {
|
1265
|
-
let mut iterd = self.into_iter().peekable();
|
1266
|
-
if iterd.peek().is_none() {
|
1267
|
-
None
|
1268
|
-
} else {
|
1269
|
-
Some(Payloads {
|
1270
|
-
payloads: iterd.map(Into::into).collect(),
|
1271
|
-
})
|
1272
|
-
}
|
1273
|
-
}
|
1274
|
-
}
|
1275
|
-
|
1276
|
-
impl From<Payload> for Payloads {
|
1277
|
-
fn from(p: Payload) -> Self {
|
1278
|
-
Self { payloads: vec![p] }
|
1279
|
-
}
|
1280
|
-
}
|
1281
|
-
|
1282
|
-
impl<T> From<T> for Payloads
|
1283
|
-
where
|
1284
|
-
T: AsRef<[u8]>,
|
1285
|
-
{
|
1286
|
-
fn from(v: T) -> Self {
|
1287
|
-
Self {
|
1288
|
-
payloads: vec![v.into()],
|
1289
|
-
}
|
1290
|
-
}
|
1291
|
-
}
|
1292
|
-
|
1293
|
-
#[derive(thiserror::Error, Debug)]
|
1294
|
-
pub enum PayloadDeserializeErr {
|
1295
|
-
/// This deserializer does not handle this type of payload. Allows composing multiple
|
1296
|
-
/// deserializers.
|
1297
|
-
#[error("This deserializer does not understand this payload")]
|
1298
|
-
DeserializerDoesNotHandle,
|
1299
|
-
#[error("Error during deserialization: {0}")]
|
1300
|
-
DeserializeErr(#[from] anyhow::Error),
|
1301
|
-
}
|
1302
|
-
|
1303
|
-
// TODO: Once the prototype SDK is un-prototyped this serialization will need to be compat with
|
1304
|
-
// other SDKs (given they might execute an activity).
|
1305
|
-
pub trait AsJsonPayloadExt {
|
1306
|
-
fn as_json_payload(&self) -> anyhow::Result<Payload>;
|
1307
|
-
}
|
1308
|
-
impl<T> AsJsonPayloadExt for T
|
1309
|
-
where
|
1310
|
-
T: Serialize,
|
1311
|
-
{
|
1312
|
-
fn as_json_payload(&self) -> anyhow::Result<Payload> {
|
1313
|
-
let as_json = serde_json::to_string(self)?;
|
1314
|
-
let mut metadata = HashMap::new();
|
1315
|
-
metadata.insert("encoding".to_string(), b"json/plain".to_vec());
|
1316
|
-
Ok(Payload {
|
1317
|
-
metadata,
|
1318
|
-
data: as_json.into_bytes(),
|
1319
|
-
})
|
1320
|
-
}
|
1321
|
-
}
|
1322
|
-
|
1323
|
-
pub trait FromJsonPayloadExt: Sized {
|
1324
|
-
fn from_json_payload(payload: &Payload) -> Result<Self, PayloadDeserializeErr>;
|
1325
|
-
}
|
1326
|
-
impl<T> FromJsonPayloadExt for T
|
1327
|
-
where
|
1328
|
-
T: for<'de> Deserialize<'de>,
|
1329
|
-
{
|
1330
|
-
fn from_json_payload(payload: &Payload) -> Result<Self, PayloadDeserializeErr> {
|
1331
|
-
if !matches!(
|
1332
|
-
payload.metadata.get("encoding").map(|v| v.as_slice()),
|
1333
|
-
Some(b"json/plain")
|
1334
|
-
) {
|
1335
|
-
return Err(PayloadDeserializeErr::DeserializerDoesNotHandle);
|
1336
|
-
}
|
1337
|
-
let payload_str = std::str::from_utf8(&payload.data).map_err(anyhow::Error::from)?;
|
1338
|
-
Ok(serde_json::from_str(payload_str).map_err(anyhow::Error::from)?)
|
1339
|
-
}
|
1340
|
-
}
|
1341
|
-
|
1342
|
-
/// Errors when converting from a [Payloads] api proto to our internal [Payload]
|
1343
|
-
#[derive(derive_more::Display, Debug)]
|
1344
|
-
pub enum PayloadsToPayloadError {
|
1345
|
-
MoreThanOnePayload,
|
1346
|
-
NoPayload,
|
1347
|
-
}
|
1348
|
-
impl TryFrom<Payloads> for Payload {
|
1349
|
-
type Error = PayloadsToPayloadError;
|
1350
|
-
|
1351
|
-
fn try_from(mut v: Payloads) -> Result<Self, Self::Error> {
|
1352
|
-
match v.payloads.pop() {
|
1353
|
-
None => Err(PayloadsToPayloadError::NoPayload),
|
1354
|
-
Some(p) => {
|
1355
|
-
if v.payloads.is_empty() {
|
1356
|
-
Ok(p)
|
1357
|
-
} else {
|
1358
|
-
Err(PayloadsToPayloadError::MoreThanOnePayload)
|
1359
|
-
}
|
1360
|
-
}
|
1361
|
-
}
|
1362
|
-
}
|
1363
|
-
}
|
1364
|
-
}
|
1365
|
-
|
1366
|
-
// No need to lint these
|
1367
|
-
#[allow(
|
1368
|
-
clippy::all,
|
1369
|
-
missing_docs,
|
1370
|
-
rustdoc::broken_intra_doc_links,
|
1371
|
-
rustdoc::bare_urls
|
1372
|
-
)]
|
1373
|
-
// This is disgusting, but unclear to me how to avoid it. TODO: Discuss w/ prost maintainer
|
1374
|
-
pub mod temporal {
|
1375
|
-
pub mod api {
|
1376
|
-
pub mod batch {
|
1377
|
-
pub mod v1 {
|
1378
|
-
tonic::include_proto!("temporal.api.batch.v1");
|
1379
|
-
}
|
1380
|
-
}
|
1381
|
-
pub mod command {
|
1382
|
-
pub mod v1 {
|
1383
|
-
tonic::include_proto!("temporal.api.command.v1");
|
1384
|
-
|
1385
|
-
use crate::{
|
1386
|
-
coresdk::{workflow_commands, IntoPayloadsExt},
|
1387
|
-
temporal::api::{
|
1388
|
-
common::v1::{ActivityType, WorkflowType},
|
1389
|
-
enums::v1::CommandType,
|
1390
|
-
},
|
1391
|
-
};
|
1392
|
-
use command::Attributes;
|
1393
|
-
use std::fmt::{Display, Formatter};
|
1394
|
-
|
1395
|
-
impl From<command::Attributes> for Command {
|
1396
|
-
fn from(c: command::Attributes) -> Self {
|
1397
|
-
match c {
|
1398
|
-
a @ Attributes::StartTimerCommandAttributes(_) => Self {
|
1399
|
-
command_type: CommandType::StartTimer as i32,
|
1400
|
-
attributes: Some(a),
|
1401
|
-
},
|
1402
|
-
a @ Attributes::CancelTimerCommandAttributes(_) => Self {
|
1403
|
-
command_type: CommandType::CancelTimer as i32,
|
1404
|
-
attributes: Some(a),
|
1405
|
-
},
|
1406
|
-
a @ Attributes::CompleteWorkflowExecutionCommandAttributes(_) => Self {
|
1407
|
-
command_type: CommandType::CompleteWorkflowExecution as i32,
|
1408
|
-
attributes: Some(a),
|
1409
|
-
},
|
1410
|
-
a @ Attributes::FailWorkflowExecutionCommandAttributes(_) => Self {
|
1411
|
-
command_type: CommandType::FailWorkflowExecution as i32,
|
1412
|
-
attributes: Some(a),
|
1413
|
-
},
|
1414
|
-
a @ Attributes::ScheduleActivityTaskCommandAttributes(_) => Self {
|
1415
|
-
command_type: CommandType::ScheduleActivityTask as i32,
|
1416
|
-
attributes: Some(a),
|
1417
|
-
},
|
1418
|
-
a @ Attributes::RequestCancelActivityTaskCommandAttributes(_) => Self {
|
1419
|
-
command_type: CommandType::RequestCancelActivityTask as i32,
|
1420
|
-
attributes: Some(a),
|
1421
|
-
},
|
1422
|
-
a @ Attributes::ContinueAsNewWorkflowExecutionCommandAttributes(_) => {
|
1423
|
-
Self {
|
1424
|
-
command_type: CommandType::ContinueAsNewWorkflowExecution
|
1425
|
-
as i32,
|
1426
|
-
attributes: Some(a),
|
1427
|
-
}
|
1428
|
-
}
|
1429
|
-
a @ Attributes::CancelWorkflowExecutionCommandAttributes(_) => Self {
|
1430
|
-
command_type: CommandType::CancelWorkflowExecution as i32,
|
1431
|
-
attributes: Some(a),
|
1432
|
-
},
|
1433
|
-
_ => unimplemented!(),
|
1434
|
-
}
|
1435
|
-
}
|
1436
|
-
}
|
1437
|
-
|
1438
|
-
impl Display for Command {
|
1439
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1440
|
-
let ct = CommandType::from_i32(self.command_type)
|
1441
|
-
.unwrap_or(CommandType::Unspecified);
|
1442
|
-
write!(f, "{:?}", ct)
|
1443
|
-
}
|
1444
|
-
}
|
1445
|
-
|
1446
|
-
impl From<workflow_commands::StartTimer> for command::Attributes {
|
1447
|
-
fn from(s: workflow_commands::StartTimer) -> Self {
|
1448
|
-
Self::StartTimerCommandAttributes(StartTimerCommandAttributes {
|
1449
|
-
timer_id: s.seq.to_string(),
|
1450
|
-
start_to_fire_timeout: s.start_to_fire_timeout,
|
1451
|
-
})
|
1452
|
-
}
|
1453
|
-
}
|
1454
|
-
|
1455
|
-
impl From<workflow_commands::UpsertWorkflowSearchAttributes> for command::Attributes {
|
1456
|
-
fn from(s: workflow_commands::UpsertWorkflowSearchAttributes) -> Self {
|
1457
|
-
Self::UpsertWorkflowSearchAttributesCommandAttributes(
|
1458
|
-
UpsertWorkflowSearchAttributesCommandAttributes {
|
1459
|
-
search_attributes: Some(s.search_attributes.into()),
|
1460
|
-
},
|
1461
|
-
)
|
1462
|
-
}
|
1463
|
-
}
|
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
|
-
|
1475
|
-
impl From<workflow_commands::CancelTimer> for command::Attributes {
|
1476
|
-
fn from(s: workflow_commands::CancelTimer) -> Self {
|
1477
|
-
Self::CancelTimerCommandAttributes(CancelTimerCommandAttributes {
|
1478
|
-
timer_id: s.seq.to_string(),
|
1479
|
-
})
|
1480
|
-
}
|
1481
|
-
}
|
1482
|
-
|
1483
|
-
impl From<workflow_commands::ScheduleActivity> for command::Attributes {
|
1484
|
-
fn from(s: workflow_commands::ScheduleActivity) -> Self {
|
1485
|
-
Self::ScheduleActivityTaskCommandAttributes(
|
1486
|
-
ScheduleActivityTaskCommandAttributes {
|
1487
|
-
activity_id: s.activity_id,
|
1488
|
-
activity_type: Some(ActivityType {
|
1489
|
-
name: s.activity_type,
|
1490
|
-
}),
|
1491
|
-
task_queue: Some(s.task_queue.into()),
|
1492
|
-
header: Some(s.headers.into()),
|
1493
|
-
input: s.arguments.into_payloads(),
|
1494
|
-
schedule_to_close_timeout: s.schedule_to_close_timeout,
|
1495
|
-
schedule_to_start_timeout: s.schedule_to_start_timeout,
|
1496
|
-
start_to_close_timeout: s.start_to_close_timeout,
|
1497
|
-
heartbeat_timeout: s.heartbeat_timeout,
|
1498
|
-
retry_policy: s.retry_policy.map(Into::into),
|
1499
|
-
request_eager_execution: !s.do_not_eagerly_execute,
|
1500
|
-
},
|
1501
|
-
)
|
1502
|
-
}
|
1503
|
-
}
|
1504
|
-
|
1505
|
-
impl From<workflow_commands::StartChildWorkflowExecution> for command::Attributes {
|
1506
|
-
fn from(s: workflow_commands::StartChildWorkflowExecution) -> Self {
|
1507
|
-
Self::StartChildWorkflowExecutionCommandAttributes(
|
1508
|
-
StartChildWorkflowExecutionCommandAttributes {
|
1509
|
-
workflow_id: s.workflow_id,
|
1510
|
-
workflow_type: Some(WorkflowType {
|
1511
|
-
name: s.workflow_type,
|
1512
|
-
}),
|
1513
|
-
control: "".into(),
|
1514
|
-
namespace: s.namespace,
|
1515
|
-
task_queue: Some(s.task_queue.into()),
|
1516
|
-
header: Some(s.headers.into()),
|
1517
|
-
memo: Some(s.memo.into()),
|
1518
|
-
search_attributes: Some(s.search_attributes.into()),
|
1519
|
-
input: s.input.into_payloads(),
|
1520
|
-
workflow_id_reuse_policy: s.workflow_id_reuse_policy,
|
1521
|
-
workflow_execution_timeout: s.workflow_execution_timeout,
|
1522
|
-
workflow_run_timeout: s.workflow_run_timeout,
|
1523
|
-
workflow_task_timeout: s.workflow_task_timeout,
|
1524
|
-
retry_policy: s.retry_policy.map(Into::into),
|
1525
|
-
cron_schedule: s.cron_schedule.clone(),
|
1526
|
-
parent_close_policy: s.parent_close_policy,
|
1527
|
-
},
|
1528
|
-
)
|
1529
|
-
}
|
1530
|
-
}
|
1531
|
-
|
1532
|
-
impl From<workflow_commands::CompleteWorkflowExecution> for command::Attributes {
|
1533
|
-
fn from(c: workflow_commands::CompleteWorkflowExecution) -> Self {
|
1534
|
-
Self::CompleteWorkflowExecutionCommandAttributes(
|
1535
|
-
CompleteWorkflowExecutionCommandAttributes {
|
1536
|
-
result: c.result.map(Into::into),
|
1537
|
-
},
|
1538
|
-
)
|
1539
|
-
}
|
1540
|
-
}
|
1541
|
-
|
1542
|
-
impl From<workflow_commands::FailWorkflowExecution> for command::Attributes {
|
1543
|
-
fn from(c: workflow_commands::FailWorkflowExecution) -> Self {
|
1544
|
-
Self::FailWorkflowExecutionCommandAttributes(
|
1545
|
-
FailWorkflowExecutionCommandAttributes {
|
1546
|
-
failure: c.failure.map(Into::into),
|
1547
|
-
},
|
1548
|
-
)
|
1549
|
-
}
|
1550
|
-
}
|
1551
|
-
|
1552
|
-
impl From<workflow_commands::ContinueAsNewWorkflowExecution> for command::Attributes {
|
1553
|
-
fn from(c: workflow_commands::ContinueAsNewWorkflowExecution) -> Self {
|
1554
|
-
Self::ContinueAsNewWorkflowExecutionCommandAttributes(
|
1555
|
-
ContinueAsNewWorkflowExecutionCommandAttributes {
|
1556
|
-
workflow_type: Some(c.workflow_type.into()),
|
1557
|
-
task_queue: Some(c.task_queue.into()),
|
1558
|
-
input: c.arguments.into_payloads(),
|
1559
|
-
workflow_run_timeout: c.workflow_run_timeout,
|
1560
|
-
workflow_task_timeout: c.workflow_task_timeout,
|
1561
|
-
memo: if c.memo.is_empty() {
|
1562
|
-
None
|
1563
|
-
} else {
|
1564
|
-
Some(c.memo.into())
|
1565
|
-
},
|
1566
|
-
header: if c.headers.is_empty() {
|
1567
|
-
None
|
1568
|
-
} else {
|
1569
|
-
Some(c.headers.into())
|
1570
|
-
},
|
1571
|
-
retry_policy: c.retry_policy,
|
1572
|
-
search_attributes: if c.search_attributes.is_empty() {
|
1573
|
-
None
|
1574
|
-
} else {
|
1575
|
-
Some(c.search_attributes.into())
|
1576
|
-
},
|
1577
|
-
..Default::default()
|
1578
|
-
},
|
1579
|
-
)
|
1580
|
-
}
|
1581
|
-
}
|
1582
|
-
|
1583
|
-
impl From<workflow_commands::CancelWorkflowExecution> for command::Attributes {
|
1584
|
-
fn from(_c: workflow_commands::CancelWorkflowExecution) -> Self {
|
1585
|
-
Self::CancelWorkflowExecutionCommandAttributes(
|
1586
|
-
CancelWorkflowExecutionCommandAttributes { details: None },
|
1587
|
-
)
|
1588
|
-
}
|
1589
|
-
}
|
1590
|
-
}
|
1591
|
-
}
|
1592
|
-
pub mod common {
|
1593
|
-
pub mod v1 {
|
1594
|
-
use base64::{prelude::BASE64_STANDARD, Engine};
|
1595
|
-
use std::{
|
1596
|
-
collections::HashMap,
|
1597
|
-
fmt::{Display, Formatter},
|
1598
|
-
};
|
1599
|
-
tonic::include_proto!("temporal.api.common.v1");
|
1600
|
-
|
1601
|
-
impl<T> From<T> for Payload
|
1602
|
-
where
|
1603
|
-
T: AsRef<[u8]>,
|
1604
|
-
{
|
1605
|
-
fn from(v: T) -> Self {
|
1606
|
-
// TODO: Set better encodings, whole data converter deal. Setting anything
|
1607
|
-
// for now at least makes it show up in the web UI.
|
1608
|
-
let mut metadata = HashMap::new();
|
1609
|
-
metadata.insert("encoding".to_string(), b"binary/plain".to_vec());
|
1610
|
-
Self {
|
1611
|
-
metadata,
|
1612
|
-
data: v.as_ref().to_vec(),
|
1613
|
-
}
|
1614
|
-
}
|
1615
|
-
}
|
1616
|
-
|
1617
|
-
impl Payload {
|
1618
|
-
// Is its own function b/c asref causes implementation conflicts
|
1619
|
-
pub fn as_slice(&self) -> &[u8] {
|
1620
|
-
self.data.as_slice()
|
1621
|
-
}
|
1622
|
-
}
|
1623
|
-
|
1624
|
-
impl Display for Payload {
|
1625
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1626
|
-
if self.data.len() > 64 {
|
1627
|
-
let mut windows = self.data.as_slice().windows(32);
|
1628
|
-
write!(
|
1629
|
-
f,
|
1630
|
-
"[{}..{}]",
|
1631
|
-
BASE64_STANDARD.encode(windows.next().unwrap_or_default()),
|
1632
|
-
BASE64_STANDARD.encode(windows.next_back().unwrap_or_default())
|
1633
|
-
)
|
1634
|
-
} else {
|
1635
|
-
write!(f, "[{}]", BASE64_STANDARD.encode(&self.data))
|
1636
|
-
}
|
1637
|
-
}
|
1638
|
-
}
|
1639
|
-
|
1640
|
-
impl Display for Header {
|
1641
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1642
|
-
write!(f, "Header(")?;
|
1643
|
-
for kv in &self.fields {
|
1644
|
-
write!(f, "{}: ", kv.0)?;
|
1645
|
-
write!(f, "{}, ", kv.1)?;
|
1646
|
-
}
|
1647
|
-
write!(f, ")")
|
1648
|
-
}
|
1649
|
-
}
|
1650
|
-
|
1651
|
-
impl From<Header> for HashMap<String, Payload> {
|
1652
|
-
fn from(h: Header) -> Self {
|
1653
|
-
h.fields.into_iter().map(|(k, v)| (k, v.into())).collect()
|
1654
|
-
}
|
1655
|
-
}
|
1656
|
-
|
1657
|
-
impl From<Memo> for HashMap<String, Payload> {
|
1658
|
-
fn from(h: Memo) -> Self {
|
1659
|
-
h.fields.into_iter().map(|(k, v)| (k, v.into())).collect()
|
1660
|
-
}
|
1661
|
-
}
|
1662
|
-
|
1663
|
-
impl From<SearchAttributes> for HashMap<String, Payload> {
|
1664
|
-
fn from(h: SearchAttributes) -> Self {
|
1665
|
-
h.indexed_fields
|
1666
|
-
.into_iter()
|
1667
|
-
.map(|(k, v)| (k, v.into()))
|
1668
|
-
.collect()
|
1669
|
-
}
|
1670
|
-
}
|
1671
|
-
|
1672
|
-
impl From<HashMap<String, Payload>> for SearchAttributes {
|
1673
|
-
fn from(h: HashMap<String, Payload>) -> Self {
|
1674
|
-
Self {
|
1675
|
-
indexed_fields: h.into_iter().map(|(k, v)| (k, v.into())).collect(),
|
1676
|
-
}
|
1677
|
-
}
|
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
|
-
}
|
1699
|
-
}
|
1700
|
-
}
|
1701
|
-
pub mod enums {
|
1702
|
-
pub mod v1 {
|
1703
|
-
tonic::include_proto!("temporal.api.enums.v1");
|
1704
|
-
}
|
1705
|
-
}
|
1706
|
-
pub mod failure {
|
1707
|
-
pub mod v1 {
|
1708
|
-
tonic::include_proto!("temporal.api.failure.v1");
|
1709
|
-
}
|
1710
|
-
}
|
1711
|
-
pub mod filter {
|
1712
|
-
pub mod v1 {
|
1713
|
-
tonic::include_proto!("temporal.api.filter.v1");
|
1714
|
-
}
|
1715
|
-
}
|
1716
|
-
pub mod history {
|
1717
|
-
pub mod v1 {
|
1718
|
-
use crate::temporal::api::{
|
1719
|
-
enums::v1::EventType, history::v1::history_event::Attributes,
|
1720
|
-
};
|
1721
|
-
use anyhow::bail;
|
1722
|
-
use prost::alloc::fmt::Formatter;
|
1723
|
-
use std::fmt::Display;
|
1724
|
-
|
1725
|
-
tonic::include_proto!("temporal.api.history.v1");
|
1726
|
-
|
1727
|
-
impl History {
|
1728
|
-
pub fn extract_run_id_from_start(&self) -> Result<&str, anyhow::Error> {
|
1729
|
-
extract_original_run_id_from_events(&self.events)
|
1730
|
-
}
|
1731
|
-
|
1732
|
-
/// Returns the event id of the final event in the history. Will return 0 if
|
1733
|
-
/// there are no events.
|
1734
|
-
pub fn last_event_id(&self) -> i64 {
|
1735
|
-
self.events.last().map(|e| e.event_id).unwrap_or_default()
|
1736
|
-
}
|
1737
|
-
}
|
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
|
-
|
1751
|
-
impl HistoryEvent {
|
1752
|
-
/// Returns true if this is an event created to mirror a command
|
1753
|
-
pub fn is_command_event(&self) -> bool {
|
1754
|
-
EventType::from_i32(self.event_type).map_or(false, |et| match et {
|
1755
|
-
EventType::ActivityTaskScheduled
|
1756
|
-
| EventType::ActivityTaskCancelRequested
|
1757
|
-
| EventType::MarkerRecorded
|
1758
|
-
| EventType::RequestCancelExternalWorkflowExecutionInitiated
|
1759
|
-
| EventType::SignalExternalWorkflowExecutionInitiated
|
1760
|
-
| EventType::StartChildWorkflowExecutionInitiated
|
1761
|
-
| EventType::TimerCanceled
|
1762
|
-
| EventType::TimerStarted
|
1763
|
-
| EventType::UpsertWorkflowSearchAttributes
|
1764
|
-
| EventType::WorkflowPropertiesModified
|
1765
|
-
| EventType::WorkflowExecutionCanceled
|
1766
|
-
| EventType::WorkflowExecutionCompleted
|
1767
|
-
| EventType::WorkflowExecutionContinuedAsNew
|
1768
|
-
| EventType::WorkflowExecutionFailed => true,
|
1769
|
-
_ => false,
|
1770
|
-
})
|
1771
|
-
}
|
1772
|
-
|
1773
|
-
/// Returns the command's initiating event id, if present. This is the id of the
|
1774
|
-
/// event which "started" the command. Usually, the "scheduled" event for the
|
1775
|
-
/// command.
|
1776
|
-
pub fn get_initial_command_event_id(&self) -> Option<i64> {
|
1777
|
-
self.attributes.as_ref().and_then(|a| {
|
1778
|
-
// Fun! Not really any way to make this better w/o incompatibly changing
|
1779
|
-
// protos.
|
1780
|
-
match a {
|
1781
|
-
Attributes::ActivityTaskStartedEventAttributes(a) =>
|
1782
|
-
Some(a.scheduled_event_id),
|
1783
|
-
Attributes::ActivityTaskCompletedEventAttributes(a) =>
|
1784
|
-
Some(a.scheduled_event_id),
|
1785
|
-
Attributes::ActivityTaskFailedEventAttributes(a) => Some(a.scheduled_event_id),
|
1786
|
-
Attributes::ActivityTaskTimedOutEventAttributes(a) => Some(a.scheduled_event_id),
|
1787
|
-
Attributes::ActivityTaskCancelRequestedEventAttributes(a) => Some(a.scheduled_event_id),
|
1788
|
-
Attributes::ActivityTaskCanceledEventAttributes(a) => Some(a.scheduled_event_id),
|
1789
|
-
Attributes::TimerFiredEventAttributes(a) => Some(a.started_event_id),
|
1790
|
-
Attributes::TimerCanceledEventAttributes(a) => Some(a.started_event_id),
|
1791
|
-
Attributes::RequestCancelExternalWorkflowExecutionFailedEventAttributes(a) => Some(a.initiated_event_id),
|
1792
|
-
Attributes::ExternalWorkflowExecutionCancelRequestedEventAttributes(a) => Some(a.initiated_event_id),
|
1793
|
-
Attributes::StartChildWorkflowExecutionFailedEventAttributes(a) => Some(a.initiated_event_id),
|
1794
|
-
Attributes::ChildWorkflowExecutionStartedEventAttributes(a) => Some(a.initiated_event_id),
|
1795
|
-
Attributes::ChildWorkflowExecutionCompletedEventAttributes(a) => Some(a.initiated_event_id),
|
1796
|
-
Attributes::ChildWorkflowExecutionFailedEventAttributes(a) => Some(a.initiated_event_id),
|
1797
|
-
Attributes::ChildWorkflowExecutionCanceledEventAttributes(a) => Some(a.initiated_event_id),
|
1798
|
-
Attributes::ChildWorkflowExecutionTimedOutEventAttributes(a) => Some(a.initiated_event_id),
|
1799
|
-
Attributes::ChildWorkflowExecutionTerminatedEventAttributes(a) => Some(a.initiated_event_id),
|
1800
|
-
Attributes::SignalExternalWorkflowExecutionFailedEventAttributes(a) => Some(a.initiated_event_id),
|
1801
|
-
Attributes::ExternalWorkflowExecutionSignaledEventAttributes(a) => Some(a.initiated_event_id),
|
1802
|
-
Attributes::WorkflowTaskStartedEventAttributes(a) => Some(a.scheduled_event_id),
|
1803
|
-
Attributes::WorkflowTaskCompletedEventAttributes(a) => Some(a.scheduled_event_id),
|
1804
|
-
Attributes::WorkflowTaskTimedOutEventAttributes(a) => Some(a.scheduled_event_id),
|
1805
|
-
Attributes::WorkflowTaskFailedEventAttributes(a) => Some(a.scheduled_event_id),
|
1806
|
-
_ => None
|
1807
|
-
}
|
1808
|
-
})
|
1809
|
-
}
|
1810
|
-
|
1811
|
-
/// Returns true if the event is one which would end a workflow
|
1812
|
-
pub fn is_final_wf_execution_event(&self) -> bool {
|
1813
|
-
match self.event_type() {
|
1814
|
-
EventType::WorkflowExecutionCompleted => true,
|
1815
|
-
EventType::WorkflowExecutionCanceled => true,
|
1816
|
-
EventType::WorkflowExecutionFailed => true,
|
1817
|
-
EventType::WorkflowExecutionTimedOut => true,
|
1818
|
-
EventType::WorkflowExecutionContinuedAsNew => true,
|
1819
|
-
EventType::WorkflowExecutionTerminated => true,
|
1820
|
-
_ => false,
|
1821
|
-
}
|
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
|
-
}
|
1832
|
-
}
|
1833
|
-
|
1834
|
-
impl Display for HistoryEvent {
|
1835
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
1836
|
-
write!(
|
1837
|
-
f,
|
1838
|
-
"HistoryEvent(id: {}, {:?})",
|
1839
|
-
self.event_id,
|
1840
|
-
EventType::from_i32(self.event_type)
|
1841
|
-
)
|
1842
|
-
}
|
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
|
-
}
|
1898
|
-
}
|
1899
|
-
}
|
1900
|
-
pub mod namespace {
|
1901
|
-
pub mod v1 {
|
1902
|
-
tonic::include_proto!("temporal.api.namespace.v1");
|
1903
|
-
}
|
1904
|
-
}
|
1905
|
-
pub mod operatorservice {
|
1906
|
-
pub mod v1 {
|
1907
|
-
tonic::include_proto!("temporal.api.operatorservice.v1");
|
1908
|
-
}
|
1909
|
-
}
|
1910
|
-
pub mod protocol {
|
1911
|
-
pub mod v1 {
|
1912
|
-
tonic::include_proto!("temporal.api.protocol.v1");
|
1913
|
-
}
|
1914
|
-
}
|
1915
|
-
pub mod query {
|
1916
|
-
pub mod v1 {
|
1917
|
-
tonic::include_proto!("temporal.api.query.v1");
|
1918
|
-
}
|
1919
|
-
}
|
1920
|
-
pub mod replication {
|
1921
|
-
pub mod v1 {
|
1922
|
-
tonic::include_proto!("temporal.api.replication.v1");
|
1923
|
-
}
|
1924
|
-
}
|
1925
|
-
pub mod schedule {
|
1926
|
-
pub mod v1 {
|
1927
|
-
tonic::include_proto!("temporal.api.schedule.v1");
|
1928
|
-
}
|
1929
|
-
}
|
1930
|
-
pub mod sdk {
|
1931
|
-
pub mod v1 {
|
1932
|
-
tonic::include_proto!("temporal.api.sdk.v1");
|
1933
|
-
}
|
1934
|
-
}
|
1935
|
-
pub mod taskqueue {
|
1936
|
-
pub mod v1 {
|
1937
|
-
use crate::temporal::api::enums::v1::TaskQueueKind;
|
1938
|
-
tonic::include_proto!("temporal.api.taskqueue.v1");
|
1939
|
-
|
1940
|
-
impl From<String> for TaskQueue {
|
1941
|
-
fn from(name: String) -> Self {
|
1942
|
-
Self {
|
1943
|
-
name,
|
1944
|
-
kind: TaskQueueKind::Normal as i32,
|
1945
|
-
}
|
1946
|
-
}
|
1947
|
-
}
|
1948
|
-
}
|
1949
|
-
}
|
1950
|
-
pub mod testservice {
|
1951
|
-
pub mod v1 {
|
1952
|
-
tonic::include_proto!("temporal.api.testservice.v1");
|
1953
|
-
}
|
1954
|
-
}
|
1955
|
-
pub mod update {
|
1956
|
-
pub mod v1 {
|
1957
|
-
tonic::include_proto!("temporal.api.update.v1");
|
1958
|
-
}
|
1959
|
-
}
|
1960
|
-
pub mod version {
|
1961
|
-
pub mod v1 {
|
1962
|
-
tonic::include_proto!("temporal.api.version.v1");
|
1963
|
-
}
|
1964
|
-
}
|
1965
|
-
pub mod workflow {
|
1966
|
-
pub mod v1 {
|
1967
|
-
tonic::include_proto!("temporal.api.workflow.v1");
|
1968
|
-
}
|
1969
|
-
}
|
1970
|
-
pub mod workflowservice {
|
1971
|
-
pub mod v1 {
|
1972
|
-
use std::{
|
1973
|
-
convert::TryInto,
|
1974
|
-
fmt::{Display, Formatter},
|
1975
|
-
time::{Duration, SystemTime},
|
1976
|
-
};
|
1977
|
-
|
1978
|
-
tonic::include_proto!("temporal.api.workflowservice.v1");
|
1979
|
-
|
1980
|
-
macro_rules! sched_to_start_impl {
|
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.
|
1984
|
-
pub fn sched_to_start(&self) -> Option<Duration> {
|
1985
|
-
if let Some((sch, st)) =
|
1986
|
-
self.$sched_field.clone().zip(self.started_time.clone())
|
1987
|
-
{
|
1988
|
-
let sch: Result<SystemTime, _> = sch.try_into();
|
1989
|
-
let st: Result<SystemTime, _> = st.try_into();
|
1990
|
-
if let (Ok(sch), Ok(st)) = (sch, st) {
|
1991
|
-
return st.duration_since(sch).ok();
|
1992
|
-
}
|
1993
|
-
}
|
1994
|
-
None
|
1995
|
-
}
|
1996
|
-
};
|
1997
|
-
}
|
1998
|
-
|
1999
|
-
impl PollWorkflowTaskQueueResponse {
|
2000
|
-
sched_to_start_impl!(scheduled_time);
|
2001
|
-
}
|
2002
|
-
|
2003
|
-
impl Display for PollWorkflowTaskQueueResponse {
|
2004
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
2005
|
-
let last_event = self
|
2006
|
-
.history
|
2007
|
-
.as_ref()
|
2008
|
-
.and_then(|h| h.events.last().map(|he| he.event_id))
|
2009
|
-
.unwrap_or(0);
|
2010
|
-
write!(
|
2011
|
-
f,
|
2012
|
-
"PollWFTQResp(run_id: {}, attempt: {}, last_event: {})",
|
2013
|
-
self.workflow_execution
|
2014
|
-
.as_ref()
|
2015
|
-
.map_or("", |we| we.run_id.as_str()),
|
2016
|
-
self.attempt,
|
2017
|
-
last_event
|
2018
|
-
)
|
2019
|
-
}
|
2020
|
-
}
|
2021
|
-
|
2022
|
-
/// Can be used while debugging to avoid filling up a whole screen with poll resps
|
2023
|
-
pub struct CompactHist<'a>(pub &'a PollWorkflowTaskQueueResponse);
|
2024
|
-
impl Display for CompactHist<'_> {
|
2025
|
-
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
2026
|
-
writeln!(
|
2027
|
-
f,
|
2028
|
-
"PollWorkflowTaskQueueResponse (prev_started: {}, started: {})",
|
2029
|
-
self.0.previous_started_event_id, self.0.started_event_id
|
2030
|
-
)?;
|
2031
|
-
if let Some(h) = self.0.history.as_ref() {
|
2032
|
-
for event in &h.events {
|
2033
|
-
writeln!(f, "{}", event)?;
|
2034
|
-
}
|
2035
|
-
}
|
2036
|
-
writeln!(f, "query: {:#?}", self.0.query)?;
|
2037
|
-
writeln!(f, "queries: {:#?}", self.0.queries)
|
2038
|
-
}
|
2039
|
-
}
|
2040
|
-
|
2041
|
-
impl PollActivityTaskQueueResponse {
|
2042
|
-
sched_to_start_impl!(current_attempt_scheduled_time);
|
2043
|
-
}
|
2044
|
-
|
2045
|
-
impl QueryWorkflowResponse {
|
2046
|
-
/// Unwrap a successful response as vec of payloads
|
2047
|
-
pub fn unwrap(self) -> Vec<crate::temporal::api::common::v1::Payload> {
|
2048
|
-
self.query_result.unwrap().payloads
|
2049
|
-
}
|
2050
|
-
}
|
2051
|
-
}
|
2052
|
-
}
|
2053
|
-
}
|
2054
|
-
}
|
2055
|
-
|
2056
|
-
#[allow(
|
2057
|
-
clippy::all,
|
2058
|
-
missing_docs,
|
2059
|
-
rustdoc::broken_intra_doc_links,
|
2060
|
-
rustdoc::bare_urls
|
2061
|
-
)]
|
2062
|
-
pub mod grpc {
|
2063
|
-
pub mod health {
|
2064
|
-
pub mod v1 {
|
2065
|
-
tonic::include_proto!("grpc.health.v1");
|
2066
|
-
}
|
2067
|
-
}
|
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
|
-
}
|