temporalio 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +301 -0
- data/bridge/Cargo.lock +2888 -0
- data/bridge/Cargo.toml +27 -0
- data/bridge/sdk-core/ARCHITECTURE.md +76 -0
- data/bridge/sdk-core/Cargo.lock +2606 -0
- data/bridge/sdk-core/Cargo.toml +2 -0
- data/bridge/sdk-core/LICENSE.txt +23 -0
- data/bridge/sdk-core/README.md +104 -0
- data/bridge/sdk-core/arch_docs/diagrams/README.md +10 -0
- data/bridge/sdk-core/arch_docs/diagrams/sticky_queues.puml +40 -0
- data/bridge/sdk-core/arch_docs/diagrams/workflow_internals.svg +1 -0
- data/bridge/sdk-core/arch_docs/sticky_queues.md +51 -0
- data/bridge/sdk-core/client/Cargo.toml +40 -0
- data/bridge/sdk-core/client/LICENSE.txt +23 -0
- data/bridge/sdk-core/client/src/lib.rs +1286 -0
- data/bridge/sdk-core/client/src/metrics.rs +165 -0
- data/bridge/sdk-core/client/src/raw.rs +932 -0
- data/bridge/sdk-core/client/src/retry.rs +751 -0
- data/bridge/sdk-core/client/src/workflow_handle/mod.rs +185 -0
- data/bridge/sdk-core/core/Cargo.toml +116 -0
- data/bridge/sdk-core/core/LICENSE.txt +23 -0
- data/bridge/sdk-core/core/benches/workflow_replay.rs +76 -0
- data/bridge/sdk-core/core/src/abstractions.rs +166 -0
- data/bridge/sdk-core/core/src/core_tests/activity_tasks.rs +1014 -0
- data/bridge/sdk-core/core/src/core_tests/child_workflows.rs +221 -0
- data/bridge/sdk-core/core/src/core_tests/determinism.rs +107 -0
- data/bridge/sdk-core/core/src/core_tests/local_activities.rs +925 -0
- data/bridge/sdk-core/core/src/core_tests/mod.rs +100 -0
- data/bridge/sdk-core/core/src/core_tests/queries.rs +894 -0
- data/bridge/sdk-core/core/src/core_tests/replay_flag.rs +65 -0
- data/bridge/sdk-core/core/src/core_tests/workers.rs +259 -0
- data/bridge/sdk-core/core/src/core_tests/workflow_cancels.rs +124 -0
- data/bridge/sdk-core/core/src/core_tests/workflow_tasks.rs +2090 -0
- data/bridge/sdk-core/core/src/ephemeral_server/mod.rs +515 -0
- data/bridge/sdk-core/core/src/lib.rs +282 -0
- data/bridge/sdk-core/core/src/pollers/mod.rs +54 -0
- data/bridge/sdk-core/core/src/pollers/poll_buffer.rs +297 -0
- data/bridge/sdk-core/core/src/protosext/mod.rs +428 -0
- data/bridge/sdk-core/core/src/replay/mod.rs +215 -0
- data/bridge/sdk-core/core/src/retry_logic.rs +202 -0
- data/bridge/sdk-core/core/src/telemetry/log_export.rs +190 -0
- data/bridge/sdk-core/core/src/telemetry/metrics.rs +428 -0
- data/bridge/sdk-core/core/src/telemetry/mod.rs +407 -0
- data/bridge/sdk-core/core/src/telemetry/prometheus_server.rs +78 -0
- data/bridge/sdk-core/core/src/test_help/mod.rs +889 -0
- data/bridge/sdk-core/core/src/worker/activities/activity_heartbeat_manager.rs +580 -0
- data/bridge/sdk-core/core/src/worker/activities/local_activities.rs +1048 -0
- data/bridge/sdk-core/core/src/worker/activities.rs +481 -0
- data/bridge/sdk-core/core/src/worker/client/mocks.rs +87 -0
- data/bridge/sdk-core/core/src/worker/client.rs +373 -0
- data/bridge/sdk-core/core/src/worker/mod.rs +570 -0
- data/bridge/sdk-core/core/src/worker/workflow/bridge.rs +37 -0
- data/bridge/sdk-core/core/src/worker/workflow/driven_workflow.rs +101 -0
- data/bridge/sdk-core/core/src/worker/workflow/history_update.rs +532 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/activity_state_machine.rs +907 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_external_state_machine.rs +294 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/cancel_workflow_state_machine.rs +167 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/child_workflow_state_machine.rs +858 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/complete_workflow_state_machine.rs +136 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/continue_as_new_workflow_state_machine.rs +157 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/fail_workflow_state_machine.rs +129 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/local_activity_state_machine.rs +1450 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/mod.rs +316 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/modify_workflow_properties_state_machine.rs +178 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/patch_state_machine.rs +708 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/signal_external_state_machine.rs +439 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/timer_state_machine.rs +435 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/transition_coverage.rs +175 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/upsert_search_attributes_state_machine.rs +242 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines/local_acts.rs +96 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_machines.rs +1200 -0
- data/bridge/sdk-core/core/src/worker/workflow/machines/workflow_task_state_machine.rs +272 -0
- data/bridge/sdk-core/core/src/worker/workflow/managed_run/managed_wf_test.rs +198 -0
- data/bridge/sdk-core/core/src/worker/workflow/managed_run.rs +655 -0
- data/bridge/sdk-core/core/src/worker/workflow/mod.rs +1200 -0
- data/bridge/sdk-core/core/src/worker/workflow/run_cache.rs +145 -0
- data/bridge/sdk-core/core/src/worker/workflow/wft_poller.rs +88 -0
- data/bridge/sdk-core/core/src/worker/workflow/workflow_stream.rs +985 -0
- data/bridge/sdk-core/core-api/Cargo.toml +32 -0
- data/bridge/sdk-core/core-api/LICENSE.txt +23 -0
- data/bridge/sdk-core/core-api/src/errors.rs +95 -0
- data/bridge/sdk-core/core-api/src/lib.rs +109 -0
- data/bridge/sdk-core/core-api/src/telemetry.rs +147 -0
- data/bridge/sdk-core/core-api/src/worker.rs +148 -0
- data/bridge/sdk-core/etc/deps.svg +162 -0
- data/bridge/sdk-core/etc/dynamic-config.yaml +2 -0
- data/bridge/sdk-core/etc/otel-collector-config.yaml +36 -0
- data/bridge/sdk-core/etc/prometheus.yaml +6 -0
- data/bridge/sdk-core/etc/regen-depgraph.sh +5 -0
- data/bridge/sdk-core/fsm/Cargo.toml +18 -0
- data/bridge/sdk-core/fsm/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/README.md +3 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/Cargo.toml +27 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/src/lib.rs +647 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/progress.rs +8 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.rs +18 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dupe_transitions_fail.stderr +12 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/dynamic_dest_pass.rs +41 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.rs +14 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/forgot_name_fail.stderr +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_arg_pass.rs +32 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/handler_pass.rs +31 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/medium_complex_pass.rs +46 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.rs +29 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/no_handle_conversions_require_into_fail.stderr +12 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/simple_pass.rs +32 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.rs +18 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/struct_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.rs +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_more_item_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.rs +11 -0
- data/bridge/sdk-core/fsm/rustfsm_procmacro/tests/trybuild/tuple_zero_item_event_variant_fail.stderr +5 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/Cargo.toml +14 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/LICENSE.txt +23 -0
- data/bridge/sdk-core/fsm/rustfsm_trait/src/lib.rs +249 -0
- data/bridge/sdk-core/fsm/src/lib.rs +2 -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 +7 -0
- data/bridge/sdk-core/protos/api_upstream/README.md +9 -0
- data/bridge/sdk-core/protos/api_upstream/api-linter.yaml +40 -0
- data/bridge/sdk-core/protos/api_upstream/buf.yaml +9 -0
- 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/build/tools.go +29 -0
- data/bridge/sdk-core/protos/api_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/api_upstream/go.mod +6 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/batch/v1/message.proto +89 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/command/v1/message.proto +260 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/common/v1/message.proto +112 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/batch_operation.proto +47 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/command_type.proto +57 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/common.proto +56 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/event_type.proto +170 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/failed_cause.proto +118 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/interaction_type.proto +39 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/namespace.proto +51 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/query.proto +50 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/reset.proto +41 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/schedule.proto +60 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/task_queue.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/update.proto +40 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/enums/v1/workflow.proto +122 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/errordetails/v1/message.proto +108 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/failure/v1/message.proto +114 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/filter/v1/message.proto +56 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/history/v1/message.proto +758 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/interaction/v1/message.proto +87 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/namespace/v1/message.proto +97 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/request_response.proto +121 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/operatorservice/v1/service.proto +80 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/query/v1/message.proto +61 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/replication/v1/message.proto +55 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/schedule/v1/message.proto +379 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/taskqueue/v1/message.proto +108 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/version/v1/message.proto +59 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflow/v1/message.proto +146 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/request_response.proto +1168 -0
- data/bridge/sdk-core/protos/api_upstream/temporal/api/workflowservice/v1/service.proto +415 -0
- data/bridge/sdk-core/protos/grpc/health/v1/health.proto +63 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_result/activity_result.proto +78 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/activity_task/activity_task.proto +79 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/child_workflow/child_workflow.proto +77 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/common/common.proto +15 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/core_interface.proto +30 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/external_data/external_data.proto +30 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_activation/workflow_activation.proto +263 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto +304 -0
- data/bridge/sdk-core/protos/local/temporal/sdk/core/workflow_completion/workflow_completion.proto +29 -0
- data/bridge/sdk-core/protos/testsrv_upstream/api-linter.yaml +38 -0
- data/bridge/sdk-core/protos/testsrv_upstream/buf.yaml +13 -0
- data/bridge/sdk-core/protos/testsrv_upstream/dependencies/gogoproto/gogo.proto +141 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/request_response.proto +63 -0
- data/bridge/sdk-core/protos/testsrv_upstream/temporal/api/testservice/v1/service.proto +90 -0
- data/bridge/sdk-core/rustfmt.toml +1 -0
- data/bridge/sdk-core/sdk/Cargo.toml +47 -0
- data/bridge/sdk-core/sdk/LICENSE.txt +23 -0
- data/bridge/sdk-core/sdk/src/activity_context.rs +230 -0
- data/bridge/sdk-core/sdk/src/app_data.rs +37 -0
- data/bridge/sdk-core/sdk/src/interceptors.rs +50 -0
- data/bridge/sdk-core/sdk/src/lib.rs +794 -0
- data/bridge/sdk-core/sdk/src/payload_converter.rs +11 -0
- data/bridge/sdk-core/sdk/src/workflow_context/options.rs +295 -0
- data/bridge/sdk-core/sdk/src/workflow_context.rs +694 -0
- data/bridge/sdk-core/sdk/src/workflow_future.rs +499 -0
- data/bridge/sdk-core/sdk-core-protos/Cargo.toml +30 -0
- data/bridge/sdk-core/sdk-core-protos/LICENSE.txt +23 -0
- data/bridge/sdk-core/sdk-core-protos/build.rs +107 -0
- data/bridge/sdk-core/sdk-core-protos/src/constants.rs +7 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_builder.rs +544 -0
- data/bridge/sdk-core/sdk-core-protos/src/history_info.rs +230 -0
- data/bridge/sdk-core/sdk-core-protos/src/lib.rs +1970 -0
- data/bridge/sdk-core/sdk-core-protos/src/task_token.rs +38 -0
- data/bridge/sdk-core/sdk-core-protos/src/utilities.rs +14 -0
- data/bridge/sdk-core/test-utils/Cargo.toml +36 -0
- data/bridge/sdk-core/test-utils/src/canned_histories.rs +1579 -0
- data/bridge/sdk-core/test-utils/src/histfetch.rs +28 -0
- data/bridge/sdk-core/test-utils/src/lib.rs +650 -0
- data/bridge/sdk-core/tests/integ_tests/client_tests.rs +36 -0
- data/bridge/sdk-core/tests/integ_tests/ephemeral_server_tests.rs +128 -0
- data/bridge/sdk-core/tests/integ_tests/heartbeat_tests.rs +221 -0
- data/bridge/sdk-core/tests/integ_tests/metrics_tests.rs +37 -0
- data/bridge/sdk-core/tests/integ_tests/polling_tests.rs +133 -0
- data/bridge/sdk-core/tests/integ_tests/queries_tests.rs +437 -0
- data/bridge/sdk-core/tests/integ_tests/visibility_tests.rs +93 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/activities.rs +878 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/appdata_propagation.rs +61 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_external.rs +59 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/cancel_wf.rs +58 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/child_workflows.rs +50 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/continue_as_new.rs +60 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/determinism.rs +54 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs +788 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs +53 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/patches.rs +113 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/replay.rs +223 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/resets.rs +93 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/signals.rs +167 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/stickyness.rs +99 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/timers.rs +131 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests/upsert_search_attrs.rs +75 -0
- data/bridge/sdk-core/tests/integ_tests/workflow_tests.rs +597 -0
- data/bridge/sdk-core/tests/load_tests.rs +191 -0
- data/bridge/sdk-core/tests/main.rs +113 -0
- data/bridge/sdk-core/tests/runner.rs +93 -0
- data/bridge/src/connection.rs +186 -0
- data/bridge/src/lib.rs +239 -0
- data/bridge/src/runtime.rs +54 -0
- data/bridge/src/worker.rs +124 -0
- data/ext/Rakefile +9 -0
- data/lib/bridge.so +0 -0
- data/lib/gen/dependencies/gogoproto/gogo_pb.rb +14 -0
- data/lib/gen/temporal/api/batch/v1/message_pb.rb +50 -0
- data/lib/gen/temporal/api/command/v1/message_pb.rb +174 -0
- data/lib/gen/temporal/api/common/v1/message_pb.rb +69 -0
- data/lib/gen/temporal/api/enums/v1/batch_operation_pb.rb +33 -0
- data/lib/gen/temporal/api/enums/v1/command_type_pb.rb +39 -0
- data/lib/gen/temporal/api/enums/v1/common_pb.rb +42 -0
- data/lib/gen/temporal/api/enums/v1/event_type_pb.rb +68 -0
- data/lib/gen/temporal/api/enums/v1/failed_cause_pb.rb +77 -0
- data/lib/gen/temporal/api/enums/v1/interaction_type_pb.rb +25 -0
- data/lib/gen/temporal/api/enums/v1/namespace_pb.rb +37 -0
- data/lib/gen/temporal/api/enums/v1/query_pb.rb +31 -0
- data/lib/gen/temporal/api/enums/v1/reset_pb.rb +24 -0
- data/lib/gen/temporal/api/enums/v1/schedule_pb.rb +28 -0
- data/lib/gen/temporal/api/enums/v1/task_queue_pb.rb +30 -0
- data/lib/gen/temporal/api/enums/v1/update_pb.rb +23 -0
- data/lib/gen/temporal/api/enums/v1/workflow_pb.rb +89 -0
- data/lib/gen/temporal/api/errordetails/v1/message_pb.rb +84 -0
- data/lib/gen/temporal/api/failure/v1/message_pb.rb +83 -0
- data/lib/gen/temporal/api/filter/v1/message_pb.rb +40 -0
- data/lib/gen/temporal/api/history/v1/message_pb.rb +490 -0
- data/lib/gen/temporal/api/interaction/v1/message_pb.rb +49 -0
- data/lib/gen/temporal/api/namespace/v1/message_pb.rb +63 -0
- data/lib/gen/temporal/api/operatorservice/v1/request_response_pb.rb +85 -0
- data/lib/gen/temporal/api/operatorservice/v1/service_pb.rb +20 -0
- data/lib/gen/temporal/api/query/v1/message_pb.rb +38 -0
- data/lib/gen/temporal/api/replication/v1/message_pb.rb +37 -0
- data/lib/gen/temporal/api/schedule/v1/message_pb.rb +149 -0
- data/lib/gen/temporal/api/taskqueue/v1/message_pb.rb +73 -0
- data/lib/gen/temporal/api/version/v1/message_pb.rb +41 -0
- data/lib/gen/temporal/api/workflow/v1/message_pb.rb +111 -0
- data/lib/gen/temporal/api/workflowservice/v1/request_response_pb.rb +788 -0
- data/lib/gen/temporal/api/workflowservice/v1/service_pb.rb +20 -0
- data/lib/gen/temporal/sdk/core/activity_result/activity_result_pb.rb +58 -0
- data/lib/gen/temporal/sdk/core/activity_task/activity_task_pb.rb +57 -0
- data/lib/gen/temporal/sdk/core/bridge/bridge_pb.rb +222 -0
- data/lib/gen/temporal/sdk/core/child_workflow/child_workflow_pb.rb +57 -0
- data/lib/gen/temporal/sdk/core/common/common_pb.rb +22 -0
- data/lib/gen/temporal/sdk/core/core_interface_pb.rb +34 -0
- data/lib/gen/temporal/sdk/core/external_data/external_data_pb.rb +27 -0
- data/lib/gen/temporal/sdk/core/workflow_activation/workflow_activation_pb.rb +165 -0
- data/lib/gen/temporal/sdk/core/workflow_commands/workflow_commands_pb.rb +196 -0
- data/lib/gen/temporal/sdk/core/workflow_completion/workflow_completion_pb.rb +34 -0
- data/lib/temporalio/activity/context.rb +97 -0
- data/lib/temporalio/activity/info.rb +67 -0
- data/lib/temporalio/activity.rb +85 -0
- data/lib/temporalio/bridge/error.rb +8 -0
- data/lib/temporalio/bridge.rb +14 -0
- data/lib/temporalio/client/implementation.rb +340 -0
- data/lib/temporalio/client/workflow_handle.rb +243 -0
- data/lib/temporalio/client.rb +131 -0
- data/lib/temporalio/connection.rb +751 -0
- data/lib/temporalio/data_converter.rb +191 -0
- data/lib/temporalio/error/failure.rb +194 -0
- data/lib/temporalio/error/workflow_failure.rb +19 -0
- data/lib/temporalio/errors.rb +40 -0
- data/lib/temporalio/failure_converter/base.rb +26 -0
- data/lib/temporalio/failure_converter/basic.rb +319 -0
- data/lib/temporalio/failure_converter.rb +7 -0
- data/lib/temporalio/interceptor/chain.rb +28 -0
- data/lib/temporalio/interceptor/client.rb +123 -0
- data/lib/temporalio/payload_codec/base.rb +32 -0
- data/lib/temporalio/payload_converter/base.rb +24 -0
- data/lib/temporalio/payload_converter/bytes.rb +27 -0
- data/lib/temporalio/payload_converter/composite.rb +49 -0
- data/lib/temporalio/payload_converter/encoding_base.rb +35 -0
- data/lib/temporalio/payload_converter/json.rb +26 -0
- data/lib/temporalio/payload_converter/nil.rb +26 -0
- data/lib/temporalio/payload_converter.rb +14 -0
- data/lib/temporalio/retry_policy.rb +82 -0
- data/lib/temporalio/retry_state.rb +35 -0
- data/lib/temporalio/runtime.rb +25 -0
- data/lib/temporalio/timeout_type.rb +29 -0
- data/lib/temporalio/version.rb +3 -0
- data/lib/temporalio/worker/activity_runner.rb +92 -0
- data/lib/temporalio/worker/activity_worker.rb +138 -0
- data/lib/temporalio/worker/reactor.rb +46 -0
- data/lib/temporalio/worker/runner.rb +63 -0
- data/lib/temporalio/worker/sync_worker.rb +88 -0
- data/lib/temporalio/worker/thread_pool_executor.rb +51 -0
- data/lib/temporalio/worker.rb +198 -0
- data/lib/temporalio/workflow/execution_info.rb +54 -0
- data/lib/temporalio/workflow/execution_status.rb +36 -0
- data/lib/temporalio/workflow/id_reuse_policy.rb +36 -0
- data/lib/temporalio/workflow/query_reject_condition.rb +33 -0
- data/lib/temporalio.rb +12 -1
- data/lib/thermite_patch.rb +23 -0
- data/temporalio.gemspec +45 -0
- metadata +566 -9
- data/lib/temporal/version.rb +0 -3
- data/lib/temporal.rb +0 -4
- data/temporal.gemspec +0 -20
data/bridge/src/lib.rs
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
#[macro_use]
|
2
|
+
extern crate rutie;
|
3
|
+
extern crate lazy_static;
|
4
|
+
|
5
|
+
mod connection;
|
6
|
+
mod runtime;
|
7
|
+
mod worker;
|
8
|
+
|
9
|
+
use connection::{Connection, RpcParams};
|
10
|
+
use runtime::Runtime;
|
11
|
+
use rutie::{
|
12
|
+
Module, Object, Symbol, RString, Encoding, AnyObject, AnyException, Exception, VM, Thread,
|
13
|
+
NilClass, Hash, Integer,
|
14
|
+
};
|
15
|
+
use std::collections::HashMap;
|
16
|
+
use temporal_sdk_core_api::telemetry::{Logger, TelemetryOptionsBuilder};
|
17
|
+
use tokio_util::sync::CancellationToken;
|
18
|
+
use worker::{Worker, WorkerError, WorkerResult};
|
19
|
+
|
20
|
+
const RUNTIME_THREAD_COUNT: u8 = 2;
|
21
|
+
|
22
|
+
fn raise_bridge_exception(message: &str) {
|
23
|
+
VM::raise_ex(AnyException::new("Temporalio::Bridge::Error", Some(message)));
|
24
|
+
}
|
25
|
+
|
26
|
+
fn wrap_worker_error(e: &WorkerError) -> AnyException {
|
27
|
+
let name = match e {
|
28
|
+
WorkerError::Shutdown() => "Temporalio::Bridge::Error::WorkerShutdown",
|
29
|
+
_ => "Temporalio::Bridge::Error"
|
30
|
+
};
|
31
|
+
|
32
|
+
AnyException::new(name, Some(&format!("[{:?}] {}", e, e)))
|
33
|
+
}
|
34
|
+
|
35
|
+
fn wrap_bytes(bytes: Vec<u8>) -> RString {
|
36
|
+
let enc = Encoding::find("ASCII-8BIT").unwrap();
|
37
|
+
RString::from_bytes(&bytes, &enc)
|
38
|
+
}
|
39
|
+
|
40
|
+
fn unwrap_bytes(string: RString) -> Vec<u8> {
|
41
|
+
// It is important to use the _unchecked conversion, otherwise Rutie
|
42
|
+
// will assume incorrect encoding and screw up the encoded proto
|
43
|
+
string.to_vec_u8_unchecked()
|
44
|
+
}
|
45
|
+
|
46
|
+
fn to_hash_map(hash: Hash) -> HashMap<String, String> {
|
47
|
+
let mut result = HashMap::new();
|
48
|
+
|
49
|
+
hash.each(|k, v| {
|
50
|
+
result.insert(
|
51
|
+
k.try_convert_to::<RString>().map_err(VM::raise_ex).unwrap().to_string(),
|
52
|
+
v.try_convert_to::<RString>().map_err(VM::raise_ex).unwrap().to_string()
|
53
|
+
);
|
54
|
+
});
|
55
|
+
|
56
|
+
result
|
57
|
+
}
|
58
|
+
|
59
|
+
fn worker_result_to_proc_args(result: WorkerResult) -> [AnyObject; 2] {
|
60
|
+
let ruby_nil = NilClass::new().to_any_object();
|
61
|
+
match result {
|
62
|
+
Ok(bytes) => [wrap_bytes(bytes).to_any_object(), ruby_nil],
|
63
|
+
Err(e) => [ruby_nil, wrap_worker_error(&e).to_any_object()]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
wrappable_struct!(Connection, ConnectionWrapper, CONNECTION_WRAPPER);
|
68
|
+
wrappable_struct!(Runtime, RuntimeWrapper, RUNTIME_WRAPPER);
|
69
|
+
wrappable_struct!(Worker, WorkerWrapper, WORKER_WRAPPER);
|
70
|
+
|
71
|
+
class!(TemporalBridge);
|
72
|
+
|
73
|
+
methods!(
|
74
|
+
TemporalBridge,
|
75
|
+
_rtself, // somehow compiler is sure this is unused and insists on the "_"
|
76
|
+
|
77
|
+
fn create_connection(runtime: AnyObject, host: RString) -> AnyObject {
|
78
|
+
let host = host.map_err(VM::raise_ex).unwrap().to_string();
|
79
|
+
let runtime = runtime.unwrap();
|
80
|
+
let runtime = runtime.get_data(&*RUNTIME_WRAPPER);
|
81
|
+
|
82
|
+
let result = Thread::call_without_gvl(move || {
|
83
|
+
Connection::connect(runtime.tokio_runtime.clone(), host.clone())
|
84
|
+
}, Some(|| {}));
|
85
|
+
|
86
|
+
let connection = result.map_err(|e| raise_bridge_exception(&e.to_string())).unwrap();
|
87
|
+
|
88
|
+
Module::from_existing("Temporalio")
|
89
|
+
.get_nested_module("Bridge")
|
90
|
+
.get_nested_class("Connection")
|
91
|
+
.wrap_data(connection, &*CONNECTION_WRAPPER)
|
92
|
+
}
|
93
|
+
|
94
|
+
fn call_rpc(rpc: Symbol, request: RString, metadata: Hash, timeout: Integer) -> RString {
|
95
|
+
let rpc = rpc.map_err(VM::raise_ex).unwrap().to_string();
|
96
|
+
let request = unwrap_bytes(request.map_err(VM::raise_ex).unwrap());
|
97
|
+
let metadata = to_hash_map(metadata.map_err(VM::raise_ex).unwrap());
|
98
|
+
let timeout = timeout.map_or(None, |v| Some(v.to_u64()));
|
99
|
+
let token = CancellationToken::new();
|
100
|
+
|
101
|
+
let result = Thread::call_without_gvl(|| {
|
102
|
+
let connection = _rtself.get_data_mut(&*CONNECTION_WRAPPER);
|
103
|
+
let params = RpcParams {
|
104
|
+
rpc: rpc.clone(),
|
105
|
+
request: request.clone(),
|
106
|
+
metadata: metadata.clone(),
|
107
|
+
timeout_millis: timeout
|
108
|
+
};
|
109
|
+
connection.call(params, token.clone())
|
110
|
+
}, Some(|| { token.cancel() }));
|
111
|
+
|
112
|
+
let response = result.map_err(|e| raise_bridge_exception(&e.to_string())).unwrap();
|
113
|
+
|
114
|
+
wrap_bytes(response)
|
115
|
+
}
|
116
|
+
|
117
|
+
fn init_runtime() -> AnyObject {
|
118
|
+
let telemetry_options = TelemetryOptionsBuilder::default()
|
119
|
+
.logging(Logger::Console { filter: "temporal_sdk_core=DEBUG".to_string() })
|
120
|
+
.build()
|
121
|
+
.map_err(|e| raise_bridge_exception(&e.to_string()))
|
122
|
+
.unwrap();
|
123
|
+
|
124
|
+
let runtime = Runtime::new(RUNTIME_THREAD_COUNT, telemetry_options);
|
125
|
+
|
126
|
+
Module::from_existing("Temporalio")
|
127
|
+
.get_nested_module("Bridge")
|
128
|
+
.get_nested_class("Runtime")
|
129
|
+
.wrap_data(runtime, &*RUNTIME_WRAPPER)
|
130
|
+
}
|
131
|
+
|
132
|
+
fn run_callback_loop() -> NilClass {
|
133
|
+
let runtime = _rtself.get_data_mut(&*RUNTIME_WRAPPER);
|
134
|
+
runtime.run_callback_loop();
|
135
|
+
|
136
|
+
NilClass::new()
|
137
|
+
}
|
138
|
+
|
139
|
+
fn create_worker(runtime: AnyObject, connection: AnyObject, namespace: RString, task_queue: RString) -> AnyObject {
|
140
|
+
let namespace = namespace.map_err(VM::raise_ex).unwrap().to_string();
|
141
|
+
let task_queue = task_queue.map_err(VM::raise_ex).unwrap().to_string();
|
142
|
+
let runtime = runtime.unwrap();
|
143
|
+
let runtime = runtime.get_data(&*RUNTIME_WRAPPER);
|
144
|
+
let connection = connection.unwrap();
|
145
|
+
let connection = connection.get_data(&*CONNECTION_WRAPPER);
|
146
|
+
let worker = Worker::new(runtime, &connection.client, &namespace, &task_queue);
|
147
|
+
|
148
|
+
Module::from_existing("Temporalio")
|
149
|
+
.get_nested_module("Bridge")
|
150
|
+
.get_nested_class("Worker")
|
151
|
+
.wrap_data(worker.unwrap(), &*WORKER_WRAPPER)
|
152
|
+
}
|
153
|
+
|
154
|
+
fn worker_poll_activity_task() -> NilClass {
|
155
|
+
if !VM::is_block_given() {
|
156
|
+
panic!("Called #poll_activity_task without a block");
|
157
|
+
}
|
158
|
+
|
159
|
+
let ruby_callback = VM::block_proc();
|
160
|
+
let callback = move |result: WorkerResult| {
|
161
|
+
ruby_callback.call(&worker_result_to_proc_args(result));
|
162
|
+
};
|
163
|
+
|
164
|
+
let worker = _rtself.get_data_mut(&*WORKER_WRAPPER);
|
165
|
+
let result = worker.poll_activity_task(callback);
|
166
|
+
|
167
|
+
result.map_err(|e| raise_bridge_exception(&e.to_string())).unwrap();
|
168
|
+
|
169
|
+
NilClass::new()
|
170
|
+
}
|
171
|
+
|
172
|
+
fn worker_complete_activity_task(proto: RString) -> NilClass {
|
173
|
+
if !VM::is_block_given() {
|
174
|
+
panic!("Called #worker_complete_activity_task without a block");
|
175
|
+
}
|
176
|
+
|
177
|
+
let bytes = unwrap_bytes(proto.map_err(VM::raise_ex).unwrap());
|
178
|
+
let ruby_callback = VM::block_proc();
|
179
|
+
let callback = move |result: WorkerResult| {
|
180
|
+
ruby_callback.call(&worker_result_to_proc_args(result));
|
181
|
+
};
|
182
|
+
|
183
|
+
let worker = _rtself.get_data_mut(&*WORKER_WRAPPER);
|
184
|
+
let result = worker.complete_activity_task(bytes, callback);
|
185
|
+
|
186
|
+
result.map_err(|e| raise_bridge_exception(&e.to_string())).unwrap();
|
187
|
+
|
188
|
+
NilClass::new()
|
189
|
+
}
|
190
|
+
|
191
|
+
fn worker_record_activity_heartbeat(proto: RString) -> NilClass {
|
192
|
+
let bytes = unwrap_bytes(proto.map_err(VM::raise_ex).unwrap());
|
193
|
+
let worker = _rtself.get_data_mut(&*WORKER_WRAPPER);
|
194
|
+
|
195
|
+
let result = worker.record_activity_heartbeat(bytes);
|
196
|
+
|
197
|
+
result.map_err(|e| raise_bridge_exception(&e.to_string())).unwrap();
|
198
|
+
|
199
|
+
NilClass::new()
|
200
|
+
}
|
201
|
+
|
202
|
+
fn worker_initiate_shutdown() -> NilClass {
|
203
|
+
let worker = _rtself.get_data_mut(&*WORKER_WRAPPER);
|
204
|
+
worker.initiate_shutdown();
|
205
|
+
|
206
|
+
NilClass::new()
|
207
|
+
}
|
208
|
+
|
209
|
+
fn worker_shutdown() -> NilClass {
|
210
|
+
let worker = _rtself.get_data_mut(&*WORKER_WRAPPER);
|
211
|
+
worker.shutdown();
|
212
|
+
|
213
|
+
NilClass::new()
|
214
|
+
}
|
215
|
+
);
|
216
|
+
|
217
|
+
#[no_mangle]
|
218
|
+
pub extern "C" fn init_bridge() {
|
219
|
+
Module::from_existing("Temporalio").get_nested_module("Bridge").define(|module| {
|
220
|
+
module.define_nested_class("Runtime", None).define(|klass| {
|
221
|
+
klass.def_self("init", init_runtime);
|
222
|
+
klass.def("run_callback_loop", run_callback_loop);
|
223
|
+
});
|
224
|
+
|
225
|
+
module.define_nested_class("Connection", None).define(|klass| {
|
226
|
+
klass.def_self("connect", create_connection);
|
227
|
+
klass.def("call", call_rpc);
|
228
|
+
});
|
229
|
+
|
230
|
+
module.define_nested_class("Worker", None).define(|klass| {
|
231
|
+
klass.def_self("create", create_worker);
|
232
|
+
klass.def("poll_activity_task", worker_poll_activity_task);
|
233
|
+
klass.def("complete_activity_task", worker_complete_activity_task);
|
234
|
+
klass.def("record_activity_heartbeat", worker_record_activity_heartbeat);
|
235
|
+
klass.def("initiate_shutdown", worker_initiate_shutdown);
|
236
|
+
klass.def("shutdown", worker_shutdown);
|
237
|
+
});
|
238
|
+
});
|
239
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
use rutie::Thread;
|
2
|
+
use std::sync::Arc;
|
3
|
+
use std::sync::mpsc::{channel, Sender, Receiver};
|
4
|
+
use temporal_sdk_core::CoreRuntime;
|
5
|
+
use temporal_sdk_core_api::telemetry::TelemetryOptions;
|
6
|
+
use tokio::runtime::{Builder, Runtime as TokioRuntime};
|
7
|
+
|
8
|
+
pub type Callback = Box<dyn FnOnce() + Send + 'static>;
|
9
|
+
|
10
|
+
pub enum Command {
|
11
|
+
RunCallback(Callback),
|
12
|
+
Shutdown,
|
13
|
+
}
|
14
|
+
|
15
|
+
pub struct Runtime {
|
16
|
+
pub core_runtime: Arc<CoreRuntime>,
|
17
|
+
pub tokio_runtime: Arc<TokioRuntime>,
|
18
|
+
pub callback_tx: Sender<Command>,
|
19
|
+
callback_rx: Receiver<Command>,
|
20
|
+
}
|
21
|
+
|
22
|
+
impl Runtime {
|
23
|
+
pub fn new(thread_count: u8, telemetry_options: TelemetryOptions) -> Self {
|
24
|
+
let (tx, rx): (Sender<Command>, Receiver<Command>) = channel();
|
25
|
+
let tokio_runtime = Arc::new(
|
26
|
+
Builder::new_multi_thread()
|
27
|
+
.worker_threads(thread_count.into())
|
28
|
+
.enable_all()
|
29
|
+
.thread_name("core")
|
30
|
+
.build()
|
31
|
+
.expect("Unable to start a runtime")
|
32
|
+
);
|
33
|
+
let core_runtime = Arc::new(
|
34
|
+
CoreRuntime::new(telemetry_options, Builder::new_multi_thread())
|
35
|
+
.expect("Failed to initialize Core telemetry")
|
36
|
+
);
|
37
|
+
|
38
|
+
Runtime { core_runtime, tokio_runtime, callback_tx: tx, callback_rx: rx }
|
39
|
+
}
|
40
|
+
|
41
|
+
// This function is expected to be called from a Ruby thread
|
42
|
+
pub fn run_callback_loop(&self) {
|
43
|
+
let unblock = || {
|
44
|
+
self.callback_tx.send(Command::Shutdown {}).expect("Unable to close callback loop");
|
45
|
+
};
|
46
|
+
|
47
|
+
while let Ok(msg) = Thread::call_without_gvl(|| self.callback_rx.recv(), Some(unblock)) {
|
48
|
+
match msg {
|
49
|
+
Command::RunCallback(callback) => callback(),
|
50
|
+
Command::Shutdown => break,
|
51
|
+
}
|
52
|
+
};
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,124 @@
|
|
1
|
+
use crate::connection::Client;
|
2
|
+
use crate::runtime::{Callback, Command, Runtime};
|
3
|
+
use prost::Message;
|
4
|
+
use std::sync::Arc;
|
5
|
+
use std::sync::mpsc::Sender;
|
6
|
+
use temporal_sdk_core::api::{Worker as WorkerTrait};
|
7
|
+
use temporal_sdk_core_api::errors::{PollActivityError};
|
8
|
+
use temporal_sdk_core_api::worker::{WorkerConfigBuilder, WorkerConfigBuilderError};
|
9
|
+
use temporal_sdk_core_protos::coresdk::{ActivityHeartbeat, ActivityTaskCompletion};
|
10
|
+
use thiserror::Error;
|
11
|
+
use tokio::runtime::{Runtime as TokioRuntime};
|
12
|
+
|
13
|
+
#[derive(Error, Debug)]
|
14
|
+
pub enum WorkerError {
|
15
|
+
#[error(transparent)]
|
16
|
+
EncodeError(#[from] prost::EncodeError),
|
17
|
+
|
18
|
+
#[error(transparent)]
|
19
|
+
DecodeError(#[from] prost::DecodeError),
|
20
|
+
|
21
|
+
#[error(transparent)]
|
22
|
+
InvalidWorkerOptions(#[from] WorkerConfigBuilderError),
|
23
|
+
|
24
|
+
#[error(transparent)]
|
25
|
+
UnableToPollActivityTask(#[from] temporal_sdk_core::api::errors::PollActivityError),
|
26
|
+
|
27
|
+
#[error(transparent)]
|
28
|
+
UnableToCompleteActivityTask(#[from] temporal_sdk_core::api::errors::CompleteActivityError),
|
29
|
+
|
30
|
+
#[error("Unable to send a request. Channel is closed")]
|
31
|
+
ChannelClosed(),
|
32
|
+
|
33
|
+
#[error("Core worker is shutting down")]
|
34
|
+
Shutdown(),
|
35
|
+
}
|
36
|
+
|
37
|
+
pub type WorkerResult = Result<Vec<u8>, WorkerError>;
|
38
|
+
|
39
|
+
pub struct Worker {
|
40
|
+
core_worker: Arc<temporal_sdk_core::Worker>,
|
41
|
+
tokio_runtime: Arc<TokioRuntime>,
|
42
|
+
callback_tx: Sender<Command>,
|
43
|
+
}
|
44
|
+
|
45
|
+
impl Worker {
|
46
|
+
// TODO: Extend this to include full worker config
|
47
|
+
pub fn new(runtime: &Runtime, client: &Client, namespace: &str, task_queue: &str) -> Result<Worker, WorkerError> {
|
48
|
+
let config = WorkerConfigBuilder::default()
|
49
|
+
.namespace(namespace)
|
50
|
+
.task_queue(task_queue)
|
51
|
+
.worker_build_id("test-worker-build") // TODO: replace this with an actual build id
|
52
|
+
.build()?;
|
53
|
+
|
54
|
+
let core_worker = runtime.tokio_runtime.block_on(async move {
|
55
|
+
temporal_sdk_core::init_worker(&runtime.core_runtime, config, client.clone())
|
56
|
+
}).expect("Failed to initialize Core Worker");
|
57
|
+
|
58
|
+
Ok(Worker {
|
59
|
+
core_worker: Arc::new(core_worker),
|
60
|
+
tokio_runtime: runtime.tokio_runtime.clone(),
|
61
|
+
callback_tx: runtime.callback_tx.clone(),
|
62
|
+
})
|
63
|
+
}
|
64
|
+
|
65
|
+
pub fn poll_activity_task<F>(&self, callback: F) -> Result<(), WorkerError> where F: FnOnce(WorkerResult) + Send + 'static {
|
66
|
+
let core_worker = self.core_worker.clone();
|
67
|
+
let callback_tx = self.callback_tx.clone();
|
68
|
+
|
69
|
+
self.tokio_runtime.spawn(async move {
|
70
|
+
let result = core_worker.poll_activity_task().await;
|
71
|
+
|
72
|
+
let callback: Callback = match result {
|
73
|
+
Ok(task) => {
|
74
|
+
let bytes = task.encode_to_vec();
|
75
|
+
Box::new(move || callback(Ok(bytes)))
|
76
|
+
},
|
77
|
+
Err(PollActivityError::ShutDown) => Box::new(move || callback(Err(WorkerError::Shutdown()))),
|
78
|
+
Err(e) => Box::new(move || callback(Err(WorkerError::UnableToPollActivityTask(e))))
|
79
|
+
};
|
80
|
+
|
81
|
+
callback_tx.send(Command::RunCallback(callback)).expect("Unable to send a callback");
|
82
|
+
});
|
83
|
+
|
84
|
+
Ok(())
|
85
|
+
}
|
86
|
+
|
87
|
+
pub fn complete_activity_task<F>(&self, bytes: Vec<u8>, callback: F) -> Result<(), WorkerError> where F: FnOnce(WorkerResult) + Send + 'static {
|
88
|
+
let core_worker = self.core_worker.clone();
|
89
|
+
let callback_tx = self.callback_tx.clone();
|
90
|
+
let proto = ActivityTaskCompletion::decode(&*bytes)?;
|
91
|
+
|
92
|
+
self.tokio_runtime.spawn(async move {
|
93
|
+
let result = core_worker.complete_activity_task(proto).await;
|
94
|
+
|
95
|
+
let callback: Callback = match result {
|
96
|
+
Ok(()) => Box::new(move || callback(Ok(vec!()))),
|
97
|
+
Err(e) => Box::new(move || callback(Err(WorkerError::UnableToCompleteActivityTask(e))))
|
98
|
+
};
|
99
|
+
|
100
|
+
callback_tx.send(Command::RunCallback(callback)).expect("Unable to send a callback");
|
101
|
+
});
|
102
|
+
|
103
|
+
Ok(())
|
104
|
+
}
|
105
|
+
|
106
|
+
pub fn record_activity_heartbeat(&self, bytes: Vec<u8>) -> Result<(), WorkerError> {
|
107
|
+
let proto = ActivityHeartbeat::decode(&*bytes)?;
|
108
|
+
self.core_worker.record_activity_heartbeat(proto);
|
109
|
+
|
110
|
+
Ok(())
|
111
|
+
}
|
112
|
+
|
113
|
+
pub fn initiate_shutdown(&self) {
|
114
|
+
self.core_worker.initiate_shutdown();
|
115
|
+
}
|
116
|
+
|
117
|
+
pub fn shutdown(&self) {
|
118
|
+
let core_worker = self.core_worker.clone();
|
119
|
+
|
120
|
+
self.tokio_runtime.block_on(async move {
|
121
|
+
core_worker.shutdown().await;
|
122
|
+
});
|
123
|
+
}
|
124
|
+
}
|
data/ext/Rakefile
ADDED
data/lib/bridge.so
ADDED
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: dependencies/gogoproto/gogo.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/protobuf/descriptor_pb'
|
7
|
+
|
8
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
9
|
+
add_file("dependencies/gogoproto/gogo.proto", :syntax => :proto2) do
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module Gogoproto
|
14
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: temporal/api/batch/v1/message.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'dependencies/gogoproto/gogo_pb'
|
7
|
+
require 'google/protobuf/timestamp_pb'
|
8
|
+
require 'temporal/api/common/v1/message_pb'
|
9
|
+
require 'temporal/api/enums/v1/batch_operation_pb'
|
10
|
+
|
11
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
12
|
+
add_file("temporal/api/batch/v1/message.proto", :syntax => :proto3) do
|
13
|
+
add_message "temporal.api.batch.v1.BatchOperationInfo" do
|
14
|
+
optional :job_id, :string, 1
|
15
|
+
optional :state, :enum, 2, "temporal.api.enums.v1.BatchOperationState"
|
16
|
+
optional :start_time, :message, 3, "google.protobuf.Timestamp"
|
17
|
+
optional :close_time, :message, 4, "google.protobuf.Timestamp"
|
18
|
+
end
|
19
|
+
add_message "temporal.api.batch.v1.BatchOperationTermination" do
|
20
|
+
optional :details, :message, 1, "temporal.api.common.v1.Payloads"
|
21
|
+
optional :identity, :string, 2
|
22
|
+
end
|
23
|
+
add_message "temporal.api.batch.v1.BatchOperationSignal" do
|
24
|
+
optional :signal, :string, 1
|
25
|
+
optional :input, :message, 2, "temporal.api.common.v1.Payloads"
|
26
|
+
optional :header, :message, 3, "temporal.api.common.v1.Header"
|
27
|
+
optional :identity, :string, 4
|
28
|
+
end
|
29
|
+
add_message "temporal.api.batch.v1.BatchOperationCancellation" do
|
30
|
+
optional :identity, :string, 1
|
31
|
+
end
|
32
|
+
add_message "temporal.api.batch.v1.BatchOperationDeletion" do
|
33
|
+
optional :identity, :string, 1
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Temporalio
|
39
|
+
module Api
|
40
|
+
module Batch
|
41
|
+
module V1
|
42
|
+
BatchOperationInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.batch.v1.BatchOperationInfo").msgclass
|
43
|
+
BatchOperationTermination = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.batch.v1.BatchOperationTermination").msgclass
|
44
|
+
BatchOperationSignal = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.batch.v1.BatchOperationSignal").msgclass
|
45
|
+
BatchOperationCancellation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.batch.v1.BatchOperationCancellation").msgclass
|
46
|
+
BatchOperationDeletion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.batch.v1.BatchOperationDeletion").msgclass
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: temporal/api/command/v1/message.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/protobuf/duration_pb'
|
7
|
+
require 'dependencies/gogoproto/gogo_pb'
|
8
|
+
require 'temporal/api/enums/v1/workflow_pb'
|
9
|
+
require 'temporal/api/enums/v1/command_type_pb'
|
10
|
+
require 'temporal/api/common/v1/message_pb'
|
11
|
+
require 'temporal/api/failure/v1/message_pb'
|
12
|
+
require 'temporal/api/interaction/v1/message_pb'
|
13
|
+
require 'temporal/api/taskqueue/v1/message_pb'
|
14
|
+
|
15
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
16
|
+
add_file("temporal/api/command/v1/message.proto", :syntax => :proto3) do
|
17
|
+
add_message "temporal.api.command.v1.ScheduleActivityTaskCommandAttributes" do
|
18
|
+
optional :activity_id, :string, 1
|
19
|
+
optional :activity_type, :message, 2, "temporal.api.common.v1.ActivityType"
|
20
|
+
optional :task_queue, :message, 4, "temporal.api.taskqueue.v1.TaskQueue"
|
21
|
+
optional :header, :message, 5, "temporal.api.common.v1.Header"
|
22
|
+
optional :input, :message, 6, "temporal.api.common.v1.Payloads"
|
23
|
+
optional :schedule_to_close_timeout, :message, 7, "google.protobuf.Duration"
|
24
|
+
optional :schedule_to_start_timeout, :message, 8, "google.protobuf.Duration"
|
25
|
+
optional :start_to_close_timeout, :message, 9, "google.protobuf.Duration"
|
26
|
+
optional :heartbeat_timeout, :message, 10, "google.protobuf.Duration"
|
27
|
+
optional :retry_policy, :message, 11, "temporal.api.common.v1.RetryPolicy"
|
28
|
+
optional :request_eager_execution, :bool, 12
|
29
|
+
end
|
30
|
+
add_message "temporal.api.command.v1.RequestCancelActivityTaskCommandAttributes" do
|
31
|
+
optional :scheduled_event_id, :int64, 1
|
32
|
+
end
|
33
|
+
add_message "temporal.api.command.v1.StartTimerCommandAttributes" do
|
34
|
+
optional :timer_id, :string, 1
|
35
|
+
optional :start_to_fire_timeout, :message, 2, "google.protobuf.Duration"
|
36
|
+
end
|
37
|
+
add_message "temporal.api.command.v1.CompleteWorkflowExecutionCommandAttributes" do
|
38
|
+
optional :result, :message, 1, "temporal.api.common.v1.Payloads"
|
39
|
+
end
|
40
|
+
add_message "temporal.api.command.v1.FailWorkflowExecutionCommandAttributes" do
|
41
|
+
optional :failure, :message, 1, "temporal.api.failure.v1.Failure"
|
42
|
+
end
|
43
|
+
add_message "temporal.api.command.v1.CancelTimerCommandAttributes" do
|
44
|
+
optional :timer_id, :string, 1
|
45
|
+
end
|
46
|
+
add_message "temporal.api.command.v1.CancelWorkflowExecutionCommandAttributes" do
|
47
|
+
optional :details, :message, 1, "temporal.api.common.v1.Payloads"
|
48
|
+
end
|
49
|
+
add_message "temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes" do
|
50
|
+
optional :namespace, :string, 1
|
51
|
+
optional :workflow_id, :string, 2
|
52
|
+
optional :run_id, :string, 3
|
53
|
+
optional :control, :string, 4
|
54
|
+
optional :child_workflow_only, :bool, 5
|
55
|
+
optional :reason, :string, 6
|
56
|
+
end
|
57
|
+
add_message "temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes" do
|
58
|
+
optional :namespace, :string, 1
|
59
|
+
optional :execution, :message, 2, "temporal.api.common.v1.WorkflowExecution"
|
60
|
+
optional :signal_name, :string, 3
|
61
|
+
optional :input, :message, 4, "temporal.api.common.v1.Payloads"
|
62
|
+
optional :control, :string, 5
|
63
|
+
optional :child_workflow_only, :bool, 6
|
64
|
+
optional :header, :message, 7, "temporal.api.common.v1.Header"
|
65
|
+
end
|
66
|
+
add_message "temporal.api.command.v1.UpsertWorkflowSearchAttributesCommandAttributes" do
|
67
|
+
optional :search_attributes, :message, 1, "temporal.api.common.v1.SearchAttributes"
|
68
|
+
end
|
69
|
+
add_message "temporal.api.command.v1.ModifyWorkflowPropertiesCommandAttributes" do
|
70
|
+
optional :upserted_memo, :message, 1, "temporal.api.common.v1.Memo"
|
71
|
+
end
|
72
|
+
add_message "temporal.api.command.v1.RecordMarkerCommandAttributes" do
|
73
|
+
optional :marker_name, :string, 1
|
74
|
+
map :details, :string, :message, 2, "temporal.api.common.v1.Payloads"
|
75
|
+
optional :header, :message, 3, "temporal.api.common.v1.Header"
|
76
|
+
optional :failure, :message, 4, "temporal.api.failure.v1.Failure"
|
77
|
+
end
|
78
|
+
add_message "temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes" do
|
79
|
+
optional :workflow_type, :message, 1, "temporal.api.common.v1.WorkflowType"
|
80
|
+
optional :task_queue, :message, 2, "temporal.api.taskqueue.v1.TaskQueue"
|
81
|
+
optional :input, :message, 3, "temporal.api.common.v1.Payloads"
|
82
|
+
optional :workflow_run_timeout, :message, 4, "google.protobuf.Duration"
|
83
|
+
optional :workflow_task_timeout, :message, 5, "google.protobuf.Duration"
|
84
|
+
optional :backoff_start_interval, :message, 6, "google.protobuf.Duration"
|
85
|
+
optional :retry_policy, :message, 7, "temporal.api.common.v1.RetryPolicy"
|
86
|
+
optional :initiator, :enum, 8, "temporal.api.enums.v1.ContinueAsNewInitiator"
|
87
|
+
optional :failure, :message, 9, "temporal.api.failure.v1.Failure"
|
88
|
+
optional :last_completion_result, :message, 10, "temporal.api.common.v1.Payloads"
|
89
|
+
optional :cron_schedule, :string, 11
|
90
|
+
optional :header, :message, 12, "temporal.api.common.v1.Header"
|
91
|
+
optional :memo, :message, 13, "temporal.api.common.v1.Memo"
|
92
|
+
optional :search_attributes, :message, 14, "temporal.api.common.v1.SearchAttributes"
|
93
|
+
end
|
94
|
+
add_message "temporal.api.command.v1.StartChildWorkflowExecutionCommandAttributes" do
|
95
|
+
optional :namespace, :string, 1
|
96
|
+
optional :workflow_id, :string, 2
|
97
|
+
optional :workflow_type, :message, 3, "temporal.api.common.v1.WorkflowType"
|
98
|
+
optional :task_queue, :message, 4, "temporal.api.taskqueue.v1.TaskQueue"
|
99
|
+
optional :input, :message, 5, "temporal.api.common.v1.Payloads"
|
100
|
+
optional :workflow_execution_timeout, :message, 6, "google.protobuf.Duration"
|
101
|
+
optional :workflow_run_timeout, :message, 7, "google.protobuf.Duration"
|
102
|
+
optional :workflow_task_timeout, :message, 8, "google.protobuf.Duration"
|
103
|
+
optional :parent_close_policy, :enum, 9, "temporal.api.enums.v1.ParentClosePolicy"
|
104
|
+
optional :control, :string, 10
|
105
|
+
optional :workflow_id_reuse_policy, :enum, 11, "temporal.api.enums.v1.WorkflowIdReusePolicy"
|
106
|
+
optional :retry_policy, :message, 12, "temporal.api.common.v1.RetryPolicy"
|
107
|
+
optional :cron_schedule, :string, 13
|
108
|
+
optional :header, :message, 14, "temporal.api.common.v1.Header"
|
109
|
+
optional :memo, :message, 15, "temporal.api.common.v1.Memo"
|
110
|
+
optional :search_attributes, :message, 16, "temporal.api.common.v1.SearchAttributes"
|
111
|
+
end
|
112
|
+
add_message "temporal.api.command.v1.AcceptWorkflowUpdateCommandAttributes" do
|
113
|
+
optional :meta, :message, 1, "temporal.api.interaction.v1.Meta"
|
114
|
+
optional :input, :message, 2, "temporal.api.interaction.v1.Input"
|
115
|
+
end
|
116
|
+
add_message "temporal.api.command.v1.CompleteWorkflowUpdateCommandAttributes" do
|
117
|
+
optional :meta, :message, 1, "temporal.api.interaction.v1.Meta"
|
118
|
+
optional :output, :message, 2, "temporal.api.interaction.v1.Output"
|
119
|
+
end
|
120
|
+
add_message "temporal.api.command.v1.RejectWorkflowUpdateCommandAttributes" do
|
121
|
+
optional :meta, :message, 1, "temporal.api.interaction.v1.Meta"
|
122
|
+
optional :failure, :message, 2, "temporal.api.failure.v1.Failure"
|
123
|
+
end
|
124
|
+
add_message "temporal.api.command.v1.Command" do
|
125
|
+
optional :command_type, :enum, 1, "temporal.api.enums.v1.CommandType"
|
126
|
+
oneof :attributes do
|
127
|
+
optional :schedule_activity_task_command_attributes, :message, 2, "temporal.api.command.v1.ScheduleActivityTaskCommandAttributes"
|
128
|
+
optional :start_timer_command_attributes, :message, 3, "temporal.api.command.v1.StartTimerCommandAttributes"
|
129
|
+
optional :complete_workflow_execution_command_attributes, :message, 4, "temporal.api.command.v1.CompleteWorkflowExecutionCommandAttributes"
|
130
|
+
optional :fail_workflow_execution_command_attributes, :message, 5, "temporal.api.command.v1.FailWorkflowExecutionCommandAttributes"
|
131
|
+
optional :request_cancel_activity_task_command_attributes, :message, 6, "temporal.api.command.v1.RequestCancelActivityTaskCommandAttributes"
|
132
|
+
optional :cancel_timer_command_attributes, :message, 7, "temporal.api.command.v1.CancelTimerCommandAttributes"
|
133
|
+
optional :cancel_workflow_execution_command_attributes, :message, 8, "temporal.api.command.v1.CancelWorkflowExecutionCommandAttributes"
|
134
|
+
optional :request_cancel_external_workflow_execution_command_attributes, :message, 9, "temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes"
|
135
|
+
optional :record_marker_command_attributes, :message, 10, "temporal.api.command.v1.RecordMarkerCommandAttributes"
|
136
|
+
optional :continue_as_new_workflow_execution_command_attributes, :message, 11, "temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes"
|
137
|
+
optional :start_child_workflow_execution_command_attributes, :message, 12, "temporal.api.command.v1.StartChildWorkflowExecutionCommandAttributes"
|
138
|
+
optional :signal_external_workflow_execution_command_attributes, :message, 13, "temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes"
|
139
|
+
optional :upsert_workflow_search_attributes_command_attributes, :message, 14, "temporal.api.command.v1.UpsertWorkflowSearchAttributesCommandAttributes"
|
140
|
+
optional :accept_workflow_update_command_attributes, :message, 15, "temporal.api.command.v1.AcceptWorkflowUpdateCommandAttributes"
|
141
|
+
optional :complete_workflow_update_command_attributes, :message, 16, "temporal.api.command.v1.CompleteWorkflowUpdateCommandAttributes"
|
142
|
+
optional :modify_workflow_properties_command_attributes, :message, 17, "temporal.api.command.v1.ModifyWorkflowPropertiesCommandAttributes"
|
143
|
+
optional :reject_workflow_update_command_attributes, :message, 18, "temporal.api.command.v1.RejectWorkflowUpdateCommandAttributes"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
module Temporalio
|
150
|
+
module Api
|
151
|
+
module Command
|
152
|
+
module V1
|
153
|
+
ScheduleActivityTaskCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.ScheduleActivityTaskCommandAttributes").msgclass
|
154
|
+
RequestCancelActivityTaskCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.RequestCancelActivityTaskCommandAttributes").msgclass
|
155
|
+
StartTimerCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.StartTimerCommandAttributes").msgclass
|
156
|
+
CompleteWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.CompleteWorkflowExecutionCommandAttributes").msgclass
|
157
|
+
FailWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.FailWorkflowExecutionCommandAttributes").msgclass
|
158
|
+
CancelTimerCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.CancelTimerCommandAttributes").msgclass
|
159
|
+
CancelWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.CancelWorkflowExecutionCommandAttributes").msgclass
|
160
|
+
RequestCancelExternalWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.RequestCancelExternalWorkflowExecutionCommandAttributes").msgclass
|
161
|
+
SignalExternalWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes").msgclass
|
162
|
+
UpsertWorkflowSearchAttributesCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.UpsertWorkflowSearchAttributesCommandAttributes").msgclass
|
163
|
+
ModifyWorkflowPropertiesCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.ModifyWorkflowPropertiesCommandAttributes").msgclass
|
164
|
+
RecordMarkerCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.RecordMarkerCommandAttributes").msgclass
|
165
|
+
ContinueAsNewWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes").msgclass
|
166
|
+
StartChildWorkflowExecutionCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.StartChildWorkflowExecutionCommandAttributes").msgclass
|
167
|
+
AcceptWorkflowUpdateCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.AcceptWorkflowUpdateCommandAttributes").msgclass
|
168
|
+
CompleteWorkflowUpdateCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.CompleteWorkflowUpdateCommandAttributes").msgclass
|
169
|
+
RejectWorkflowUpdateCommandAttributes = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.RejectWorkflowUpdateCommandAttributes").msgclass
|
170
|
+
Command = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.command.v1.Command").msgclass
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|