├── .github ├── CODEOWNERS └── workflows │ └── nightly.yml ├── temporalio ├── sig │ ├── common.rbs │ ├── temporalio │ │ ├── api.rbs │ │ ├── version.rbs │ │ ├── activity.rbs │ │ ├── testing.rbs │ │ ├── activity │ │ │ ├── complete_async_error.rbs │ │ │ ├── cancellation_details.rbs │ │ │ ├── context.rbs │ │ │ ├── definition.rbs │ │ │ └── info.rbs │ │ ├── converters │ │ │ ├── payload_converter │ │ │ │ ├── binary_null.rbs │ │ │ │ ├── binary_plain.rbs │ │ │ │ ├── json_protobuf.rbs │ │ │ │ ├── binary_protobuf.rbs │ │ │ │ ├── json_plain.rbs │ │ │ │ ├── encoding.rbs │ │ │ │ └── composite.rbs │ │ │ ├── raw_value.rbs │ │ │ ├── payload_codec.rbs │ │ │ ├── failure_converter.rbs │ │ │ ├── payload_converter.rbs │ │ │ └── data_converter.rbs │ │ ├── worker │ │ │ ├── activity_executor │ │ │ │ ├── fiber.rbs │ │ │ │ └── thread_pool.rbs │ │ │ ├── workflow_executor.rbs │ │ │ ├── activity_executor.rbs │ │ │ ├── deployment_options.rbs │ │ │ ├── poller_behavior.rbs │ │ │ ├── illegal_workflow_call_validator.rbs │ │ │ ├── thread_pool.rbs │ │ │ └── workflow_executor │ │ │ │ └── thread_pool.rbs │ │ ├── workflow │ │ │ ├── handler_unfinished_policy.rbs │ │ │ ├── activity_cancellation_type.rbs │ │ │ ├── parent_close_policy.rbs │ │ │ ├── child_workflow_cancellation_type.rbs │ │ │ ├── update_info.rbs │ │ │ ├── external_workflow_handle.rbs │ │ │ ├── child_workflow_handle.rbs │ │ │ └── future.rbs │ │ ├── client │ │ │ ├── workflow_update_wait_stage.rbs │ │ │ ├── workflow_query_reject_condition.rbs │ │ │ ├── activity_id_reference.rbs │ │ │ ├── workflow_execution_status.rbs │ │ │ ├── connection │ │ │ │ ├── service.rbs │ │ │ │ ├── test_service.rbs │ │ │ │ └── operator_service.rbs │ │ │ ├── workflow_execution_count.rbs │ │ │ ├── workflow_update_handle.rbs │ │ │ ├── schedule_handle.rbs │ │ │ ├── workflow_execution.rbs │ │ │ └── async_activity_handle.rbs │ │ ├── internal │ │ │ ├── bridge.rbs │ │ │ ├── worker │ │ │ │ ├── workflow_instance │ │ │ │ │ ├── external_workflow_handle.rbs │ │ │ │ │ ├── replay_safe_logger.rbs │ │ │ │ │ ├── replay_safe_metric.rbs │ │ │ │ │ ├── externally_immutable_hash.rbs │ │ │ │ │ ├── handler_hash.rbs │ │ │ │ │ ├── handler_execution.rbs │ │ │ │ │ ├── child_workflow_handle.rbs │ │ │ │ │ ├── inbound_implementation.rbs │ │ │ │ │ ├── scheduler.rbs │ │ │ │ │ ├── illegal_call_tracer.rbs │ │ │ │ │ ├── outbound_implementation.rbs │ │ │ │ │ └── details.rbs │ │ │ │ └── activity_worker.rbs │ │ │ ├── client │ │ │ │ └── implementation.rbs │ │ │ ├── bridge │ │ │ │ └── metric.rbs │ │ │ └── metric.rbs │ │ ├── workflow_history.rbs │ │ ├── scoped_logger.rbs │ │ ├── priority.rbs │ │ ├── versioning_override.rbs │ │ ├── common_enums.rbs │ │ ├── worker_deployment_version.rbs │ │ ├── retry_policy.rbs │ │ ├── cancellation.rbs │ │ ├── testing │ │ │ └── activity_environment.rbs │ │ ├── runtime │ │ │ └── metric_buffer.rbs │ │ ├── metric.rbs │ │ ├── search_attributes.rbs │ │ ├── error.rbs │ │ └── contrib │ │ │ └── open_telemetry.rbs │ └── temporalio.rbs ├── .yardopts ├── ext │ ├── .cargo │ │ └── config.toml │ ├── extconf.rb │ ├── additional_protos │ │ └── temporal │ │ │ └── api │ │ │ └── common │ │ │ └── v1 │ │ │ └── grpc_status.proto │ ├── Cargo.toml │ ├── src │ │ └── lib.rs │ └── README.md ├── test │ ├── sig │ │ ├── client_workflow_test.rbs │ │ ├── extra_assertions.rbs │ │ ├── runtime_test.rbs │ │ ├── worker_test.rbs │ │ ├── envconfig_test.rbs │ │ ├── workflow │ │ │ └── definition_test.rbs │ │ ├── worker_workflow_priority_test.rbs │ │ ├── gc_utils.rbs │ │ ├── worker_workflow_versioning_test.rbs │ │ ├── worker_activity_test.rbs │ │ ├── test.rbs │ │ ├── contrib │ │ │ └── open_telemetry_test.rbs │ │ └── workflow_utils.rbs │ ├── extra_assertions.rb │ ├── base64_codec.rb │ ├── golangworker │ │ └── go.mod │ ├── cancellation_test.rb │ ├── scoped_logger_test.rb │ └── workflow_utils.rb ├── lib │ ├── temporalio │ │ ├── version.rb │ │ ├── internal │ │ │ ├── bridge │ │ │ │ ├── api.rb │ │ │ │ ├── api │ │ │ │ │ ├── common │ │ │ │ │ │ └── common.rb │ │ │ │ │ ├── external_data │ │ │ │ │ │ └── external_data.rb │ │ │ │ │ └── workflow_completion │ │ │ │ │ │ └── workflow_completion.rb │ │ │ │ ├── runtime.rb │ │ │ │ └── testing.rb │ │ │ ├── worker │ │ │ │ └── workflow_instance │ │ │ │ │ ├── externally_immutable_hash.rb │ │ │ │ │ ├── handler_execution.rb │ │ │ │ │ ├── external_workflow_handle.rb │ │ │ │ │ ├── replay_safe_metric.rb │ │ │ │ │ ├── replay_safe_logger.rb │ │ │ │ │ ├── handler_hash.rb │ │ │ │ │ ├── inbound_implementation.rb │ │ │ │ │ └── details.rb │ │ │ └── bridge.rb │ │ ├── api │ │ │ ├── operatorservice.rb │ │ │ ├── workflowservice.rb │ │ │ ├── cloud │ │ │ │ ├── cloudservice.rb │ │ │ │ ├── resource │ │ │ │ │ └── v1 │ │ │ │ │ │ └── message.rb │ │ │ │ ├── region │ │ │ │ │ └── v1 │ │ │ │ │ │ └── message.rb │ │ │ │ ├── sink │ │ │ │ │ └── v1 │ │ │ │ │ │ └── message.rb │ │ │ │ └── operation │ │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ ├── common │ │ │ │ └── v1 │ │ │ │ │ └── grpc_status.rb │ │ │ ├── enums │ │ │ │ └── v1 │ │ │ │ │ ├── nexus.rb │ │ │ │ │ ├── schedule.rb │ │ │ │ │ ├── query.rb │ │ │ │ │ ├── update.rb │ │ │ │ │ ├── namespace.rb │ │ │ │ │ ├── reset.rb │ │ │ │ │ ├── batch_operation.rb │ │ │ │ │ ├── command_type.rb │ │ │ │ │ └── deployment.rb │ │ │ ├── sdk │ │ │ │ └── v1 │ │ │ │ │ ├── user_metadata.rb │ │ │ │ │ ├── task_complete_metadata.rb │ │ │ │ │ ├── worker_config.rb │ │ │ │ │ ├── workflow_metadata.rb │ │ │ │ │ └── enhanced_stack_trace.rb │ │ │ ├── protocol │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ ├── export │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ ├── activity │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ ├── testservice │ │ │ │ └── v1 │ │ │ │ │ └── service.rb │ │ │ ├── filter │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ ├── replication │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ ├── version │ │ │ │ └── v1 │ │ │ │ │ └── message.rb │ │ │ └── query │ │ │ │ └── v1 │ │ │ │ └── message.rb │ │ ├── internal.rb │ │ ├── converters.rb │ │ ├── testing.rb │ │ ├── activity │ │ │ ├── complete_async_error.rb │ │ │ └── cancellation_details.rb │ │ ├── workflow │ │ │ ├── handler_unfinished_policy.rb │ │ │ ├── update_info.rb │ │ │ ├── parent_close_policy.rb │ │ │ ├── activity_cancellation_type.rb │ │ │ ├── child_workflow_cancellation_type.rb │ │ │ ├── external_workflow_handle.rb │ │ │ └── child_workflow_handle.rb │ │ ├── activity.rb │ │ ├── api.rb │ │ ├── client │ │ │ ├── workflow_query_reject_condition.rb │ │ │ ├── workflow_update_wait_stage.rb │ │ │ ├── workflow_execution_status.rb │ │ │ ├── activity_id_reference.rb │ │ │ ├── workflow_execution_count.rb │ │ │ └── connection │ │ │ │ └── service.rb │ │ ├── converters │ │ │ ├── raw_value.rb │ │ │ ├── payload_converter │ │ │ │ ├── binary_null.rb │ │ │ │ ├── binary_plain.rb │ │ │ │ ├── json_protobuf.rb │ │ │ │ ├── binary_protobuf.rb │ │ │ │ └── encoding.rb │ │ │ └── payload_codec.rb │ │ ├── worker │ │ │ ├── workflow_executor.rb │ │ │ ├── deployment_options.rb │ │ │ ├── activity_executor │ │ │ │ ├── fiber.rb │ │ │ │ └── thread_pool.rb │ │ │ └── activity_executor.rb │ │ ├── workflow_history.rb │ │ ├── versioning_override.rb │ │ └── worker_deployment_version.rb │ └── temporalio.rb ├── Steepfile ├── rbs_collection.yaml ├── Gemfile ├── Cargo.toml ├── smoke_test │ └── smoke_test_gem.rb └── temporalio.gemspec ├── .gitmodules ├── .gitignore └── LICENSE /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @temporalio/sdk 2 | -------------------------------------------------------------------------------- /temporalio/sig/common.rbs: -------------------------------------------------------------------------------- 1 | type duration = Integer | Float -------------------------------------------------------------------------------- /temporalio/.yardopts: -------------------------------------------------------------------------------- 1 | --readme README.md 2 | --protected 3 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/api.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Api 3 | end 4 | end -------------------------------------------------------------------------------- /temporalio/ext/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.'cfg(all())'] 2 | rustflags = ["--edition=2024"] -------------------------------------------------------------------------------- /temporalio/sig/temporalio/version.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | VERSION: String 3 | end 4 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/activity.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Activity 3 | end 4 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/testing.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Testing 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | def self._root_file_path: -> String 3 | end 4 | -------------------------------------------------------------------------------- /temporalio/test/sig/client_workflow_test.rbs: -------------------------------------------------------------------------------- 1 | class ClientWorkflowTest < Test 2 | def start_simple: -> void 3 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | VERSION = '1.1.0' 5 | end 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "temporalio/ext/sdk-core"] 2 | path = temporalio/ext/sdk-core 3 | url = https://github.com/temporalio/sdk-core.git 4 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge/api.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/bridge/api/core_interface' 4 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/operatorservice.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api/operatorservice/v1/request_response' 4 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/workflowservice.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api/workflowservice/v1/request_response' 4 | -------------------------------------------------------------------------------- /temporalio/test/sig/extra_assertions.rbs: -------------------------------------------------------------------------------- 1 | module ExtraAssertions 2 | def assert_eventually: [T] (?timeout: Float, ?interval: Float) { -> T } -> T 3 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/cloud/cloudservice.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api/cloud/cloudservice/v1/request_response' 4 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | # @!visibility private 5 | module Internal 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /temporalio/ext/extconf.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'mkmf' 4 | require 'rb_sys/mkmf' 5 | 6 | create_rust_makefile('temporalio/temporalio_bridge') 7 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/activity/complete_async_error.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Activity 3 | class CompleteAsyncError < Error 4 | end 5 | end 6 | end -------------------------------------------------------------------------------- /.github/workflows/nightly.yml: -------------------------------------------------------------------------------- 1 | name: Nightly 2 | 3 | on: 4 | schedule: 5 | # (12 AM PST) 6 | - cron: "00 07 * * *" 7 | 8 | jobs: 9 | nightly: 10 | uses: ./.github/workflows/run-bench.yml -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/binary_null.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class BinaryNull < Encoding 5 | end 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/binary_plain.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class BinaryPlain < Encoding 5 | end 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/json_protobuf.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class JsonProtobuf < Encoding 5 | end 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/binary_protobuf.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class BinaryProtobuf < Encoding 5 | end 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/converters/data_converter' 4 | 5 | module Temporalio 6 | # Module for data conversion. 7 | module Converters 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/activity_executor/fiber.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class ActivityExecutor 4 | class Fiber < ActivityExecutor 5 | def self.default: -> Fiber 6 | end 7 | end 8 | end 9 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/raw_value.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class RawValue 4 | attr_reader payload: untyped 5 | 6 | def initialize: (untyped payload) -> void 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/handler_unfinished_policy.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | module HandlerUnfinishedPolicy 4 | type enum = Integer 5 | 6 | WARN_AND_ABANDON: enum 7 | ABANDON: enum 8 | end 9 | end 10 | end -------------------------------------------------------------------------------- /temporalio/test/sig/runtime_test.rbs: -------------------------------------------------------------------------------- 1 | class RuntimeTest < Test 2 | def assert_metric_line: ( 3 | String dump, 4 | String metric, 5 | **untyped required_attrs 6 | ) -> String? 7 | 8 | def assert_bad_call: (?String? message_includes) { (?) -> untyped } -> void 9 | end -------------------------------------------------------------------------------- /temporalio/test/sig/worker_test.rbs: -------------------------------------------------------------------------------- 1 | class WorkerTest < Test 2 | class TrackingSlotSupplier < Temporalio::Worker::Tuner::SlotSupplier::Custom 3 | attr_reader events: Array[[Symbol, untyped]] 4 | 5 | def add_event: (Symbol method, untyped context) -> void 6 | end 7 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/workflow_update_wait_stage.rbs: -------------------------------------------------------------------------------- 1 | 2 | module Temporalio 3 | class Client 4 | module WorkflowUpdateWaitStage 5 | type enum = Integer 6 | 7 | ADMITTED: enum 8 | ACCEPTED: enum 9 | COMPLETED: enum 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_codec.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadCodec 4 | def encode: (Enumerable[untyped] payloads) -> Array[untyped] 5 | def decode: (Enumerable[untyped] payloads) -> Array[untyped] 6 | end 7 | end 8 | end -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | target/ 3 | Gemfile.lock 4 | .gem_rbs_collection 5 | *.so 6 | temporalio/test/golangworker/golangworker 7 | temporalio/.yardoc 8 | temporalio/doc 9 | temporalio/pkg 10 | temporalio/lib/temporalio/internal/bridge/temporalio_bridge.bundle 11 | temporalio/.bundle 12 | .idea/ 13 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/testing.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/testing/activity_environment' 4 | require 'temporalio/testing/workflow_environment' 5 | 6 | module Temporalio 7 | # Module for all testing environments. 8 | module Testing 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/workflow_query_reject_condition.rbs: -------------------------------------------------------------------------------- 1 | 2 | module Temporalio 3 | class Client 4 | module WorkflowQueryRejectCondition 5 | type enum = Integer 6 | 7 | NONE: enum 8 | NOT_OPEN: enum 9 | NOT_COMPLETED_CLEANLY: enum 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/activity_cancellation_type.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | module ActivityCancellationType 4 | type enum = Integer 5 | 6 | TRY_CANCEL: enum 7 | WAIT_CANCELLATION_COMPLETED: enum 8 | ABANDON: enum 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/parent_close_policy.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | module ParentClosePolicy 4 | type enum = Integer 5 | 6 | UNSPECIFIED: enum 7 | TERMINATE: enum 8 | ABANDON: enum 9 | REQUEST_CANCEL: enum 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/bridge.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Bridge 4 | def self.assert_fiber_compatibility!: -> void 5 | def self.fibers_supported: -> bool 6 | 7 | # Defined in Rust 8 | 9 | class Error < StandardError 10 | end 11 | end 12 | end 13 | end -------------------------------------------------------------------------------- /temporalio/test/sig/envconfig_test.rbs: -------------------------------------------------------------------------------- 1 | class EnvConfigTest < Test 2 | TOML_CONFIG_BASE: String 3 | TOML_CONFIG_STRICT_FAIL: String 4 | TOML_CONFIG_MALFORMED: String 5 | TOML_CONFIG_TLS_DETAILED: String 6 | 7 | private 8 | 9 | def with_temp_config_file: [T] (String content) { (String config_file) -> T } -> T 10 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/activity_executor/thread_pool.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class ActivityExecutor 4 | class ThreadPool < ActivityExecutor 5 | def self.default: -> ThreadPool 6 | 7 | def initialize: (?ThreadPool thread_poll) -> void 8 | end 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /temporalio/test/sig/workflow/definition_test.rbs: -------------------------------------------------------------------------------- 1 | module Workflow 2 | class DefinitionTest < Test 3 | class ValidWorkflowAdvancedBase < Temporalio::Workflow::Definition 4 | end 5 | 6 | def assert_invalid_workflow_code: ( 7 | String message_contains, 8 | String code_to_eval 9 | ) -> void 10 | end 11 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/version' 4 | require 'temporalio/versioning_override' 5 | 6 | # Temporal Ruby SDK. See the README at https://github.com/temporalio/sdk-ruby. 7 | module Temporalio 8 | # @!visibility private 9 | def self._root_file_path 10 | __FILE__ 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/activity/complete_async_error.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/error' 4 | 5 | module Temporalio 6 | module Activity 7 | # Error raised inside an activity to mark that the activity will be completed asynchronously. 8 | class CompleteAsyncError < Error 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/child_workflow_cancellation_type.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | module ChildWorkflowCancellationType 4 | type enum = Integer 5 | 6 | ABANDON: enum 7 | TRY_CANCEL: enum 8 | WAIT_CANCELLATION_COMPLETED: enum 9 | WAIT_CANCELLATION_REQUESTED: enum 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/update_info.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | class UpdateInfo 4 | attr_reader id: String 5 | attr_reader name: String 6 | 7 | def initialize: ( 8 | id: String, 9 | name: String 10 | ) -> void 11 | 12 | def to_h: -> Hash[Symbol, untyped] 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow_history.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class WorkflowHistory 3 | def self.from_history_json: (String json) -> WorkflowHistory 4 | 5 | attr_reader events: Array[untyped] 6 | 7 | def initialize: (Array[untyped] events) -> void 8 | 9 | def workflow_id: -> String 10 | 11 | def to_history_json: -> String 12 | end 13 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/activity_id_reference.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class ActivityIDReference 4 | attr_reader workflow_id: String 5 | attr_reader run_id: String? 6 | attr_reader activity_id: String 7 | 8 | def initialize: (workflow_id: String, run_id: String?, activity_id: String) -> void 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/json_plain.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class JsonPlain < Encoding 5 | def initialize: ( 6 | ?Hash[Symbol, untyped] parse_options, 7 | ?Hash[Symbol, untyped] generate_options 8 | ) -> void 9 | end 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/workflow_execution_status.rbs: -------------------------------------------------------------------------------- 1 | 2 | module Temporalio 3 | class Client 4 | module WorkflowExecutionStatus 5 | type enum = Integer 6 | 7 | RUNNING: enum 8 | COMPLETED: enum 9 | FAILED: enum 10 | CANCELED: enum 11 | TERMINATED: enum 12 | CONTINUED_AS_NEW: enum 13 | TIMED_OUT: enum 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /temporalio/test/sig/worker_workflow_priority_test.rbs: -------------------------------------------------------------------------------- 1 | class WorkerWorkflowPriorityTest < Test 2 | class WorkflowUsingPriorities < Temporalio::Workflow::Definition 3 | def float_matches?: (Float? expected, Float? actual, ?Float tolerance) -> bool 4 | def execute: (Integer? expected_priority, bool stop_after_check, ?String? expected_fairness_key, ?Float? expected_weight) -> String 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/encoding.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class Encoding 5 | def encoding: -> String 6 | 7 | def to_payload: (Object? value, ?hint: Object?) -> untyped? 8 | 9 | def from_payload: (untyped payload, ?hint: Object?) -> Object? 10 | end 11 | end 12 | end 13 | end -------------------------------------------------------------------------------- /temporalio/test/extra_assertions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module ExtraAssertions 4 | def assert_eventually(timeout: 10, interval: 0.2) 5 | start_time = Time.now 6 | loop do 7 | begin 8 | return yield 9 | rescue Minitest::Assertion => e 10 | raise e if Time.now - start_time > timeout 11 | end 12 | sleep(interval) 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/handler_unfinished_policy.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Workflow 5 | # Actions taken if a workflow completes with running handlers. 6 | module HandlerUnfinishedPolicy 7 | # Issue a warning in addition to abandoning. 8 | WARN_AND_ABANDON = 1 9 | # Abandon the handler with no warning. 10 | ABANDON = 2 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/activity.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/activity/cancellation_details' 4 | require 'temporalio/activity/complete_async_error' 5 | require 'temporalio/activity/context' 6 | require 'temporalio/activity/definition' 7 | require 'temporalio/activity/info' 8 | require 'temporalio/priority' 9 | 10 | module Temporalio 11 | # All activity related classes. 12 | module Activity 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/scoped_logger.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class ScopedLogger < Logger 3 | attr_accessor scoped_values_getter: Proc? 4 | attr_accessor disable_scoped_values: bool 5 | 6 | def initialize: (Logger) -> void 7 | 8 | class LogMessage 9 | attr_reader message: Object 10 | attr_reader scoped_values: Object 11 | 12 | def initialize: (Object message, Object scoped_values) -> void 13 | end 14 | end 15 | end -------------------------------------------------------------------------------- /temporalio/Steepfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | D = Steep::Diagnostic 4 | 5 | target :lib do 6 | signature 'sig', 'test/sig' 7 | 8 | check 'lib', 'test' 9 | 10 | ignore 'lib/temporalio/api', 'lib/temporalio/internal/bridge/api' 11 | 12 | library 'uri', 'objspace' 13 | 14 | configure_code_diagnostics do |hash| 15 | # TODO(cretz): Fix as more protos are generated 16 | hash[D::Ruby::UnknownConstant] = :information 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/external_workflow_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class ExternalWorkflowHandle < Workflow::ExternalWorkflowHandle 6 | def initialize: ( 7 | id: String, 8 | run_id: String?, 9 | instance: Object 10 | ) -> void 11 | end 12 | end 13 | end 14 | end 15 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter/composite.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | class Composite < PayloadConverter 5 | class ConverterNotFound < Error 6 | end 7 | class EncodingNotSet < Error 8 | end 9 | 10 | attr_reader converters: Hash[String, Encoding] 11 | 12 | def initialize: (*Encoding converters) -> void 13 | end 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/replay_safe_logger.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class ReplaySafeLogger < ScopedLogger 6 | def initialize: ( 7 | logger: Logger, 8 | instance: WorkflowInstance 9 | ) -> void 10 | 11 | def replay_safety_disabled: [T] { -> T } -> T 12 | end 13 | end 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/failure_converter.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class FailureConverter 4 | def self.default: -> FailureConverter 5 | 6 | def initialize: (?encode_common_attributes: bool) -> void 7 | 8 | def to_failure: (Exception error, DataConverter | PayloadConverter converter) -> untyped 9 | def from_failure: (untyped failure, DataConverter | PayloadConverter converter) -> Exception 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/external_workflow_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | class ExternalWorkflowHandle 4 | def id: -> String 5 | def run_id: -> String? 6 | 7 | def signal: ( 8 | Workflow::Definition::Signal | Symbol | String signal, 9 | *Object? args, 10 | ?cancellation: Cancellation, 11 | ?arg_hints: Array[Object]? 12 | ) -> void 13 | 14 | def cancel: -> void 15 | end 16 | end 17 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/replay_safe_metric.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class ReplaySafeMetric < Temporalio::Metric 6 | def initialize: (Temporalio::Metric) -> void 7 | 8 | class Meter < Temporalio::Metric::Meter 9 | def initialize: (Temporalio::Metric::Meter) -> void 10 | end 11 | end 12 | end 13 | end 14 | end 15 | end -------------------------------------------------------------------------------- /temporalio/test/sig/gc_utils.rbs: -------------------------------------------------------------------------------- 1 | module GCUtils 2 | def self.find_retaining_path_to: ( 3 | Integer target_id, 4 | ?max_depth: Integer, 5 | ?max_visits: Integer, 6 | ?category_whitelist: Array[String]? 7 | ) -> [Array[untyped], String] 8 | 9 | def self.print_annotated_path: (Array[untyped] path, root_category: String) -> void 10 | 11 | def self.edge_labels: (untyped parent, untyped child) -> Array[String] 12 | 13 | def self.describe_obj: (untyped obj) -> String 14 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/connection/service.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class Connection 4 | class Service 5 | def initialize: (Connection, untyped) -> void 6 | 7 | def invoke_rpc: [REQ < Object, RESP < Object] ( 8 | rpc: String, 9 | request_class: class REQ, 10 | response_class: class RESP, 11 | request: REQ, 12 | rpc_options: RPCOptions? 13 | ) -> RESP 14 | end 15 | end 16 | end 17 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api/cloud/cloudservice' 4 | require 'temporalio/api/common/v1/grpc_status' 5 | require 'temporalio/api/errordetails/v1/message' 6 | require 'temporalio/api/export/v1/message' 7 | require 'temporalio/api/operatorservice' 8 | require 'temporalio/api/sdk/v1/workflow_metadata' 9 | require 'temporalio/api/workflowservice' 10 | 11 | module Temporalio 12 | # Raw protocol buffer models. 13 | module Api 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/priority.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Priority 3 | attr_reader priority_key: Integer? 4 | attr_reader fairness_key: String? 5 | attr_reader fairness_weight: Float? 6 | 7 | def initialize: (?priority_key: Integer?, ?fairness_key: String?, ?fairness_weight: Float?) -> void 8 | 9 | def self._from_proto: (untyped) -> Priority 10 | 11 | def self.default: -> Priority 12 | 13 | def _to_proto: -> untyped 14 | 15 | def empty?: -> bool 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/workflow_executor.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class WorkflowExecutor 4 | def _validate_worker: ( 5 | Internal::Worker::WorkflowWorker workflow_worker, 6 | Internal::Worker::WorkflowWorker::State worker_state 7 | ) -> void 8 | 9 | def _activate: ( 10 | untyped activation, 11 | Internal::Worker::WorkflowWorker::State worker_state 12 | ) { (untyped completion) -> void } -> void 13 | end 14 | end 15 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/versioning_override.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class VersioningOverride 3 | def _to_proto: -> untyped 4 | 5 | class Pinned < VersioningOverride 6 | attr_reader version: WorkerDeploymentVersion 7 | 8 | def initialize: (WorkerDeploymentVersion version) -> void 9 | def _to_proto: -> untyped 10 | end 11 | 12 | class AutoUpgrade < VersioningOverride 13 | def initialize: -> void 14 | def _to_proto: -> untyped 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class ExternallyImmutableHash[K, V] < Hash[K, V] 6 | def initialize: (Hash[K, V] initial_hash) -> void 7 | 8 | def _update: { (Hash[K, V]) -> void } -> void 9 | 10 | def __getobj__: -> Hash[K, V] 11 | def __setobj__: (Hash[K, V] value) -> void 12 | end 13 | end 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/activity_executor.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class ActivityExecutor 4 | def self.defaults: -> Hash[Symbol, ActivityExecutor] 5 | 6 | def initialize_activity: (Activity::Definition::Info defn) -> void 7 | def execute_activity: (Activity::Definition::Info defn) { -> void } -> void 8 | def activity_context: -> Activity::Context? 9 | def set_activity_context: (Activity::Definition::Info defn, Activity::Context? context) -> void 10 | end 11 | end 12 | end -------------------------------------------------------------------------------- /temporalio/ext/additional_protos/temporal/api/common/v1/grpc_status.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package temporal.api.common.v1; 4 | 5 | option ruby_package = "Temporalio::Api::Common::V1"; 6 | 7 | import "google/protobuf/any.proto"; 8 | 9 | // From https://github.com/grpc/grpc/blob/master/src/proto/grpc/status/status.proto 10 | // since we don't import grpc but still need the status info 11 | message GrpcStatus { 12 | int32 code = 1; 13 | string message = 2; 14 | repeated google.protobuf.Any details = 3; 15 | } 16 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/handler_hash.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class HandlerHash[D] < Hash[String?, D] 6 | def initialize: ( 7 | Hash[String?, D] initial_frozen_hash, 8 | singleton(Workflow::Definition::Signal) | singleton(Workflow::Definition::Query) | singleton(Workflow::Definition::Update) definition_class, 9 | ) ?{ (D) -> void } -> void 10 | end 11 | end 12 | end 13 | end 14 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/child_workflow_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | class ChildWorkflowHandle 4 | def id: -> String 5 | def first_execution_run_id: -> String 6 | def result_hint: -> Object? 7 | 8 | def result: (?result_hint: Object?) -> Object? 9 | 10 | def signal: ( 11 | Workflow::Definition::Signal | Symbol | String signal, 12 | *Object? args, 13 | ?cancellation: Cancellation, 14 | ?arg_hints: Array[Object]? 15 | ) -> void 16 | end 17 | end 18 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/workflow_execution_count.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class WorkflowExecutionCount 4 | attr_reader count: Integer 5 | attr_reader groups: Array[AggregationGroup] 6 | 7 | def initialize: (Integer count, Array[AggregationGroup] groups) -> void 8 | 9 | class AggregationGroup 10 | attr_reader count: Integer 11 | attr_reader group_values: Array[Object?] 12 | 13 | def initialize: (Integer count, Array[Object?] group_values) -> void 14 | end 15 | end 16 | end 17 | end -------------------------------------------------------------------------------- /temporalio/test/sig/worker_workflow_versioning_test.rbs: -------------------------------------------------------------------------------- 1 | class WorkerWorkflowVersioningTest < Test 2 | def _test_worker_deployment_dynamic_workflow: (untyped workflow_type, untyped expected_versioning_behavior) -> void 3 | def wait_until_worker_deployment_visible: (untyped client, Temporalio::WorkerDeploymentVersion version) -> untyped 4 | def set_current_deployment_version: (untyped client, String task_queue, Temporalio::WorkerDeploymentVersion version) -> untyped 5 | def set_ramping_version: (untyped client, String task_queue, Temporalio::WorkerDeploymentVersion version, Float rate) -> untyped 6 | end 7 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/client/workflow_query_reject_condition.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | 5 | module Temporalio 6 | class Client 7 | # Whether a query should be rejected in certain conditions. 8 | module WorkflowQueryRejectCondition 9 | NONE = Api::Enums::V1::QueryRejectCondition::QUERY_REJECT_CONDITION_NONE 10 | NOT_OPEN = Api::Enums::V1::QueryRejectCondition::QUERY_REJECT_CONDITION_NOT_OPEN 11 | NOT_COMPLETED_CLEANLY = Api::Enums::V1::QueryRejectCondition::QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/activity/cancellation_details.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Activity 3 | class CancellationDetails 4 | def initialize: ( 5 | ?gone_from_server: bool, 6 | ?cancel_requested: bool, 7 | ?timed_out: bool, 8 | ?worker_shutdown: bool, 9 | ?paused: bool, 10 | ?reset: bool 11 | ) -> void 12 | 13 | def gone_from_server?: -> bool 14 | def cancel_requested?: -> bool 15 | def timed_out?: -> bool 16 | def worker_shutdown?: -> bool 17 | def paused?: -> bool 18 | def reset?: -> bool 19 | end 20 | end 21 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/deployment_options.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class DeploymentOptions 4 | attr_reader version: WorkerDeploymentVersion 5 | attr_reader use_worker_versioning: bool 6 | attr_reader default_versioning_behavior: VersioningBehavior::enum 7 | 8 | def initialize: ( 9 | version: WorkerDeploymentVersion, 10 | ?use_worker_versioning: bool, 11 | ?default_versioning_behavior: VersioningBehavior::enum 12 | ) -> void 13 | 14 | def _to_bridge_options: -> Internal::Bridge::Worker::DeploymentOptions 15 | end 16 | end 17 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/update_info.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Workflow 5 | # Information about a workflow update 6 | # 7 | # @!attribute id 8 | # @return [String] Update ID. 9 | # @!attribute name 10 | # @return [String] Update name. 11 | # 12 | # @note WARNING: This class may have required parameters added to its constructor. Users should not instantiate this 13 | # class or it may break in incompatible ways. 14 | UpdateInfo = Struct.new( 15 | :id, 16 | :name, 17 | keyword_init: true 18 | ) 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/common_enums.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module WorkflowIDReusePolicy 3 | type enum = Integer 4 | 5 | ALLOW_DUPLICATE: enum 6 | ALLOW_DUPLICATE_FAILED_ONLY: enum 7 | REJECT_DUPLICATE: enum 8 | TERMINATE_IF_RUNNING: enum 9 | end 10 | 11 | module WorkflowIDConflictPolicy 12 | type enum = Integer 13 | 14 | UNSPECIFIED: enum 15 | FAIL: enum 16 | USE_EXISTING: enum 17 | TERMINATE_EXISTING: enum 18 | end 19 | 20 | module VersioningBehavior 21 | type enum = Integer 22 | 23 | UNSPECIFIED: enum 24 | PINNED: enum 25 | AUTO_UPGRADE: enum 26 | end 27 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker_deployment_version.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class WorkerDeploymentVersion 3 | attr_reader deployment_name: String 4 | attr_reader build_id: String 5 | 6 | def self.from_canonical_string: (String canonical) -> WorkerDeploymentVersion 7 | 8 | def self._from_bridge: (untyped bridge) -> WorkerDeploymentVersion? 9 | 10 | def initialize: (deployment_name: String, build_id: String) -> void 11 | 12 | def to_canonical_string: -> String 13 | 14 | def _to_bridge_options: -> Internal::Bridge::Worker::WorkerDeploymentVersion 15 | def _to_proto: -> untyped 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/handler_execution.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class HandlerExecution 6 | attr_reader name: String 7 | attr_reader update_id: String? 8 | attr_reader unfinished_policy: Workflow::HandlerUnfinishedPolicy::enum 9 | 10 | def initialize: ( 11 | name: String, 12 | update_id: String?, 13 | unfinished_policy: Workflow::HandlerUnfinishedPolicy::enum 14 | ) -> void 15 | end 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/client/implementation.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Client 4 | class Implementation < Temporalio::Client::Interceptor::Outbound 5 | def self.with_default_rpc_options: (Temporalio::Client::RPCOptions? user_rpc_options) -> Temporalio::Client::RPCOptions 6 | 7 | def initialize: (Temporalio::Client client) -> void 8 | 9 | def _start_workflow_request_from_with_start_options: ( 10 | untyped klass, Temporalio::Client::WithStartWorkflowOperation::Options start_options 11 | ) -> untyped 12 | end 13 | end 14 | end 15 | end -------------------------------------------------------------------------------- /temporalio/test/base64_codec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | require 'temporalio/converters/payload_codec' 5 | 6 | class Base64Codec < Temporalio::Converters::PayloadCodec 7 | def encode(payloads) 8 | payloads.map do |p| 9 | Temporalio::Api::Common::V1::Payload.new( 10 | metadata: { 'encoding' => 'test/base64' }, 11 | data: Base64.strict_encode64(p.to_proto) 12 | ) 13 | end 14 | end 15 | 16 | def decode(payloads) 17 | payloads.map do |p| 18 | Temporalio::Api::Common::V1::Payload.decode( 19 | Base64.strict_decode64(p.data) 20 | ) 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/child_workflow_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class ChildWorkflowHandle < Workflow::ChildWorkflowHandle 6 | def initialize: ( 7 | id: String, 8 | first_execution_run_id: String, 9 | instance: WorkflowInstance, 10 | cancellation: Cancellation, 11 | cancel_callback_key: Object, 12 | result_hint: Object? 13 | ) -> void 14 | 15 | def _resolve: (untyped resolution) -> void 16 | end 17 | end 18 | end 19 | end 20 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/retry_policy.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class RetryPolicy 3 | attr_reader initial_interval: duration 4 | attr_reader backoff_coefficient: duration 5 | attr_reader max_interval: duration? 6 | attr_reader max_attempts: Integer 7 | attr_reader non_retryable_error_types: Array[String]? 8 | 9 | def self._from_proto: (untyped raw_policy) -> RetryPolicy 10 | 11 | def initialize: ( 12 | ?initial_interval: duration, 13 | ?backoff_coefficient: duration, 14 | ?max_interval: duration?, 15 | ?max_attempts: Integer, 16 | ?non_retryable_error_types: Array[String]? 17 | ) -> void 18 | 19 | def _to_proto: -> untyped 20 | end 21 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/payload_converter.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class PayloadConverter 4 | def self.default: -> PayloadConverter 5 | 6 | def self.new_with_defaults: ( 7 | ?json_parse_options: Hash[Symbol, untyped], 8 | ?json_generate_options: Hash[Symbol, untyped] 9 | ) -> PayloadConverter 10 | 11 | def to_payload: (Object? value, ?hint: Object?) -> untyped 12 | def to_payloads: (Array[Object?] values, ?hints: Array[Object]?) -> untyped 13 | 14 | def from_payload: (untyped payload, ?hint: Object?) -> Object? 15 | def from_payloads: (untyped payloads, ?hints: Array[Object]?) -> Array[Object?] 16 | end 17 | end 18 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/externally_immutable_hash.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'delegate' 4 | 5 | module Temporalio 6 | module Internal 7 | module Worker 8 | class WorkflowInstance 9 | # Delegator to a hash that does not allow external mutations. Used for memo. 10 | class ExternallyImmutableHash < SimpleDelegator 11 | def initialize(initial_hash) 12 | super(initial_hash.freeze) 13 | end 14 | 15 | def _update(&) 16 | new_hash = __getobj__.dup 17 | yield new_hash 18 | __setobj__(new_hash.freeze) 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/workflow_update_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class WorkflowUpdateHandle 4 | attr_reader id: String 5 | attr_reader workflow_id: String 6 | attr_reader workflow_run_id: String? 7 | attr_reader result_hint: Object? 8 | 9 | def initialize: ( 10 | client: Client, 11 | id: String, 12 | workflow_id: String, 13 | workflow_run_id: String?, 14 | known_outcome: untyped?, 15 | result_hint: Object? 16 | ) -> void 17 | 18 | def result_obtained?: -> bool 19 | 20 | def result: ( 21 | ?result_hint: Object?, 22 | ?rpc_options: RPCOptions? 23 | ) -> Object? 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/client/workflow_update_wait_stage.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | 5 | module Temporalio 6 | class Client 7 | # Stage to wait for workflow update to reach before returning from {WorkflowHandle.start_update}. 8 | module WorkflowUpdateWaitStage 9 | ADMITTED = 10 | Api::Enums::V1::UpdateWorkflowExecutionLifecycleStage::UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ADMITTED 11 | ACCEPTED = 12 | Api::Enums::V1::UpdateWorkflowExecutionLifecycleStage::UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED 13 | COMPLETED = 14 | Api::Enums::V1::UpdateWorkflowExecutionLifecycleStage::UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/bridge/metric.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Bridge 4 | class Metric 5 | def initialize: ( 6 | Meter meter, 7 | Symbol metric_type, 8 | String name, 9 | String? description, 10 | String? unit, 11 | Symbol value_type 12 | ) -> void 13 | 14 | def record_value: (untyped value, Attributes attrs) -> void 15 | 16 | class Meter 17 | def initialize: (Runtime runtime) -> void 18 | 19 | def default_attributes: -> Attributes 20 | end 21 | 22 | class Attributes 23 | def with_additional: (Hash[untyped, untyped] attrs) -> Attributes 24 | end 25 | end 26 | end 27 | end 28 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/inbound_implementation.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class InboundImplementation < Temporalio::Worker::Interceptor::Workflow::Inbound 6 | def initialize: (WorkflowInstance instance) -> void 7 | 8 | def invoke_handler: ( 9 | String name, 10 | Temporalio::Worker::Interceptor::Workflow::HandleSignalInput | 11 | Temporalio::Worker::Interceptor::Workflow::HandleQueryInput | 12 | Temporalio::Worker::Interceptor::Workflow::HandleUpdateInput input, 13 | ?to_invoke: Symbol | Proc | nil 14 | ) -> Object? 15 | end 16 | end 17 | end 18 | end 19 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/cancellation.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Cancellation 3 | def initialize: (*Cancellation parents) -> void 4 | 5 | def canceled?: -> bool 6 | def canceled_reason: -> String? 7 | def pending_canceled?: -> bool 8 | def pending_canceled_reason: -> String? 9 | def check!: (?Exception err) -> void 10 | def to_ary: -> [Cancellation, Proc] 11 | def wait: -> void 12 | def shield: [T] { (?) -> T } -> T 13 | def add_cancel_callback: { -> untyped } -> Object 14 | def remove_cancel_callback: (Object key) -> void 15 | 16 | private def on_cancel: (reason: Object?) -> void 17 | private def prepare_cancel: (reason: Object?) -> Array[Proc]? 18 | private def canceled_mutex_synchronize: [T] { (?) -> T } -> T 19 | end 20 | end -------------------------------------------------------------------------------- /temporalio/rbs_collection.yaml: -------------------------------------------------------------------------------- 1 | sources: 2 | - type: git 3 | name: ruby/gem_rbs_collection 4 | remote: https://github.com/ruby/gem_rbs_collection.git 5 | revision: main 6 | repo_dir: gems 7 | 8 | path: .gem_rbs_collection 9 | 10 | gems: 11 | # Bad/unnecessary RBS 12 | # - name: activesupport 13 | # ignore: true 14 | - name: ast 15 | ignore: true 16 | # - name: concurrent-ruby 17 | # ignore: true 18 | - name: connection_pool 19 | ignore: true 20 | - name: diff-lcs 21 | ignore: true 22 | - name: listen 23 | ignore: true 24 | - name: parser 25 | ignore: true 26 | - name: rainbow 27 | ignore: true 28 | - name: rake 29 | ignore: true 30 | - name: rubocop 31 | ignore: true 32 | - name: rubocop-ast 33 | ignore: true 34 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/raw_value.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Converters 5 | # Raw value wrapper that has the raw payload. When raw args are configured at implementation time, the inbound 6 | # arguments will be instances of this class. When instances of this class are sent outbound or returned from 7 | # inbound calls, the raw payload will be serialized instead of applying traditional conversion. 8 | class RawValue 9 | # @return [Api::Common::V1::Payload] Payload. 10 | attr_reader :payload 11 | 12 | # Create a raw value. 13 | # 14 | # @param payload [Api::Common::V1::Payload] Payload. 15 | def initialize(payload) 16 | @payload = payload 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/poller_behavior.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class PollerBehavior 4 | def _to_bridge_options: -> untyped 5 | end 6 | 7 | class SimpleMaximum < PollerBehavior 8 | attr_reader maximum: Integer 9 | 10 | def initialize: (Integer) -> void 11 | def _to_bridge_options: -> Internal::Bridge::Worker::PollerBehaviorSimpleMaximum 12 | end 13 | 14 | class Autoscaling < PollerBehavior 15 | attr_reader minimum: Integer 16 | attr_reader maximum: Integer 17 | attr_reader initial: Integer 18 | 19 | def initialize: (?minimum: Integer, ?maximum: Integer, ?initial: Integer) -> void 20 | def _to_bridge_options: -> Internal::Bridge::Worker::PollerBehaviorAutoscaling 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/scheduler.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class Scheduler 6 | def initialize: (WorkflowInstance instance) -> void 7 | 8 | def context: -> Context 9 | 10 | def run_until_all_yielded: -> void 11 | 12 | def wait_condition: [T] (cancellation: Cancellation?) { -> T } -> T 13 | 14 | def stack_trace: -> String 15 | 16 | # Only needed to say block is required 17 | def timeout_after: [T] ( 18 | duration? duration, 19 | singleton(Exception) exception_class, 20 | *Object? exception_args 21 | ) { -> T } -> T 22 | end 23 | end 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/workflow/future.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Workflow 3 | class Future[unchecked out T] 4 | def self.any_of: [T] (*Future[T] futures) -> Future[T] 5 | def self.all_of: (*Future[untyped] futures) -> Future[nil] 6 | def self.try_any_of: [T] (*Future[T] futures) -> Future[Future[T]] 7 | def self.try_all_of: (*Future[untyped] futures) -> Future[nil] 8 | 9 | attr_reader result: T? 10 | attr_reader failure: Exception? 11 | 12 | def initialize: ?{ -> T } -> void 13 | 14 | def done?: -> bool 15 | def result?: -> bool 16 | def result=: (T result) -> void 17 | def failure?: -> bool 18 | def failure=: (Exception failure) -> void 19 | 20 | def wait: -> T 21 | def wait_no_raise: -> T? 22 | end 23 | end 24 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/handler_execution.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Internal 5 | module Worker 6 | class WorkflowInstance 7 | # Representation of a currently-executing handler. Used to track whether any handlers are still running and warn 8 | # on workflow complete as needed. 9 | class HandlerExecution 10 | attr_reader :name, :update_id, :unfinished_policy 11 | 12 | def initialize( 13 | name:, 14 | update_id:, 15 | unfinished_policy: 16 | ) 17 | @name = name 18 | @update_id = update_id 19 | @unfinished_policy = unfinished_policy 20 | end 21 | end 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/illegal_workflow_call_validator.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class IllegalWorkflowCallValidator 4 | class CallInfo 5 | attr_reader class_name: String 6 | attr_reader method_name: Symbol 7 | attr_reader trace_point: TracePoint 8 | 9 | def initialize: ( 10 | class_name: String, 11 | method_name: Symbol, 12 | trace_point: TracePoint 13 | ) -> void 14 | end 15 | 16 | def self.default_time_validators: -> Array[IllegalWorkflowCallValidator] 17 | def self.known_safe_mutex_validator: -> IllegalWorkflowCallValidator 18 | 19 | attr_reader method_name: Symbol? 20 | attr_reader block: ^(CallInfo) -> void 21 | 22 | def initialize: (?method_name: Symbol?) { (CallInfo) -> void } -> void 23 | end 24 | end 25 | end -------------------------------------------------------------------------------- /temporalio/ext/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "temporalio_bridge" 3 | version = "0.1.0" 4 | edition = "2024" 5 | authors = ["Chad Retz "] 6 | license = "MIT" 7 | publish = false 8 | 9 | [lib] 10 | crate-type = ["cdylib"] 11 | 12 | [dependencies] 13 | async-trait = "0.1" 14 | futures = "0.3" 15 | log = "0.4" 16 | magnus = "0.7" 17 | parking_lot = "0.12" 18 | prost = { workspace = true } 19 | rb-sys = "0.9" 20 | temporalio-client = { version = "0.1.0", path = "./sdk-core/crates/client" } 21 | temporalio-common = { version = "0.1.0", path = "./sdk-core/crates/common", features = ["envconfig"] } 22 | temporalio-sdk-core = { version = "0.1.0", path = "./sdk-core/crates/sdk-core", features = ["ephemeral-server"] } 23 | tokio = "1.47" 24 | tokio-stream = "0.1" 25 | tokio-util = "0.7" 26 | tonic = { workspace = true } 27 | tracing = "0.1" 28 | url = "2.5" 29 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/testing/activity_environment.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Testing 3 | class ActivityEnvironment 4 | def self.default_info: -> Activity::Info 5 | 6 | def initialize: ( 7 | ?info: Activity::Info, 8 | ?on_heartbeat: Proc?, 9 | ?cancellation: Cancellation, 10 | ?on_cancellation_details: Proc?, 11 | ?worker_shutdown_cancellation: Cancellation, 12 | ?payload_converter: Converters::PayloadConverter, 13 | ?logger: Logger, 14 | ?activity_executors: Hash[Symbol, Worker::ActivityExecutor], 15 | ?metric_meter: Metric::Meter?, 16 | ?client: Client? 17 | ) -> void 18 | 19 | def run: ( 20 | Activity::Definition | singleton(Activity::Definition) | Activity::Definition::Info activity, 21 | *Object? args 22 | ) -> untyped 23 | end 24 | end 25 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/worker/workflow_executor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/worker/workflow_executor/thread_pool' 4 | 5 | module Temporalio 6 | class Worker 7 | # Workflow executor that executes workflow tasks. Unlike {ActivityExecutor}, this class is not meant for user 8 | # implementation. The only implementation that is currently accepted is {WorkflowExecutor::ThreadPool}. 9 | class WorkflowExecutor 10 | # @!visibility private 11 | def initialize 12 | raise 'Cannot create custom executors' 13 | end 14 | 15 | # @!visibility private 16 | def _validate_worker(workflow_worker, worker_state) 17 | raise NotImplementedError 18 | end 19 | 20 | # @!visibility private 21 | def _activate(activation, worker_state, &) 22 | raise NotImplementedError 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/parent_close_policy.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/bridge/api' 4 | 5 | module Temporalio 6 | module Workflow 7 | # How a child workflow should be handled when the parent closes. 8 | module ParentClosePolicy 9 | # Unset. 10 | UNSPECIFIED = Internal::Bridge::Api::ChildWorkflow::ParentClosePolicy::PARENT_CLOSE_POLICY_UNSPECIFIED 11 | # The child workflow will also terminate. 12 | TERMINATE = Internal::Bridge::Api::ChildWorkflow::ParentClosePolicy::PARENT_CLOSE_POLICY_TERMINATE 13 | # The child workflow will do nothing. 14 | ABANDON = Internal::Bridge::Api::ChildWorkflow::ParentClosePolicy::PARENT_CLOSE_POLICY_ABANDON 15 | # Cancellation will be requested of the child workflow. 16 | REQUEST_CANCEL = Internal::Bridge::Api::ChildWorkflow::ParentClosePolicy::PARENT_CLOSE_POLICY_REQUEST_CANCEL 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/client/workflow_execution_status.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | 5 | module Temporalio 6 | class Client 7 | # Status of a workflow execution. 8 | module WorkflowExecutionStatus 9 | RUNNING = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_RUNNING 10 | COMPLETED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_COMPLETED 11 | FAILED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_FAILED 12 | CANCELED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_CANCELED 13 | TERMINATED = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_TERMINATED 14 | CONTINUED_AS_NEW = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_CONTINUED_AS_NEW 15 | TIMED_OUT = Api::Enums::V1::WorkflowExecutionStatus::WORKFLOW_EXECUTION_STATUS_TIMED_OUT 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/activity/context.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Activity 3 | class Context 4 | def self.current: -> Context 5 | def self.current_or_nil: -> Context? 6 | def self.exist?: -> bool 7 | 8 | def self._current_executor: -> Worker::ActivityExecutor? 9 | def self._current_executor=: (Worker::ActivityExecutor? executor) -> void 10 | 11 | def info: -> Info 12 | def instance: -> Definition? 13 | def heartbeat: (*Object? details, ?detail_hints: Array[Object]?) -> void 14 | def cancellation: -> Cancellation 15 | def cancellation_details: -> CancellationDetails? 16 | def worker_shutdown_cancellation: -> Cancellation 17 | def payload_converter: -> Converters::PayloadConverter 18 | def logger: -> ScopedLogger 19 | 20 | def _scoped_logger_info: -> Hash[Symbol, Object] 21 | 22 | def metric_meter: -> Metric::Meter 23 | def client: -> Client 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/illegal_call_tracer.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class IllegalCallTracer 6 | def self.frozen_validated_illegal_calls: ( 7 | Hash[String, :all | Array[Symbol | Temporalio::Worker::IllegalWorkflowCallValidator] | Temporalio::Worker::IllegalWorkflowCallValidator] illegal_calls 8 | ) -> Hash[String, :all | Hash[Symbol, TrueClass | Temporalio::Worker::IllegalWorkflowCallValidator] | Temporalio::Worker::IllegalWorkflowCallValidator] 9 | 10 | def initialize: ( 11 | Hash[String, :all | Hash[Symbol, TrueClass | Temporalio::Worker::IllegalWorkflowCallValidator] | Temporalio::Worker::IllegalWorkflowCallValidator] illegal_calls 12 | ) -> void 13 | 14 | def enable: [T] { -> T } -> T 15 | def disable_temporarily: [T] { -> T } -> T 16 | end 17 | end 18 | end 19 | end 20 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/common/v1/grpc_status.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/common/v1/grpc_status.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/any_pb' 8 | 9 | 10 | descriptor_data = "\n(temporal/api/common/v1/grpc_status.proto\x12\x16temporal.api.common.v1\x1a\x19google/protobuf/any.proto\"R\n\nGrpcStatus\x12\x0c\n\x04\x63ode\x18\x01 \x01(\x05\x12\x0f\n\x07message\x18\x02 \x01(\t\x12%\n\x07\x64\x65tails\x18\x03 \x03(\x0b\x32\x14.google.protobuf.AnyB\x1e\xea\x02\x1bTemporalio::Api::Common::V1b\x06proto3" 11 | 12 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 13 | pool.add_serialized_file(descriptor_data) 14 | 15 | module Temporalio 16 | module Api 17 | module Common 18 | module V1 19 | GrpcStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.common.v1.GrpcStatus").msgclass 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/converters/data_converter.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Converters 3 | class DataConverter 4 | attr_reader payload_converter: PayloadConverter 5 | attr_reader failure_converter: FailureConverter 6 | attr_reader payload_codec: PayloadCodec? 7 | 8 | def self.default: -> DataConverter 9 | 10 | def initialize: ( 11 | ?payload_converter: PayloadConverter, 12 | ?failure_converter: FailureConverter, 13 | ?payload_codec: PayloadCodec? 14 | ) -> void 15 | 16 | def to_payload: (Object? value, ?hint: Object?) -> untyped 17 | def to_payloads: (Array[Object?] values, ?hints: Array[Object]?) -> untyped 18 | 19 | def from_payload: (untyped payload, ?hint: Object?) -> Object? 20 | def from_payloads: (untyped payloads, ?hints: Array[Object]?) -> Array[Object?] 21 | 22 | def to_failure: (Exception error) -> untyped 23 | def from_failure: (untyped failure) -> Exception 24 | end 25 | end 26 | end -------------------------------------------------------------------------------- /temporalio/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source 'https://rubygems.org' 4 | 5 | gemspec 6 | 7 | group :development do 8 | gem 'activemodel' 9 | gem 'activerecord' 10 | gem 'async' 11 | gem 'base64' 12 | gem 'grpc', '~> 1.69' 13 | gem 'grpc-tools', '~> 1.69' 14 | gem 'minitest' 15 | # Have to explicitly depend on openssl for macos issue in GH CI described at 16 | # https://github.com/rails/rails/issues/55886 until 3.4.8 is released 17 | gem 'openssl' if RUBY_PLATFORM.include?('darwin') 18 | # We are intentionally not pinning OTel versions here so that CI tests the latest. This also means that the OTel 19 | # contrib library also does not require specific versions, we are relying on the compatibility rigor of OTel. 20 | gem 'opentelemetry-api' 21 | gem 'opentelemetry-sdk' 22 | gem 'rake' 23 | gem 'rake-compiler' 24 | gem 'rbs', '~> 3.5.3' 25 | gem 'rb_sys', '~> 0.9.63' 26 | gem 'rubocop' 27 | gem 'sqlite3' 28 | gem 'steep', '~> 1.7.1' 29 | gem 'yard' 30 | end 31 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/payload_converter/binary_null.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | require 'temporalio/converters/payload_converter/encoding' 5 | 6 | module Temporalio 7 | module Converters 8 | class PayloadConverter 9 | # Encoding for +nil+ values for +binary/null+ encoding. 10 | class BinaryNull < Encoding 11 | ENCODING = 'binary/null' 12 | 13 | # (see Encoding.encoding) 14 | def encoding 15 | ENCODING 16 | end 17 | 18 | # (see Encoding.to_payload) 19 | def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 20 | return nil unless value.nil? 21 | 22 | Api::Common::V1::Payload.new( 23 | metadata: { 'encoding' => ENCODING } 24 | ) 25 | end 26 | 27 | # (see Encoding.from_payload) 28 | def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 29 | nil 30 | end 31 | end 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /temporalio/Cargo.toml: -------------------------------------------------------------------------------- 1 | # Ruby and rb-sys seem to require a Cargo.toml here at the gem root (see https://github.com/oxidize-rb/rb-sys/issues/405), 2 | # and Rust is broken if one workspace is nested within another without the ability to exclude (see 3 | # https://github.com/rust-lang/cargo/issues/6745). So we basically must copy sdk-core's workspace for now. 4 | # TODO(cretz): Fix this situation if possible without moving sdk-core submodule. 5 | 6 | [workspace] 7 | members = ["./ext"] 8 | resolver = "2" 9 | 10 | [workspace.package] 11 | license = "MIT" 12 | license-file = "LICENSE" 13 | 14 | [workspace.dependencies] 15 | derive_builder = "0.20" 16 | derive_more = { version = "2.0", features = ["constructor", "display", "from", "into", "debug", "try_into"] } 17 | thiserror = "2" 18 | tonic = "0.14" 19 | tonic-prost = "0.14" 20 | tonic-prost-build = "0.14" 21 | opentelemetry = { version = "0.31", features = ["metrics"] } 22 | prost = "0.14" 23 | prost-types = { version = "0.7", package = "prost-wkt-types" } 24 | 25 | [workspace.lints.rust] 26 | unreachable_pub = "warn" 27 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/client/activity_id_reference.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | require 'temporalio/client/interceptor' 5 | require 'temporalio/error' 6 | 7 | module Temporalio 8 | class Client 9 | # Reference to an existing activity by its workflow ID, run ID, and activity ID. 10 | class ActivityIDReference 11 | # @return [String] ID for the workflow. 12 | attr_reader :workflow_id 13 | 14 | # @return [String, nil] Run ID for the workflow. 15 | attr_reader :run_id 16 | 17 | # @return [String] ID for the activity. 18 | attr_reader :activity_id 19 | 20 | # Create an activity ID reference. 21 | # 22 | # @param workflow_id [String] ID for the workflow. 23 | # @param run_id [String, nil] Run ID for the workflow. 24 | # @param activity_id [String] ID for the workflow. 25 | def initialize(workflow_id:, run_id:, activity_id:) 26 | @workflow_id = workflow_id 27 | @run_id = run_id 28 | @activity_id = activity_id 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/connection/test_service.rbs: -------------------------------------------------------------------------------- 1 | # Generated code. DO NOT EDIT! 2 | 3 | module Temporalio 4 | class Client 5 | class Connection 6 | class TestService < Service 7 | def initialize: (Connection) -> void 8 | def lock_time_skipping: ( 9 | untyped request, 10 | ?rpc_options: RPCOptions? 11 | ) -> untyped 12 | def unlock_time_skipping: ( 13 | untyped request, 14 | ?rpc_options: RPCOptions? 15 | ) -> untyped 16 | def sleep: ( 17 | untyped request, 18 | ?rpc_options: RPCOptions? 19 | ) -> untyped 20 | def sleep_until: ( 21 | untyped request, 22 | ?rpc_options: RPCOptions? 23 | ) -> untyped 24 | def unlock_time_skipping_with_sleep: ( 25 | untyped request, 26 | ?rpc_options: RPCOptions? 27 | ) -> untyped 28 | def get_current_time: ( 29 | untyped request, 30 | ?rpc_options: RPCOptions? 31 | ) -> untyped 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/activity_cancellation_type.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/bridge/api' 4 | 5 | module Temporalio 6 | module Workflow 7 | # Cancellation types for activities. 8 | module ActivityCancellationType 9 | # Initiate a cancellation request and immediately report cancellation to the workflow. 10 | TRY_CANCEL = Internal::Bridge::Api::WorkflowCommands::ActivityCancellationType::TRY_CANCEL 11 | # Wait for activity cancellation completion. Note that activity must heartbeat to receive a cancellation 12 | # notification. This can block the cancellation for a long time if activity doesn't heartbeat or chooses to ignore 13 | # the cancellation request. 14 | WAIT_CANCELLATION_COMPLETED = 15 | Internal::Bridge::Api::WorkflowCommands::ActivityCancellationType::WAIT_CANCELLATION_COMPLETED 16 | # Do not request cancellation of the activity and immediately report cancellation to the workflow. 17 | ABANDON = Internal::Bridge::Api::WorkflowCommands::ActivityCancellationType::ABANDON 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/schedule_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class ScheduleHandle 4 | attr_reader id: String 5 | 6 | def initialize: ( 7 | client: Client, 8 | id: String 9 | ) -> void 10 | 11 | def backfill: ( 12 | *Schedule::Backfill backfills, 13 | ?rpc_options: RPCOptions? 14 | ) -> void 15 | 16 | def delete: ( 17 | ?rpc_options: RPCOptions? 18 | ) -> void 19 | 20 | def describe: ( 21 | ?rpc_options: RPCOptions? 22 | ) -> Schedule::Description 23 | 24 | def pause: ( 25 | ?note: String, 26 | ?rpc_options: RPCOptions? 27 | ) -> void 28 | 29 | def trigger: ( 30 | ?overlap: Schedule::OverlapPolicy::enum?, 31 | ?rpc_options: RPCOptions? 32 | ) -> void 33 | 34 | def unpause: ( 35 | ?note: String, 36 | ?rpc_options: RPCOptions? 37 | ) -> void 38 | 39 | def update: ( 40 | ?rpc_options: RPCOptions? 41 | ) { (Schedule::Update::Input) -> Schedule::Update? } -> void 42 | end 43 | end 44 | end -------------------------------------------------------------------------------- /temporalio/smoke_test/smoke_test_gem.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | raise 'Must provide gem file glob' if ARGV.length != 1 4 | 5 | gem_files = Dir.glob(ARGV.first) 6 | raise "Unable to find single gem file, found #{gem_files.length}" unless gem_files.length == 1 7 | 8 | # TODO(cretz): For Linux musl, we have to install google-protobuf manually because latest versions do not work with 9 | # musl. Remove this when https://github.com/protocolbuffers/protobuf/issues/16853 is resolved. 10 | if RUBY_PLATFORM.include?('linux-musl') 11 | system('gem', 'install', '--verbose', 'google-protobuf', '--platform', 'ruby', exception: true) 12 | end 13 | 14 | system('gem', 'install', '--verbose', gem_files.first, exception: true) 15 | 16 | # Create a local environment and start a workflow 17 | require 'temporalio/client' 18 | require 'temporalio/testing/workflow_environment' 19 | 20 | Temporalio::Testing::WorkflowEnvironment.start_local do |env| 21 | handle = env.client.start_workflow('MyWorkflow', id: 'my-workflow', task_queue: 'my-task-queue') 22 | puts "Successfully created workflow with run ID: #{handle.result_run_id}" 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/nexus.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/nexus.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n!temporal/api/enums/v1/nexus.proto\x12\x15temporal.api.enums.v1*\xbc\x01\n\x1eNexusHandlerErrorRetryBehavior\x12\x32\n.NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_UNSPECIFIED\x10\x00\x12\x30\n,NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_RETRYABLE\x10\x01\x12\x34\n0NEXUS_HANDLER_ERROR_RETRY_BEHAVIOR_NON_RETRYABLE\x10\x02\x42\x82\x01\n\x18io.temporal.api.enums.v1B\nNexusProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | NexusHandlerErrorRetryBehavior = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.NexusHandlerErrorRetryBehavior").enummodule 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /temporalio/temporalio.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require_relative 'lib/temporalio/version' 4 | 5 | Gem::Specification.new do |spec| 6 | spec.name = 'temporalio' 7 | spec.version = Temporalio::VERSION 8 | spec.authors = ['Temporal Technologies Inc'] 9 | spec.email = ['sdk@temporal.io'] 10 | 11 | spec.summary = 'Temporal.io Ruby SDK' 12 | spec.homepage = 'https://github.com/temporalio/sdk-ruby' 13 | spec.license = 'MIT' 14 | 15 | spec.metadata['homepage_uri'] = spec.homepage 16 | spec.metadata['source_code_uri'] = 'https://github.com/temporalio/sdk-ruby' 17 | 18 | spec.files = Dir['lib/**/*.rb', 'LICENSE', 'README.md', 'Cargo.*', 19 | 'temporalio.gemspec', 'Gemfile', 'Rakefile', '.yardopts'] 20 | 21 | spec.bindir = 'exe' 22 | spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } 23 | spec.require_paths = ['lib'] 24 | spec.extensions = ['ext/Cargo.toml'] 25 | spec.metadata['rubygems_mfa_required'] = 'true' 26 | spec.required_ruby_version = '>= 3.2.0' 27 | 28 | spec.add_dependency 'google-protobuf', '>= 3.25.0' 29 | spec.add_dependency 'logger' 30 | end 31 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/child_workflow_cancellation_type.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/bridge/api' 4 | 5 | module Temporalio 6 | module Workflow 7 | # Cancellation types for child workflows. 8 | module ChildWorkflowCancellationType 9 | # Do not request cancellation of the child workflow if already scheduled. 10 | ABANDON = Internal::Bridge::Api::ChildWorkflow::ChildWorkflowCancellationType::ABANDON 11 | # Initiate a cancellation request and immediately report cancellation to the parent. 12 | TRY_CANCEL = Internal::Bridge::Api::ChildWorkflow::ChildWorkflowCancellationType::TRY_CANCEL 13 | # Wait for child cancellation completion. 14 | WAIT_CANCELLATION_COMPLETED = 15 | Internal::Bridge::Api::ChildWorkflow::ChildWorkflowCancellationType::WAIT_CANCELLATION_COMPLETED 16 | # Request cancellation of the child and wait for confirmation that the request was received. 17 | WAIT_CANCELLATION_REQUESTED = 18 | Internal::Bridge::Api::ChildWorkflow::ChildWorkflowCancellationType::WAIT_CANCELLATION_REQUESTED 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/sdk/v1/user_metadata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/sdk/v1/user_metadata.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'temporalio/api/common/v1/message' 8 | 9 | 10 | descriptor_data = "\n\'temporal/api/sdk/v1/user_metadata.proto\x12\x13temporal.api.sdk.v1\x1a$temporal/api/common/v1/message.proto\"r\n\x0cUserMetadata\x12\x30\n\x07summary\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x30\n\x07\x64\x65tails\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadB\x7f\n\x16io.temporal.api.sdk.v1B\x11UserMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3" 11 | 12 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 13 | pool.add_serialized_file(descriptor_data) 14 | 15 | module Temporalio 16 | module Api 17 | module Sdk 18 | module V1 19 | UserMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.UserMetadata").msgclass 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/sdk/v1/task_complete_metadata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/sdk/v1/task_complete_metadata.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1\"x\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\tB\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Sdk 16 | module V1 17 | WorkflowTaskCompletedMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkflowTaskCompletedMetadata").msgclass 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/external_workflow_handle.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/cancellation' 4 | require 'temporalio/workflow' 5 | require 'temporalio/workflow/external_workflow_handle' 6 | 7 | module Temporalio 8 | module Internal 9 | module Worker 10 | class WorkflowInstance 11 | # Implementation of the external workflow handle. 12 | class ExternalWorkflowHandle < Workflow::ExternalWorkflowHandle 13 | attr_reader :id, :run_id 14 | 15 | def initialize(id:, run_id:, instance:) # rubocop:disable Lint/MissingSuper 16 | @id = id 17 | @run_id = run_id 18 | @instance = instance 19 | end 20 | 21 | def signal(signal, *args, cancellation: Workflow.cancellation, arg_hints: nil) 22 | @instance.context._signal_external_workflow(id:, run_id:, signal:, args:, cancellation:, arg_hints:) 23 | end 24 | 25 | def cancel 26 | @instance.context._cancel_external_workflow(id:, run_id:) 27 | end 28 | end 29 | end 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2024 Temporal Technologies Inc. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/payload_converter/binary_plain.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | require 'temporalio/converters/payload_converter/encoding' 5 | 6 | module Temporalio 7 | module Converters 8 | class PayloadConverter 9 | # Encoding for +ASCII_8BIT+ string values for +binary/plain+ encoding. 10 | class BinaryPlain < Encoding 11 | ENCODING = 'binary/plain' 12 | 13 | # (see Encoding.encoding) 14 | def encoding 15 | ENCODING 16 | end 17 | 18 | # (see Encoding.to_payload) 19 | def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 20 | return nil unless value.is_a?(String) && value.encoding == ::Encoding::ASCII_8BIT 21 | 22 | Temporalio::Api::Common::V1::Payload.new( 23 | metadata: { 'encoding' => ENCODING }, 24 | data: value 25 | ) 26 | end 27 | 28 | # (see Encoding.from_payload) 29 | def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 30 | payload.data 31 | end 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/workflow_execution.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class WorkflowExecution 4 | attr_reader raw_info: untyped 5 | 6 | def initialize: (untyped raw_info, Converters::DataConverter data_converter) -> void 7 | 8 | def close_time: -> Time? 9 | def execution_time: -> Time? 10 | def history_length: -> Integer 11 | def id: -> String 12 | def memo: -> Hash[String, Object?] 13 | def parent_id: -> String? 14 | def parent_run_id: -> String? 15 | def run_id: -> String 16 | def search_attributes: -> SearchAttributes? 17 | def start_time: -> Time 18 | def status: -> WorkflowExecutionStatus::enum 19 | def task_queue: -> String 20 | def workflow_type: -> String 21 | 22 | class Description < WorkflowExecution 23 | attr_reader raw_description: untyped 24 | 25 | def initialize: (untyped raw_description, Converters::DataConverter data_converter) -> void 26 | 27 | def static_summary: -> String? 28 | def static_details: -> String? 29 | 30 | private def user_metadata: -> [String?, String?] 31 | end 32 | end 33 | end 34 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/metric.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | class Metric < Temporalio::Metric 4 | def initialize: ( 5 | metric_type: (:counter | :histogram | :gauge), 6 | name: String, 7 | description: String?, 8 | unit: String?, 9 | value_type: (:integer | :float | :duration), 10 | bridge: Bridge::Metric, 11 | bridge_attrs: Bridge::Metric::Attributes 12 | ) -> void 13 | 14 | class Meter < Temporalio::Metric::Meter 15 | def self.create_from_runtime: (Runtime runtime) -> Meter? 16 | 17 | def initialize: (Bridge::Metric::Meter bridge, Bridge::Metric::Attributes bridge_attrs) -> void 18 | end 19 | 20 | class NullMeter < Temporalio::Metric::Meter 21 | def self.instance: -> NullMeter 22 | end 23 | 24 | class NullMetric < Temporalio::Metric 25 | def initialize: ( 26 | metric_type: (:counter | :histogram | :gauge), 27 | name: String, 28 | description: String?, 29 | unit: String?, 30 | value_type: (:integer | :float | :duration) 31 | ) -> void 32 | end 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/async_activity_handle.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Client 3 | class AsyncActivityHandle 4 | attr_reader task_token: String? 5 | attr_reader id_reference: ActivityIDReference? 6 | 7 | def initialize: ( 8 | client: Client, 9 | task_token: String?, 10 | id_reference: ActivityIDReference? 11 | ) -> void 12 | 13 | def heartbeat: ( 14 | *Object? details, 15 | ?detail_hints: Array[Object]?, 16 | ?rpc_options: RPCOptions? 17 | ) -> void 18 | 19 | def complete: ( 20 | ?Object? result, 21 | ?result_hint: Object?, 22 | ?rpc_options: RPCOptions? 23 | ) -> void 24 | 25 | def fail: ( 26 | Exception error, 27 | ?last_heartbeat_details: Array[Object?], 28 | ?last_heartbeat_detail_hints: Array[Object]?, 29 | ?rpc_options: RPCOptions? 30 | ) -> void 31 | 32 | def report_cancellation: ( 33 | *Object? details, 34 | ?detail_hints: Array[Object]?, 35 | ?rpc_options: RPCOptions? 36 | ) -> void 37 | 38 | private def task_token_or_id_reference: -> (String | ActivityIDReference) 39 | end 40 | end 41 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/protocol/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/protocol/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/any_pb' 8 | 9 | 10 | descriptor_data = "\n&temporal/api/protocol/v1/message.proto\x12\x18temporal.api.protocol.v1\x1a\x19google/protobuf/any.proto\"\x95\x01\n\x07Message\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x12\n\x08\x65vent_id\x18\x03 \x01(\x03H\x00\x12\x17\n\rcommand_index\x18\x04 \x01(\x03H\x00\x12\"\n\x04\x62ody\x18\x05 \x01(\x0b\x32\x14.google.protobuf.AnyB\x0f\n\rsequencing_idB\x93\x01\n\x1bio.temporal.api.protocol.v1B\x0cMessageProtoP\x01Z\'go.temporal.io/api/protocol/v1;protocol\xaa\x02\x1aTemporalio.Api.Protocol.V1\xea\x02\x1dTemporalio::Api::Protocol::V1b\x06proto3" 11 | 12 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 13 | pool.add_serialized_file(descriptor_data) 14 | 15 | module Temporalio 16 | module Api 17 | module Protocol 18 | module V1 19 | Message = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.protocol.v1.Message").msgclass 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/replay_safe_metric.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/scoped_logger' 4 | 5 | module Temporalio 6 | module Internal 7 | module Worker 8 | class WorkflowInstance 9 | # Wrapper for a metric that does not log on replay. 10 | class ReplaySafeMetric < SimpleDelegator 11 | def record(value, additional_attributes: nil) 12 | return if Temporalio::Workflow.in_workflow? && Temporalio::Workflow::Unsafe.replaying? 13 | 14 | super 15 | end 16 | 17 | def with_additional_attributes(additional_attributes) 18 | ReplaySafeMetric.new(super) 19 | end 20 | 21 | class Meter < SimpleDelegator 22 | def create_metric( 23 | metric_type, 24 | name, 25 | description: nil, 26 | unit: nil, 27 | value_type: :integer 28 | ) 29 | ReplaySafeMetric.new(super) 30 | end 31 | 32 | def with_additional_attributes(additional_attributes) 33 | Meter.new(super) 34 | end 35 | end 36 | end 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/payload_codec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Converters 5 | # Base class for encoding and decoding payloads. Commonly used for encryption. 6 | class PayloadCodec 7 | # Encode the given payloads into a new set of payloads. 8 | # 9 | # @param payloads [Enumerable] Payloads to encode. This value should not be mutated. 10 | # @return [Array] Encoded payloads. Note, this does not have to be the same number as 11 | # payloads given, but it must be at least one and cannot be more than was given. 12 | def encode(payloads) 13 | raise NotImplementedError 14 | end 15 | 16 | # Decode the given payloads into a new set of payloads. 17 | # 18 | # @param payloads [Enumerable] Payloads to decode. This value should not be mutated. 19 | # @return [Array] Decoded payloads. Note, this does not have to be the same number as 20 | # payloads given, but it must be at least one and cannot be more than was given. 21 | def decode(payloads) 22 | raise NotImplementedError 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/schedule.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/schedule.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n$temporal/api/enums/v1/schedule.proto\x12\x15temporal.api.enums.v1*\xb0\x02\n\x15ScheduleOverlapPolicy\x12\'\n#SCHEDULE_OVERLAP_POLICY_UNSPECIFIED\x10\x00\x12 \n\x1cSCHEDULE_OVERLAP_POLICY_SKIP\x10\x01\x12&\n\"SCHEDULE_OVERLAP_POLICY_BUFFER_ONE\x10\x02\x12&\n\"SCHEDULE_OVERLAP_POLICY_BUFFER_ALL\x10\x03\x12(\n$SCHEDULE_OVERLAP_POLICY_CANCEL_OTHER\x10\x04\x12+\n\'SCHEDULE_OVERLAP_POLICY_TERMINATE_OTHER\x10\x05\x12%\n!SCHEDULE_OVERLAP_POLICY_ALLOW_ALL\x10\x06\x42\x85\x01\n\x18io.temporal.api.enums.v1B\rScheduleProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | ScheduleOverlapPolicy = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.ScheduleOverlapPolicy").enummodule 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/outbound_implementation.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class OutboundImplementation < Temporalio::Worker::Interceptor::Workflow::Outbound 6 | def initialize: (WorkflowInstance instance) -> void 7 | 8 | def execute_activity_with_local_backoffs: ( 9 | local: bool, 10 | cancellation: Cancellation, 11 | result_hint: Object? 12 | ) { (untyped?) -> Integer } -> Object? 13 | 14 | def execute_activity_once: ( 15 | local: bool, 16 | cancellation: Cancellation, 17 | last_local_backoff: untyped?, 18 | result_hint: Object? 19 | ) { (untyped?) -> Integer } -> Object? 20 | 21 | def _signal_external_workflow: ( 22 | id: String, 23 | run_id: String?, 24 | child: bool, 25 | signal: Workflow::Definition::Signal | Symbol | String, 26 | args: Array[Object?], 27 | cancellation: Cancellation, 28 | arg_hints: Array[Object]?, 29 | headers: Hash[String, Object?] 30 | ) -> void 31 | end 32 | end 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/export/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/export/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'temporalio/api/history/v1/message' 8 | 9 | 10 | descriptor_data = "\n$temporal/api/export/v1/message.proto\x12\x16temporal.api.export.v1\x1a%temporal/api/history/v1/message.proto\"F\n\x11WorkflowExecution\x12\x31\n\x07history\x18\x01 \x01(\x0b\x32 .temporal.api.history.v1.History\"N\n\x12WorkflowExecutions\x12\x38\n\x05items\x18\x01 \x03(\x0b\x32).temporal.api.export.v1.WorkflowExecutionB\x89\x01\n\x19io.temporal.api.export.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/export/v1;export\xaa\x02\x18Temporalio.Api.Export.V1\xea\x02\x1bTemporalio::Api::Export::V1b\x06proto3" 11 | 12 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 13 | pool.add_serialized_file(descriptor_data) 14 | 15 | module Temporalio 16 | module Api 17 | module Export 18 | module V1 19 | WorkflowExecution = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.export.v1.WorkflowExecution").msgclass 20 | WorkflowExecutions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.export.v1.WorkflowExecutions").msgclass 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/client/workflow_execution_count.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | class Client 5 | # Representation of a count from a count workflows call. 6 | class WorkflowExecutionCount 7 | # @return [Integer] Approximate number of workflows matching the original query. If the query had a group-by 8 | # clause, this is simply the sum of all the counts in {groups}. 9 | attr_reader :count 10 | 11 | # @return [Array] Groups if the query had a group-by clause, or empty if not. 12 | attr_reader :groups 13 | 14 | # @!visibility private 15 | def initialize(count, groups) 16 | @count = count 17 | @groups = groups 18 | end 19 | 20 | # Aggregation group if the workflow count query had a group-by clause. 21 | class AggregationGroup 22 | # @return [Integer] Approximate number of workflows matching the original query for this group. 23 | attr_reader :count 24 | 25 | # @return [Array] Search attribute values for this group. 26 | attr_reader :group_values 27 | 28 | # @!visibility private 29 | def initialize(count, group_values) 30 | @count = count 31 | @group_values = group_values 32 | end 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/replay_safe_logger.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/scoped_logger' 4 | require 'temporalio/workflow' 5 | 6 | module Temporalio 7 | module Internal 8 | module Worker 9 | class WorkflowInstance 10 | # Wrapper for a scoped logger that does not log on replay. 11 | class ReplaySafeLogger < ScopedLogger 12 | def initialize(logger:, instance:) 13 | @instance = instance 14 | @replay_safety_disabled = false 15 | super(logger) 16 | end 17 | 18 | def replay_safety_disabled(&) 19 | @replay_safety_disabled = true 20 | yield 21 | ensure 22 | @replay_safety_disabled = false 23 | end 24 | 25 | def add(...) 26 | if !@replay_safety_disabled && Temporalio::Workflow.in_workflow? && Temporalio::Workflow::Unsafe.replaying? 27 | return true 28 | end 29 | 30 | # Disable scheduler since logs technically have local mutexes in them that cannot be done durably or they 31 | # will block workflows 32 | @instance.context.durable_scheduler_disabled do 33 | super 34 | end 35 | end 36 | end 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/client/connection/service.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'google/protobuf' 4 | require 'temporalio/api' 5 | require 'temporalio/error' 6 | 7 | module Temporalio 8 | class Client 9 | class Connection 10 | # Base class for raw gRPC services. 11 | class Service 12 | # @!visibility private 13 | def initialize(connection, service) 14 | @connection = connection 15 | @service = service 16 | end 17 | 18 | protected 19 | 20 | def invoke_rpc(rpc:, request_class:, response_class:, request:, rpc_options:) 21 | raise 'Invalid request type' unless request.is_a?(request_class) 22 | 23 | begin 24 | @connection._core_client._invoke_rpc( 25 | service: @service, 26 | rpc:, 27 | request:, 28 | response_class:, 29 | rpc_options: 30 | ) 31 | rescue Internal::Bridge::Client::RPCFailure => e 32 | if e.code == Error::RPCError::Code::CANCELED && e.message == '<__user_canceled__>' 33 | raise Error::CanceledError, 'User canceled' 34 | end 35 | 36 | raise Error::RPCError.new(e.message, code: e.code, raw_grpc_status: e.details) 37 | end 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/runtime/metric_buffer.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Runtime 3 | class MetricBuffer 4 | module DurationFormat 5 | type enum = Symbol 6 | 7 | MILLISECONDS: enum 8 | SECONDS: enum 9 | end 10 | 11 | class Update 12 | attr_reader metric: Metric 13 | attr_reader value: Integer | Float 14 | attr_reader attributes: Hash[String, String | Integer | Float | bool] 15 | 16 | def initialize: ( 17 | metric: Metric, 18 | value: Integer | Float, 19 | attributes: Hash[String, String | Integer | Float | bool] 20 | ) -> void 21 | end 22 | 23 | class Metric 24 | attr_reader name: String 25 | attr_reader description: String? 26 | attr_reader unit: String? 27 | attr_reader kind: (:counter | :histogram | :gauge) 28 | 29 | def initialize: ( 30 | name: String, 31 | description: String?, 32 | unit: String?, 33 | kind: (:counter | :histogram | :gauge) 34 | ) -> void 35 | end 36 | 37 | def initialize: ( 38 | Integer buffer_size, 39 | ?duration_format: DurationFormat::enum 40 | ) -> void 41 | 42 | def retrieve_updates: -> Array[Update] 43 | 44 | def _buffer_size: -> Integer 45 | 46 | def _set_runtime: (Runtime runtime) -> void 47 | end 48 | end 49 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/query.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/query.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n!temporal/api/enums/v1/query.proto\x12\x15temporal.api.enums.v1*r\n\x0fQueryResultType\x12!\n\x1dQUERY_RESULT_TYPE_UNSPECIFIED\x10\x00\x12\x1e\n\x1aQUERY_RESULT_TYPE_ANSWERED\x10\x01\x12\x1c\n\x18QUERY_RESULT_TYPE_FAILED\x10\x02*\xb6\x01\n\x14QueryRejectCondition\x12&\n\"QUERY_REJECT_CONDITION_UNSPECIFIED\x10\x00\x12\x1f\n\x1bQUERY_REJECT_CONDITION_NONE\x10\x01\x12#\n\x1fQUERY_REJECT_CONDITION_NOT_OPEN\x10\x02\x12\x30\n,QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY\x10\x03\x42\x82\x01\n\x18io.temporal.api.enums.v1B\nQueryProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | QueryResultType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.QueryResultType").enummodule 18 | QueryRejectCondition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.QueryRejectCondition").enummodule 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /temporalio/test/sig/worker_activity_test.rbs: -------------------------------------------------------------------------------- 1 | class WorkerActivityTest < Test 2 | def execute_activity: [T] ( 3 | untyped activity, 4 | *untyped args, 5 | ?retry_max_attempts: Integer, 6 | ?logger: Logger?, 7 | ?heartbeat_timeout: Float?, 8 | ?start_to_close_timeout: Float?, 9 | ?override_name: String?, 10 | ?cancel_on_signal: String?, 11 | ?wait_for_cancellation: bool, 12 | ?cancellation: Temporalio::Cancellation, 13 | ?raise_in_block_on_shutdown: bool, 14 | ?activity_executors: Hash[Symbol, Temporalio::Worker::ActivityExecutor], 15 | ?interceptors: Array[Temporalio::Worker::Interceptor::Activity], 16 | ?client: Temporalio::Client 17 | ) ?{ (Temporalio::Client::WorkflowHandle, Temporalio::Worker) -> T } -> T | ( 18 | untyped activity, 19 | *untyped args, 20 | ?retry_max_attempts: Integer, 21 | ?logger: Logger?, 22 | ?heartbeat_timeout: Float?, 23 | ?start_to_close_timeout: Float?, 24 | ?override_name: String?, 25 | ?cancel_on_signal: String?, 26 | ?wait_for_cancellation: bool, 27 | ?cancellation: Temporalio::Cancellation, 28 | ?raise_in_block_on_shutdown: bool, 29 | ?activity_executors: Hash[Symbol, Temporalio::Worker::ActivityExecutor], 30 | ?interceptors: Array[Temporalio::Worker::Interceptor::Activity], 31 | ?client: Temporalio::Client 32 | ) -> Object? 33 | 34 | def assert_multi_worker_activities: (?) -> untyped 35 | def assert_single_worker_activities: (?) -> untyped 36 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/cloud/resource/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/cloud/resource/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n,temporal/api/cloud/resource/v1/message.proto\x12\x1etemporal.api.cloud.resource.v1*\xe3\x02\n\rResourceState\x12\x1e\n\x1aRESOURCE_STATE_UNSPECIFIED\x10\x00\x12\x1d\n\x19RESOURCE_STATE_ACTIVATING\x10\x01\x12$\n RESOURCE_STATE_ACTIVATION_FAILED\x10\x02\x12\x19\n\x15RESOURCE_STATE_ACTIVE\x10\x03\x12\x1b\n\x17RESOURCE_STATE_UPDATING\x10\x04\x12 \n\x1cRESOURCE_STATE_UPDATE_FAILED\x10\x05\x12\x1b\n\x17RESOURCE_STATE_DELETING\x10\x06\x12 \n\x1cRESOURCE_STATE_DELETE_FAILED\x10\x07\x12\x1a\n\x16RESOURCE_STATE_DELETED\x10\x08\x12\x1c\n\x18RESOURCE_STATE_SUSPENDED\x10\t\x12\x1a\n\x16RESOURCE_STATE_EXPIRED\x10\nB\xac\x01\n!io.temporal.api.cloud.resource.v1B\x0cMessageProtoP\x01Z-go.temporal.io/api/cloud/resource/v1;resource\xaa\x02 Temporalio.Api.Cloud.Resource.V1\xea\x02$Temporalio::Api::Cloud::Resource::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Cloud 16 | module Resource 17 | module V1 18 | ResourceState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.resource.v1.ResourceState").enummodule 19 | end 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/payload_converter/json_protobuf.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'google/protobuf' 4 | require 'temporalio/api' 5 | require 'temporalio/converters/payload_converter/encoding' 6 | 7 | module Temporalio 8 | module Converters 9 | class PayloadConverter 10 | # Encoding for Protobuf values for +json/protobuf+ encoding. 11 | class JSONProtobuf < Encoding 12 | ENCODING = 'json/protobuf' 13 | 14 | # (see Encoding.encoding) 15 | def encoding 16 | ENCODING 17 | end 18 | 19 | # (see Encoding.to_payload) 20 | def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 21 | return nil unless value.is_a?(Google::Protobuf::MessageExts) 22 | 23 | Api::Common::V1::Payload.new( 24 | metadata: { 'encoding' => ENCODING, 'messageType' => value.class.descriptor.name }, 25 | data: value.to_json.b 26 | ) 27 | end 28 | 29 | # (see Encoding.from_payload) 30 | def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 31 | type = payload.metadata['messageType'] 32 | # @type var desc: untyped 33 | desc = Google::Protobuf::DescriptorPool.generated_pool.lookup(type) 34 | raise "No protobuf message found in global pool for message type #{type}" unless desc 35 | 36 | desc.msgclass.decode_json(payload.data) 37 | end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/update.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/update.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n\"temporal/api/enums/v1/update.proto\x12\x15temporal.api.enums.v1*\x8b\x02\n%UpdateWorkflowExecutionLifecycleStage\x12\x39\n5UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_UNSPECIFIED\x10\x00\x12\x36\n2UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ADMITTED\x10\x01\x12\x36\n2UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_ACCEPTED\x10\x02\x12\x37\n3UPDATE_WORKFLOW_EXECUTION_LIFECYCLE_STAGE_COMPLETED\x10\x03*s\n\x19UpdateAdmittedEventOrigin\x12,\n(UPDATE_ADMITTED_EVENT_ORIGIN_UNSPECIFIED\x10\x00\x12(\n$UPDATE_ADMITTED_EVENT_ORIGIN_REAPPLY\x10\x01\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bUpdateProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | UpdateWorkflowExecutionLifecycleStage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.UpdateWorkflowExecutionLifecycleStage").enummodule 18 | UpdateAdmittedEventOrigin = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.UpdateAdmittedEventOrigin").enummodule 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /temporalio/test/golangworker/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/cretz/temporal-sdk-ruby-poc/temporalio/test/golangworker 2 | 3 | go 1.23.0 4 | 5 | require go.temporal.io/sdk v1.29.1 6 | 7 | require ( 8 | github.com/davecgh/go-spew v1.1.1 // indirect 9 | github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect 10 | github.com/gogo/protobuf v1.3.2 // indirect 11 | github.com/golang/mock v1.6.0 // indirect 12 | github.com/google/uuid v1.6.0 // indirect 13 | github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect 14 | github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect 15 | github.com/nexus-rpc/sdk-go v0.0.10 // indirect 16 | github.com/pborman/uuid v1.2.1 // indirect 17 | github.com/pmezard/go-difflib v1.0.0 // indirect 18 | github.com/robfig/cron v1.2.0 // indirect 19 | github.com/stretchr/objx v0.5.2 // indirect 20 | github.com/stretchr/testify v1.9.0 // indirect 21 | go.temporal.io/api v1.39.0 // indirect 22 | golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect 23 | golang.org/x/net v0.38.0 // indirect 24 | golang.org/x/sync v0.12.0 // indirect 25 | golang.org/x/sys v0.31.0 // indirect 26 | golang.org/x/text v0.23.0 // indirect 27 | golang.org/x/time v0.7.0 // indirect 28 | google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect 29 | google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect 30 | google.golang.org/grpc v1.67.1 // indirect 31 | google.golang.org/protobuf v1.35.1 // indirect 32 | gopkg.in/yaml.v3 v3.0.1 // indirect 33 | ) 34 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow_history.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/api' 4 | 5 | module Temporalio 6 | # Representation of a workflow's history. 7 | class WorkflowHistory 8 | # Convert a JSON string to workflow history. This supports the JSON format exported by Temporal UI and CLI. 9 | # 10 | # @param json [String] JSON string. 11 | # @return [WorkflowHistory] Converted history. 12 | def self.from_history_json(json) 13 | WorkflowHistory.new(Api::History::V1::History.decode_json(json).events.to_a) 14 | end 15 | 16 | # @return [Array] History events for the workflow. 17 | attr_reader :events 18 | 19 | # @!visibility private 20 | def initialize(events) 21 | @events = events 22 | end 23 | 24 | # @return [String] ID of the workflow, extracted from the first event. 25 | def workflow_id 26 | start = events.first&.workflow_execution_started_event_attributes 27 | raise 'First event not a start event' if start.nil? 28 | 29 | start.workflow_id 30 | end 31 | 32 | # Convert to history JSON. 33 | # 34 | # @return [String] JSON string. 35 | def to_history_json 36 | Api::History::V1::History.encode_json(Api::History::V1::History.new(events:)) 37 | end 38 | 39 | # Compare history. 40 | # 41 | # @param other [WorkflowHistory] Other history. 42 | # @return [Boolean] True if equal. 43 | def ==(other) 44 | other.is_a?(WorkflowHistory) && events == other.events 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/metric.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Metric 3 | def record: ( 4 | Numeric value, 5 | ?additional_attributes: Hash[String | Symbol, String | Integer | Float | bool]? 6 | ) -> void 7 | 8 | def with_additional_attributes: ( 9 | Hash[String | Symbol, String | Integer | Float | bool] additional_attributes 10 | ) -> Metric 11 | 12 | def metric_type: -> (:counter | :histogram | :gauge) 13 | 14 | def name: -> String 15 | 16 | def description: -> String? 17 | 18 | def unit: -> String? 19 | 20 | def value_type: -> (:integer | :float | :duration) 21 | 22 | class Meter 23 | def self.null: -> Meter 24 | 25 | def create_metric: 26 | ( 27 | :counter metric_type, 28 | String name, 29 | ?description: String?, 30 | ?unit: String?, 31 | ?value_type: :integer 32 | ) -> Metric 33 | | 34 | ( 35 | :histogram metric_type, 36 | String name, 37 | ?description: String?, 38 | ?unit: String?, 39 | ?value_type: (:integer | :float | :duration) 40 | ) -> Metric 41 | | 42 | ( 43 | :gauge metric_type, 44 | String name, 45 | ?description: String?, 46 | ?unit: String?, 47 | ?value_type: (:integer | :float) 48 | ) -> Metric 49 | 50 | def with_additional_attributes: ( 51 | Hash[String | Symbol, String | Integer | Float | bool] additional_attributes 52 | ) -> Meter 53 | end 54 | end 55 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/cloud/region/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/cloud/region/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n*temporal/api/cloud/region/v1/message.proto\x12\x1ctemporal.api.cloud.region.v1\"\x99\x02\n\x06Region\x12\n\n\x02id\x18\x01 \x01(\t\x12%\n\x19\x63loud_provider_deprecated\x18\x02 \x01(\tB\x02\x18\x01\x12J\n\x0e\x63loud_provider\x18\x05 \x01(\x0e\x32\x32.temporal.api.cloud.region.v1.Region.CloudProvider\x12\x1d\n\x15\x63loud_provider_region\x18\x03 \x01(\t\x12\x10\n\x08location\x18\x04 \x01(\t\"_\n\rCloudProvider\x12\x1e\n\x1a\x43LOUD_PROVIDER_UNSPECIFIED\x10\x00\x12\x16\n\x12\x43LOUD_PROVIDER_AWS\x10\x01\x12\x16\n\x12\x43LOUD_PROVIDER_GCP\x10\x02\x42\xa2\x01\n\x1fio.temporal.api.cloud.region.v1B\x0cMessageProtoP\x01Z)go.temporal.io/api/cloud/region/v1;region\xaa\x02\x1eTemporalio.Api.Cloud.Region.V1\xea\x02\"Temporalio::Api::Cloud::Region::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Cloud 16 | module Region 17 | module V1 18 | Region = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.region.v1.Region").msgclass 19 | Region::CloudProvider = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.region.v1.Region.CloudProvider").enummodule 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/payload_converter/binary_protobuf.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'google/protobuf' 4 | require 'temporalio/api' 5 | require 'temporalio/converters/payload_converter/encoding' 6 | 7 | module Temporalio 8 | module Converters 9 | class PayloadConverter 10 | # Encoding for Protobuf values for +binary/protobuf+ encoding. 11 | class BinaryProtobuf < Encoding 12 | ENCODING = 'binary/protobuf' 13 | 14 | # (see Encoding.encoding) 15 | def encoding 16 | ENCODING 17 | end 18 | 19 | # (see Encoding.to_payload) 20 | def to_payload(value, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 21 | return nil unless value.is_a?(Google::Protobuf::MessageExts) 22 | 23 | # @type var value: Google::Protobuf::MessageExts 24 | Api::Common::V1::Payload.new( 25 | metadata: { 'encoding' => ENCODING, 'messageType' => value.class.descriptor.name }, 26 | data: value.to_proto 27 | ) 28 | end 29 | 30 | # (see Encoding.from_payload) 31 | def from_payload(payload, hint: nil) # rubocop:disable Lint/UnusedMethodArgument 32 | type = payload.metadata['messageType'] 33 | # @type var desc: untyped 34 | desc = Google::Protobuf::DescriptorPool.generated_pool.lookup(type) 35 | raise "No protobuf message found in global pool for message type #{type}" unless desc 36 | 37 | desc.msgclass.decode(payload.data) 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/external_workflow_handle.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/workflow' 4 | 5 | module Temporalio 6 | module Workflow 7 | # Handle for interacting with an external workflow. 8 | # 9 | # This is created via {Workflow.external_workflow_handle}, it is never instantiated directly. 10 | class ExternalWorkflowHandle 11 | # @!visibility private 12 | def initialize 13 | raise NotImplementedError, 'Cannot instantiate an external handle directly' 14 | end 15 | 16 | # @return [String] ID for the workflow. 17 | def id 18 | raise NotImplementedError 19 | end 20 | 21 | # @return [String, nil] Run ID for the workflow. 22 | def run_id 23 | raise NotImplementedError 24 | end 25 | 26 | # Signal the external workflow. 27 | # 28 | # @param signal [Workflow::Definition::Signal, Symbol, String] Signal definition or name. 29 | # @param args [Array] Signal args. 30 | # @param cancellation [Cancellation] Cancellation for canceling the signalling. 31 | # @param arg_hints [Array, nil] Overrides converter hints for arguments if any. If unset/nil and the 32 | # signal definition has arg hints, those are used by default. 33 | def signal(signal, *args, cancellation: Workflow.cancellation, arg_hints: nil) 34 | raise NotImplementedError 35 | end 36 | 37 | # Cancel the external workflow. 38 | def cancel 39 | raise NotImplementedError 40 | end 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge/api/common/common.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/sdk/core/common/common.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/duration_pb' 8 | 9 | 10 | descriptor_data = "\n%temporal/sdk/core/common/common.proto\x12\x0e\x63oresdk.common\x1a\x1egoogle/protobuf/duration.proto\"U\n\x1bNamespacedWorkflowExecution\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\"D\n\x17WorkerDeploymentVersion\x12\x17\n\x0f\x64\x65ployment_name\x18\x01 \x01(\t\x12\x10\n\x08\x62uild_id\x18\x02 \x01(\t*@\n\x10VersioningIntent\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCOMPATIBLE\x10\x01\x12\x0b\n\x07\x44\x45\x46\x41ULT\x10\x02\x42,\xea\x02)Temporalio::Internal::Bridge::Api::Commonb\x06proto3" 11 | 12 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 13 | pool.add_serialized_file(descriptor_data) 14 | 15 | module Temporalio 16 | module Internal 17 | module Bridge 18 | module Api 19 | module Common 20 | NamespacedWorkflowExecution = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.NamespacedWorkflowExecution").msgclass 21 | WorkerDeploymentVersion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.WorkerDeploymentVersion").msgclass 22 | VersioningIntent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.common.VersioningIntent").enummodule 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/thread_pool.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class ThreadPool 4 | def self.default: -> ThreadPool 5 | 6 | def self._monotonic_time: -> Float 7 | 8 | def initialize: ( 9 | ?max_threads: Integer?, 10 | ?idle_timeout: Float 11 | ) -> void 12 | 13 | def execute: { -> void } -> void 14 | 15 | def largest_length: -> Integer 16 | def scheduled_task_count: -> Integer 17 | def completed_task_count: -> Integer 18 | def active_count: -> Integer 19 | def length: -> Integer 20 | def queue_length: -> Integer 21 | def shutdown: -> void 22 | def kill: -> void 23 | 24 | def _remove_busy_worker: (Worker worker) -> void 25 | def _ready_worker: (Worker worker, Float last_message) -> void 26 | def _worker_died: (Worker worker) -> void 27 | def _worker_task_completed: -> void 28 | private def locked_assign_worker: { (?) -> untyped } -> void 29 | private def locked_enqueue: { (?) -> untyped } -> void 30 | private def locked_add_busy_worker: -> Worker? 31 | private def locked_prune_pool: -> void 32 | private def locked_remove_busy_worker: (Worker worker) -> void 33 | private def locked_ready_worker: (Worker worker, Float last_message) -> void 34 | private def locked_worker_died: (Worker worker) -> void 35 | 36 | class Worker 37 | def initialize: (ThreadPool pool, Integer id) -> void 38 | def <<: (Proc block) -> void 39 | def stop: -> void 40 | def kill: -> void 41 | end 42 | end 43 | end 44 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/worker/deployment_options.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/common_enums' 4 | require 'temporalio/worker_deployment_version' 5 | 6 | module Temporalio 7 | class Worker 8 | DeploymentOptions = Data.define( 9 | :version, 10 | :use_worker_versioning, 11 | :default_versioning_behavior 12 | ) 13 | 14 | # Options for configuring the Worker Versioning feature. 15 | # 16 | # WARNING: Deployment-based versioning is experimental and APIs may change. 17 | # 18 | # @!attribute version 19 | # @return [WorkerDeploymentVersion] The worker deployment version. 20 | # @!attribute use_worker_versioning 21 | # @return [Boolean] Whether worker versioning is enabled. 22 | # @!attribute default_versioning_behavior 23 | # @return [VersioningBehavior] The default versioning behavior. 24 | class DeploymentOptions 25 | def initialize( 26 | version:, 27 | use_worker_versioning: false, 28 | default_versioning_behavior: VersioningBehavior::UNSPECIFIED 29 | ) 30 | super 31 | end 32 | 33 | # @!visibility private 34 | def _to_bridge_options 35 | Internal::Bridge::Worker::DeploymentOptions.new( 36 | version: Internal::Bridge::Worker::WorkerDeploymentVersion.new( 37 | deployment_name: version.deployment_name, build_id: version.build_id 38 | ), 39 | use_worker_versioning: use_worker_versioning, 40 | default_versioning_behavior: default_versioning_behavior 41 | ) 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Use Ruby-version-specific Rust library if present. When the gem is compiled 4 | # via the cross-gem action, it is placed in a version specific directory. E.g. 5 | # for the Linux gem as of this writing, there will be files at: 6 | # * temporalio/internal/bridge/3.2/temporalio_bridge.so 7 | # * temporalio/internal/bridge/3.3/temporalio_bridge.so 8 | # * temporalio/internal/bridge/3.4/temporalio_bridge.so 9 | # We fallback to just temporalio/internal/bridge/temporalio_bridge.so because 10 | # rake compile puts it there during manual build/development. 11 | begin 12 | RUBY_VERSION =~ /(\d+\.\d+)/ 13 | require "temporalio/internal/bridge/#{Regexp.last_match(1)}/temporalio_bridge" 14 | rescue LoadError 15 | require 'temporalio/internal/bridge/temporalio_bridge' 16 | end 17 | 18 | module Temporalio 19 | module Internal 20 | module Bridge 21 | def self.assert_fiber_compatibility! 22 | return unless Fiber.current_scheduler && !fibers_supported 23 | 24 | raise 'Temporal SDK only supports fibers with Ruby 3.3 and newer, ' \ 25 | 'see https://github.com/temporalio/sdk-ruby/issues/162' 26 | end 27 | 28 | def self.fibers_supported # rubocop:disable Naming/PredicateMethod 29 | # We do not allow fibers on < 3.3 due to a bug we still need to dig 30 | # into: https://github.com/temporalio/sdk-ruby/issues/162 31 | major, minor = RUBY_VERSION.split('.').take(2).map(&:to_i) 32 | !major.nil? && major >= 3 && !minor.nil? && minor >= 3 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/handler_hash.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Internal 5 | module Worker 6 | class WorkflowInstance 7 | # Hash for handlers that notifies when one is added. Only `[]=` and `store` can be used to mutate it. 8 | class HandlerHash < SimpleDelegator 9 | def initialize(initial_frozen_hash, definition_class, &on_new_definition) 10 | super(initial_frozen_hash) 11 | @definition_class = definition_class 12 | @on_new_definition = on_new_definition 13 | end 14 | 15 | def []=(name, definition) 16 | store(name, definition) 17 | end 18 | 19 | # steep:ignore:start 20 | def store(name, definition) 21 | raise ArgumentError, 'Name must be a string or nil' unless name.nil? || name.is_a?(String) 22 | 23 | unless definition.nil? || definition.is_a?(@definition_class) 24 | raise ArgumentError, 25 | "Value must be a #{@definition_class.name} or nil" 26 | end 27 | raise ArgumentError, 'Name does not match one in definition' if definition && name != definition.name 28 | 29 | # Do a copy-on-write op on the underlying frozen hash 30 | new_hash = __getobj__.dup 31 | new_hash[name] = definition 32 | __setobj__(new_hash.freeze) 33 | @on_new_definition&.call(definition) unless definition.nil? 34 | definition 35 | end 36 | # steep:ignore:end 37 | end 38 | end 39 | end 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /temporalio/test/sig/test.rbs: -------------------------------------------------------------------------------- 1 | class Test < Minitest::Test 2 | include ExtraAssertions 3 | include WorkflowUtils 4 | 5 | ATTR_KEY_TEXT: Temporalio::SearchAttributes::Key 6 | ATTR_KEY_KEYWORD: Temporalio::SearchAttributes::Key 7 | ATTR_KEY_INTEGER: Temporalio::SearchAttributes::Key 8 | ATTR_KEY_FLOAT: Temporalio::SearchAttributes::Key 9 | ATTR_KEY_BOOLEAN: Temporalio::SearchAttributes::Key 10 | ATTR_KEY_TIME: Temporalio::SearchAttributes::Key 11 | ATTR_KEY_KEYWORD_LIST: Temporalio::SearchAttributes::Key 12 | 13 | def self.also_run_all_tests_in_fiber: -> void 14 | 15 | def skip_if_fibers_not_supported!: -> void 16 | def skip_if_not_x86!: -> void 17 | 18 | def env: -> TestEnvironment 19 | 20 | def run_in_background: { (?) -> untyped } -> (Thread | Fiber) 21 | 22 | def find_free_port: -> Integer 23 | def assert_no_schedules: -> void 24 | def delete_schedules: (*String ids) -> void 25 | 26 | def safe_capture_io: { (?) -> untyped } -> [String, String] 27 | 28 | class TestEnvironment 29 | include Singleton 30 | 31 | # Need manual instance method: https://github.com/ruby/rbs/issues/1498 32 | def self.instance: -> TestEnvironment 33 | 34 | attr_reader server: Temporalio::Testing::WorkflowEnvironment 35 | 36 | def client: -> Temporalio::Client 37 | 38 | def with_kitchen_sink_worker: [T] ( 39 | ?Temporalio::Client worker_client, 40 | ?task_queue: String 41 | ) { (String task_queue) -> T } -> T 42 | 43 | def kitchen_sink_exe: -> String 44 | 45 | def ensure_common_search_attribute_keys: -> void 46 | 47 | def ensure_search_attribute_keys: (*Temporalio::SearchAttributes::Key keys) -> void 48 | end 49 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge/runtime.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Internal 5 | module Bridge 6 | class Runtime 7 | Options = Struct.new( 8 | :telemetry, 9 | :worker_heartbeat_interval, 10 | keyword_init: true 11 | ) 12 | 13 | TelemetryOptions = Struct.new( 14 | :logging, # Optional 15 | :metrics, # Optional 16 | keyword_init: true 17 | ) 18 | 19 | LoggingOptions = Struct.new( 20 | :log_filter, 21 | :forward_to, # Optional 22 | keyword_init: true 23 | ) 24 | 25 | MetricsOptions = Struct.new( 26 | :opentelemetry, # Optional 27 | :prometheus, # Optional 28 | :buffered_with_size, # Optional 29 | :attach_service_name, 30 | :global_tags, # Optional 31 | :metric_prefix, # Optional 32 | keyword_init: true 33 | ) 34 | 35 | OpenTelemetryMetricsOptions = Struct.new( 36 | :url, 37 | :headers, # Optional 38 | :metric_periodicity, # Optional 39 | :metric_temporality_delta, 40 | :durations_as_seconds, 41 | :http, 42 | :histogram_bucket_overrides, # Optional 43 | keyword_init: true 44 | ) 45 | 46 | PrometheusMetricsOptions = Struct.new( 47 | :bind_address, 48 | :counters_total_suffix, 49 | :unit_suffix, 50 | :durations_as_seconds, 51 | :histogram_bucket_overrides, # Optional 52 | keyword_init: true 53 | ) 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/namespace.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/namespace.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n%temporal/api/enums/v1/namespace.proto\x12\x15temporal.api.enums.v1*\x8e\x01\n\x0eNamespaceState\x12\x1f\n\x1bNAMESPACE_STATE_UNSPECIFIED\x10\x00\x12\x1e\n\x1aNAMESPACE_STATE_REGISTERED\x10\x01\x12\x1e\n\x1aNAMESPACE_STATE_DEPRECATED\x10\x02\x12\x1b\n\x17NAMESPACE_STATE_DELETED\x10\x03*h\n\rArchivalState\x12\x1e\n\x1a\x41RCHIVAL_STATE_UNSPECIFIED\x10\x00\x12\x1b\n\x17\x41RCHIVAL_STATE_DISABLED\x10\x01\x12\x1a\n\x16\x41RCHIVAL_STATE_ENABLED\x10\x02*s\n\x10ReplicationState\x12!\n\x1dREPLICATION_STATE_UNSPECIFIED\x10\x00\x12\x1c\n\x18REPLICATION_STATE_NORMAL\x10\x01\x12\x1e\n\x1aREPLICATION_STATE_HANDOVER\x10\x02\x42\x86\x01\n\x18io.temporal.api.enums.v1B\x0eNamespaceProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | NamespaceState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.NamespaceState").enummodule 18 | ArchivalState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.ArchivalState").enummodule 19 | ReplicationState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.ReplicationState").enummodule 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/activity/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/activity/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'temporalio/api/common/v1/message' 8 | require 'temporalio/api/taskqueue/v1/message' 9 | require 'google/protobuf/duration_pb' 10 | 11 | 12 | descriptor_data = "\n&temporal/api/activity/v1/message.proto\x12\x18temporal.api.activity.v1\x1a$temporal/api/common/v1/message.proto\x1a\'temporal/api/taskqueue/v1/message.proto\x1a\x1egoogle/protobuf/duration.proto\"\xf3\x02\n\x0f\x41\x63tivityOptions\x12\x38\n\ntask_queue\x18\x01 \x01(\x0b\x32$.temporal.api.taskqueue.v1.TaskQueue\x12<\n\x19schedule_to_close_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\x03 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x06 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicyB\x93\x01\n\x1bio.temporal.api.activity.v1B\x0cMessageProtoP\x01Z\'go.temporal.io/api/activity/v1;activity\xaa\x02\x1aTemporalio.Api.Activity.V1\xea\x02\x1dTemporalio::Api::Activity::V1b\x06proto3" 13 | 14 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 15 | pool.add_serialized_file(descriptor_data) 16 | 17 | module Temporalio 18 | module Api 19 | module Activity 20 | module V1 21 | ActivityOptions = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.activity.v1.ActivityOptions").msgclass 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge/api/external_data/external_data.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/sdk/core/external_data/external_data.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/duration_pb' 8 | require 'google/protobuf/timestamp_pb' 9 | 10 | 11 | descriptor_data = "\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xfe\x01\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3" 12 | 13 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 14 | pool.add_serialized_file(descriptor_data) 15 | 16 | module Temporalio 17 | module Internal 18 | module Bridge 19 | module Api 20 | module ExternalData 21 | LocalActivityMarkerData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.external_data.LocalActivityMarkerData").msgclass 22 | PatchedMarkerData = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.external_data.PatchedMarkerData").msgclass 23 | end 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/worker/activity_executor/fiber.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/error' 4 | require 'temporalio/worker/activity_executor' 5 | 6 | module Temporalio 7 | class Worker 8 | class ActivityExecutor 9 | # Activity executor for scheduling activites as fibers. 10 | class Fiber 11 | # @return [Fiber] Default/shared Fiber executor instance. 12 | def self.default 13 | @default ||= new 14 | end 15 | 16 | # @see ActivityExecutor.initialize_activity 17 | def initialize_activity(defn) 18 | # If there is not a current scheduler, we're going to preemptively 19 | # fail the registration 20 | return unless ::Fiber.current_scheduler.nil? 21 | 22 | raise ArgumentError, "Activity '#{defn.name}' wants a fiber executor but no current fiber scheduler" 23 | end 24 | 25 | # @see ActivityExecutor.initialize_activity 26 | def execute_activity(_defn, &) 27 | ::Fiber.schedule(&) 28 | end 29 | 30 | # @see ActivityExecutor.activity_context 31 | def activity_context 32 | ::Fiber[:temporal_activity_context] 33 | end 34 | 35 | # @see ActivityExecutor.set_activity_context 36 | def set_activity_context(defn, context) 37 | ::Fiber[:temporal_activity_context] = context 38 | # If they have opted in to raising on cancel, wire that up 39 | return unless defn.cancel_raise 40 | 41 | fiber = ::Fiber.current 42 | context&.cancellation&.add_cancel_callback do 43 | fiber.raise(Error::CanceledError.new('Activity canceled')) 44 | end 45 | end 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/worker/activity_executor/thread_pool.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/worker/thread_pool' 4 | 5 | module Temporalio 6 | class Worker 7 | class ActivityExecutor 8 | # Activity executor for scheduling activities in their own thread using {Worker::ThreadPool}. 9 | class ThreadPool < ActivityExecutor 10 | # @return [ThreadPool] Default/shared thread pool executor using default thread pool. 11 | def self.default 12 | @default ||= new 13 | end 14 | 15 | # Create a new thread pool executor. 16 | # 17 | # @param thread_pool [Worker::ThreadPool] Thread pool to use. 18 | def initialize(thread_pool = Worker::ThreadPool.default) # rubocop:disable Lint/MissingSuper 19 | @thread_pool = thread_pool 20 | end 21 | 22 | # @see ActivityExecutor.execute_activity 23 | def execute_activity(_defn, &) 24 | @thread_pool.execute(&) 25 | end 26 | 27 | # @see ActivityExecutor.activity_context 28 | def activity_context 29 | Thread.current[:temporal_activity_context] 30 | end 31 | 32 | # @see ActivityExecutor.set_activity_context 33 | def set_activity_context(defn, context) 34 | Thread.current[:temporal_activity_context] = context 35 | # If they have opted in to raising on cancel, wire that up 36 | return unless defn.cancel_raise 37 | 38 | thread = Thread.current 39 | context&.cancellation&.add_cancel_callback do 40 | thread.raise(Error::CanceledError.new('Activity canceled')) if thread[:temporal_activity_context] == context 41 | end 42 | end 43 | end 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/worker/workflow_executor/thread_pool.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Worker 3 | class WorkflowExecutor 4 | class ThreadPool < WorkflowExecutor 5 | def self.default: -> ThreadPool 6 | 7 | def initialize: ( 8 | ?max_threads: Integer, 9 | ?thread_pool: Temporalio::Worker::ThreadPool 10 | ) -> void 11 | 12 | def _thread_pool: -> Temporalio::Worker::ThreadPool 13 | 14 | def _remove_workflow: ( 15 | Internal::Worker::WorkflowWorker::State worker_state, 16 | String run_id 17 | ) -> void 18 | 19 | class Worker 20 | LOG_ACTIVATIONS: bool 21 | 22 | attr_accessor workflow_count: Integer 23 | 24 | def initialize: (ThreadPool executor) -> void 25 | 26 | def enqueue_activation: ( 27 | untyped activation, 28 | Internal::Worker::WorkflowWorker::State worker_state 29 | ) { (untyped completion) -> void } -> void 30 | 31 | def shutdown: -> void 32 | 33 | def run: -> void 34 | 35 | def activate: ( 36 | untyped activation, 37 | Internal::Worker::WorkflowWorker::State worker_state 38 | ) { (untyped completion) -> void } -> void 39 | 40 | def create_instance: ( 41 | untyped initial_activation, 42 | Internal::Worker::WorkflowWorker::State worker_state 43 | ) -> Internal::Worker::WorkflowInstance 44 | 45 | def evict: ( 46 | Internal::Worker::WorkflowWorker::State worker_state, 47 | String run_id, 48 | untyped cache_remove_job 49 | ) -> void 50 | end 51 | 52 | class DeadlockError < Exception 53 | end 54 | end 55 | end 56 | end 57 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/sdk/v1/worker_config.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/sdk/v1/worker_config.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n\'temporal/api/sdk/v1/worker_config.proto\x12\x13temporal.api.sdk.v1\"\x89\x03\n\x0cWorkerConfig\x12\x1b\n\x13workflow_cache_size\x18\x01 \x01(\x05\x12X\n\x16simple_poller_behavior\x18\x02 \x01(\x0b\x32\x36.temporal.api.sdk.v1.WorkerConfig.SimplePollerBehaviorH\x00\x12\x62\n\x1b\x61utoscaling_poller_behavior\x18\x03 \x01(\x0b\x32;.temporal.api.sdk.v1.WorkerConfig.AutoscalingPollerBehaviorH\x00\x1a+\n\x14SimplePollerBehavior\x12\x13\n\x0bmax_pollers\x18\x01 \x01(\x05\x1a^\n\x19\x41utoscalingPollerBehavior\x12\x13\n\x0bmin_pollers\x18\x01 \x01(\x05\x12\x13\n\x0bmax_pollers\x18\x02 \x01(\x05\x12\x17\n\x0finitial_pollers\x18\x03 \x01(\x05\x42\x11\n\x0fpoller_behaviorB\x7f\n\x16io.temporal.api.sdk.v1B\x11WorkerConfigProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Sdk 16 | module V1 17 | WorkerConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkerConfig").msgclass 18 | WorkerConfig::SimplePollerBehavior = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkerConfig.SimplePollerBehavior").msgclass 19 | WorkerConfig::AutoscalingPollerBehavior = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkerConfig.AutoscalingPollerBehavior").msgclass 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/activity/definition.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Activity 3 | class Definition 4 | def self.activity_name: (String | Symbol name) -> void 5 | def self.activity_executor: (Symbol executor_name) -> void 6 | def self.activity_cancel_raise: (bool cancel_raise) -> void 7 | def self.activity_dynamic: (?bool value) -> void 8 | def self.activity_raw_args: (?bool value) -> void 9 | def self.activity_arg_hint: (*Object hints) -> void 10 | def self.activity_result_hint: (Object? hint) -> void 11 | 12 | def self._activity_definition_details: -> { 13 | activity_name: String | Symbol | nil, 14 | activity_executor: Symbol, 15 | activity_cancel_raise: bool, 16 | activity_raw_args: bool, 17 | activity_arg_hints: Array[Object]?, 18 | activity_result_hint: Object? 19 | } 20 | 21 | def execute: (*untyped) -> untyped 22 | 23 | class Info 24 | attr_reader name: String | Symbol | nil 25 | attr_reader instance: Object | Proc | nil 26 | attr_reader proc: Proc 27 | attr_reader executor: Symbol 28 | attr_reader cancel_raise: bool 29 | attr_reader raw_args: bool 30 | attr_reader arg_hints: Array[Object]? 31 | attr_reader result_hint: Object? 32 | 33 | def self.from_activity: (Definition | singleton(Definition) | Info activity) -> Info 34 | 35 | def initialize: ( 36 | name: String | Symbol | nil, 37 | ?instance: Object | Proc | nil, 38 | ?executor: Symbol, 39 | ?cancel_raise: bool, 40 | ?raw_args: bool, 41 | ?arg_hints: Array[Object]?, 42 | ?result_hint: Object? 43 | ) { (?) -> untyped } -> void 44 | end 45 | end 46 | end 47 | end -------------------------------------------------------------------------------- /temporalio/test/sig/contrib/open_telemetry_test.rbs: -------------------------------------------------------------------------------- 1 | module Contrib 2 | class OpenTelemetryTest < Test 3 | def init_tracer_and_exporter: -> [untyped, untyped] 4 | def trace: ( 5 | ?tracer_and_exporter: [untyped, untyped], 6 | ?always_create_workflow_spans: bool, 7 | ?check_root: bool, 8 | ?append_finished_spans_to: Array[untyped]? 9 | ) { (Temporalio::Client) -> void } -> untyped 10 | def trace_workflow: ( 11 | Symbol scenario, 12 | ?tracer_and_exporter: [untyped, untyped], 13 | ?start_with_untraced_client: bool, 14 | ?always_create_workflow_spans: bool, 15 | ?check_root: bool, 16 | ?append_finished_spans_to: Array[untyped]? 17 | ) { (Temporalio::Client::WorkflowHandle) -> void } -> untyped 18 | 19 | class ExpectedSpan 20 | def self.from_span_data: (untyped all_spans) -> Array[ExpectedSpan] 21 | 22 | attr_reader name: String 23 | attr_reader children: Array[ExpectedSpan] 24 | attr_reader attributes: Hash[untyped, untyped] 25 | attr_reader links: Array[ExpectedSpan] 26 | attr_reader exception_message: String? 27 | attr_reader status_ok: bool 28 | 29 | def initialize: ( 30 | name: String, 31 | ?children: Array[ExpectedSpan], 32 | ?attributes: Hash[untyped, untyped], 33 | ?links: Array[ExpectedSpan], 34 | ?exception_message: String?, 35 | ?status_ok: bool 36 | ) -> void 37 | 38 | def add_child: ( 39 | name: String, 40 | ?attributes: Hash[untyped, untyped], 41 | ?links: Array[ExpectedSpan], 42 | ?exception_message: String?, 43 | ?status_ok: bool, 44 | ?insert_at: Integer? 45 | ) -> ExpectedSpan 46 | 47 | def to_s_indented: (?indent: String) -> String 48 | end 49 | end 50 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/converters/payload_converter/encoding.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Converters 5 | class PayloadConverter 6 | # Base class for encoding converters that can be used for {Composite} converters. Each converter has an {encoding} 7 | # that should be set on the Payload metadata for values it can process. Implementers must implement {encoding} 8 | class Encoding 9 | # @return [String] Encoding that will be put on the payload metadata if this encoding converter can handle the 10 | # value. 11 | def encoding 12 | raise NotImplementedError 13 | end 14 | 15 | # Convert value to payload if this encoding converter can handle it, or return +nil+. If the converter can 16 | # handle it, the resulting payload must have +encoding+ metadata on the payload set to the value of {encoding}. 17 | # 18 | # @param value [Object] Ruby value to possibly convert. 19 | # @param hint [Object, nil] Hint, if any, to assist conversion. 20 | # @return [Api::Common::V1::Payload, nil] Converted payload if it can handle it, +nil+ otherwise. 21 | def to_payload(value, hint: nil) 22 | raise NotImplementedError 23 | end 24 | 25 | # Convert the payload to a Ruby value. The caller confirms the +encoding+ metadata matches {encoding}, so this 26 | # will error if it cannot convert. 27 | # 28 | # @param payload [Api::Common::V1::Payload] Payload to convert. 29 | # @param hint [Object, nil] Hint, if any, to assist conversion. 30 | # @return [Object] Converted Ruby value. 31 | def from_payload(payload, hint: nil) 32 | raise NotImplementedError 33 | end 34 | end 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/reset.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/reset.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n!temporal/api/enums/v1/reset.proto\x12\x15temporal.api.enums.v1*\xec\x01\n\x17ResetReapplyExcludeType\x12*\n&RESET_REAPPLY_EXCLUDE_TYPE_UNSPECIFIED\x10\x00\x12%\n!RESET_REAPPLY_EXCLUDE_TYPE_SIGNAL\x10\x01\x12%\n!RESET_REAPPLY_EXCLUDE_TYPE_UPDATE\x10\x02\x12$\n RESET_REAPPLY_EXCLUDE_TYPE_NEXUS\x10\x03\x12\x31\n)RESET_REAPPLY_EXCLUDE_TYPE_CANCEL_REQUEST\x10\x04\x1a\x02\x08\x01*\x97\x01\n\x10ResetReapplyType\x12\"\n\x1eRESET_REAPPLY_TYPE_UNSPECIFIED\x10\x00\x12\x1d\n\x19RESET_REAPPLY_TYPE_SIGNAL\x10\x01\x12\x1b\n\x17RESET_REAPPLY_TYPE_NONE\x10\x02\x12#\n\x1fRESET_REAPPLY_TYPE_ALL_ELIGIBLE\x10\x03*n\n\tResetType\x12\x1a\n\x16RESET_TYPE_UNSPECIFIED\x10\x00\x12\"\n\x1eRESET_TYPE_FIRST_WORKFLOW_TASK\x10\x01\x12!\n\x1dRESET_TYPE_LAST_WORKFLOW_TASK\x10\x02\x42\x82\x01\n\x18io.temporal.api.enums.v1B\nResetProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | ResetReapplyExcludeType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.ResetReapplyExcludeType").enummodule 18 | ResetReapplyType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.ResetReapplyType").enummodule 19 | ResetType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.ResetType").enummodule 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/testservice/v1/service.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/testservice/v1/service.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'temporalio/api/testservice/v1/request_response' 8 | require 'google/protobuf/empty_pb' 9 | 10 | 11 | descriptor_data = "\n)temporal/api/testservice/v1/service.proto\x12\x1btemporal.api.testservice.v1\x1a\x32temporal/api/testservice/v1/request_response.proto\x1a\x1bgoogle/protobuf/empty.proto2\xc2\x05\n\x0bTestService\x12\x81\x01\n\x10LockTimeSkipping\x12\x34.temporal.api.testservice.v1.LockTimeSkippingRequest\x1a\x35.temporal.api.testservice.v1.LockTimeSkippingResponse\"\x00\x12\x87\x01\n\x12UnlockTimeSkipping\x12\x36.temporal.api.testservice.v1.UnlockTimeSkippingRequest\x1a\x37.temporal.api.testservice.v1.UnlockTimeSkippingResponse\"\x00\x12`\n\x05Sleep\x12).temporal.api.testservice.v1.SleepRequest\x1a*.temporal.api.testservice.v1.SleepResponse\"\x00\x12j\n\nSleepUntil\x12..temporal.api.testservice.v1.SleepUntilRequest\x1a*.temporal.api.testservice.v1.SleepResponse\"\x00\x12v\n\x1bUnlockTimeSkippingWithSleep\x12).temporal.api.testservice.v1.SleepRequest\x1a*.temporal.api.testservice.v1.SleepResponse\"\x00\x12_\n\x0eGetCurrentTime\x12\x16.google.protobuf.Empty\x1a\x33.temporal.api.testservice.v1.GetCurrentTimeResponse\"\x00\x42\xa2\x01\n\x1eio.temporal.api.testservice.v1B\x0cServiceProtoP\x01Z-go.temporal.io/api/testservice/v1;testservice\xaa\x02\x1dTemporalio.Api.TestService.V1\xea\x02 Temporalio::Api::TestService::V1b\x06proto3" 12 | 13 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 14 | pool.add_serialized_file(descriptor_data) 15 | 16 | module Temporalio 17 | module Api 18 | module TestService 19 | module V1 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/sdk/v1/workflow_metadata.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/sdk/v1/workflow_metadata.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n+temporal/api/sdk/v1/workflow_metadata.proto\x12\x13temporal.api.sdk.v1\"h\n\x10WorkflowMetadata\x12;\n\ndefinition\x18\x01 \x01(\x0b\x32\'.temporal.api.sdk.v1.WorkflowDefinition\x12\x17\n\x0f\x63urrent_details\x18\x02 \x01(\t\"\x91\x02\n\x12WorkflowDefinition\x12\x0c\n\x04type\x18\x01 \x01(\t\x12M\n\x11query_definitions\x18\x02 \x03(\x0b\x32\x32.temporal.api.sdk.v1.WorkflowInteractionDefinition\x12N\n\x12signal_definitions\x18\x03 \x03(\x0b\x32\x32.temporal.api.sdk.v1.WorkflowInteractionDefinition\x12N\n\x12update_definitions\x18\x04 \x03(\x0b\x32\x32.temporal.api.sdk.v1.WorkflowInteractionDefinition\"B\n\x1dWorkflowInteractionDefinition\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\tB\x83\x01\n\x16io.temporal.api.sdk.v1B\x15WorkflowMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Sdk 16 | module V1 17 | WorkflowMetadata = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkflowMetadata").msgclass 18 | WorkflowDefinition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkflowDefinition").msgclass 19 | WorkflowInteractionDefinition = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.WorkflowInteractionDefinition").msgclass 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/batch_operation.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/batch_operation.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n+temporal/api/enums/v1/batch_operation.proto\x12\x15temporal.api.enums.v1*\x9a\x03\n\x12\x42\x61tchOperationType\x12$\n BATCH_OPERATION_TYPE_UNSPECIFIED\x10\x00\x12\"\n\x1e\x42\x41TCH_OPERATION_TYPE_TERMINATE\x10\x01\x12\x1f\n\x1b\x42\x41TCH_OPERATION_TYPE_CANCEL\x10\x02\x12\x1f\n\x1b\x42\x41TCH_OPERATION_TYPE_SIGNAL\x10\x03\x12\x1f\n\x1b\x42\x41TCH_OPERATION_TYPE_DELETE\x10\x04\x12\x1e\n\x1a\x42\x41TCH_OPERATION_TYPE_RESET\x10\x05\x12\x31\n-BATCH_OPERATION_TYPE_UPDATE_EXECUTION_OPTIONS\x10\x06\x12)\n%BATCH_OPERATION_TYPE_UNPAUSE_ACTIVITY\x10\x07\x12\x30\n,BATCH_OPERATION_TYPE_UPDATE_ACTIVITY_OPTIONS\x10\x08\x12\'\n#BATCH_OPERATION_TYPE_RESET_ACTIVITY\x10\t*\xa6\x01\n\x13\x42\x61tchOperationState\x12%\n!BATCH_OPERATION_STATE_UNSPECIFIED\x10\x00\x12!\n\x1d\x42\x41TCH_OPERATION_STATE_RUNNING\x10\x01\x12#\n\x1f\x42\x41TCH_OPERATION_STATE_COMPLETED\x10\x02\x12 \n\x1c\x42\x41TCH_OPERATION_STATE_FAILED\x10\x03\x42\x8b\x01\n\x18io.temporal.api.enums.v1B\x13\x42\x61tchOperationProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | BatchOperationType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.BatchOperationType").enummodule 18 | BatchOperationState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.BatchOperationState").enummodule 19 | end 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/activity/cancellation_details.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/error' 4 | 5 | module Temporalio 6 | module Activity 7 | # Details that are set when an activity is cancelled. This is only valid at the time the cancel was received, the 8 | # state may change on the server after it is received. 9 | class CancellationDetails 10 | def initialize( 11 | gone_from_server: false, 12 | cancel_requested: true, 13 | timed_out: false, 14 | worker_shutdown: false, 15 | paused: false, 16 | reset: false 17 | ) 18 | @gone_from_server = gone_from_server 19 | @cancel_requested = cancel_requested 20 | @timed_out = timed_out 21 | @worker_shutdown = worker_shutdown 22 | @paused = paused 23 | @reset = reset 24 | end 25 | 26 | # @return [Boolean] Whether the activity no longer exists on the server (may already be completed or its workflow 27 | # may be completed). 28 | def gone_from_server? 29 | @gone_from_server 30 | end 31 | 32 | # @return [Boolean] Whether the activity was explicitly cancelled. 33 | def cancel_requested? 34 | @cancel_requested 35 | end 36 | 37 | # @return [Boolean] Whether the activity timeout caused activity to be marked cancelled. 38 | def timed_out? 39 | @timed_out 40 | end 41 | 42 | # @return [Boolean] Whether the worker the activity is running on is shutting down. 43 | def worker_shutdown? 44 | @worker_shutdown 45 | end 46 | 47 | # @return [Boolean] Whether the activity was explicitly paused. 48 | def paused? 49 | @paused 50 | end 51 | 52 | # @return [Boolean] Whether the activity was explicitly reset. 53 | def reset? 54 | @reset 55 | end 56 | end 57 | end 58 | end 59 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/command_type.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/command_type.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n(temporal/api/enums/v1/command_type.proto\x12\x15temporal.api.enums.v1*\x9c\x06\n\x0b\x43ommandType\x12\x1c\n\x18\x43OMMAND_TYPE_UNSPECIFIED\x10\x00\x12\'\n#COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK\x10\x01\x12-\n)COMMAND_TYPE_REQUEST_CANCEL_ACTIVITY_TASK\x10\x02\x12\x1c\n\x18\x43OMMAND_TYPE_START_TIMER\x10\x03\x12,\n(COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION\x10\x04\x12(\n$COMMAND_TYPE_FAIL_WORKFLOW_EXECUTION\x10\x05\x12\x1d\n\x19\x43OMMAND_TYPE_CANCEL_TIMER\x10\x06\x12*\n&COMMAND_TYPE_CANCEL_WORKFLOW_EXECUTION\x10\x07\x12;\n7COMMAND_TYPE_REQUEST_CANCEL_EXTERNAL_WORKFLOW_EXECUTION\x10\x08\x12\x1e\n\x1a\x43OMMAND_TYPE_RECORD_MARKER\x10\t\x12\x33\n/COMMAND_TYPE_CONTINUE_AS_NEW_WORKFLOW_EXECUTION\x10\n\x12/\n+COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION\x10\x0b\x12\x33\n/COMMAND_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION\x10\x0c\x12\x32\n.COMMAND_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES\x10\r\x12!\n\x1d\x43OMMAND_TYPE_PROTOCOL_MESSAGE\x10\x0e\x12+\n\'COMMAND_TYPE_MODIFY_WORKFLOW_PROPERTIES\x10\x10\x12)\n%COMMAND_TYPE_SCHEDULE_NEXUS_OPERATION\x10\x11\x12/\n+COMMAND_TYPE_REQUEST_CANCEL_NEXUS_OPERATION\x10\x12\x42\x88\x01\n\x18io.temporal.api.enums.v1B\x10\x43ommandTypeProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | CommandType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.CommandType").enummodule 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/filter/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/filter/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/timestamp_pb' 8 | require 'temporalio/api/enums/v1/workflow' 9 | 10 | 11 | descriptor_data = "\n$temporal/api/filter/v1/message.proto\x12\x16temporal.api.filter.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/enums/v1/workflow.proto\">\n\x17WorkflowExecutionFilter\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x0e\n\x06run_id\x18\x02 \x01(\t\"\"\n\x12WorkflowTypeFilter\x12\x0c\n\x04name\x18\x01 \x01(\t\"u\n\x0fStartTimeFilter\x12\x31\n\rearliest_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0blatest_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"N\n\x0cStatusFilter\x12>\n\x06status\x18\x01 \x01(\x0e\x32..temporal.api.enums.v1.WorkflowExecutionStatusB\x89\x01\n\x19io.temporal.api.filter.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/filter/v1;filter\xaa\x02\x18Temporalio.Api.Filter.V1\xea\x02\x1bTemporalio::Api::Filter::V1b\x06proto3" 12 | 13 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 14 | pool.add_serialized_file(descriptor_data) 15 | 16 | module Temporalio 17 | module Api 18 | module Filter 19 | module V1 20 | WorkflowExecutionFilter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.filter.v1.WorkflowExecutionFilter").msgclass 21 | WorkflowTypeFilter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.filter.v1.WorkflowTypeFilter").msgclass 22 | StartTimeFilter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.filter.v1.StartTimeFilter").msgclass 23 | StatusFilter = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.filter.v1.StatusFilter").msgclass 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/activity/info.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Activity 3 | class Info 4 | attr_reader activity_id: String 5 | attr_reader activity_type: String 6 | attr_reader attempt: Integer 7 | attr_reader current_attempt_scheduled_time: Time 8 | attr_reader heartbeat_timeout: Float? 9 | attr_reader local?: bool 10 | attr_reader priority: Temporalio::Priority 11 | attr_reader raw_heartbeat_details: Array[Converters::RawValue] 12 | attr_reader retry_policy: RetryPolicy? 13 | attr_reader schedule_to_close_timeout: Float? 14 | attr_reader scheduled_time: Time 15 | attr_reader start_to_close_timeout: Float? 16 | attr_reader started_time: Time 17 | attr_reader task_queue: String 18 | attr_reader task_token: String 19 | attr_reader workflow_id: String 20 | attr_reader workflow_namespace: String 21 | attr_reader workflow_run_id: String 22 | attr_reader workflow_type: String 23 | 24 | def initialize: ( 25 | activity_id: String, 26 | activity_type: String, 27 | attempt: Integer, 28 | current_attempt_scheduled_time: Time, 29 | heartbeat_timeout: Float?, 30 | local?: bool, 31 | priority: Temporalio::Priority?, 32 | raw_heartbeat_details: Array[Converters::RawValue], 33 | retry_policy: RetryPolicy?, 34 | schedule_to_close_timeout: Float?, 35 | scheduled_time: Time, 36 | start_to_close_timeout: Float?, 37 | started_time: Time, 38 | task_queue: String, 39 | task_token: String, 40 | workflow_id: String, 41 | workflow_namespace: String, 42 | workflow_run_id: String, 43 | workflow_type: String 44 | ) -> void 45 | 46 | def heartbeat_details: (?hints: Array[Object]?) -> Array[Object?] 47 | 48 | def with: (**untyped) -> Info 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/replication/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/replication/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/timestamp_pb' 8 | require 'temporalio/api/enums/v1/namespace' 9 | 10 | 11 | descriptor_data = "\n)temporal/api/replication/v1/message.proto\x12\x1btemporal.api.replication.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a%temporal/api/enums/v1/namespace.proto\"0\n\x18\x43lusterReplicationConfig\x12\x14\n\x0c\x63luster_name\x18\x01 \x01(\t\"\xba\x01\n\x1aNamespaceReplicationConfig\x12\x1b\n\x13\x61\x63tive_cluster_name\x18\x01 \x01(\t\x12G\n\x08\x63lusters\x18\x02 \x03(\x0b\x32\x35.temporal.api.replication.v1.ClusterReplicationConfig\x12\x36\n\x05state\x18\x03 \x01(\x0e\x32\'.temporal.api.enums.v1.ReplicationState\"]\n\x0e\x46\x61iloverStatus\x12\x31\n\rfailover_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x18\n\x10\x66\x61ilover_version\x18\x02 \x01(\x03\x42\xa2\x01\n\x1eio.temporal.api.replication.v1B\x0cMessageProtoP\x01Z-go.temporal.io/api/replication/v1;replication\xaa\x02\x1dTemporalio.Api.Replication.V1\xea\x02 Temporalio::Api::Replication::V1b\x06proto3" 12 | 13 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 14 | pool.add_serialized_file(descriptor_data) 15 | 16 | module Temporalio 17 | module Api 18 | module Replication 19 | module V1 20 | ClusterReplicationConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.replication.v1.ClusterReplicationConfig").msgclass 21 | NamespaceReplicationConfig = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.replication.v1.NamespaceReplicationConfig").msgclass 22 | FailoverStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.replication.v1.FailoverStatus").msgclass 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/client/connection/operator_service.rbs: -------------------------------------------------------------------------------- 1 | # Generated code. DO NOT EDIT! 2 | 3 | module Temporalio 4 | class Client 5 | class Connection 6 | class OperatorService < Service 7 | def initialize: (Connection) -> void 8 | def add_search_attributes: ( 9 | untyped request, 10 | ?rpc_options: RPCOptions? 11 | ) -> untyped 12 | def remove_search_attributes: ( 13 | untyped request, 14 | ?rpc_options: RPCOptions? 15 | ) -> untyped 16 | def list_search_attributes: ( 17 | untyped request, 18 | ?rpc_options: RPCOptions? 19 | ) -> untyped 20 | def delete_namespace: ( 21 | untyped request, 22 | ?rpc_options: RPCOptions? 23 | ) -> untyped 24 | def add_or_update_remote_cluster: ( 25 | untyped request, 26 | ?rpc_options: RPCOptions? 27 | ) -> untyped 28 | def remove_remote_cluster: ( 29 | untyped request, 30 | ?rpc_options: RPCOptions? 31 | ) -> untyped 32 | def list_clusters: ( 33 | untyped request, 34 | ?rpc_options: RPCOptions? 35 | ) -> untyped 36 | def get_nexus_endpoint: ( 37 | untyped request, 38 | ?rpc_options: RPCOptions? 39 | ) -> untyped 40 | def create_nexus_endpoint: ( 41 | untyped request, 42 | ?rpc_options: RPCOptions? 43 | ) -> untyped 44 | def update_nexus_endpoint: ( 45 | untyped request, 46 | ?rpc_options: RPCOptions? 47 | ) -> untyped 48 | def delete_nexus_endpoint: ( 49 | untyped request, 50 | ?rpc_options: RPCOptions? 51 | ) -> untyped 52 | def list_nexus_endpoints: ( 53 | untyped request, 54 | ?rpc_options: RPCOptions? 55 | ) -> untyped 56 | end 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/workflow/child_workflow_handle.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Workflow 5 | # Handle for interacting with a child workflow. 6 | # 7 | # This is created via {Workflow.start_child_workflow}, it is never instantiated directly. 8 | class ChildWorkflowHandle 9 | # @!visibility private 10 | def initialize 11 | raise NotImplementedError, 'Cannot instantiate a child handle directly' 12 | end 13 | 14 | # @return [String] ID for the workflow. 15 | def id 16 | raise NotImplementedError 17 | end 18 | 19 | # @return [String] Run ID for the workflow. 20 | def first_execution_run_id 21 | raise NotImplementedError 22 | end 23 | 24 | # @return [Object, nil] Hint for the result if any. 25 | def result_hint 26 | raise NotImplementedError 27 | end 28 | 29 | # Wait for the result. 30 | # 31 | # @param result_hint [Object, nil] Override the result hint, or if nil uses the one on the handle. 32 | # @return [Object] Result of the child workflow. 33 | # 34 | # @raise [Error::ChildWorkflowError] Workflow failed with +cause+ as the cause. 35 | def result(result_hint: nil) 36 | raise NotImplementedError 37 | end 38 | 39 | # Signal the child workflow. 40 | # 41 | # @param signal [Workflow::Definition::Signal, Symbol, String] Signal definition or name. 42 | # @param args [Array] Signal args. 43 | # @param cancellation [Cancellation] Cancellation for canceling the signalling. 44 | # @param arg_hints [Array, nil] Overrides converter hints for arguments if any. If unset/nil and the 45 | # signal definition has arg hints, those are used by default. 46 | def signal(signal, *args, cancellation: Workflow.cancellation, arg_hints: nil) 47 | raise NotImplementedError 48 | end 49 | end 50 | end 51 | end 52 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/version/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/version/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/timestamp_pb' 8 | require 'temporalio/api/enums/v1/common' 9 | 10 | 11 | descriptor_data = "\n%temporal/api/version/v1/message.proto\x12\x17temporal.api.version.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\"temporal/api/enums/v1/common.proto\"_\n\x0bReleaseInfo\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x30\n\x0crelease_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\r\n\x05notes\x18\x03 \x01(\t\"K\n\x05\x41lert\x12\x0f\n\x07message\x18\x01 \x01(\t\x12\x31\n\x08severity\x18\x02 \x01(\x0e\x32\x1f.temporal.api.enums.v1.Severity\"\xfb\x01\n\x0bVersionInfo\x12\x35\n\x07\x63urrent\x18\x01 \x01(\x0b\x32$.temporal.api.version.v1.ReleaseInfo\x12\x39\n\x0brecommended\x18\x02 \x01(\x0b\x32$.temporal.api.version.v1.ReleaseInfo\x12\x14\n\x0cinstructions\x18\x03 \x01(\t\x12.\n\x06\x61lerts\x18\x04 \x03(\x0b\x32\x1e.temporal.api.version.v1.Alert\x12\x34\n\x10last_update_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x8e\x01\n\x1aio.temporal.api.version.v1B\x0cMessageProtoP\x01Z%go.temporal.io/api/version/v1;version\xaa\x02\x19Temporalio.Api.Version.V1\xea\x02\x1cTemporalio::Api::Version::V1b\x06proto3" 12 | 13 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 14 | pool.add_serialized_file(descriptor_data) 15 | 16 | module Temporalio 17 | module Api 18 | module Version 19 | module V1 20 | ReleaseInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.version.v1.ReleaseInfo").msgclass 21 | Alert = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.version.v1.Alert").msgclass 22 | VersionInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.version.v1.VersionInfo").msgclass 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /temporalio/ext/src/lib.rs: -------------------------------------------------------------------------------- 1 | use magnus::{Error, ExceptionClass, RModule, Ruby, prelude::*, value::Lazy}; 2 | 3 | mod client; 4 | mod client_rpc_generated; 5 | mod envconfig; 6 | mod metric; 7 | mod runtime; 8 | mod testing; 9 | mod util; 10 | mod worker; 11 | 12 | pub static ROOT_MOD: Lazy = Lazy::new(|ruby| { 13 | ruby.define_module("Temporalio") 14 | .expect("Module definition failed") 15 | .define_module("Internal") 16 | .expect("Module definition failed") 17 | .define_module("Bridge") 18 | .expect("Module definition failed") 19 | }); 20 | 21 | pub static ROOT_ERR: Lazy = Lazy::new(|ruby| { 22 | ruby.get_inner(&ROOT_MOD) 23 | .define_error("Error", ruby.exception_standard_error()) 24 | .expect("Error definition failed") 25 | }); 26 | 27 | #[macro_export] 28 | macro_rules! error { 29 | ($($arg:expr),*) => { 30 | Error::new(Ruby::get().expect("Not in Ruby thread").get_inner(&$crate::ROOT_ERR), format!($($arg),*)) 31 | }; 32 | } 33 | 34 | #[macro_export] 35 | macro_rules! new_error { 36 | ($($arg:expr),*) => { 37 | Ruby::get().expect("Not in Ruby thread").get_inner(&$crate::ROOT_ERR).new_instance((format!($($arg),*),)).expect("Cannot create exception") 38 | }; 39 | } 40 | 41 | #[macro_export] 42 | macro_rules! id { 43 | ($str:expr) => {{ 44 | static VAL: magnus::value::LazyId = magnus::value::LazyId::new($str); 45 | *VAL 46 | }}; 47 | } 48 | 49 | #[macro_export] 50 | macro_rules! lazy_id { 51 | ($str:expr) => {{ 52 | static VAL: magnus::value::LazyId = magnus::value::LazyId::new($str); 53 | &VAL 54 | }}; 55 | } 56 | 57 | #[magnus::init] 58 | fn init(ruby: &Ruby) -> Result<(), Error> { 59 | Lazy::force(&ROOT_ERR, ruby); 60 | 61 | client::init(ruby)?; 62 | envconfig::init(ruby)?; 63 | metric::init(ruby)?; 64 | runtime::init(ruby)?; 65 | testing::init(ruby)?; 66 | worker::init(ruby)?; 67 | 68 | Ok(()) 69 | } 70 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/cloud/sink/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/cloud/sink/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n(temporal/api/cloud/sink/v1/message.proto\x12\x1atemporal.api.cloud.sink.v1\"i\n\x06S3Spec\x12\x11\n\trole_name\x18\x01 \x01(\t\x12\x13\n\x0b\x62ucket_name\x18\x02 \x01(\t\x12\x0e\n\x06region\x18\x03 \x01(\t\x12\x0f\n\x07kms_arn\x18\x04 \x01(\t\x12\x16\n\x0e\x61ws_account_id\x18\x05 \x01(\t\"U\n\x07GCSSpec\x12\r\n\x05sa_id\x18\x01 \x01(\t\x12\x13\n\x0b\x62ucket_name\x18\x02 \x01(\t\x12\x16\n\x0egcp_project_id\x18\x03 \x01(\t\x12\x0e\n\x06region\x18\x04 \x01(\t\"I\n\x0bKinesisSpec\x12\x11\n\trole_name\x18\x01 \x01(\t\x12\x17\n\x0f\x64\x65stination_uri\x18\x02 \x01(\t\x12\x0e\n\x06region\x18\x03 \x01(\t\"T\n\nPubSubSpec\x12\x1a\n\x12service_account_id\x18\x01 \x01(\t\x12\x12\n\ntopic_name\x18\x02 \x01(\t\x12\x16\n\x0egcp_project_id\x18\x03 \x01(\tB\x98\x01\n\x1dio.temporal.api.cloud.sink.v1B\x0cMessageProtoP\x01Z%go.temporal.io/api/cloud/sink/v1;sink\xaa\x02\x1cTemporalio.Api.Cloud.Sink.V1\xea\x02 Temporalio::Api::Cloud::Sink::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Cloud 16 | module Sink 17 | module V1 18 | S3Spec = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.sink.v1.S3Spec").msgclass 19 | GCSSpec = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.sink.v1.GCSSpec").msgclass 20 | KinesisSpec = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.sink.v1.KinesisSpec").msgclass 21 | PubSubSpec = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.sink.v1.PubSubSpec").msgclass 22 | end 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/inbound_implementation.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/worker/workflow_instance' 4 | require 'temporalio/worker/interceptor' 5 | require 'temporalio/workflow' 6 | 7 | module Temporalio 8 | module Internal 9 | module Worker 10 | class WorkflowInstance 11 | # Root implementation of the inbound interceptor. 12 | class InboundImplementation < Temporalio::Worker::Interceptor::Workflow::Inbound 13 | def initialize(instance) 14 | super(nil) # steep:ignore 15 | @instance = instance 16 | end 17 | 18 | def init(outbound) 19 | @instance.context._outbound = outbound 20 | end 21 | 22 | def execute(input) 23 | @instance.instance.execute(*input.args) 24 | end 25 | 26 | def handle_signal(input) 27 | invoke_handler(input.signal, input) 28 | end 29 | 30 | def handle_query(input) 31 | invoke_handler(input.query, input) 32 | end 33 | 34 | def validate_update(input) 35 | invoke_handler(input.update, input, to_invoke: input.definition.validator_to_invoke) 36 | end 37 | 38 | def handle_update(input) 39 | invoke_handler(input.update, input) 40 | end 41 | 42 | private 43 | 44 | def invoke_handler(name, input, to_invoke: input.definition.to_invoke) 45 | args = input.args 46 | # Add name as first param if dynamic 47 | args = [name] + args if input.definition.name.nil? 48 | # Assume symbol or proc 49 | case to_invoke 50 | when Symbol 51 | @instance.instance.send(to_invoke, *args) 52 | when Proc 53 | to_invoke.call(*args) 54 | else 55 | raise "Unrecognized invocation type #{to_invoke.class}" 56 | end 57 | end 58 | end 59 | end 60 | end 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/worker/workflow_instance/details.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Temporalio 4 | module Internal 5 | module Worker 6 | class WorkflowInstance 7 | # Details needed to instantiate a {WorkflowInstance}. 8 | class Details 9 | attr_reader :namespace, :task_queue, :definition, :initial_activation, :logger, :metric_meter, 10 | :payload_converter, :failure_converter, :interceptors, :disable_eager_activity_execution, 11 | :illegal_calls, :workflow_failure_exception_types, :unsafe_workflow_io_enabled, 12 | :assert_valid_local_activity 13 | 14 | def initialize( 15 | namespace:, 16 | task_queue:, 17 | definition:, 18 | initial_activation:, 19 | logger:, 20 | metric_meter:, 21 | payload_converter:, 22 | failure_converter:, 23 | interceptors:, 24 | disable_eager_activity_execution:, 25 | illegal_calls:, 26 | workflow_failure_exception_types:, 27 | unsafe_workflow_io_enabled:, 28 | assert_valid_local_activity: 29 | ) 30 | @namespace = namespace 31 | @task_queue = task_queue 32 | @definition = definition 33 | @initial_activation = initial_activation 34 | @logger = logger 35 | @metric_meter = metric_meter 36 | @payload_converter = payload_converter 37 | @failure_converter = failure_converter 38 | @interceptors = interceptors 39 | @disable_eager_activity_execution = disable_eager_activity_execution 40 | @illegal_calls = illegal_calls 41 | @workflow_failure_exception_types = workflow_failure_exception_types 42 | @unsafe_workflow_io_enabled = unsafe_workflow_io_enabled 43 | @assert_valid_local_activity = assert_valid_local_activity 44 | end 45 | end 46 | end 47 | end 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /temporalio/test/cancellation_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/cancellation' 4 | require 'test' 5 | 6 | class CancellationTest < Test 7 | also_run_all_tests_in_fiber 8 | 9 | def test_simple_cancellation 10 | # Create and confirm uncanceled state 11 | cancel, cancel_proc = Temporalio::Cancellation.new 12 | refute cancel.canceled? 13 | cancel.check! 14 | got_cancel1 = false 15 | cancel.add_cancel_callback { got_cancel1 = true } 16 | refute got_cancel1 17 | got_cancel_from_wait_queue = Queue.new 18 | run_in_background do 19 | cancel.wait 20 | got_cancel_from_wait_queue.push(true) 21 | end 22 | 23 | # Do the cancel and confirm state 24 | cancel_proc.call 25 | assert cancel.canceled? 26 | assert_raises(Temporalio::Error::CanceledError) { cancel.check! } 27 | assert got_cancel1 28 | got_cancel2 = false 29 | cancel.add_cancel_callback { got_cancel2 = true } 30 | assert got_cancel2 31 | assert got_cancel_from_wait_queue.pop 32 | cancel.wait 33 | end 34 | 35 | def test_parent_cancellation 36 | cancel_grandparent, cancel_grandparent_proc = Temporalio::Cancellation.new 37 | cancel_parent = Temporalio::Cancellation.new(cancel_grandparent) 38 | cancel = Temporalio::Cancellation.new(cancel_parent) 39 | 40 | refute cancel_grandparent.canceled? 41 | refute cancel_parent.canceled? 42 | refute cancel.canceled? 43 | 44 | cancel_grandparent_proc.call 45 | assert cancel_grandparent.canceled? 46 | assert cancel_parent.canceled? 47 | assert cancel.canceled? 48 | end 49 | 50 | def test_shielding 51 | # Create a cancellation, shield a couple of levels deep and confirm 52 | cancel, cancel_proc = Temporalio::Cancellation.new 53 | cancel.shield do 54 | cancel.shield do 55 | cancel_proc.call(reason: 'some reason') 56 | refute cancel.canceled? 57 | end 58 | refute cancel.canceled? 59 | end 60 | assert cancel.canceled? 61 | assert_equal 'some reason', cancel.canceled_reason 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/query/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/query/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'temporalio/api/enums/v1/query' 8 | require 'temporalio/api/enums/v1/workflow' 9 | require 'temporalio/api/common/v1/message' 10 | require 'temporalio/api/failure/v1/message' 11 | 12 | 13 | descriptor_data = "\n#temporal/api/query/v1/message.proto\x12\x15temporal.api.query.v1\x1a!temporal/api/enums/v1/query.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a$temporal/api/common/v1/message.proto\x1a%temporal/api/failure/v1/message.proto\"\x89\x01\n\rWorkflowQuery\x12\x12\n\nquery_type\x18\x01 \x01(\t\x12\x34\n\nquery_args\x18\x02 \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12.\n\x06header\x18\x03 \x01(\x0b\x32\x1e.temporal.api.common.v1.Header\"\xce\x01\n\x13WorkflowQueryResult\x12;\n\x0bresult_type\x18\x01 \x01(\x0e\x32&.temporal.api.enums.v1.QueryResultType\x12\x30\n\x06\x61nswer\x18\x02 \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x15\n\rerror_message\x18\x03 \x01(\t\x12\x31\n\x07\x66\x61ilure\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\"O\n\rQueryRejected\x12>\n\x06status\x18\x01 \x01(\x0e\x32..temporal.api.enums.v1.WorkflowExecutionStatusB\x84\x01\n\x18io.temporal.api.query.v1B\x0cMessageProtoP\x01Z!go.temporal.io/api/query/v1;query\xaa\x02\x17Temporalio.Api.Query.V1\xea\x02\x1aTemporalio::Api::Query::V1b\x06proto3" 14 | 15 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 16 | pool.add_serialized_file(descriptor_data) 17 | 18 | module Temporalio 19 | module Api 20 | module Query 21 | module V1 22 | WorkflowQuery = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.query.v1.WorkflowQuery").msgclass 23 | WorkflowQueryResult = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.query.v1.WorkflowQueryResult").msgclass 24 | QueryRejected = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.query.v1.QueryRejected").msgclass 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/versioning_override.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/worker_deployment_version' 4 | 5 | module Temporalio 6 | # Base class for version overrides that can be provided in start workflow options. 7 | # Used to control the versioning behavior of workflows started with this override. 8 | # 9 | # WARNING: Experimental API. 10 | class VersioningOverride 11 | # @!visibility private 12 | def _to_proto 13 | raise NotImplementedError, 'Subclasses must implement this method' 14 | end 15 | 16 | # Represents a versioning override to pin a workflow to a specific version 17 | class Pinned < VersioningOverride 18 | # The worker deployment version to pin to 19 | # @return [WorkerDeploymentVersion] 20 | attr_reader :version 21 | 22 | # Create a new pinned versioning override 23 | # 24 | # @param version [WorkerDeploymentVersion] The worker deployment version to pin to 25 | def initialize(version) 26 | @version = version 27 | super() 28 | end 29 | 30 | # TODO: Remove deprecated field setting once removed from server 31 | 32 | # @!visibility private 33 | def _to_proto 34 | Api::Workflow::V1::VersioningOverride.new( 35 | behavior: Api::Enums::V1::VersioningBehavior::VERSIONING_BEHAVIOR_PINNED, 36 | pinned_version: @version.to_canonical_string, 37 | pinned: Api::Workflow::V1::VersioningOverride::PinnedOverride.new( 38 | behavior: Api::Workflow::V1::VersioningOverride::PinnedOverrideBehavior::PINNED_OVERRIDE_BEHAVIOR_PINNED, 39 | version: @version._to_proto 40 | ) 41 | ) 42 | end 43 | end 44 | 45 | # Represents a versioning override to auto-upgrade a workflow 46 | class AutoUpgrade < VersioningOverride 47 | # @!visibility private 48 | def _to_proto 49 | Api::Workflow::V1::VersioningOverride.new( 50 | behavior: Api::Enums::V1::VersioningBehavior::VERSIONING_BEHAVIOR_AUTO_UPGRADE, 51 | auto_upgrade: true 52 | ) 53 | end 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /temporalio/test/scoped_logger_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/scoped_logger' 4 | require 'test' 5 | 6 | class ScopedLoggerTest < Test 7 | def test_logger_with_values 8 | # Default doesn't change anything 9 | out, = safe_capture_io do 10 | logger = Temporalio::ScopedLogger.new(Logger.new($stdout, level: Logger::INFO)) 11 | logger.info('info1') 12 | logger.error('error1') 13 | logger.debug('debug1') 14 | logger.with_level(Logger::DEBUG) { logger.debug('debug2') } # steep:ignore 15 | logger.error(RuntimeError.new('exception1')) 16 | end 17 | lines = out.split("\n") 18 | assert(lines.one? { |l| l.include?('INFO') && l.end_with?('info1') }) 19 | assert(lines.one? { |l| l.include?('ERROR') && l.end_with?('error1') }) 20 | assert(lines.none? { |l| l.include?('debug1') }) 21 | assert(lines.one? { |l| l.include?('DEBUG') && l.end_with?('debug2') }) 22 | assert(lines.one? { |l| l.include?('ERROR') && l.end_with?('exception1 (RuntimeError)') }) 23 | 24 | # With a getter that returns some values 25 | extra_vals = { some_key: { foo: 'bar', 'baz' => 123 } } 26 | out, = safe_capture_io do 27 | logger = Temporalio::ScopedLogger.new(Logger.new($stdout, level: Logger::INFO)) 28 | logger.scoped_values_getter = proc { extra_vals } 29 | logger.add(Logger::WARN, 'warn1') 30 | logger.info('info1') 31 | logger.error('error1') 32 | logger.debug('debug1') 33 | logger.with_level(Logger::DEBUG) { logger.debug('debug2') } # steep:ignore 34 | logger.error(RuntimeError.new('exception1')) 35 | end 36 | lines = out.split("\n") 37 | assert(lines.one? { |l| l.include?('INFO') && l.end_with?("info1 #{extra_vals.inspect}") }) 38 | assert(lines.one? { |l| l.include?('ERROR') && l.end_with?("error1 #{extra_vals.inspect}") }) 39 | assert(lines.none? { |l| l.include?('debug1') }) 40 | assert(lines.one? { |l| l.include?('DEBUG') && l.end_with?("debug2 #{extra_vals.inspect}") }) 41 | assert(lines.one? { |l| l.include?('ERROR') && l.end_with?("exception1 #{extra_vals.inspect} (RuntimeError)") }) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge/testing.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/bridge' 4 | 5 | module Temporalio 6 | module Internal 7 | module Bridge 8 | module Testing 9 | class EphemeralServer 10 | StartDevServerOptions = Struct.new( 11 | :existing_path, # Optional 12 | :sdk_name, 13 | :sdk_version, 14 | :download_version, 15 | :download_dest_dir, # Optional 16 | :namespace, 17 | :ip, 18 | :port, # Optional 19 | :database_filename, # Optional 20 | :ui, 21 | :ui_port, # Optional, should be nil if ui is false 22 | :log_format, 23 | :log_level, 24 | :extra_args, 25 | :download_ttl, # Optional 26 | keyword_init: true 27 | ) 28 | 29 | StartTestServerOptions = Struct.new( 30 | :existing_path, # Optional 31 | :sdk_name, 32 | :sdk_version, 33 | :download_version, 34 | :download_dest_dir, # Optional 35 | :port, # Optional 36 | :extra_args, 37 | :download_ttl, # Optional 38 | keyword_init: true 39 | ) 40 | 41 | def self.start_dev_server(runtime, options) 42 | queue = Queue.new 43 | async_start_dev_server(runtime, options, queue) 44 | result = queue.pop 45 | raise result if result.is_a?(Exception) 46 | 47 | result 48 | end 49 | 50 | def self.start_test_server(runtime, options) 51 | queue = Queue.new 52 | async_start_test_server(runtime, options, queue) 53 | result = queue.pop 54 | raise result if result.is_a?(Exception) 55 | 56 | result 57 | end 58 | 59 | def shutdown 60 | queue = Queue.new 61 | async_shutdown(queue) 62 | result = queue.pop 63 | raise result if result.is_a?(Exception) 64 | end 65 | end 66 | end 67 | end 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/workflow_instance/details.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class WorkflowInstance 5 | class Details 6 | attr_reader namespace: String 7 | attr_reader task_queue: String 8 | attr_reader definition: Workflow::Definition::Info 9 | attr_reader initial_activation: untyped 10 | attr_reader logger: Logger 11 | attr_reader metric_meter: Temporalio::Metric::Meter 12 | attr_reader payload_converter: Converters::PayloadConverter 13 | attr_reader failure_converter: Converters::FailureConverter 14 | attr_reader interceptors: Array[Temporalio::Worker::Interceptor::Workflow] 15 | attr_reader disable_eager_activity_execution: bool 16 | attr_reader illegal_calls: Hash[String, :all | Hash[Symbol, TrueClass | Temporalio::Worker::IllegalWorkflowCallValidator] | Temporalio::Worker::IllegalWorkflowCallValidator] 17 | attr_reader workflow_failure_exception_types: Array[singleton(Exception)] 18 | attr_reader unsafe_workflow_io_enabled: bool 19 | attr_reader assert_valid_local_activity: ^(String) -> void 20 | 21 | def initialize: ( 22 | namespace: String, 23 | task_queue: String, 24 | definition: Workflow::Definition::Info, 25 | initial_activation: untyped, 26 | logger: Logger, 27 | metric_meter: Temporalio::Metric::Meter, 28 | payload_converter: Converters::PayloadConverter, 29 | failure_converter: Converters::FailureConverter, 30 | interceptors: Array[Temporalio::Worker::Interceptor::Workflow], 31 | disable_eager_activity_execution: bool, 32 | illegal_calls: Hash[String, :all | Hash[Symbol, TrueClass | Temporalio::Worker::IllegalWorkflowCallValidator] | Temporalio::Worker::IllegalWorkflowCallValidator], 33 | workflow_failure_exception_types: Array[singleton(Exception)], 34 | unsafe_workflow_io_enabled: bool, 35 | assert_valid_local_activity: ^(String) -> void 36 | ) -> void 37 | end 38 | end 39 | end 40 | end 41 | end -------------------------------------------------------------------------------- /temporalio/sig/temporalio/search_attributes.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class SearchAttributes 3 | class Key 4 | attr_reader name: String 5 | attr_reader type: Integer 6 | 7 | def initialize: (String name, Integer type) -> void 8 | 9 | def validate_value: (Object value) -> void 10 | 11 | def value_set: (Object value) -> Update 12 | def value_unset: -> Update 13 | end 14 | 15 | class Update 16 | attr_reader key: Key 17 | attr_reader value: Object? 18 | 19 | def initialize: (Key key, Object? value) -> void 20 | 21 | def _to_proto_pair: -> [String, untyped] 22 | end 23 | 24 | def self._from_proto: ( 25 | untyped proto, 26 | ?disable_mutations: bool, 27 | ?never_nil: bool 28 | ) -> SearchAttributes? 29 | 30 | def self._value_from_payload: (untyped payload) -> Object? 31 | 32 | def self._to_proto_pair: (Key key, Object? value) -> [String, untyped] 33 | 34 | def initialize: (SearchAttributes existing) -> void 35 | | (Hash[Key, Object] existing) -> void 36 | | -> void 37 | 38 | def []=: (Key | String | Symbol key, Object? value) -> void 39 | def []: (Key key) -> Object? 40 | 41 | def delete: (Key | String | Symbol key) -> void 42 | 43 | def each: { (Key key, Object value) -> void } -> self 44 | 45 | def to_h: -> Hash[Key, Object] 46 | 47 | def dup: -> SearchAttributes 48 | 49 | def empty?: -> bool 50 | 51 | def length: -> Integer 52 | 53 | alias size length 54 | 55 | def update: (*Update updates) -> SearchAttributes 56 | 57 | def update!: (*Update updates) -> void 58 | 59 | def _raw_hash: -> Hash[Key, Object] 60 | 61 | def _to_proto: -> untyped 62 | 63 | def _to_proto_hash: -> Hash[String, untyped] 64 | 65 | def _assert_mutations_enabled: -> void 66 | 67 | def _disable_mutations=: (bool value) -> void 68 | 69 | module IndexedValueType 70 | TEXT: Integer 71 | KEYWORD: Integer 72 | INTEGER: Integer 73 | FLOAT: Integer 74 | BOOLEAN: Integer 75 | TIME: Integer 76 | KEYWORD_LIST: Integer 77 | 78 | PROTO_NAMES: Hash[Integer, String] 79 | PROTO_VALUES: Hash[String, Integer] 80 | end 81 | end 82 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/cloud/operation/v1/message.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/cloud/operation/v1/message.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'google/protobuf/duration_pb' 8 | require 'google/protobuf/timestamp_pb' 9 | require 'google/protobuf/any_pb' 10 | 11 | 12 | descriptor_data = "\n-temporal/api/cloud/operation/v1/message.proto\x12\x1ftemporal.api.cloud.operation.v1\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x19google/protobuf/any.proto\"\x92\x04\n\x0e\x41syncOperation\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x10state_deprecated\x18\x02 \x01(\tB\x02\x18\x01\x12\x44\n\x05state\x18\t \x01(\x0e\x32\x35.temporal.api.cloud.operation.v1.AsyncOperation.State\x12\x31\n\x0e\x63heck_duration\x18\x03 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x16\n\x0eoperation_type\x18\x04 \x01(\t\x12-\n\x0foperation_input\x18\x05 \x01(\x0b\x32\x14.google.protobuf.Any\x12\x16\n\x0e\x66\x61ilure_reason\x18\x06 \x01(\t\x12\x30\n\x0cstarted_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x31\n\rfinished_time\x18\x08 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\x98\x01\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x11\n\rSTATE_PENDING\x10\x01\x12\x15\n\x11STATE_IN_PROGRESS\x10\x02\x12\x10\n\x0cSTATE_FAILED\x10\x03\x12\x13\n\x0fSTATE_CANCELLED\x10\x04\x12\x13\n\x0fSTATE_FULFILLED\x10\x05\x12\x12\n\x0eSTATE_REJECTED\x10\x06\x42\xb1\x01\n\"io.temporal.api.cloud.operation.v1B\x0cMessageProtoP\x01Z/go.temporal.io/api/cloud/operation/v1;operation\xaa\x02!Temporalio.Api.Cloud.Operation.V1\xea\x02%Temporalio::Api::Cloud::Operation::V1b\x06proto3" 13 | 14 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 15 | pool.add_serialized_file(descriptor_data) 16 | 17 | module Temporalio 18 | module Api 19 | module Cloud 20 | module Operation 21 | module V1 22 | AsyncOperation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.operation.v1.AsyncOperation").msgclass 23 | AsyncOperation::State = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.cloud.operation.v1.AsyncOperation.State").enummodule 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/worker_deployment_version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/internal/bridge/worker' 4 | 5 | module Temporalio 6 | WorkerDeploymentVersion = Data.define( 7 | :deployment_name, 8 | :build_id 9 | ) 10 | 11 | # Represents the version of a specific worker deployment. 12 | # 13 | # WARNING: Experimental API. 14 | class WorkerDeploymentVersion 15 | # Parse a version from a canonical string, which must be in the format 16 | # `.`. Deployment name must not have a `.` in it. 17 | # 18 | # @param canonical [String] The canonical string representation of the version. 19 | # @return [WorkerDeploymentVersion] The parsed version. 20 | def self.from_canonical_string(canonical) 21 | parts = canonical.split('.', 2) 22 | if parts.length != 2 23 | raise ArgumentError, 24 | "Cannot parse version string: #{canonical}, must be in format ." 25 | end 26 | new(deployment_name: parts[0], build_id: parts[1]) 27 | end 28 | 29 | # @!visibility private 30 | def self._from_bridge(bridge) 31 | return nil if bridge.nil? 32 | 33 | new(deployment_name: bridge.deployment_name, build_id: bridge.build_id) 34 | end 35 | 36 | # Create WorkerDeploymentVersion. 37 | # 38 | # @param deployment_name [String] The name of the deployment. 39 | # @param build_id [String] The build identifier specific to this worker build. 40 | def initialize(deployment_name:, build_id:) # rubocop:disable Lint/UselessMethodDefinition 41 | super 42 | end 43 | 44 | # Returns the canonical string representation of the version. 45 | # 46 | # @return [String] 47 | def to_canonical_string 48 | "#{deployment_name}.#{build_id}" 49 | end 50 | 51 | # @!visibility private 52 | def _to_bridge_options 53 | Internal::Bridge::Worker::WorkerDeploymentVersion.new( 54 | deployment_name: deployment_name, 55 | build_id: build_id 56 | ) 57 | end 58 | 59 | # @!visibility private 60 | def _to_proto 61 | Api::Deployment::V1::WorkerDeploymentVersion.new( 62 | deployment_name: deployment_name, 63 | build_id: build_id 64 | ) 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/error.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | class Error < StandardError 3 | def self.canceled?: (Exception error) -> bool 4 | 5 | def self._with_backtrace_and_cause: ( 6 | Exception err, 7 | backtrace: Array[String]?, 8 | cause: Exception? 9 | ) -> Exception 10 | 11 | class WorkflowFailedError < Error 12 | def initialize: -> void 13 | end 14 | 15 | class WorkflowContinuedAsNewError < Error 16 | attr_reader new_run_id: String 17 | 18 | def initialize: (new_run_id: String) -> void 19 | end 20 | 21 | class WorkflowQueryFailedError < Error 22 | end 23 | 24 | class WorkflowQueryRejectedError < Error 25 | attr_reader status: Client::WorkflowExecutionStatus::enum 26 | 27 | def initialize: (status: Client::WorkflowExecutionStatus::enum) -> void 28 | end 29 | 30 | class WorkflowUpdateFailedError < Error 31 | def initialize: -> void 32 | end 33 | 34 | class WorkflowUpdateRPCTimeoutOrCanceledError < Error 35 | def initialize: -> void 36 | end 37 | 38 | class ScheduleAlreadyRunningError < Error 39 | def initialize: -> void 40 | end 41 | 42 | class AsyncActivityCanceledError < Error 43 | attr_reader details: Activity::CancellationDetails 44 | 45 | def initialize: (Activity::CancellationDetails details) -> void 46 | end 47 | 48 | class RPCError < Error 49 | attr_reader code: Code::enum 50 | 51 | def initialize: ( 52 | String message, 53 | code: Code::enum, 54 | raw_grpc_status: String? | untyped 55 | ) -> void 56 | 57 | def grpc_status: -> untyped 58 | 59 | private def create_grpc_status: -> untyped 60 | 61 | module Code 62 | OK: 0 63 | CANCELLED: 1 64 | UNKNOWN: 2 65 | INVALID_ARGUMENT: 3 66 | DEADLINE_EXCEEDED: 4 67 | NOT_FOUND: 5 68 | ALREADY_EXISTS: 6 69 | PERMISSION_DENIED: 7 70 | RESOURCE_EXHAUSTED: 8 71 | FAILED_PRECONDITION: 9 72 | ABORTED: 10 73 | OUT_OF_RANGE: 11 74 | UNIMPLEMENTED: 12 75 | INTERNAL: 13 76 | UNAVAILABLE: 14 77 | DATA_LOSS: 15 78 | UNAUTHENTICATED: 16 79 | 80 | type enum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 81 | end 82 | end 83 | end 84 | end -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/enums/v1/deployment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/enums/v1/deployment.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n&temporal/api/enums/v1/deployment.proto\x12\x15temporal.api.enums.v1*\xc4\x01\n\x16\x44\x65ploymentReachability\x12\'\n#DEPLOYMENT_REACHABILITY_UNSPECIFIED\x10\x00\x12%\n!DEPLOYMENT_REACHABILITY_REACHABLE\x10\x01\x12\x31\n-DEPLOYMENT_REACHABILITY_CLOSED_WORKFLOWS_ONLY\x10\x02\x12\'\n#DEPLOYMENT_REACHABILITY_UNREACHABLE\x10\x03*\x8b\x01\n\x15VersionDrainageStatus\x12\'\n#VERSION_DRAINAGE_STATUS_UNSPECIFIED\x10\x00\x12$\n VERSION_DRAINAGE_STATUS_DRAINING\x10\x01\x12#\n\x1fVERSION_DRAINAGE_STATUS_DRAINED\x10\x02*\x8c\x01\n\x14WorkerVersioningMode\x12&\n\"WORKER_VERSIONING_MODE_UNSPECIFIED\x10\x00\x12&\n\"WORKER_VERSIONING_MODE_UNVERSIONED\x10\x01\x12$\n WORKER_VERSIONING_MODE_VERSIONED\x10\x02*\xb9\x02\n\x1dWorkerDeploymentVersionStatus\x12\x30\n,WORKER_DEPLOYMENT_VERSION_STATUS_UNSPECIFIED\x10\x00\x12-\n)WORKER_DEPLOYMENT_VERSION_STATUS_INACTIVE\x10\x01\x12,\n(WORKER_DEPLOYMENT_VERSION_STATUS_CURRENT\x10\x02\x12,\n(WORKER_DEPLOYMENT_VERSION_STATUS_RAMPING\x10\x03\x12-\n)WORKER_DEPLOYMENT_VERSION_STATUS_DRAINING\x10\x04\x12,\n(WORKER_DEPLOYMENT_VERSION_STATUS_DRAINED\x10\x05\x42\x87\x01\n\x18io.temporal.api.enums.v1B\x0f\x44\x65ploymentProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Enums 16 | module V1 17 | DeploymentReachability = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.DeploymentReachability").enummodule 18 | VersionDrainageStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.VersionDrainageStatus").enummodule 19 | WorkerVersioningMode = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.WorkerVersioningMode").enummodule 20 | WorkerDeploymentVersionStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.enums.v1.WorkerDeploymentVersionStatus").enummodule 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/api/sdk/v1/enhanced_stack_trace.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/api/sdk/v1/enhanced_stack_trace.proto 4 | 5 | require 'google/protobuf' 6 | 7 | 8 | descriptor_data = "\n.temporal/api/sdk/v1/enhanced_stack_trace.proto\x12\x13temporal.api.sdk.v1\"\x9b\x02\n\x12\x45nhancedStackTrace\x12\x33\n\x03sdk\x18\x01 \x01(\x0b\x32&.temporal.api.sdk.v1.StackTraceSDKInfo\x12\x45\n\x07sources\x18\x02 \x03(\x0b\x32\x34.temporal.api.sdk.v1.EnhancedStackTrace.SourcesEntry\x12/\n\x06stacks\x18\x03 \x03(\x0b\x32\x1f.temporal.api.sdk.v1.StackTrace\x1aX\n\x0cSourcesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x37\n\x05value\x18\x02 \x01(\x0b\x32(.temporal.api.sdk.v1.StackTraceFileSlice:\x02\x38\x01\"2\n\x11StackTraceSDKInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\";\n\x13StackTraceFileSlice\x12\x13\n\x0bline_offset\x18\x01 \x01(\r\x12\x0f\n\x07\x63ontent\x18\x02 \x01(\t\"w\n\x16StackTraceFileLocation\x12\x11\n\tfile_path\x18\x01 \x01(\t\x12\x0c\n\x04line\x18\x02 \x01(\x05\x12\x0e\n\x06\x63olumn\x18\x03 \x01(\x05\x12\x15\n\rfunction_name\x18\x04 \x01(\t\x12\x15\n\rinternal_code\x18\x05 \x01(\x08\"L\n\nStackTrace\x12>\n\tlocations\x18\x01 \x03(\x0b\x32+.temporal.api.sdk.v1.StackTraceFileLocationB\x85\x01\n\x16io.temporal.api.sdk.v1B\x17\x45nhancedStackTraceProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3" 9 | 10 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 11 | pool.add_serialized_file(descriptor_data) 12 | 13 | module Temporalio 14 | module Api 15 | module Sdk 16 | module V1 17 | EnhancedStackTrace = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.EnhancedStackTrace").msgclass 18 | StackTraceSDKInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.StackTraceSDKInfo").msgclass 19 | StackTraceFileSlice = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.StackTraceFileSlice").msgclass 20 | StackTraceFileLocation = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.StackTraceFileLocation").msgclass 21 | StackTrace = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("temporal.api.sdk.v1.StackTrace").msgclass 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/internal/bridge/api/workflow_completion/workflow_completion.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: temporal/sdk/core/workflow_completion/workflow_completion.proto 4 | 5 | require 'google/protobuf' 6 | 7 | require 'temporalio/api/failure/v1/message' 8 | require 'temporalio/api/enums/v1/failed_cause' 9 | require 'temporalio/api/enums/v1/workflow' 10 | require 'temporalio/internal/bridge/api/common/common' 11 | require 'temporalio/internal/bridge/api/workflow_commands/workflow_commands' 12 | 13 | 14 | descriptor_data = "\n?temporal/sdk/core/workflow_completion/workflow_completion.proto\x12\x1b\x63oresdk.workflow_completion\x1a%temporal/api/failure/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a;temporal/sdk/core/workflow_commands/workflow_commands.proto\"\xac\x01\n\x1cWorkflowActivationCompletion\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12:\n\nsuccessful\x18\x02 \x01(\x0b\x32$.coresdk.workflow_completion.SuccessH\x00\x12\x36\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32$.coresdk.workflow_completion.FailureH\x00\x42\x08\n\x06status\"\xac\x01\n\x07Success\x12<\n\x08\x63ommands\x18\x01 \x03(\x0b\x32*.coresdk.workflow_commands.WorkflowCommand\x12\x1b\n\x13used_internal_flags\x18\x06 \x03(\r\x12\x46\n\x13versioning_behavior\x18\x07 \x01(\x0e\x32).temporal.api.enums.v1.VersioningBehavior\"\x81\x01\n\x07\x46\x61ilure\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12\x43\n\x0b\x66orce_cause\x18\x02 \x01(\x0e\x32..temporal.api.enums.v1.WorkflowTaskFailedCauseB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowCompletionb\x06proto3" 15 | 16 | pool = ::Google::Protobuf::DescriptorPool.generated_pool 17 | pool.add_serialized_file(descriptor_data) 18 | 19 | module Temporalio 20 | module Internal 21 | module Bridge 22 | module Api 23 | module WorkflowCompletion 24 | WorkflowActivationCompletion = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_completion.WorkflowActivationCompletion").msgclass 25 | Success = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_completion.Success").msgclass 26 | Failure = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("coresdk.workflow_completion.Failure").msgclass 27 | end 28 | end 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /temporalio/lib/temporalio/worker/activity_executor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'temporalio/worker/activity_executor/fiber' 4 | require 'temporalio/worker/activity_executor/thread_pool' 5 | 6 | module Temporalio 7 | class Worker 8 | # Base class to be extended by activity executor implementations. Most users will not use this, but rather keep with 9 | # the two defaults of thread pool and fiber executors. 10 | class ActivityExecutor 11 | # @return [Hash] Default set of executors (immutable). 12 | def self.defaults 13 | @defaults ||= { 14 | default: ThreadPool.default, 15 | thread_pool: ThreadPool.default, 16 | fiber: Fiber.default 17 | }.freeze 18 | end 19 | 20 | # Initialize an activity. This is called on worker initialize for every activity that will use this executor. This 21 | # allows executor implementations to do eager validation based on the definition. This does not have to be 22 | # implemented and the default is a no-op. 23 | # 24 | # @param defn [Activity::Definition::Info] Activity definition info. 25 | def initialize_activity(defn) 26 | # Default no-op 27 | end 28 | 29 | # Execute the given block in the executor. The block is built to never raise and need no arguments. Implementers 30 | # must implement this. 31 | # 32 | # @param defn [Activity::Definition::Info] Activity definition info. 33 | # @yield Block to execute. 34 | def execute_activity(defn, &) 35 | raise NotImplementedError 36 | end 37 | 38 | # @return [Activity::Context, nil] Get the current activity context. This is called by users from inside the 39 | # activity. Implementers must implement this. 40 | def activity_context 41 | raise NotImplementedError 42 | end 43 | 44 | # Set the current activity context (or unset if nil). This is called by the system from within the block given to 45 | # {execute_activity} with a context before user code is executed and with nil after user code is complete. 46 | # Implementers must implement this. 47 | # 48 | # @param defn [Activity::Definition::Info] Activity definition info. 49 | # @param context [Activity::Context, nil] The value to set. 50 | def set_activity_context(defn, context) 51 | raise NotImplementedError 52 | end 53 | end 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /temporalio/sig/temporalio/contrib/open_telemetry.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Contrib 3 | module OpenTelemetry 4 | class TracingInterceptor 5 | include Client::Interceptor 6 | include Worker::Interceptor::Activity 7 | include Worker::Interceptor::Workflow 8 | 9 | attr_reader tracer: untyped 10 | 11 | def initialize: ( 12 | untyped tracer, 13 | ?header_key: String, 14 | ?propagator: untyped, 15 | ?always_create_workflow_spans: bool 16 | ) -> void 17 | 18 | def _apply_context_to_headers: (Hash[String, untyped] headers, ?context: untyped) -> void 19 | def _attach_context: (Hash[String, untyped] headers) -> void 20 | def _context_from_headers: (Hash[String, untyped] headers) -> untyped 21 | def _with_started_span: [T] ( 22 | name: String, 23 | kind: Symbol, 24 | ?attributes: Hash[untyped, untyped]?, 25 | ?outbound_input: untyped 26 | ) { () -> T } -> T 27 | def _always_create_workflow_spans: -> bool 28 | 29 | class WorkflowInbound < Worker::Interceptor::Workflow::Inbound 30 | def initialize: (TracingInterceptor root, Worker::Interceptor::Workflow::Inbound next_interceptor) -> void 31 | 32 | def _attach_context: (Hash[String, untyped] headers) -> void 33 | def _links_from_headers: (Hash[String, untyped] headers) -> Array[untyped] 34 | end 35 | 36 | class WorkflowOutbound < Worker::Interceptor::Workflow::Outbound 37 | def initialize: (TracingInterceptor root, Worker::Interceptor::Workflow::Outbound next_interceptor) -> void 38 | 39 | def _apply_span_to_headers: (Hash[String, untyped] headers, untyped span) -> void 40 | end 41 | end 42 | 43 | module Workflow 44 | def self.with_completed_span: [T] ( 45 | String name, 46 | ?attributes: Hash[untyped, untyped], 47 | ?links: Array[untyped]?, 48 | ?kind: Symbol?, 49 | ?exception: Exception?, 50 | ?even_during_replay: bool 51 | ) { -> T } -> T 52 | 53 | def self.completed_span: ( 54 | String name, 55 | ?attributes: Hash[untyped, untyped], 56 | ?links: Array[untyped]?, 57 | ?kind: Symbol?, 58 | ?exception: Exception?, 59 | ?even_during_replay: bool 60 | ) -> untyped 61 | end 62 | end 63 | end 64 | end -------------------------------------------------------------------------------- /temporalio/test/sig/workflow_utils.rbs: -------------------------------------------------------------------------------- 1 | module WorkflowUtils 2 | def execute_workflow: ( 3 | singleton(Temporalio::Workflow::Definition) workflow, 4 | *Object? args, 5 | ?activities: Array[Temporalio::Activity::Definition | singleton(Temporalio::Activity::Definition)], 6 | ?more_workflows: Array[singleton(Temporalio::Workflow::Definition)], 7 | ?task_queue: String, 8 | ?id: String, 9 | ?search_attributes: Temporalio::SearchAttributes?, 10 | ?memo: Hash[String | Symbol, Object?]?, 11 | ?retry_policy: Temporalio::RetryPolicy?, 12 | ?workflow_failure_exception_types: Array[singleton(Exception)], 13 | ?max_cached_workflows: Integer, 14 | ?logger: Logger?, 15 | ?client: Temporalio::Client, 16 | ?workflow_payload_codec_thread_pool: Temporalio::Worker::ThreadPool?, 17 | ?id_conflict_policy: Temporalio::WorkflowIDConflictPolicy::enum, 18 | ?max_heartbeat_throttle_interval: Float, 19 | ?task_timeout: duration?, 20 | ?on_worker_run: Proc?, 21 | ?unsafe_workflow_io_enabled: bool, 22 | ?priority: Temporalio::Priority, 23 | ?start_workflow_client: Temporalio::Client, 24 | ?tuner: Temporalio::Worker::Tuner 25 | ) -> Object? | 26 | [T] ( 27 | singleton(Temporalio::Workflow::Definition) workflow, 28 | *Object? args, 29 | ?activities: Array[Temporalio::Activity::Definition | singleton(Temporalio::Activity::Definition)], 30 | ?more_workflows: Array[singleton(Temporalio::Workflow::Definition)], 31 | ?task_queue: String, 32 | ?id: String, 33 | ?search_attributes: Temporalio::SearchAttributes?, 34 | ?memo: Hash[String | Symbol, Object?]?, 35 | ?retry_policy: Temporalio::RetryPolicy?, 36 | ?workflow_failure_exception_types: Array[singleton(Exception)], 37 | ?max_cached_workflows: Integer, 38 | ?logger: Logger?, 39 | ?client: Temporalio::Client, 40 | ?workflow_payload_codec_thread_pool: Temporalio::Worker::ThreadPool?, 41 | ?id_conflict_policy: Temporalio::WorkflowIDConflictPolicy::enum, 42 | ?max_heartbeat_throttle_interval: Float, 43 | ?task_timeout: duration?, 44 | ?on_worker_run: Proc?, 45 | ?unsafe_workflow_io_enabled: bool, 46 | ?priority: Temporalio::Priority, 47 | ?start_workflow_client: Temporalio::Client, 48 | ?tuner: Temporalio::Worker::Tuner 49 | ) { (Temporalio::Client::WorkflowHandle, Temporalio::Worker) -> T } -> T 50 | 51 | def assert_eventually_task_fail: ( 52 | handle: Temporalio::Client::WorkflowHandle, 53 | ?message_contains: String? 54 | ) -> void 55 | end 56 | -------------------------------------------------------------------------------- /temporalio/ext/README.md: -------------------------------------------------------------------------------- 1 | # Ruby Rust Bridge 2 | 3 | This is a Ruby extension written in Rust to incorporate https://github.com/temporalio/sdk-core (included as a 4 | submodule). This leverages https://github.com/oxidize-rb/rb-sys and https://github.com/matsadler/magnus. 5 | 6 | ## Tokio Async to Ruby Async 7 | 8 | There is no general accepted way to bridge the gap between async Tokio and async Ruby. It is important not only that 9 | calls to/from Ruby happen with the GVL, but in threads _Ruby_ creates. C extensions cannot reasonably turn a non-Ruby 10 | thread into a Ruby thread. 11 | 12 | What the current implementation does is asks the Ruby side to instantiate and run a "command loop". This eats up a 13 | single Ruby thread for the life of the runtime (which is usually the life of the process). This run-command-loop call 14 | unlocks the GVL and waits on a Rust mpsc channel to feed it work. Ignoring shutdown machinations, the work is just a 15 | Ruby callback. When the Rust channel receives a Ruby callback on this Ruby thread, it re-acquires the GVL and runs the 16 | callback. Since this occurs serially for each callback in a single thread the callback is expected to be very fast. 17 | 18 | Each thing that needs to do some async Tokio call, calls a helper with two things: the future to spawn in Tokio runtime, 19 | and the callback to handle the results in the Ruby thread. All users of this helper are expected to do basically 20 | everything in the async Tokio function, and do a very simple Ruby block call (or similar) in the callback. 21 | 22 | So async calls usually looks like this: 23 | 24 | * In Ruby, call method implemented in Rust, e.g. 25 | 26 | ``` 27 | queue = Queue.new 28 | some_bridge_thing.do_foo(queue) 29 | queue.pop 30 | ``` 31 | 32 | * In Rust, `do_foo` spawns some Tokio async thing and returns 33 | * Once Tokio async thing is completed, in the Ruby-thread callback, Rust side converts that thing to a Ruby thing and 34 | pushes to the queue 35 | 36 | This allows Ruby to remain async if in a Fiber, because Ruby `queue.pop` does not block a thread when in a Fiber 37 | context. The invocation of a queue push with a value is quite cheap in Ruby. 38 | 39 | ## Argument Passing 40 | 41 | For the smallest set of arguments, a simple positional or kwarg is fine. For anything larger, a `Struct` defined on the 42 | Ruby side should be used. Parameters to Ruby functions defined in Rust should have no defaults. We want to make sure we 43 | catch any missing arguments eagerly (e.g. the first test that even uses the struct/args). -------------------------------------------------------------------------------- /temporalio/sig/temporalio/internal/worker/activity_worker.rbs: -------------------------------------------------------------------------------- 1 | module Temporalio 2 | module Internal 3 | module Worker 4 | class ActivityWorker 5 | attr_reader worker: Temporalio::Worker 6 | attr_reader bridge_worker: Bridge::Worker 7 | 8 | def initialize: ( 9 | worker: Temporalio::Worker, 10 | bridge_worker: Bridge::Worker, 11 | ) -> void 12 | 13 | def set_running_activity: (String task_token, RunningActivity? activity) -> void 14 | def get_running_activity: (String task_token) -> RunningActivity? 15 | def remove_running_activity: (String task_token) -> void 16 | def wait_all_complete: -> void 17 | 18 | def handle_task: (untyped task) -> void 19 | def handle_start_task: (String task_token, untyped start) -> void 20 | def handle_cancel_task: (String task_token, untyped cancel) -> void 21 | 22 | def execute_activity: (String task_token, Activity::Definition::Info defn, untyped start) -> void 23 | def run_activity: ( 24 | Activity::Definition::Info defn, 25 | RunningActivity activity, 26 | Temporalio::Worker::Interceptor::Activity::ExecuteInput input 27 | ) -> void 28 | 29 | def assert_valid_activity: (String activity) -> void 30 | 31 | class RunningActivity < Activity::Context 32 | attr_reader _server_requested_cancel: bool 33 | attr_accessor instance: Activity::Definition? 34 | attr_accessor _outbound_impl: Temporalio::Worker::Interceptor::Activity::Outbound? 35 | 36 | def initialize: ( 37 | worker: Temporalio::Worker, 38 | info: Activity::Info, 39 | cancellation: Cancellation, 40 | worker_shutdown_cancellation: Cancellation, 41 | payload_converter: Converters::PayloadConverter, 42 | logger: ScopedLogger, 43 | runtime_metric_meter: Metric::Meter 44 | ) -> void 45 | 46 | def _cancel: ( 47 | reason: String, 48 | details: Activity::CancellationDetails 49 | ) -> void 50 | end 51 | 52 | class InboundImplementation < Temporalio::Worker::Interceptor::Activity::Inbound 53 | def initialize: (ActivityWorker worker) -> void 54 | end 55 | 56 | class OutboundImplementation < Temporalio::Worker::Interceptor::Activity::Outbound 57 | def initialize: (ActivityWorker worker, String task_token) -> void 58 | end 59 | end 60 | end 61 | end 62 | end -------------------------------------------------------------------------------- /temporalio/test/workflow_utils.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'securerandom' 4 | require 'temporalio/client' 5 | require 'temporalio/testing' 6 | require 'temporalio/worker' 7 | require 'temporalio/workflow' 8 | require 'test' 9 | 10 | module WorkflowUtils 11 | # @type instance: Test 12 | 13 | def execute_workflow( 14 | workflow, 15 | *args, 16 | activities: [], 17 | more_workflows: [], 18 | task_queue: "tq-#{SecureRandom.uuid}", 19 | id: "wf-#{SecureRandom.uuid}", 20 | search_attributes: nil, 21 | memo: nil, 22 | retry_policy: nil, 23 | workflow_failure_exception_types: [], 24 | max_cached_workflows: 1000, 25 | logger: nil, 26 | client: env.client, 27 | workflow_payload_codec_thread_pool: nil, 28 | id_conflict_policy: Temporalio::WorkflowIDConflictPolicy::UNSPECIFIED, 29 | max_heartbeat_throttle_interval: 60.0, 30 | task_timeout: nil, 31 | interceptors: [], 32 | on_worker_run: nil, 33 | unsafe_workflow_io_enabled: false, 34 | priority: Temporalio::Priority.default, 35 | start_workflow_client: client, 36 | tuner: Temporalio::Worker::Tuner.create_fixed 37 | ) 38 | worker = Temporalio::Worker.new( 39 | client:, 40 | task_queue:, 41 | activities:, 42 | workflows: [workflow] + more_workflows, 43 | workflow_failure_exception_types:, 44 | max_cached_workflows:, 45 | logger: logger || client.options.logger, 46 | workflow_payload_codec_thread_pool:, 47 | max_heartbeat_throttle_interval:, 48 | interceptors:, 49 | unsafe_workflow_io_enabled:, 50 | tuner: 51 | ) 52 | worker.run do 53 | on_worker_run&.call 54 | handle = start_workflow_client.start_workflow( 55 | workflow, 56 | *args, 57 | id:, 58 | task_queue: worker.task_queue, 59 | search_attributes:, 60 | memo:, 61 | retry_policy:, 62 | id_conflict_policy:, 63 | task_timeout:, 64 | priority: 65 | ) 66 | if block_given? 67 | yield handle, worker 68 | else 69 | handle.result 70 | end 71 | end 72 | end 73 | 74 | def assert_eventually_task_fail(handle:, message_contains: nil) 75 | assert_eventually do 76 | event = handle.fetch_history_events.find(&:workflow_task_failed_event_attributes) 77 | refute_nil event 78 | assert_includes(event.workflow_task_failed_event_attributes.failure.message, message_contains) if message_contains 79 | event 80 | end 81 | end 82 | end 83 | --------------------------------------------------------------------------------