temporalio 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +180 -7
- data/bridge/Cargo.lock +208 -76
- data/bridge/Cargo.toml +5 -2
- data/bridge/sdk-core/Cargo.toml +1 -1
- data/bridge/sdk-core/README.md +20 -10
- data/bridge/sdk-core/client/Cargo.toml +1 -1
- data/bridge/sdk-core/client/src/lib.rs +227 -59
- data/bridge/sdk-core/client/src/metrics.rs +17 -8
- data/bridge/sdk-core/client/src/raw.rs +13 -12
- data/bridge/sdk-core/client/src/retry.rs +132 -43
- data/bridge/sdk-core/core/Cargo.toml +28 -15
- data/bridge/sdk-core/core/benches/workflow_replay.rs +13 -10
- data/bridge/sdk-core/core/src/abstractions.rs +225 -36
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +217 -79
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +165 -2
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +565 -34
- data/bridge/sdk-core/core/src/core_tests/queries.rs +247 -90
- data/bridge/sdk-core/core/src/core_tests/workers.rs +3 -5
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +1 -1
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +430 -67
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +106 -12
- data/bridge/sdk-core/core/src/internal_flags.rs +136 -0
- data/bridge/sdk-core/core/src/lib.rs +148 -34
- data/bridge/sdk-core/core/src/protosext/mod.rs +1 -1
- data/bridge/sdk-core/core/src/replay/mod.rs +185 -41
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +219 -140
- data/bridge/sdk-core/core/src/telemetry/mod.rs +326 -315
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +20 -14
- data/bridge/sdk-core/core/src/test_help/mod.rs +85 -21
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +112 -156
- data/bridge/sdk-core/core/src/worker/activities/activity_task_poller_stream.rs +89 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +364 -128
- data/bridge/sdk-core/core/src/worker/activities.rs +263 -170
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +23 -3
- data/bridge/sdk-core/core/src/worker/client.rs +48 -6
- data/bridge/sdk-core/core/src/worker/mod.rs +186 -75
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +1 -3
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +13 -24
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +879 -226
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +101 -48
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +90 -32
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +7 -10
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +6 -9
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +160 -83
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +36 -54
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +179 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +104 -157
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +8 -12
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +9 -13
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +10 -4
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +14 -11
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +6 -17
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +395 -299
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +12 -20
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +33 -18
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +1032 -374
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +525 -392
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +40 -57
- data/bridge/sdk-core/core/src/worker/workflow/wft_extraction.rs +125 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +3 -6
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/saved_wf_inputs.rs +117 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream/tonic_status_serde.rs +24 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +456 -681
- data/bridge/sdk-core/core-api/Cargo.toml +6 -4
- data/bridge/sdk-core/core-api/src/errors.rs +1 -34
- data/bridge/sdk-core/core-api/src/lib.rs +7 -45
- data/bridge/sdk-core/core-api/src/telemetry.rs +141 -0
- data/bridge/sdk-core/core-api/src/worker.rs +27 -1
- data/bridge/sdk-core/etc/deps.svg +115 -140
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +18 -15
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +1 -1
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +8 -3
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-16_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-23_history.bin +0 -0
- data/bridge/sdk-core/histories/evict_while_la_running_no_interference-85_history.bin +0 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +0 -3
- data/bridge/sdk-core/protos/api_upstream/build/go.mod +7 -0
- data/bridge/sdk-core/protos/api_upstream/build/go.sum +5 -0
- data/bridge/sdk-core/protos/api_upstream/{temporal/api/enums/v1/cluster.proto → build/tools.go} +7 -18
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +12 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +15 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +13 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +4 -9
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +10 -8
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +28 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +24 -19
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +62 -26
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +4 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +24 -61
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +2 -21
- data/bridge/sdk-core/protos/api_upstream/temporal/api/protocol/v1/message.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +110 -31
- data/bridge/sdk-core/protos/api_upstream/temporal/api/sdk/v1/task_complete_metadata.proto +63 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +4 -4
- data/bridge/sdk-core/protos/api_upstream/temporal/api/update/v1/message.proto +71 -6
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +2 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +3 -2
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +111 -36
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +19 -5
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +1 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +9 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +9 -1
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +6 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +2 -2
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +2 -2
- data/bridge/sdk-core/sdk/Cargo.toml +4 -3
- data/bridge/sdk-core/sdk/src/interceptors.rs +36 -3
- data/bridge/sdk-core/sdk/src/lib.rs +94 -25
- data/bridge/sdk-core/sdk/src/workflow_context.rs +13 -2
- data/bridge/sdk-core/sdk/src/workflow_future.rs +10 -13
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +5 -2
- data/bridge/sdk-core/sdk-core-protos/build.rs +36 -2
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +164 -104
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +27 -23
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +252 -74
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +12 -2
- data/bridge/sdk-core/test-utils/Cargo.toml +4 -1
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +106 -296
- data/bridge/sdk-core/test-utils/src/histfetch.rs +1 -1
- data/bridge/sdk-core/test-utils/src/lib.rs +161 -50
- data/bridge/sdk-core/test-utils/src/wf_input_saver.rs +50 -0
- data/bridge/sdk-core/test-utils/src/workflows.rs +29 -0
- data/bridge/sdk-core/tests/fuzzy_workflow.rs +130 -0
- data/bridge/sdk-core/tests/{load_tests.rs → heavy_tests.rs} +125 -51
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +25 -3
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +10 -5
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +239 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +4 -60
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +5 -128
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +83 -25
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +93 -69
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +6 -13
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +6 -2
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +3 -10
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +151 -116
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +7 -28
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +115 -24
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +1 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +18 -14
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +6 -20
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +10 -21
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +6 -4
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +27 -18
- data/bridge/sdk-core/tests/main.rs +8 -16
- data/bridge/sdk-core/tests/runner.rs +75 -36
- data/bridge/sdk-core/tests/wf_input_replay.rs +32 -0
- data/bridge/src/connection.rs +117 -82
- data/bridge/src/lib.rs +356 -42
- data/bridge/src/runtime.rs +10 -3
- data/bridge/src/test_server.rs +153 -0
- data/bridge/src/worker.rs +133 -9
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +8 -6
- data/lib/gen/temporal/api/command/v1/message_pb.rb +10 -16
- data/lib/gen/temporal/api/common/v1/message_pb.rb +5 -1
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +3 -3
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +2 -1
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +5 -4
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +9 -1
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +1 -1
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +7 -10
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +1 -1
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/history/v1/message_pb.rb +34 -25
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +14 -51
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/api/protocol/v1/message_pb.rb +30 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +22 -1
- data/lib/gen/temporal/api/sdk/v1/task_complete_metadata_pb.rb +23 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +2 -2
- data/lib/gen/temporal/api/testservice/v1/request_response_pb.rb +49 -0
- data/lib/gen/temporal/api/testservice/v1/service_pb.rb +21 -0
- data/lib/gen/temporal/api/update/v1/message_pb.rb +49 -3
- data/lib/gen/temporal/api/version/v1/message_pb.rb +1 -1
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +2 -1
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +47 -20
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +1 -1
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +10 -6
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +13 -9
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +9 -3
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +7 -3
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +28 -21
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +32 -24
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +12 -5
- data/lib/temporalio/activity/context.rb +102 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/connect_options.rb +15 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge/retry_config.rb +24 -0
- data/lib/temporalio/bridge/tls_options.rb +19 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/{temporal → temporalio}/client/implementation.rb +57 -56
- data/lib/{temporal → temporalio}/client/workflow_handle.rb +35 -35
- data/lib/{temporal → temporalio}/client.rb +19 -32
- data/lib/temporalio/connection/retry_config.rb +44 -0
- data/lib/temporalio/connection/service.rb +20 -0
- data/lib/temporalio/connection/test_service.rb +92 -0
- data/lib/temporalio/connection/tls_options.rb +51 -0
- data/lib/temporalio/connection/workflow_service.rb +731 -0
- data/lib/temporalio/connection.rb +86 -0
- data/lib/{temporal → temporalio}/data_converter.rb +76 -35
- data/lib/{temporal → temporalio}/error/failure.rb +6 -6
- data/lib/{temporal → temporalio}/error/workflow_failure.rb +4 -2
- data/lib/{temporal → temporalio}/errors.rb +19 -1
- data/lib/{temporal → temporalio}/failure_converter/base.rb +5 -5
- data/lib/{temporal → temporalio}/failure_converter/basic.rb +58 -52
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/activity_inbound.rb +22 -0
- data/lib/temporalio/interceptor/activity_outbound.rb +24 -0
- data/lib/{temporal → temporalio}/interceptor/chain.rb +7 -6
- data/lib/{temporal → temporalio}/interceptor/client.rb +27 -2
- data/lib/temporalio/interceptor.rb +22 -0
- data/lib/{temporal → temporalio}/payload_codec/base.rb +5 -5
- data/lib/{temporal → temporalio}/payload_converter/base.rb +3 -3
- data/lib/{temporal → temporalio}/payload_converter/bytes.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/composite.rb +7 -5
- data/lib/{temporal → temporalio}/payload_converter/encoding_base.rb +4 -4
- data/lib/{temporal → temporalio}/payload_converter/json.rb +4 -3
- data/lib/{temporal → temporalio}/payload_converter/nil.rb +4 -3
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/{temporal → temporalio}/retry_policy.rb +17 -7
- data/lib/{temporal → temporalio}/retry_state.rb +1 -1
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/testing/time_skipping_handle.rb +32 -0
- data/lib/temporalio/testing/time_skipping_interceptor.rb +23 -0
- data/lib/temporalio/testing/workflow_environment.rb +112 -0
- data/lib/temporalio/testing.rb +175 -0
- data/lib/{temporal → temporalio}/timeout_type.rb +2 -2
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +114 -0
- data/lib/temporalio/worker/activity_worker.rb +164 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +124 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +204 -0
- data/lib/temporalio/workflow/async.rb +46 -0
- data/lib/{temporal → temporalio}/workflow/execution_info.rb +4 -4
- data/lib/{temporal → temporalio}/workflow/execution_status.rb +1 -1
- data/lib/temporalio/workflow/future.rb +138 -0
- data/lib/{temporal → temporalio}/workflow/id_reuse_policy.rb +6 -6
- data/lib/temporalio/workflow/info.rb +76 -0
- data/lib/{temporal → temporalio}/workflow/query_reject_condition.rb +5 -5
- data/lib/temporalio.rb +12 -3
- data/temporalio.gemspec +11 -6
- metadata +137 -64
- data/bridge/sdk-core/Cargo.lock +0 -2606
- data/bridge/sdk-core/bridge-ffi/Cargo.toml +0 -24
- data/bridge/sdk-core/bridge-ffi/LICENSE.txt +0 -23
- data/bridge/sdk-core/bridge-ffi/build.rs +0 -25
- data/bridge/sdk-core/bridge-ffi/include/sdk-core-bridge.h +0 -249
- data/bridge/sdk-core/bridge-ffi/src/lib.rs +0 -825
- data/bridge/sdk-core/bridge-ffi/src/wrappers.rs +0 -211
- data/bridge/sdk-core/core/src/log_export.rs +0 -62
- data/bridge/sdk-core/core/src/worker/workflow/machines/mutable_side_effect_state_machine.rs +0 -127
- data/bridge/sdk-core/core/src/worker/workflow/machines/side_effect_state_machine.rs +0 -71
- data/bridge/sdk-core/protos/api_upstream/temporal/api/cluster/v1/message.proto +0 -83
- data/bridge/sdk-core/protos/local/temporal/sdk/core/bridge/bridge.proto +0 -210
- data/bridge/sdk-core/sdk/src/conversions.rs +0 -8
- data/lib/bridge.so +0 -0
- data/lib/gen/temporal/api/cluster/v1/message_pb.rb +0 -67
- data/lib/gen/temporal/api/enums/v1/cluster_pb.rb +0 -26
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +0 -222
- data/lib/temporal/bridge.rb +0 -14
- data/lib/temporal/connection.rb +0 -736
- data/lib/temporal/failure_converter.rb +0 -8
- data/lib/temporal/payload_converter.rb +0 -14
- data/lib/temporal/runtime.rb +0 -22
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -8
@@ -2,70 +2,214 @@
|
|
2
2
|
//! to replay canned histories. It should be used by Lang SDKs to provide replay capabilities to
|
3
3
|
//! users during testing.
|
4
4
|
|
5
|
-
use crate::
|
6
|
-
|
5
|
+
use crate::{
|
6
|
+
worker::client::{mocks::mock_manual_workflow_client, WorkerClient},
|
7
|
+
Worker,
|
8
|
+
};
|
9
|
+
use futures::{FutureExt, Stream, StreamExt};
|
10
|
+
use once_cell::sync::OnceCell;
|
11
|
+
use parking_lot::Mutex;
|
7
12
|
use std::{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
},
|
12
|
-
time::Duration,
|
13
|
+
collections::HashMap,
|
14
|
+
pin::Pin,
|
15
|
+
sync::Arc,
|
16
|
+
task::{Context, Poll},
|
13
17
|
};
|
14
|
-
use temporal_sdk_core_protos::
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
use temporal_sdk_core_protos::{
|
19
|
+
coresdk::workflow_activation::remove_from_cache::EvictionReason,
|
20
|
+
temporal::api::{
|
21
|
+
common::v1::WorkflowExecution,
|
22
|
+
history::v1::History,
|
23
|
+
workflowservice::v1::{
|
24
|
+
RespondWorkflowTaskCompletedResponse, RespondWorkflowTaskFailedResponse,
|
25
|
+
},
|
19
26
|
},
|
20
27
|
};
|
21
28
|
pub use temporal_sdk_core_protos::{
|
22
29
|
default_wes_attribs, HistoryInfo, TestHistoryBuilder, DEFAULT_WORKFLOW_TYPE,
|
23
30
|
};
|
31
|
+
use tokio::sync::{mpsc, mpsc::UnboundedSender, Mutex as TokioMutex};
|
32
|
+
use tokio_stream::wrappers::UnboundedReceiverStream;
|
33
|
+
use tokio_util::sync::CancellationToken;
|
34
|
+
|
35
|
+
/// A history which will be used during replay verification. Since histories do not include the
|
36
|
+
/// workflow id, it must be manually attached.
|
37
|
+
#[derive(Debug, Clone, derive_more::Constructor)]
|
38
|
+
pub struct HistoryForReplay {
|
39
|
+
hist: History,
|
40
|
+
workflow_id: String,
|
41
|
+
}
|
42
|
+
|
43
|
+
/// Allows lang to feed histories into the replayer one at a time. Simply drop the feeder to signal
|
44
|
+
/// to the worker that you're done and it should initiate shutdown.
|
45
|
+
pub struct HistoryFeeder {
|
46
|
+
tx: mpsc::Sender<HistoryForReplay>,
|
47
|
+
}
|
48
|
+
/// The stream half of a [HistoryFeeder]
|
49
|
+
pub struct HistoryFeederStream {
|
50
|
+
rcvr: mpsc::Receiver<HistoryForReplay>,
|
51
|
+
}
|
52
|
+
|
53
|
+
impl HistoryFeeder {
|
54
|
+
/// Make a new history feeder, which will store at most `buffer_size` histories before `feed`
|
55
|
+
/// blocks.
|
56
|
+
///
|
57
|
+
/// Returns a feeder which will be used to feed in histories, and a stream you can pass to
|
58
|
+
/// one of the replay worker init functions.
|
59
|
+
pub fn new(buffer_size: usize) -> (Self, HistoryFeederStream) {
|
60
|
+
let (tx, rcvr) = mpsc::channel(buffer_size);
|
61
|
+
(Self { tx }, HistoryFeederStream { rcvr })
|
62
|
+
}
|
63
|
+
/// Feed a new history into the replayer, blocking if there is not room to accept another
|
64
|
+
/// history.
|
65
|
+
pub async fn feed(&self, history: HistoryForReplay) -> anyhow::Result<()> {
|
66
|
+
self.tx.send(history).await?;
|
67
|
+
Ok(())
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
impl Stream for HistoryFeederStream {
|
72
|
+
type Item = HistoryForReplay;
|
73
|
+
|
74
|
+
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
75
|
+
self.rcvr.poll_recv(cx)
|
76
|
+
}
|
77
|
+
}
|
24
78
|
|
25
|
-
/// Create a mock client which can be used by a replay worker to serve up canned
|
26
|
-
///
|
27
|
-
///
|
28
|
-
///
|
29
|
-
|
30
|
-
|
31
|
-
task_queue: impl Into<String>,
|
32
|
-
) -> impl WorkerClient {
|
79
|
+
/// Create a mock client which can be used by a replay worker to serve up canned histories. It will
|
80
|
+
/// return the entire history in one workflow task. If a workflow task failure is sent to the mock,
|
81
|
+
/// it will send the complete response again.
|
82
|
+
///
|
83
|
+
/// Once it runs out of histories to return, it will serve up default responses after a 10s delay
|
84
|
+
pub(crate) fn mock_client_from_histories(historator: Historator) -> impl WorkerClient {
|
33
85
|
let mut mg = mock_manual_workflow_client();
|
34
86
|
|
35
|
-
let
|
36
|
-
let
|
37
|
-
workflow_id: "fake_wf_id".to_string(),
|
38
|
-
run_id: hist_info.orig_run_id().to_string(),
|
39
|
-
};
|
87
|
+
let hist_allow_tx = historator.replay_done_tx.clone();
|
88
|
+
let historator = Arc::new(TokioMutex::new(historator));
|
40
89
|
|
41
|
-
let did_send = Arc::new(AtomicBool::new(false));
|
42
|
-
let did_send_clone = did_send.clone();
|
43
|
-
let tq = task_queue.into();
|
44
90
|
mg.expect_poll_workflow_task().returning(move |_, _| {
|
45
|
-
let
|
46
|
-
let wf = wf.clone();
|
47
|
-
let did_send_clone = did_send_clone.clone();
|
48
|
-
let tq = tq.clone();
|
91
|
+
let historator = historator.clone();
|
49
92
|
async move {
|
50
|
-
|
51
|
-
|
52
|
-
|
93
|
+
let mut hlock = historator.lock().await;
|
94
|
+
// Always wait for permission before dispatching the next task
|
95
|
+
let _ = hlock.allow_stream.next().await;
|
96
|
+
|
97
|
+
if let Some(history) = hlock.next().await {
|
98
|
+
let hist_info = HistoryInfo::new_from_history(&history.hist, None).unwrap();
|
99
|
+
let mut resp = hist_info.as_poll_wft_response();
|
100
|
+
resp.workflow_execution = Some(WorkflowExecution {
|
101
|
+
workflow_id: history.workflow_id,
|
102
|
+
run_id: hist_info.orig_run_id().to_string(),
|
103
|
+
});
|
53
104
|
Ok(resp)
|
54
105
|
} else {
|
55
|
-
|
106
|
+
if let Some(wc) = hlock.worker_closer.get() {
|
107
|
+
wc.cancel();
|
108
|
+
}
|
56
109
|
Ok(Default::default())
|
57
110
|
}
|
58
111
|
}
|
59
112
|
.boxed()
|
60
113
|
});
|
61
114
|
|
62
|
-
mg.expect_complete_workflow_task()
|
63
|
-
|
115
|
+
mg.expect_complete_workflow_task().returning(move |_| {
|
116
|
+
async move { Ok(RespondWorkflowTaskCompletedResponse::default()) }.boxed()
|
117
|
+
});
|
64
118
|
mg.expect_fail_workflow_task().returning(move |_, _, _| {
|
65
|
-
|
66
|
-
|
67
|
-
async move { Ok(RespondWorkflowTaskFailedResponse {}) }.boxed()
|
119
|
+
hist_allow_tx.send("Failed".to_string()).unwrap();
|
120
|
+
async move { Ok(RespondWorkflowTaskFailedResponse::default()) }.boxed()
|
68
121
|
});
|
69
122
|
|
70
123
|
mg
|
71
124
|
}
|
125
|
+
|
126
|
+
pub(crate) struct Historator {
|
127
|
+
iter: Pin<Box<dyn Stream<Item = HistoryForReplay> + Send>>,
|
128
|
+
allow_stream: UnboundedReceiverStream<String>,
|
129
|
+
worker_closer: Arc<OnceCell<CancellationToken>>,
|
130
|
+
dat: Arc<Mutex<HistoratorDat>>,
|
131
|
+
replay_done_tx: UnboundedSender<String>,
|
132
|
+
}
|
133
|
+
impl Historator {
|
134
|
+
pub(crate) fn new(histories: impl Stream<Item = HistoryForReplay> + Send + 'static) -> Self {
|
135
|
+
let dat = Arc::new(Mutex::new(HistoratorDat::default()));
|
136
|
+
let (replay_done_tx, replay_done_rx) = mpsc::unbounded_channel();
|
137
|
+
// Need to allow the first history item
|
138
|
+
replay_done_tx.send("fake".to_string()).unwrap();
|
139
|
+
Self {
|
140
|
+
iter: Box::pin(histories.fuse()),
|
141
|
+
allow_stream: UnboundedReceiverStream::new(replay_done_rx),
|
142
|
+
worker_closer: Arc::new(OnceCell::new()),
|
143
|
+
dat,
|
144
|
+
replay_done_tx,
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
/// Returns a callback that can be used as the post-activation hook for a worker to indicate
|
149
|
+
/// we're ready to replay the next history, or whatever else.
|
150
|
+
pub(crate) fn get_post_activate_hook(&self) -> impl Fn(&Worker, &str, usize) + Send + Sync {
|
151
|
+
let dat = self.dat.clone();
|
152
|
+
let done_tx = self.replay_done_tx.clone();
|
153
|
+
move |worker, activated_run_id, last_processed_event| {
|
154
|
+
// We can't hold the lock while evaluating the hook, or we'd deadlock.
|
155
|
+
let last_event_in_hist = dat
|
156
|
+
.lock()
|
157
|
+
.run_id_to_last_event_num
|
158
|
+
.get(activated_run_id)
|
159
|
+
.cloned();
|
160
|
+
if let Some(le) = last_event_in_hist {
|
161
|
+
if last_processed_event >= le {
|
162
|
+
worker.request_wf_eviction(
|
163
|
+
activated_run_id,
|
164
|
+
"Always evict workflows after replay",
|
165
|
+
EvictionReason::LangRequested,
|
166
|
+
);
|
167
|
+
done_tx.send(activated_run_id.to_string()).unwrap();
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
pub(crate) fn get_shutdown_setter(&self) -> impl FnOnce(CancellationToken) + 'static {
|
174
|
+
let wc = self.worker_closer.clone();
|
175
|
+
move |ct| {
|
176
|
+
wc.set(ct).expect("Shutdown token must only be set once");
|
177
|
+
}
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
impl Stream for Historator {
|
182
|
+
type Item = HistoryForReplay;
|
183
|
+
|
184
|
+
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
185
|
+
match self.iter.poll_next_unpin(cx) {
|
186
|
+
Poll::Ready(Some(history)) => {
|
187
|
+
let run_id = history
|
188
|
+
.hist
|
189
|
+
.extract_run_id_from_start()
|
190
|
+
.expect(
|
191
|
+
"Histories provided for replay must contain run ids in their workflow \
|
192
|
+
execution started events",
|
193
|
+
)
|
194
|
+
.to_string();
|
195
|
+
let last_event = history.hist.last_event_id();
|
196
|
+
self.dat
|
197
|
+
.lock()
|
198
|
+
.run_id_to_last_event_num
|
199
|
+
.insert(run_id, last_event as usize);
|
200
|
+
Poll::Ready(Some(history))
|
201
|
+
}
|
202
|
+
Poll::Ready(None) => {
|
203
|
+
self.dat.lock().all_dispatched = true;
|
204
|
+
Poll::Ready(None)
|
205
|
+
}
|
206
|
+
o => o,
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
#[derive(Default)]
|
212
|
+
struct HistoratorDat {
|
213
|
+
run_id_to_last_event_num: HashMap<String, usize>,
|
214
|
+
all_dispatched: bool,
|
215
|
+
}
|
@@ -0,0 +1,190 @@
|
|
1
|
+
use parking_lot::Mutex;
|
2
|
+
use ringbuf::{Consumer, HeapRb, Producer};
|
3
|
+
use std::{collections::HashMap, sync::Arc, time::SystemTime};
|
4
|
+
use temporal_sdk_core_api::telemetry::CoreLog;
|
5
|
+
use tracing_subscriber::Layer;
|
6
|
+
|
7
|
+
const RB_SIZE: usize = 2048;
|
8
|
+
|
9
|
+
pub(super) type CoreLogsOut = Consumer<CoreLog, Arc<HeapRb<CoreLog>>>;
|
10
|
+
|
11
|
+
pub(super) struct CoreLogExportLayer {
|
12
|
+
logs_in: Mutex<Producer<CoreLog, Arc<HeapRb<CoreLog>>>>,
|
13
|
+
}
|
14
|
+
|
15
|
+
#[derive(Debug)]
|
16
|
+
struct CoreLogFieldStorage(HashMap<String, serde_json::Value>);
|
17
|
+
|
18
|
+
impl CoreLogExportLayer {
|
19
|
+
pub(super) fn new() -> (Self, CoreLogsOut) {
|
20
|
+
let (lin, lout) = HeapRb::new(RB_SIZE).split();
|
21
|
+
(
|
22
|
+
Self {
|
23
|
+
logs_in: Mutex::new(lin),
|
24
|
+
},
|
25
|
+
lout,
|
26
|
+
)
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
impl<S> Layer<S> for CoreLogExportLayer
|
31
|
+
where
|
32
|
+
S: tracing::Subscriber,
|
33
|
+
S: for<'lookup> tracing_subscriber::registry::LookupSpan<'lookup>,
|
34
|
+
{
|
35
|
+
fn on_new_span(
|
36
|
+
&self,
|
37
|
+
attrs: &tracing::span::Attributes<'_>,
|
38
|
+
id: &tracing::span::Id,
|
39
|
+
ctx: tracing_subscriber::layer::Context<'_, S>,
|
40
|
+
) {
|
41
|
+
let span = ctx.span(id).unwrap();
|
42
|
+
let mut fields = HashMap::new();
|
43
|
+
let mut visitor = JsonVisitor(&mut fields);
|
44
|
+
attrs.record(&mut visitor);
|
45
|
+
let storage = CoreLogFieldStorage(fields);
|
46
|
+
let mut extensions = span.extensions_mut();
|
47
|
+
extensions.insert(storage);
|
48
|
+
}
|
49
|
+
|
50
|
+
fn on_record(
|
51
|
+
&self,
|
52
|
+
id: &tracing::span::Id,
|
53
|
+
values: &tracing::span::Record<'_>,
|
54
|
+
ctx: tracing_subscriber::layer::Context<'_, S>,
|
55
|
+
) {
|
56
|
+
let span = ctx.span(id).unwrap();
|
57
|
+
|
58
|
+
let mut extensions_mut = span.extensions_mut();
|
59
|
+
let custom_field_storage: &mut CoreLogFieldStorage =
|
60
|
+
extensions_mut.get_mut::<CoreLogFieldStorage>().unwrap();
|
61
|
+
let json_data = &mut custom_field_storage.0;
|
62
|
+
|
63
|
+
let mut visitor = JsonVisitor(json_data);
|
64
|
+
values.record(&mut visitor);
|
65
|
+
}
|
66
|
+
|
67
|
+
fn on_event(&self, event: &tracing::Event<'_>, ctx: tracing_subscriber::layer::Context<'_, S>) {
|
68
|
+
let mut fields = HashMap::new();
|
69
|
+
let mut visitor = JsonVisitor(&mut fields);
|
70
|
+
event.record(&mut visitor);
|
71
|
+
|
72
|
+
let mut spans = vec![];
|
73
|
+
if let Some(scope) = ctx.event_scope(event) {
|
74
|
+
for span in scope.from_root() {
|
75
|
+
let extensions = span.extensions();
|
76
|
+
let storage = extensions.get::<CoreLogFieldStorage>().unwrap();
|
77
|
+
let field_data = &storage.0;
|
78
|
+
for (k, v) in field_data {
|
79
|
+
fields.insert(k.to_string(), v.clone());
|
80
|
+
}
|
81
|
+
spans.push(span.name().to_string());
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
// "message" is the magic default field keyname for the string passed to the event
|
86
|
+
let message = fields.remove("message").unwrap_or_default();
|
87
|
+
let log = CoreLog {
|
88
|
+
target: event.metadata().target().to_string(),
|
89
|
+
// This weird as_str dance prevents adding extra quotes
|
90
|
+
message: message.as_str().unwrap_or_default().to_string(),
|
91
|
+
timestamp: SystemTime::now(),
|
92
|
+
level: *event.metadata().level(),
|
93
|
+
fields,
|
94
|
+
span_contexts: spans,
|
95
|
+
};
|
96
|
+
let _ = self.logs_in.lock().push(log);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
struct JsonVisitor<'a>(&'a mut HashMap<String, serde_json::Value>);
|
101
|
+
|
102
|
+
impl<'a> tracing::field::Visit for JsonVisitor<'a> {
|
103
|
+
fn record_f64(&mut self, field: &tracing::field::Field, value: f64) {
|
104
|
+
self.0
|
105
|
+
.insert(field.name().to_string(), serde_json::json!(value));
|
106
|
+
}
|
107
|
+
|
108
|
+
fn record_i64(&mut self, field: &tracing::field::Field, value: i64) {
|
109
|
+
self.0
|
110
|
+
.insert(field.name().to_string(), serde_json::json!(value));
|
111
|
+
}
|
112
|
+
|
113
|
+
fn record_u64(&mut self, field: &tracing::field::Field, value: u64) {
|
114
|
+
self.0
|
115
|
+
.insert(field.name().to_string(), serde_json::json!(value));
|
116
|
+
}
|
117
|
+
|
118
|
+
fn record_bool(&mut self, field: &tracing::field::Field, value: bool) {
|
119
|
+
self.0
|
120
|
+
.insert(field.name().to_string(), serde_json::json!(value));
|
121
|
+
}
|
122
|
+
|
123
|
+
fn record_str(&mut self, field: &tracing::field::Field, value: &str) {
|
124
|
+
self.0
|
125
|
+
.insert(field.name().to_string(), serde_json::json!(value));
|
126
|
+
}
|
127
|
+
|
128
|
+
fn record_error(
|
129
|
+
&mut self,
|
130
|
+
field: &tracing::field::Field,
|
131
|
+
value: &(dyn std::error::Error + 'static),
|
132
|
+
) {
|
133
|
+
self.0.insert(
|
134
|
+
field.name().to_string(),
|
135
|
+
serde_json::json!(value.to_string()),
|
136
|
+
);
|
137
|
+
}
|
138
|
+
|
139
|
+
fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn std::fmt::Debug) {
|
140
|
+
self.0.insert(
|
141
|
+
field.name().to_string(),
|
142
|
+
serde_json::json!(format!("{value:?}")),
|
143
|
+
);
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
#[cfg(test)]
|
148
|
+
mod tests {
|
149
|
+
use crate::{telemetry::construct_filter_string, telemetry_init};
|
150
|
+
use temporal_sdk_core_api::telemetry::{CoreTelemetry, Logger, TelemetryOptionsBuilder};
|
151
|
+
use tracing::Level;
|
152
|
+
|
153
|
+
#[instrument(fields(bros = "brohemian"))]
|
154
|
+
fn instrumented(thing: &str) {
|
155
|
+
warn!("warn");
|
156
|
+
info!(foo = "bar", "info");
|
157
|
+
debug!("debug");
|
158
|
+
}
|
159
|
+
|
160
|
+
#[tokio::test]
|
161
|
+
async fn test_forwarding_output() {
|
162
|
+
let opts = TelemetryOptionsBuilder::default()
|
163
|
+
.logging(Logger::Forward {
|
164
|
+
filter: construct_filter_string(Level::INFO, Level::WARN),
|
165
|
+
})
|
166
|
+
.build()
|
167
|
+
.unwrap();
|
168
|
+
let instance = telemetry_init(opts).unwrap();
|
169
|
+
let _g = tracing::subscriber::set_default(instance.trace_subscriber.clone());
|
170
|
+
|
171
|
+
let top_span = span!(Level::INFO, "yayspan", huh = "wat");
|
172
|
+
let _guard = top_span.enter();
|
173
|
+
info!("Whata?");
|
174
|
+
instrumented("hi");
|
175
|
+
info!("Donezo");
|
176
|
+
|
177
|
+
let logs = instance.fetch_buffered_logs();
|
178
|
+
// Verify debug log was not forwarded
|
179
|
+
assert!(!logs.iter().any(|l| l.message == "debug"));
|
180
|
+
assert_eq!(logs.len(), 4);
|
181
|
+
// Ensure fields are attached to events properly
|
182
|
+
let info_msg = &logs[2];
|
183
|
+
assert_eq!(info_msg.message, "info");
|
184
|
+
assert_eq!(info_msg.fields.len(), 4);
|
185
|
+
assert_eq!(info_msg.fields.get("huh"), Some(&"wat".into()));
|
186
|
+
assert_eq!(info_msg.fields.get("foo"), Some(&"bar".into()));
|
187
|
+
assert_eq!(info_msg.fields.get("bros"), Some(&"brohemian".into()));
|
188
|
+
assert_eq!(info_msg.fields.get("thing"), Some(&"hi".into()));
|
189
|
+
}
|
190
|
+
}
|