From 2bfa9af5cfe91e426ef76c17b98e64d273c400ee Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Wed, 28 Aug 2024 17:29:48 -0500 Subject: [PATCH] RBS work and other things --- temporalio/Rakefile | 34 +++++- temporalio/Steepfile | 2 +- temporalio/ext/src/client.rs | 4 +- temporalio/lib/temporalio/client.rb | 22 ++-- .../lib/temporalio/client/connection.rb | 33 ++--- .../temporalio/client/connection/service.rb | 2 +- .../lib/temporalio/client/workflow_handle.rb | 12 +- .../converters/failure_converter.rb | 18 +-- .../temporalio/converters/payload_codec.rb | 9 ++ .../converters/payload_converter.rb | 3 +- .../payload_converter/binary_protobuf.rb | 2 + .../converters/payload_converter/composite.rb | 2 +- .../payload_converter/json_protobuf.rb | 1 + .../lib/temporalio/internal/bridge/runtime.rb | 2 +- temporalio/lib/temporalio/runtime.rb | 30 +++-- .../lib/temporalio/search_attributes.rb | 36 ++++-- temporalio/rbs_collection.lock.yaml | 18 +-- temporalio/sig/temporalio.rbs | 1 - temporalio/sig/temporalio/api.rbs | 4 + temporalio/sig/temporalio/client.rbs | 102 ++++++++++++++++ .../sig/temporalio/client/connection.rbs | 114 ++++++++++++++++++ .../client/connection/cloud_service.rbs | 44 +++++++ .../client/connection/operator_service.rbs | 23 ++++ .../temporalio/client/connection/service.rbs | 19 +++ .../client/connection/workflow_service.rbs | 74 ++++++++++++ .../sig/temporalio/client/interceptor.rbs | 95 +++++++++++++++ .../sig/temporalio/client/workflow_handle.rbs | 43 +++++++ temporalio/sig/temporalio/common_enums.rbs | 19 +++ .../temporalio/converters/data_converter.rbs | 26 ++++ .../converters/failure_converter.rbs | 12 ++ .../temporalio/converters/payload_codec.rbs | 7 ++ .../converters/payload_converter.rbs | 15 +++ .../payload_converter/binary_null.rbs | 8 ++ .../payload_converter/binary_plain.rbs | 8 ++ .../payload_converter/binary_protobuf.rbs | 8 ++ .../payload_converter/composite.rbs | 16 +++ .../converters/payload_converter/encoding.rbs | 13 ++ .../payload_converter/json_plain.rbs | 12 ++ .../payload_converter/json_protobuf.rbs | 8 ++ temporalio/sig/temporalio/error.rbs | 63 ++++++++++ temporalio/sig/temporalio/internal/bridge.rbs | 17 +++ .../sig/temporalio/internal/bridge/client.rbs | 108 ++++++++++++++++- .../temporalio/internal/bridge/runtime.rbs | 83 +++++++++++++ .../temporalio/internal/bridge/testing.rbs | 56 +++++++++ .../sig/temporalio/internal/proto_utils.rbs | 12 ++ temporalio/sig/temporalio/retry_policy.rbs | 17 +++ temporalio/sig/temporalio/runtime.rbs | 105 ++++++++++++++++ .../sig/temporalio/search_attributes.rbs | 59 +++++++++ temporalio/sig/temporalio/testing.rbs | 4 + .../testing/workflow_environment.rbs | 48 ++++++++ temporalio/sig/temporalio/version.rbs | 3 + temporalio/temporalio.gemspec | 2 +- temporalio/test/client_test.rb | 6 +- temporalio/test/sig/client_test.rbs | 3 + temporalio/test/sig/test.rbs | 22 ++++ temporalio/test/sig/test_helper.rbs | 0 temporalio/test/{test_helper.rb => test.rb} | 12 +- 57 files changed, 1424 insertions(+), 97 deletions(-) create mode 100644 temporalio/lib/temporalio/converters/payload_codec.rb create mode 100644 temporalio/sig/temporalio/api.rbs create mode 100644 temporalio/sig/temporalio/client.rbs create mode 100644 temporalio/sig/temporalio/client/connection.rbs create mode 100644 temporalio/sig/temporalio/client/connection/cloud_service.rbs create mode 100644 temporalio/sig/temporalio/client/connection/operator_service.rbs create mode 100644 temporalio/sig/temporalio/client/connection/service.rbs create mode 100644 temporalio/sig/temporalio/client/connection/workflow_service.rbs create mode 100644 temporalio/sig/temporalio/client/interceptor.rbs create mode 100644 temporalio/sig/temporalio/client/workflow_handle.rbs create mode 100644 temporalio/sig/temporalio/common_enums.rbs create mode 100644 temporalio/sig/temporalio/converters/data_converter.rbs create mode 100644 temporalio/sig/temporalio/converters/failure_converter.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_codec.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/binary_null.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/binary_plain.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/binary_protobuf.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/composite.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/encoding.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/json_plain.rbs create mode 100644 temporalio/sig/temporalio/converters/payload_converter/json_protobuf.rbs create mode 100644 temporalio/sig/temporalio/error.rbs create mode 100644 temporalio/sig/temporalio/internal/bridge.rbs create mode 100644 temporalio/sig/temporalio/internal/bridge/runtime.rbs create mode 100644 temporalio/sig/temporalio/internal/bridge/testing.rbs create mode 100644 temporalio/sig/temporalio/internal/proto_utils.rbs create mode 100644 temporalio/sig/temporalio/retry_policy.rbs create mode 100644 temporalio/sig/temporalio/runtime.rbs create mode 100644 temporalio/sig/temporalio/search_attributes.rbs create mode 100644 temporalio/sig/temporalio/testing.rbs create mode 100644 temporalio/sig/temporalio/testing/workflow_environment.rbs create mode 100644 temporalio/sig/temporalio/version.rbs create mode 100644 temporalio/test/sig/client_test.rbs create mode 100644 temporalio/test/sig/test.rbs delete mode 100644 temporalio/test/sig/test_helper.rbs rename temporalio/test/{test_helper.rb => test.rb} (88%) diff --git a/temporalio/Rakefile b/temporalio/Rakefile index a09be1bc..47db256a 100644 --- a/temporalio/Rakefile +++ b/temporalio/Rakefile @@ -134,7 +134,7 @@ namespace :proto do desc = Google::Protobuf::DescriptorPool.generated_pool.lookup(qualified_service_name) raise 'Failed finding service descriptor' unless desc - # Open file to generate + # Open file to generate Ruby code File.open("lib/temporalio/client/connection/#{file_name}.rb", 'w') do |file| file.puts <<~TEXT # frozen_string_literal: true @@ -189,6 +189,35 @@ namespace :proto do end TEXT end + + # Open file to generate RBS code + # TODO(cretz): Improve this when RBS proto is supported + File.open("sig/temporalio/client/connection/#{file_name}.rbs", 'w') do |file| + file.puts <<~TEXT + # Generated code. DO NOT EDIT! + + module Temporalio + class Client + class Connection + class #{class_name} < Service + def initialize: (Connection) -> void + TEXT + + desc.each do |method| + # Camel case to snake case + rpc = method.name.gsub(/([A-Z])/, '_\1').downcase.delete_prefix('_') + file.puts <<-TEXT + def #{rpc}: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + TEXT + end + + file.puts <<~TEXT + end + end + end + end + TEXT + end end require './lib/temporalio/api/workflowservice/v1/service' @@ -293,5 +322,4 @@ Rake::Task[:build].enhance([:copy_parent_files]) do rm ['LICENSE', 'README.md'] end -# TODO(cretz): Add rbs:install_collection and :steep back when RBS is ready -task default: %i[rubocop compile test] +task default: ['rubocop', 'compile', 'rbs:install_collection', 'steep', 'test'] diff --git a/temporalio/Steepfile b/temporalio/Steepfile index d1a1a09d..713f0f63 100644 --- a/temporalio/Steepfile +++ b/temporalio/Steepfile @@ -12,7 +12,7 @@ target :lib do library 'uri' configure_code_diagnostics do |hash| + # TODO(cretz): Fix as more protos are generated hash[D::Ruby::UnknownConstant] = :information - hash[D::Ruby::NoMethod] = :information end end diff --git a/temporalio/ext/src/client.rs b/temporalio/ext/src/client.rs index f3ab6678..e9315b43 100644 --- a/temporalio/ext/src/client.rs +++ b/temporalio/ext/src/client.rs @@ -39,7 +39,7 @@ pub fn init(ruby: &Ruby) -> Result<(), Error> { class.define_singleton_method("async_new", function!(Client::async_new, 2))?; class.define_method("async_invoke_rpc", method!(Client::async_invoke_rpc, -1))?; - let inner_class = class.define_error("RpcFailure", ruby.get_inner(&ROOT_ERR))?; + let inner_class = class.define_error("RPCFailure", ruby.get_inner(&ROOT_ERR))?; inner_class.define_method("code", method!(RpcFailure::code, 0))?; inner_class.define_method("message", method!(RpcFailure::message, 0))?; inner_class.define_method("details", method!(RpcFailure::details, 0))?; @@ -220,7 +220,7 @@ impl Client { #[derive(DataTypeFunctions, TypedData)] #[magnus( - class = "Temporalio::Internal::Bridge::Client::RpcFailure", + class = "Temporalio::Internal::Bridge::Client::RPCFailure", free_immediately )] pub struct RpcFailure { diff --git a/temporalio/lib/temporalio/client.rb b/temporalio/lib/temporalio/client.rb index 6fedac07..c3aa1a9f 100644 --- a/temporalio/lib/temporalio/client.rb +++ b/temporalio/lib/temporalio/client.rb @@ -16,15 +16,15 @@ module Temporalio # Client for accessing Temporal. # # Most users will use {connect} to connect a client. The {workflow_service} method provides access to a raw gRPC - # client. To create another client on the same connection, like for a different namespace, {dup_options} may be - # used to get the options as a struct which can then be altered and splatted as kwargs to the constructor (e.g. + # client. To create another client on the same connection, like for a different namespace, {options} may be used to + # get the options as a struct which can then be dup'd, altered, and splatted as kwargs to the constructor (e.g. # +Client.new(**my_options.to_h)+). # # Clients are thread-safe and are meant to be reused for the life of the application. They are built to work in both # synchronous and asynchronous contexts. Internally they use callbacks based on {::Queue} which means they are # Fiber-compatible. class Client - # Options as returned from {dup_options} for +**to_h+ splat use in {initialize}. See {initialize} for details. + # Options as returned from {options} for +**to_h+ splat use in {initialize}. See {initialize} for details. Options = Struct.new( :connection, :namespace, @@ -58,7 +58,7 @@ class Client # @param identity [String] Identity for this client. # @param keep_alive [Connection::KeepAliveOptions] Keep-alive options for the client connection. Can be set to +nil+ # to disable. - # @param http_connect_proxy [Connection::HTTPConnectProxyOptions] Options for HTTP CONNECT proxy. + # @param http_connect_proxy [Connection::HTTPConnectProxyOptions, nil] Options for HTTP CONNECT proxy. # @param runtime [Runtime] Runtime for this client. # @param lazy_connect [Boolean] If true, the client will not connect until the first call is attempted or a worker # is created with it. Lazy clients cannot be used for workers if they have not performed a connection. @@ -103,8 +103,12 @@ def self.connect( ) end + # @return [Options] Frozen options for this client which has the same attributes as {initialize}. + attr_reader :options + # Create a client from an existing connection. Most users will prefer {connect} instead. Parameters here match - # {Options} returned from {dup_options} by intention so options can be altered and splatted to create a new client. + # {Options} returned from {options} by intention so options can be dup'd, altered, and splatted to create a new + # client. # # @param connection [Connection] Existing connection to create a client from. # @param namespace [String] Namespace to use for client calls. @@ -132,7 +136,7 @@ def initialize( data_converter:, interceptors:, default_workflow_query_reject_condition: - ) + ).freeze # Initialize interceptors @impl = interceptors.reverse_each.reduce(Implementation.new(self)) do |acc, int| int.intercept_client(acc) @@ -164,12 +168,6 @@ def operator_service connection.operator_service end - # @return [Options] Shallow duplication of options for potential use in {initialize}. Note, this is shallow, so - # attributes like {Options.interceptors} are not duplicated, but no mutations will apply. - def dup_options - @options.dup - end - # Start a workflow and return its handle. # # @param workflow [Workflow, String] Name of the workflow diff --git a/temporalio/lib/temporalio/client/connection.rb b/temporalio/lib/temporalio/client/connection.rb index ec9be937..f584d9d5 100644 --- a/temporalio/lib/temporalio/client/connection.rb +++ b/temporalio/lib/temporalio/client/connection.rb @@ -13,7 +13,7 @@ class Client # Connection to Temporal server that is not namespace specific. Most users will use {Client.connect} instead of this # directly. class Connection - # Options as returned from {dup_options} for +**to_h+ splat use in {initialize}. See {initialize} for details. + # Options as returned from {options} for +**to_h+ splat use in {initialize}. See {initialize} for details. Options = Struct.new( :target_host, :api_key, @@ -72,7 +72,8 @@ class Connection :max_retries, keyword_init: true ) do - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:initial_interval] = 0.1 unless kwargs.key?(:initial_interval) kwargs[:randomization_factor] = 0.2 unless kwargs.key?(:randomization_factor) kwargs[:multiplier] = 1.5 unless kwargs.key?(:multiplier) @@ -95,7 +96,8 @@ def initialize(*, **kwargs) :timeout, keyword_init: true ) do - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:interval] = 30.0 unless kwargs.key?(:interval) kwargs[:timeout] = 15.0 unless kwargs.key?(:timeout) super @@ -117,8 +119,8 @@ def initialize(*, **kwargs) keyword_init: true ) - # @return [String] Client identity. - attr_reader :identity + # @return [Options] Frozen options for this client which has the same attributes as {initialize}. + attr_reader :options # @return [WorkflowService] Raw gRPC workflow service. attr_reader :workflow_service @@ -130,7 +132,7 @@ def initialize(*, **kwargs) attr_reader :cloud_service # Connect to Temporal server. Most users will use {Client.connect} instead of this directly. Parameters here match - # {Options} returned from {dup_options} by intention so options can be altered and splatted to create a new + # {Options} returned from {options} by intention so options can be dup'd, altered, splatted to create a new # connection. # # @param target_host [String] +host:port+ for the Temporal server. For local development, this is often @@ -146,7 +148,7 @@ def initialize(*, **kwargs) # @param identity [String] Identity for this client. # @param keep_alive [KeepAliveOptions] Keep-alive options for the client connection. Can be set to +nil+ to # disable. - # @param http_connect_proxy [HTTPConnectProxyOptions] Options for HTTP CONNECT proxy. + # @param http_connect_proxy [HTTPConnectProxyOptions, nil] Options for HTTP CONNECT proxy. # @param runtime [Runtime] Runtime for this client. # @param lazy_connect [Boolean] If true, there is no connection until the first call is attempted or a worker # is created with it. Clients from lazy connections cannot be used for workers if they have not performed a @@ -176,7 +178,7 @@ def initialize( http_connect_proxy:, runtime:, lazy_connect: - ) + ).freeze # Create core client now if not lazy _core_client unless lazy_connect # Create service instances @@ -190,10 +192,9 @@ def target_host @options.target_host end - # @return [Options] Shallow duplication of options for potential use in {initialize}. Note, this is shallow, so - # attributes like {Options.rpc_metadata} are not duplicated, but no mutations will apply. - def dup_options - @options.dup + # @return [String] Client identity. + def identity + @options.identity end # @return [Boolean] Whether this connection is connected. This is always `true` unless `lazy_connect` option was @@ -237,10 +238,10 @@ def new_core_client if @options.tls options.tls = if @options.tls.is_a?(TLSOptions) Internal::Bridge::Client::TLSOptions.new( - client_cert: @options.tls.client_cert, - client_private_key: @options.tls.client_private_key, - server_root_ca_cert: @options.tls.server_root_ca_cert, - domain: @options.tls.domain + client_cert: @options.tls.client_cert, # steep:ignore + client_private_key: @options.tls.client_private_key, # steep:ignore + server_root_ca_cert: @options.tls.server_root_ca_cert, # steep:ignore + domain: @options.tls.domain # steep:ignore ) else Internal::Bridge::Client::TLSOptions.new diff --git a/temporalio/lib/temporalio/client/connection/service.rb b/temporalio/lib/temporalio/client/connection/service.rb index 006d8e2a..8fe12deb 100644 --- a/temporalio/lib/temporalio/client/connection/service.rb +++ b/temporalio/lib/temporalio/client/connection/service.rb @@ -31,7 +31,7 @@ def invoke_rpc(rpc:, request_class:, response_class:, request:, rpc_retry:, rpc_ rpc_metadata:, rpc_timeout: ) - rescue Internal::Bridge::Client::RpcFailure => e + rescue Internal::Bridge::Client::RPCFailure => e raise Error::RPCError.new(e.message, code: e.code, raw_grpc_status: e.details) end end diff --git a/temporalio/lib/temporalio/client/workflow_handle.rb b/temporalio/lib/temporalio/client/workflow_handle.rb index 5acd7ba2..e30292ff 100644 --- a/temporalio/lib/temporalio/client/workflow_handle.rb +++ b/temporalio/lib/temporalio/client/workflow_handle.rb @@ -92,13 +92,13 @@ def result( when :EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED attrs = event.workflow_execution_completed_event_attributes hist_run_id = attrs.new_execution_run_id - next if follow_runs && !hist_run_id.empty? + next if follow_runs && hist_run_id && !hist_run_id.empty? return @client.data_converter.from_payloads(attrs.result).first when :EVENT_TYPE_WORKFLOW_EXECUTION_FAILED attrs = event.workflow_execution_failed_event_attributes hist_run_id = attrs.new_execution_run_id - next if follow_runs && !hist_run_id.empty? + next if follow_runs && hist_run_id && !hist_run_id.empty? raise Error::WorkflowFailureError.new(cause: @client.data_converter.from_failure(attrs.failure)) when :EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED @@ -120,7 +120,7 @@ def result( when :EVENT_TYPE_WORKFLOW_EXECUTION_TIMED_OUT attrs = event.workflow_execution_timed_out_event_attributes hist_run_id = attrs.new_execution_run_id - next if follow_runs && !hist_run_id.empty? + next if follow_runs && hist_run_id && !hist_run_id.empty? raise Error::WorkflowFailureError.new( cause: Error::TimeoutError.new( @@ -131,7 +131,7 @@ def result( when :EVENT_TYPE_WORKFLOW_EXECUTION_CONTINUED_AS_NEW attrs = event.workflow_execution_continued_as_new_event_attributes hist_run_id = attrs.new_execution_run_id - next if follow_runs && !hist_run_id.empty? + next if follow_runs && hist_run_id && !hist_run_id.empty? # TODO: Use more specific error and decode failure raise Error::WorkflowContinuedAsNewError.new(new_run_id: attrs.new_execution_run_id) @@ -182,8 +182,8 @@ def fetch_history_events_for_run( wait_new_event:, event_filter_type:, skip_archival:, - rpc_metadata: nil, - rpc_timeout: nil + rpc_metadata:, + rpc_timeout: ) Enumerator.new do |yielder| input = Interceptor::FetchWorkflowHistoryEventPageInput.new( diff --git a/temporalio/lib/temporalio/converters/failure_converter.rb b/temporalio/lib/temporalio/converters/failure_converter.rb index 5e337b69..2aa4e6a5 100644 --- a/temporalio/lib/temporalio/converters/failure_converter.rb +++ b/temporalio/lib/temporalio/converters/failure_converter.rb @@ -19,20 +19,22 @@ def initialize(encode_common_attributes: false) # Convert a Ruby error to a Temporal failure. # - # @param _error [Exception] Ruby error. - # @param _payload_converter [PayloadConverter] Payload converter. + # @param error [Exception] Ruby error. + # @param payload_converter [PayloadConverter] Payload converter. # @return [Api::Failure::V1::Failure] Converted failure. - def to_failure(_error, _payload_converter) - raise 'TODO' + def to_failure(error, payload_converter) + # TODO + raise NotImplementedError end # Convert a Temporal failure to a Ruby error. # - # @param _failure [Api::Failure::V1::Failure] Failure. - # @param _payload_converter [PayloadConverter] Payload converter. + # @param failure [Api::Failure::V1::Failure] Failure. + # @param payload_converter [PayloadConverter] Payload converter. # @return [Exception] Converted Ruby error. - def from_failure(_failure, _payload_converter) - raise 'TODO' + def from_failure(failure, payload_converter) + # TODO + raise NotImplementedError end end end diff --git a/temporalio/lib/temporalio/converters/payload_codec.rb b/temporalio/lib/temporalio/converters/payload_codec.rb new file mode 100644 index 00000000..9787ba55 --- /dev/null +++ b/temporalio/lib/temporalio/converters/payload_codec.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Temporalio + module Converters + class PayloadCodec # rubocop:disable Lint/EmptyClass + # TODO + end + end +end diff --git a/temporalio/lib/temporalio/converters/payload_converter.rb b/temporalio/lib/temporalio/converters/payload_converter.rb index bc78b565..97b100b6 100644 --- a/temporalio/lib/temporalio/converters/payload_converter.rb +++ b/temporalio/lib/temporalio/converters/payload_converter.rb @@ -11,7 +11,7 @@ module Temporalio module Converters # Base class for converting Ruby values to/from Temporal payloads. class PayloadConverter - # @return [FailureConverter] Default payload converter. + # @return [PayloadConverter] Default payload converter. def self.default @default ||= new_with_defaults end @@ -20,6 +20,7 @@ def self.default # # @param json_parse_options [Hash] Options for {::JSON.parse}. # @param json_generate_options [Hash] Options for {::JSON.generate}. + # @return [PayloadConverter] Created payload converter. def self.new_with_defaults(json_parse_options: { create_additions: true }, json_generate_options: {}) Ractor.make_shareable( PayloadConverter::Composite.new( diff --git a/temporalio/lib/temporalio/converters/payload_converter/binary_protobuf.rb b/temporalio/lib/temporalio/converters/payload_converter/binary_protobuf.rb index 43580f17..6061134b 100644 --- a/temporalio/lib/temporalio/converters/payload_converter/binary_protobuf.rb +++ b/temporalio/lib/temporalio/converters/payload_converter/binary_protobuf.rb @@ -20,6 +20,7 @@ def encoding def to_payload(value) return nil unless value.is_a?(Google::Protobuf::MessageExts) + # @type var value: Google::Protobuf::MessageExts Api::Common::V1::Payload.new( metadata: { 'encoding' => ENCODING, 'messageType' => value.class.descriptor.name }, data: value.to_proto @@ -29,6 +30,7 @@ def to_payload(value) # (see Encoding.from_payload) def from_payload(payload) type = payload.metadata['messageType'] + # @type var desc: untyped desc = Google::Protobuf::DescriptorPool.generated_pool.lookup(type) raise "No protobuf message found in global pool for message type #{type}" unless desc diff --git a/temporalio/lib/temporalio/converters/payload_converter/composite.rb b/temporalio/lib/temporalio/converters/payload_converter/composite.rb index a408817d..9add8e6a 100644 --- a/temporalio/lib/temporalio/converters/payload_converter/composite.rb +++ b/temporalio/lib/temporalio/converters/payload_converter/composite.rb @@ -13,7 +13,7 @@ class Composite < PayloadConverter class ConverterNotFound < Error; end class EncodingNotSet < Error; end - # @return [Array] Encoding converters processed in order. + # @return [Hash] Encoding converters processed in order. attr_reader :converters # Create a payload converter with the given encoding converters processed in order. diff --git a/temporalio/lib/temporalio/converters/payload_converter/json_protobuf.rb b/temporalio/lib/temporalio/converters/payload_converter/json_protobuf.rb index 89f8fb79..96e7f31a 100644 --- a/temporalio/lib/temporalio/converters/payload_converter/json_protobuf.rb +++ b/temporalio/lib/temporalio/converters/payload_converter/json_protobuf.rb @@ -29,6 +29,7 @@ def to_payload(value) # (see Encoding.from_payload) def from_payload(payload) type = payload.metadata['messageType'] + # @type var desc: untyped desc = Google::Protobuf::DescriptorPool.generated_pool.lookup(type) raise "No protobuf message found in global pool for message type #{type}" unless desc diff --git a/temporalio/lib/temporalio/internal/bridge/runtime.rb b/temporalio/lib/temporalio/internal/bridge/runtime.rb index df73b063..5814d827 100644 --- a/temporalio/lib/temporalio/internal/bridge/runtime.rb +++ b/temporalio/lib/temporalio/internal/bridge/runtime.rb @@ -47,7 +47,7 @@ class Runtime ) # @!visibility private - PrometheusOptions = Struct.new( + PrometheusMetricsOptions = Struct.new( :bind_address, :counters_total_suffix, :unit_suffix, diff --git a/temporalio/lib/temporalio/runtime.rb b/temporalio/lib/temporalio/runtime.rb index c65365ea..83511d2b 100644 --- a/temporalio/lib/temporalio/runtime.rb +++ b/temporalio/lib/temporalio/runtime.rb @@ -22,13 +22,15 @@ class Runtime keyword_init: true ) do # @!visibility private - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:logging] = LoggingOptions.new unless kwargs.key?(:logging) super end # @!visibility private def _to_bridge + # @type self: TelemetryOptions Internal::Bridge::Runtime::TelemetryOptions.new( logging: logging&._to_bridge, metrics: metrics&._to_bridge @@ -47,13 +49,15 @@ def _to_bridge keyword_init: true ) do # @!visibility private - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:log_filter] = LoggingFilterOptions.new unless kwargs.key?(:log_filter) super end # @!visibility private def _to_bridge + # @type self: LoggingOptions Internal::Bridge::Runtime::LoggingOptions.new( log_filter: if log_filter.is_a?(String) log_filter @@ -78,7 +82,8 @@ def _to_bridge keyword_init: true ) do # @!visibility private - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:core_level] = 'WARN' unless kwargs.key?(:core_level) kwargs[:other_level] = 'ERROR' unless kwargs.key?(:other_level) super @@ -86,6 +91,7 @@ def initialize(*, **kwargs) # @!visibility private def _to_bridge + # @type self: LoggingFilterOptions "#{other_level},temporal_sdk_core=#{core_level},temporal_client=#{core_level},temporal_sdk=#{core_level}" end end @@ -113,13 +119,15 @@ def _to_bridge keyword_init: true ) do # @!visibility private - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:attach_service_name] = true unless kwargs.key?(:attach_service_name) super end # @!visibility private def _to_bridge + # @type self: MetricsOptions Internal::Bridge::Runtime::MetricsOptions.new( opentelemetry: opentelemetry&._to_bridge, prometheus: prometheus&._to_bridge, @@ -159,7 +167,8 @@ module MetricTemporality # rubocop:disable Lint/ConstantDefinitionInBlock end # @!visibility private - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:metric_temporality] = MetricTemporality::CUMULATIVE unless kwargs.key?(:metric_temporality) kwargs[:durations_as_seconds] = false unless kwargs.key?(:durations_as_seconds) super @@ -167,6 +176,7 @@ def initialize(*, **kwargs) # @!visibility private def _to_bridge + # @type self: OpenTelemetryMetricsOptions Internal::Bridge::Runtime::OpenTelemetryMetricsOptions.new( url:, headers:, @@ -188,11 +198,11 @@ def _to_bridge # @!attribute counters_total_suffix # @return [Boolean] If +true+, all counters will include a +_total+ suffix, default is +false+. # @!attribute unit_suffix - # @return [String] If +true+, all histograms will include the unit in their name as a suffix, default is +false+. + # @return [Boolean] If +true+, all histograms will include the unit in their name as a suffix, default is +false+. # @!attribute durations_as_seconds # @return [Boolean] Whether to use float seconds instead of integer milliseconds for durations, default is # +false+. - PrometheusOptions = Struct.new( + PrometheusMetricsOptions = Struct.new( :bind_address, :counters_total_suffix, :unit_suffix, @@ -200,7 +210,8 @@ def _to_bridge keyword_init: true ) do # @!visibility private - def initialize(*, **kwargs) + def initialize(**kwargs) + # @type var kwargs: untyped kwargs[:counters_total_suffix] = false unless kwargs.key?(:counters_total_suffix) kwargs[:unit_suffix] = false unless kwargs.key?(:unit_suffix) kwargs[:durations_as_seconds] = false unless kwargs.key?(:durations_as_seconds) @@ -209,7 +220,8 @@ def initialize(*, **kwargs) # @!visibility private def _to_bridge - Internal::Bridge::Runtime::PrometheusOptions.new( + # @type self: PrometheusMetricsOptions + Internal::Bridge::Runtime::PrometheusMetricsOptions.new( bind_address:, counters_total_suffix:, unit_suffix:, diff --git a/temporalio/lib/temporalio/search_attributes.rb b/temporalio/lib/temporalio/search_attributes.rb index b87328f9..1872ed9a 100644 --- a/temporalio/lib/temporalio/search_attributes.rb +++ b/temporalio/lib/temporalio/search_attributes.rb @@ -10,20 +10,30 @@ module Temporalio # class is frozen. class SearchAttributes # Key for a search attribute. - # - # @!attribute name - # @return [String] Name of the search attribute. - # @!attribute type - # @return [IndexedValueType] Type of the search attribute. - Key = Struct.new( - :name, - :type - ) do + class Key + # @return [String] Name of the search attribute. + attr_reader :name + + # @return [IndexedValueType] Type of the search attribute. + attr_reader :type + def initialize(name, type) raise ArgumentError, 'Invalid type' unless Api::Enums::V1::IndexedValueType.lookup(type) - super - freeze + @name = name + @type = type + end + + # @return [Boolean] Check equality. + def ==(other) + other.is_a?(Key) && other.name == @name && other.type == @type + end + + alias eql? == + + # @return [Integer] Hash + def hash + [self.class, @name, @age].hash end # Validate that the given value matches the expected {#type}. @@ -104,7 +114,7 @@ def self.from_proto(proto) key = Key.new(key_name, IndexedValueType::PROTO_VALUES[payload.metadata['type']]) value = Converters::PayloadConverter.default.from_payload(payload) # Time needs to be converted - value = Time.iso8601(value) if key.type == IndexedValueType::TIME + value = Time.iso8601(value) if key.type == IndexedValueType::TIME && value.is_a?(String) [key, value] end.to_h) end @@ -197,7 +207,7 @@ def dup # @return [SearchAttributes] New collection. def update(*updates) attrs = dup - attrs.with_updates!(*updates) + attrs.update!(*updates) attrs end diff --git a/temporalio/rbs_collection.lock.yaml b/temporalio/rbs_collection.lock.yaml index 37d7807a..274e8d62 100644 --- a/temporalio/rbs_collection.lock.yaml +++ b/temporalio/rbs_collection.lock.yaml @@ -6,7 +6,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: async @@ -14,7 +14,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: base64 @@ -30,7 +30,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: csv @@ -58,7 +58,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: grpc @@ -66,7 +66,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: i18n @@ -74,7 +74,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: json @@ -106,7 +106,7 @@ gems: source: type: stdlib - name: rbs - version: 3.5.2 + version: 3.5.3 source: type: rubygems - name: rdoc @@ -142,7 +142,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 0233af5f782a23991cc0b8bd2e5e0e0f882aadee + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems - name: yard @@ -150,7 +150,7 @@ gems: source: type: git name: ruby/gem_rbs_collection - revision: 03121e6bbf2340e3b179edcc351deac45476f4d0 + revision: e9bc1bf94c262e79a2d599a9c173342915b29808 remote: https://github.com/ruby/gem_rbs_collection.git repo_dir: gems gemfile_lock_path: Gemfile.lock diff --git a/temporalio/sig/temporalio.rbs b/temporalio/sig/temporalio.rbs index ae4011bd..66cbc4af 100644 --- a/temporalio/sig/temporalio.rbs +++ b/temporalio/sig/temporalio.rbs @@ -1,3 +1,2 @@ module Temporalio - VERSION: String end diff --git a/temporalio/sig/temporalio/api.rbs b/temporalio/sig/temporalio/api.rbs new file mode 100644 index 00000000..acef0c47 --- /dev/null +++ b/temporalio/sig/temporalio/api.rbs @@ -0,0 +1,4 @@ +module Temporalio + module Api + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/client.rbs b/temporalio/sig/temporalio/client.rbs new file mode 100644 index 00000000..c623b3a8 --- /dev/null +++ b/temporalio/sig/temporalio/client.rbs @@ -0,0 +1,102 @@ +module Temporalio + class Client + class Options + attr_accessor connection: Connection + attr_accessor namespace: String + attr_accessor data_converter: Converters::DataConverter + attr_accessor interceptors: Array[Interceptor] + attr_accessor default_workflow_query_reject_condition: Integer + + def initialize: ( + connection: Connection, + namespace: String, + data_converter: Converters::DataConverter, + interceptors: Array[Interceptor], + default_workflow_query_reject_condition: Integer + ) -> void + end + + def self.connect: ( + String target_host, + String namespace, + ?api_key: String?, + ?tls: bool | Connection::TLSOptions, + ?data_converter: Converters::DataConverter, + ?interceptors: Array[Interceptor], + ?default_workflow_query_reject_condition: Integer, + ?rpc_metadata: Hash[String, String], + ?rpc_retry: Connection::RPCRetryOptions, + ?identity: String, + ?keep_alive: Connection::KeepAliveOptions, + ?http_connect_proxy: Connection::HTTPConnectProxyOptions?, + ?runtime: Runtime, + ?lazy_connect: bool + ) -> Client + + attr_reader options: Options + + def initialize: ( + connection: Connection, + namespace: String, + ?data_converter: Converters::DataConverter, + ?interceptors: Array[Interceptor], + ?default_workflow_query_reject_condition: Integer + ) -> void + + def connection: -> Connection + def namespace: -> String + def data_converter: -> Converters::DataConverter + + # TODO(cretz): Update when generated + # def workflow_service: -> Connection::WorkflowService + # def operator_service: -> Connection::OperatorService + def workflow_service: -> untyped + def operator_service: -> untyped + + def start_workflow: ( + String workflow, + *Object args, + id: String, + task_queue: String, + ?execution_timeout: Float?, + ?run_timeout: Float?, + ?task_timeout: Float?, + ?id_reuse_policy: WorkflowIDReusePolicy::enum, + ?id_conflict_policy: WorkflowIDConflictPolicy::enum, + ?retry_policy: RetryPolicy?, + ?cron_schedule: String?, + ?memo: Hash[String, Object]?, + ?search_attributes: SearchAttributes?, + ?start_delay: Float?, + ?request_eager_start: bool, + ?rpc_metadata: Hash[String, String]?, + ?rpc_timeout: Float? + ) -> WorkflowHandle + + def execute_workflow: ( + String workflow, + *Object args, + id: String, + task_queue: String, + ?execution_timeout: Float?, + ?run_timeout: Float?, + ?task_timeout: Float?, + ?id_reuse_policy: WorkflowIDReusePolicy::enum, + ?id_conflict_policy: WorkflowIDConflictPolicy::enum, + ?retry_policy: RetryPolicy?, + ?cron_schedule: String?, + ?memo: Hash[String, Object]?, + ?search_attributes: SearchAttributes?, + ?start_delay: Float?, + ?request_eager_start: bool, + ?rpc_metadata: Hash[String, String]?, + ?rpc_timeout: Float? + ) -> Object + + def workflow_handle: ( + String workflow_id, + ?run_id: String?, + ?first_execution_run_id: String? + ) -> WorkflowHandle + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/client/connection.rbs b/temporalio/sig/temporalio/client/connection.rbs new file mode 100644 index 00000000..a7475fa6 --- /dev/null +++ b/temporalio/sig/temporalio/client/connection.rbs @@ -0,0 +1,114 @@ +module Temporalio + class Client + class Connection + class Options + attr_accessor target_host: String + attr_accessor api_key: String? + attr_accessor tls: bool | Connection::TLSOptions + attr_accessor rpc_metadata: Hash[String, String] + attr_accessor rpc_retry: RPCRetryOptions + attr_accessor identity: String + attr_accessor keep_alive: KeepAliveOptions + attr_accessor http_connect_proxy: HTTPConnectProxyOptions + attr_accessor runtime: Runtime + attr_accessor lazy_connect: bool + + def initialize: ( + target_host: String, + api_key: String?, + tls: bool | Connection::TLSOptions, + rpc_metadata: Hash[String, String], + rpc_retry: RPCRetryOptions, + identity: String, + keep_alive: KeepAliveOptions, + http_connect_proxy: HTTPConnectProxyOptions?, + runtime: Runtime, + lazy_connect: bool + ) -> void + end + + class TLSOptions + attr_accessor client_cert: String? + attr_accessor client_private_key: String? + attr_accessor server_root_ca_cert: String? + attr_accessor domain: String? + + def initialize: ( + ?client_cert: String?, + ?client_private_key: String?, + ?server_root_ca_cert: String?, + ?domain: String? + ) -> void + end + + class RPCRetryOptions + attr_accessor initial_interval: Float + attr_accessor randomization_factor: Float + attr_accessor multiplier: Float + attr_accessor max_interval: Float + attr_accessor max_elapsed_time: Float + attr_accessor max_retries: Integer + + def initialize: ( + ?initial_interval: Float, + ?randomization_factor: Float, + ?multiplier: Float, + ?max_interval: Float, + ?max_elapsed_time: Float, + ?max_retries: Integer + ) -> void + end + + class KeepAliveOptions + attr_accessor interval: Float + attr_accessor timeout: Float + + def initialize: ( + ?interval: Float, + ?timeout: Float + ) -> void + end + + class HTTPConnectProxyOptions + attr_accessor target_host: String + attr_accessor basic_auth_user: String? + attr_accessor basic_auth_pass: String? + + def initialize: ( + target_host: String, + ?basic_auth_user: String?, + ?basic_auth_pass: String? + ) -> void + end + + attr_reader options: Options + + # TODO(cretz): Update when generated + # attr_reader workflow_service: WorkflowService + # attr_reader operator_service: OperatorService + # attr_reader cloud_service: CloudService + attr_reader workflow_service: untyped + attr_reader operator_service: untyped + attr_reader cloud_service: untyped + + def initialize: ( + target_host: String, + ?api_key: String?, + ?tls: bool | Connection::TLSOptions, + ?rpc_metadata: Hash[String, String], + ?rpc_retry: RPCRetryOptions, + ?identity: String, + ?keep_alive: KeepAliveOptions, + ?http_connect_proxy: HTTPConnectProxyOptions?, + ?runtime: Runtime, + ?lazy_connect: bool + ) -> void + + def target_host: -> String + def identity: -> String + def connected?: -> bool + def _core_client: -> Internal::Bridge::Client + private def new_core_client: -> Internal::Bridge::Client + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/client/connection/cloud_service.rbs b/temporalio/sig/temporalio/client/connection/cloud_service.rbs new file mode 100644 index 00000000..0ef231bf --- /dev/null +++ b/temporalio/sig/temporalio/client/connection/cloud_service.rbs @@ -0,0 +1,44 @@ +# Generated code. DO NOT EDIT! + +module Temporalio + class Client + class Connection + class CloudService < Service + def initialize: (Connection) -> void + def get_users: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_user: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_user: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_user: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_user: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def set_user_namespace_access: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_async_operation: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_namespaces: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def rename_custom_search_attribute: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def failover_namespace_region: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def add_namespace_region: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_regions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_region: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_api_keys: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_api_key: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_api_key: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_api_key: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_api_key: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_user_groups: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_user_group: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_user_group: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_user_group: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_user_group: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def set_user_group_namespace_access: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_service_account: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_service_account: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_service_accounts: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_service_account: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_service_account: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + end + end + end +end diff --git a/temporalio/sig/temporalio/client/connection/operator_service.rbs b/temporalio/sig/temporalio/client/connection/operator_service.rbs new file mode 100644 index 00000000..368d24b4 --- /dev/null +++ b/temporalio/sig/temporalio/client/connection/operator_service.rbs @@ -0,0 +1,23 @@ +# Generated code. DO NOT EDIT! + +module Temporalio + class Client + class Connection + class OperatorService < Service + def initialize: (Connection) -> void + def add_search_attributes: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def remove_search_attributes: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_search_attributes: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def add_or_update_remote_cluster: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def remove_remote_cluster: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_clusters: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_nexus_endpoint: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_nexus_endpoint: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_nexus_endpoint: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_nexus_endpoint: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_nexus_endpoints: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + end + end + end +end diff --git a/temporalio/sig/temporalio/client/connection/service.rbs b/temporalio/sig/temporalio/client/connection/service.rbs new file mode 100644 index 00000000..5c01e0fd --- /dev/null +++ b/temporalio/sig/temporalio/client/connection/service.rbs @@ -0,0 +1,19 @@ +module Temporalio + class Client + class Connection + class Service + def initialize: (Connection, untyped) -> void + + def invoke_rpc: [REQ < Object, RESP < Object] ( + rpc: String, + request_class: class REQ, + response_class: class RESP, + request: REQ, + rpc_retry: bool, + rpc_metadata: Hash[String, String]?, + rpc_timeout: Float? + ) -> RESP + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/client/connection/workflow_service.rbs b/temporalio/sig/temporalio/client/connection/workflow_service.rbs new file mode 100644 index 00000000..e46071a4 --- /dev/null +++ b/temporalio/sig/temporalio/client/connection/workflow_service.rbs @@ -0,0 +1,74 @@ +# Generated code. DO NOT EDIT! + +module Temporalio + class Client + class Connection + class WorkflowService < Service + def initialize: (Connection) -> void + def register_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def describe_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_namespaces: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def deprecate_namespace: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def start_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def execute_multi_operation: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_workflow_execution_history: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_workflow_execution_history_reverse: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def poll_workflow_task_queue: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_workflow_task_completed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_workflow_task_failed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def poll_activity_task_queue: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def record_activity_task_heartbeat: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def record_activity_task_heartbeat_by_id: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_activity_task_completed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_activity_task_completed_by_id: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_activity_task_failed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_activity_task_failed_by_id: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_activity_task_canceled: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_activity_task_canceled_by_id: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def request_cancel_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def signal_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def signal_with_start_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def reset_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def terminate_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_open_workflow_executions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_closed_workflow_executions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_workflow_executions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_archived_workflow_executions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def scan_workflow_executions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def count_workflow_executions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_search_attributes: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_query_task_completed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def reset_sticky_task_queue: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def query_workflow: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def describe_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def describe_task_queue: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_cluster_info: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_system_info: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_task_queue_partitions: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def create_schedule: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def describe_schedule: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_schedule: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def patch_schedule: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_schedule_matching_times: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def delete_schedule: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_schedules: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_worker_build_id_compatibility: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_worker_build_id_compatibility: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_worker_versioning_rules: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_worker_versioning_rules: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def get_worker_task_reachability: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def update_workflow_execution: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def poll_workflow_execution_update: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def start_batch_operation: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def stop_batch_operation: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def describe_batch_operation: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def list_batch_operations: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def poll_nexus_task_queue: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_nexus_task_completed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + def respond_nexus_task_failed: (untyped request, ?rpc_retry: bool, ?rpc_metadata: Hash[String, String]?, ?rpc_timeout: Float?) -> untyped + end + end + end +end diff --git a/temporalio/sig/temporalio/client/interceptor.rbs b/temporalio/sig/temporalio/client/interceptor.rbs new file mode 100644 index 00000000..2ff5a35f --- /dev/null +++ b/temporalio/sig/temporalio/client/interceptor.rbs @@ -0,0 +1,95 @@ +module Temporalio + class Client + module Interceptor + def intercept_client: (Outbound next_interceptor) -> Outbound + + class StartWorkflowInput + attr_accessor workflow: String + attr_accessor args: Array[Object] + attr_accessor id: String + attr_accessor task_queue: String + attr_accessor execution_timeout: Float? + attr_accessor run_timeout: Float? + attr_accessor task_timeout: Float? + attr_accessor id_reuse_policy: WorkflowIDReusePolicy::enum + attr_accessor id_conflict_policy: WorkflowIDConflictPolicy::enum + attr_accessor retry_policy: RetryPolicy? + attr_accessor cron_schedule: String? + attr_accessor memo: Hash[String, Object]? + attr_accessor search_attributes: SearchAttributes? + attr_accessor start_delay: Float? + attr_accessor request_eager_start: bool + attr_accessor headers: Hash[String, String] + attr_accessor rpc_metadata: Hash[String, String]? + attr_accessor rpc_timeout: Float? + + def initialize: ( + workflow: String, + args: Array[Object], + id: String, + task_queue: String, + execution_timeout: Float?, + run_timeout: Float?, + task_timeout: Float?, + id_reuse_policy: WorkflowIDReusePolicy::enum, + id_conflict_policy: WorkflowIDConflictPolicy::enum, + retry_policy: RetryPolicy?, + cron_schedule: String?, + memo: Hash[String, Object]?, + search_attributes: SearchAttributes?, + start_delay: Float?, + request_eager_start: bool, + headers: Hash[String, String], + rpc_metadata: Hash[String, String]?, + rpc_timeout: Float? + ) -> void + end + + class FetchWorkflowHistoryEventPageInput + attr_accessor id: String + attr_accessor run_id: String? + attr_accessor page_size: Integer? + attr_accessor next_page_token: String? + attr_accessor wait_new_event: bool + attr_accessor event_filter_type: Integer + attr_accessor skip_archival: bool + attr_accessor rpc_metadata: Hash[String, String]? + attr_accessor rpc_timeout: Float? + + def initialize: ( + id: String, + run_id: String?, + page_size: Integer?, + next_page_token: String?, + wait_new_event: bool, + event_filter_type: Integer, + skip_archival: bool, + rpc_metadata: Hash[String, String]?, + rpc_timeout: Float? + ) -> void + end + + class FetchWorkflowHistoryEventPage + attr_accessor events: Enumerable[untyped] + attr_accessor next_page_token: String? + + def initialize: ( + events: Enumerable[untyped]?, + next_page_token: String? + ) -> void + end + + class Outbound + attr_reader next_interceptor: Outbound + + def initialize: (Outbound next_interceptor) -> void + + def start_workflow: (StartWorkflowInput input) -> WorkflowHandle + + def fetch_workflow_history_event_page: ( + FetchWorkflowHistoryEventPageInput input + ) -> FetchWorkflowHistoryEventPage + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/client/workflow_handle.rbs b/temporalio/sig/temporalio/client/workflow_handle.rbs new file mode 100644 index 00000000..1a4591f0 --- /dev/null +++ b/temporalio/sig/temporalio/client/workflow_handle.rbs @@ -0,0 +1,43 @@ +module Temporalio + class Client + class WorkflowHandle + attr_reader id: String + attr_reader run_id: String? + attr_reader result_run_id: String? + attr_reader first_execution_run_id: String? + + def initialize: ( + Client client, + String id, + ?run_id: String?, + ?result_run_id: String?, + ?first_execution_run_id: String? + ) -> void + + def result: ( + ?follow_runs: bool, + ?rpc_metadata: Hash[String, String]?, + ?rpc_timeout: Float? + ) -> Object + + def fetch_history_events: ( + ?page_size: Integer?, + ?wait_new_event: bool, + ?event_filter_type: Integer, + ?skip_archival: bool, + ?rpc_metadata: Hash[String, String]?, + ?rpc_timeout: Float? + ) -> Enumerable[untyped] + + private def fetch_history_events_for_run: ( + String? run_id, + page_size: Integer?, + wait_new_event: bool, + event_filter_type: Integer, + skip_archival: bool, + rpc_metadata: Hash[String, String]?, + rpc_timeout: Float? + ) -> Enumerator[untyped, untyped] + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/common_enums.rbs b/temporalio/sig/temporalio/common_enums.rbs new file mode 100644 index 00000000..86ba5f2a --- /dev/null +++ b/temporalio/sig/temporalio/common_enums.rbs @@ -0,0 +1,19 @@ +module Temporalio + module WorkflowIDReusePolicy + type enum = Integer + + ALLOW_DUPLICATE: enum + ALLOW_DUPLICATE_FAILED_ONLY: enum + REJECT_DUPLICATE: enum + TERMINATE_IF_RUNNING: enum + end + + module WorkflowIDConflictPolicy + type enum = Integer + + UNSPECIFIED: enum + FAIL: enum + USE_EXISTING: enum + TERMINATE_EXISTING: enum + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/data_converter.rbs b/temporalio/sig/temporalio/converters/data_converter.rbs new file mode 100644 index 00000000..9f1b89b3 --- /dev/null +++ b/temporalio/sig/temporalio/converters/data_converter.rbs @@ -0,0 +1,26 @@ +module Temporalio + module Converters + class DataConverter + attr_reader payload_converter: PayloadConverter + attr_reader failure_converter: FailureConverter + attr_reader payload_codec: PayloadCodec? + + def self.default: -> DataConverter + + def initialize: ( + ?payload_converter: PayloadConverter, + ?failure_converter: FailureConverter, + ?payload_codec: PayloadCodec? + ) -> void + + def to_payload: (Object? value) -> untyped + def to_payloads: (Array[Object?] values) -> untyped + + def from_payload: (untyped payload) -> Object? + def from_payloads: (untyped payloads) -> Array[Object?] + + def to_failure: (Exception error) -> untyped + def from_failure: (untyped failure) -> Exception + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/failure_converter.rbs b/temporalio/sig/temporalio/converters/failure_converter.rbs new file mode 100644 index 00000000..4e85e3d9 --- /dev/null +++ b/temporalio/sig/temporalio/converters/failure_converter.rbs @@ -0,0 +1,12 @@ +module Temporalio + module Converters + class FailureConverter + def self.default: -> FailureConverter + + def initialize: (?encode_common_attributes: bool) -> void + + def to_failure: (Exception error, PayloadConverter payload_converter) -> untyped + def from_failure: (untyped failure, PayloadConverter payload_converter) -> Exception + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_codec.rbs b/temporalio/sig/temporalio/converters/payload_codec.rbs new file mode 100644 index 00000000..3d174b45 --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_codec.rbs @@ -0,0 +1,7 @@ +module Temporalio + module Converters + class PayloadCodec + # TODO + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter.rbs b/temporalio/sig/temporalio/converters/payload_converter.rbs new file mode 100644 index 00000000..1c191ce5 --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter.rbs @@ -0,0 +1,15 @@ +module Temporalio + module Converters + class PayloadConverter + def self.default: -> PayloadConverter + + def self.new_with_defaults: ( + ?json_parse_options: Hash[Symbol, untyped], + ?json_generate_options: Hash[Symbol, untyped] + ) -> PayloadConverter + + def to_payload: (Object? value) -> untyped + def from_payload: (untyped payload) -> Object? + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/binary_null.rbs b/temporalio/sig/temporalio/converters/payload_converter/binary_null.rbs new file mode 100644 index 00000000..86f5176f --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/binary_null.rbs @@ -0,0 +1,8 @@ +module Temporalio + module Converters + class PayloadConverter + class BinaryNull < Encoding + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/binary_plain.rbs b/temporalio/sig/temporalio/converters/payload_converter/binary_plain.rbs new file mode 100644 index 00000000..90f69eac --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/binary_plain.rbs @@ -0,0 +1,8 @@ +module Temporalio + module Converters + class PayloadConverter + class BinaryPlain < Encoding + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/binary_protobuf.rbs b/temporalio/sig/temporalio/converters/payload_converter/binary_protobuf.rbs new file mode 100644 index 00000000..79f391cd --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/binary_protobuf.rbs @@ -0,0 +1,8 @@ +module Temporalio + module Converters + class PayloadConverter + class BinaryProtobuf < Encoding + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/composite.rbs b/temporalio/sig/temporalio/converters/payload_converter/composite.rbs new file mode 100644 index 00000000..42d98401 --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/composite.rbs @@ -0,0 +1,16 @@ +module Temporalio + module Converters + class PayloadConverter + class Composite < PayloadConverter + class ConverterNotFound < Error + end + class EncodingNotSet < Error + end + + attr_reader converters: Hash[String, Encoding] + + def initialize: (*Encoding converters) -> void + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/encoding.rbs b/temporalio/sig/temporalio/converters/payload_converter/encoding.rbs new file mode 100644 index 00000000..af7b8714 --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/encoding.rbs @@ -0,0 +1,13 @@ +module Temporalio + module Converters + class PayloadConverter + class Encoding + def encoding: -> String + + def to_payload: (Object? value) -> untyped? + + def from_payload: (untyped payload) -> Object? + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/json_plain.rbs b/temporalio/sig/temporalio/converters/payload_converter/json_plain.rbs new file mode 100644 index 00000000..196f28e3 --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/json_plain.rbs @@ -0,0 +1,12 @@ +module Temporalio + module Converters + class PayloadConverter + class JsonPlain < Encoding + def initialize: ( + ?Hash[Symbol, untyped] parse_options, + ?Hash[Symbol, untyped] generate_options + ) -> void + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/converters/payload_converter/json_protobuf.rbs b/temporalio/sig/temporalio/converters/payload_converter/json_protobuf.rbs new file mode 100644 index 00000000..99ad7354 --- /dev/null +++ b/temporalio/sig/temporalio/converters/payload_converter/json_protobuf.rbs @@ -0,0 +1,8 @@ +module Temporalio + module Converters + class PayloadConverter + class JsonProtobuf < Encoding + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/error.rbs b/temporalio/sig/temporalio/error.rbs new file mode 100644 index 00000000..70b350ce --- /dev/null +++ b/temporalio/sig/temporalio/error.rbs @@ -0,0 +1,63 @@ +module Temporalio + class Error < StandardError + class WorkflowFailureError < Error + attr_reader cause: Exception + + def initialize: (cause: Exception) -> void + end + + class WorkflowContinuedAsNewError < Error + attr_reader new_run_id: String + + def initialize: (new_run_id: String) -> void + end + + class WorkflowAlreadyStartedError < Error + attr_reader workflow_id: String + attr_reader workflow_type: String + attr_reader run_id: String + + def initialize: ( + workflow_id: String, + workflow_type: String, + run_id: String + ) -> void + end + + class RPCError < Error + attr_reader code: Code::enum + + def initialize: ( + String message, + code: Code::enum, + raw_grpc_status: String? + ) -> void + + def grpc_status: -> untyped + + private def create_grpc_status: -> untyped + + module Code + OK: 0 + CANCELLED: 1 + UNKNOWN: 2 + INVALID_ARGUMENT: 3 + DEADLINE_EXCEEDED: 4 + NOT_FOUND: 5 + ALREADY_EXISTS: 6 + PERMISSION_DENIED: 7 + RESOURCE_EXHAUSTED: 8 + FAILED_PRECONDITION: 9 + ABORTED: 10 + OUT_OF_RANGE: 11 + UNIMPLEMENTED: 12 + INTERNAL: 13 + UNAVAILABLE: 14 + DATA_LOSS: 15 + UNAUTHENTICATED: 16 + + type enum = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/internal/bridge.rbs b/temporalio/sig/temporalio/internal/bridge.rbs new file mode 100644 index 00000000..df44cb00 --- /dev/null +++ b/temporalio/sig/temporalio/internal/bridge.rbs @@ -0,0 +1,17 @@ +module Temporalio + module Internal + module Bridge + interface _ResultQueue[T] + def push: ([T, Exception]) -> void + def pop: () -> [T, Exception] + end + + def self.async_call: [T] { (_ResultQueue[T] queue) -> void } -> T + + # Defined in Rust + + class Error < StandardError + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/internal/bridge/client.rbs b/temporalio/sig/temporalio/internal/bridge/client.rbs index 15948e1a..27575de8 100644 --- a/temporalio/sig/temporalio/internal/bridge/client.rbs +++ b/temporalio/sig/temporalio/internal/bridge/client.rbs @@ -2,8 +2,112 @@ module Temporalio module Internal module Bridge class Client - # TODO(cretz): Improve - def self.new: (untyped, untyped) -> Client + class Options + attr_accessor target_host: String + attr_accessor client_name: String + attr_accessor client_version: String + attr_accessor rpc_metadata: Hash[String, String] + attr_accessor api_key: String? + attr_accessor identity: String + attr_accessor tls: TLSOptions? + attr_accessor rpc_retry: RPCRetryOptions + attr_accessor keep_alive: KeepAliveOptions? + attr_accessor http_connect_proxy: HTTPConnectProxyOptions? + + def initialize: ( + target_host: String, + client_name: String, + client_version: String, + rpc_metadata: Hash[String, String], + api_key: String?, + identity: String, + ?tls: TLSOptions?, + rpc_retry: RPCRetryOptions, + ?keep_alive: KeepAliveOptions?, + ?http_connect_proxy: HTTPConnectProxyOptions? + ) -> void + end + + class TLSOptions + attr_accessor client_cert: String? + attr_accessor client_private_key: String? + attr_accessor server_root_ca_cert: String? + attr_accessor domain: String? + + def initialize: ( + ?client_cert: String?, + ?client_private_key: String?, + ?server_root_ca_cert: String?, + ?domain: String? + ) -> void + end + + class RPCRetryOptions + attr_accessor initial_interval: Float + attr_accessor randomization_factor: Float + attr_accessor multiplier: Float + attr_accessor max_interval: Float + attr_accessor max_elapsed_time: Float + attr_accessor max_retries: Integer + + def initialize: ( + initial_interval: Float, + randomization_factor: Float, + multiplier: Float, + max_interval: Float, + max_elapsed_time: Float, + max_retries: Integer + ) -> void + end + + class KeepAliveOptions + attr_accessor interval: Float + attr_accessor timeout: Float + + def initialize: ( + interval: Float, + timeout: Float + ) -> void + end + + class HTTPConnectProxyOptions + attr_accessor target_host: String + attr_accessor basic_auth_user: String? + attr_accessor basic_auth_pass: String? + + def initialize: ( + target_host: String, + basic_auth_user: String?, + basic_auth_pass: String? + ) -> void + end + + # Defined in Rust + + SERVICE_WORKFLOW: Integer + SERVICE_OPERATOR: Integer + SERVICE_CLOUD: Integer + SERVICE_TEST: Integer + SERVICE_HEALTH: Integer + + def self.new: (Runtime runtime, Options options) -> Client + + def self.async_new: (Runtime runtime, Options options) { ([Client, Exception]) -> void } -> void + + def async_invoke_rpc: ( + service: Integer, + rpc: String, + request: String, + rpc_retry: bool, + rpc_metadata: Hash[String, String]?, + rpc_timeout: Float? + ) { ([String, RPCFailure]) -> void } -> void + + class RPCFailure < Error + def code: -> Temporalio::Error::RPCError::Code::enum + def message: -> String + def details: -> String + end end end end diff --git a/temporalio/sig/temporalio/internal/bridge/runtime.rbs b/temporalio/sig/temporalio/internal/bridge/runtime.rbs new file mode 100644 index 00000000..7d4e752d --- /dev/null +++ b/temporalio/sig/temporalio/internal/bridge/runtime.rbs @@ -0,0 +1,83 @@ +module Temporalio + module Internal + module Bridge + class Runtime + class Options + attr_accessor telemetry: TelemetryOptions + + def initialize: (telemetry: TelemetryOptions) -> void + end + + class TelemetryOptions + attr_accessor logging: LoggingOptions? + attr_accessor metrics: MetricsOptions? + + def initialize: ( + logging: LoggingOptions?, + metrics: MetricsOptions? + ) -> void + end + + class LoggingOptions + attr_accessor log_filter: String? + + def initialize: ( + log_filter: String? + ) -> void + end + + class MetricsOptions + attr_accessor opentelemetry: OpenTelemetryMetricsOptions? + attr_accessor prometheus: PrometheusMetricsOptions? + attr_accessor attach_service_name: bool + attr_accessor global_tags: Hash[String, String]? + attr_accessor metric_prefix: String? + + def initialize: ( + opentelemetry: OpenTelemetryMetricsOptions?, + prometheus: PrometheusMetricsOptions?, + attach_service_name: bool, + global_tags: Hash[String, String]?, + metric_prefix: String? + ) -> void + end + + class OpenTelemetryMetricsOptions + attr_accessor url: String + attr_accessor headers: Hash[String, String]? + attr_accessor metric_periodicity: Float? + attr_accessor metric_temporality_delta: bool + attr_accessor durations_as_seconds: bool + + def initialize: ( + url: String, + headers: Hash[String, String]?, + metric_periodicity: Float?, + metric_temporality_delta: bool, + durations_as_seconds: bool + ) -> void + end + + class PrometheusMetricsOptions + attr_accessor bind_address: String + attr_accessor counters_total_suffix: bool + attr_accessor unit_suffix: bool + attr_accessor durations_as_seconds: bool + + def initialize: ( + bind_address: String, + counters_total_suffix: bool, + unit_suffix: bool, + durations_as_seconds: bool + ) -> void + end + + # Defined in Rust + + def self.new: (Options options) -> Runtime + + def run_command_loop: -> void + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/internal/bridge/testing.rbs b/temporalio/sig/temporalio/internal/bridge/testing.rbs new file mode 100644 index 00000000..ca000d99 --- /dev/null +++ b/temporalio/sig/temporalio/internal/bridge/testing.rbs @@ -0,0 +1,56 @@ +module Temporalio + module Internal + module Bridge + module Testing + class EphemeralServer + class StartDevServerOptions + attr_accessor existing_path: String? + attr_accessor sdk_name: String + attr_accessor sdk_version: String + attr_accessor download_version: String + attr_accessor download_dest_dir: String? + attr_accessor namespace: String + attr_accessor ip: String + attr_accessor port: Integer? + attr_accessor database_filename: String? + attr_accessor ui: bool + attr_accessor log_format: String + attr_accessor log_level: String + attr_accessor extra_args: Array[String] + + def initialize: ( + existing_path: String?, + sdk_name: String, + sdk_version: String, + download_version: String, + download_dest_dir: String?, + namespace: String, + ip: String, + port: Integer?, + database_filename: String?, + ui: bool, + log_format: String, + log_level: String, + extra_args: Array[String] + ) -> void + end + + def self.start_dev_server: (Runtime runtime, StartDevServerOptions options) -> EphemeralServer + + def shutdown: -> void + + # Defined in Rust + + def self.async_start_dev_server: ( + Runtime runtime, + StartDevServerOptions options + ) { ([EphemeralServer, Error]) -> void } -> void + + def target: -> String + + def async_shutdown: { ([nil, Error]) -> void } -> void + end + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/internal/proto_utils.rbs b/temporalio/sig/temporalio/internal/proto_utils.rbs new file mode 100644 index 00000000..55ed0adf --- /dev/null +++ b/temporalio/sig/temporalio/internal/proto_utils.rbs @@ -0,0 +1,12 @@ +module Temporalio + module Internal + module ProtoUtils + def self.seconds_to_duration: (Float? seconds_float) -> untyped? + + def self.memo_to_proto: ( + Hash[String, untyped?]? hash, + Converters::DataConverter data_converter + ) -> untyped? + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/retry_policy.rbs b/temporalio/sig/temporalio/retry_policy.rbs new file mode 100644 index 00000000..b80ab02d --- /dev/null +++ b/temporalio/sig/temporalio/retry_policy.rbs @@ -0,0 +1,17 @@ +module Temporalio + class RetryPolicy + attr_accessor initial_interval: Float + attr_accessor backoff_coefficient: Float + attr_accessor max_interval: Float? + attr_accessor max_attempts: Integer + attr_accessor non_retryable_error_types: Array[String]? + + def initialize: ( + ?initial_interval: Float, + ?backoff_coefficient: Float, + ?max_interval: Float?, + ?max_attempts: Integer, + ?non_retryable_error_types: Array[String]? + ) -> void + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/runtime.rbs b/temporalio/sig/temporalio/runtime.rbs new file mode 100644 index 00000000..8c9feaf5 --- /dev/null +++ b/temporalio/sig/temporalio/runtime.rbs @@ -0,0 +1,105 @@ +module Temporalio + class Runtime + class TelemetryOptions + attr_accessor logging: LoggingOptions? + attr_accessor metrics: MetricsOptions? + + def initialize: ( + ?logging: LoggingOptions?, + ?metrics: MetricsOptions? + ) -> void + + def _to_bridge: -> Internal::Bridge::Runtime::TelemetryOptions + end + + class LoggingOptions + attr_accessor log_filter: LoggingFilterOptions | String + + def initialize: ( + ?log_filter: LoggingFilterOptions | String + ) -> void + + def _to_bridge: -> Internal::Bridge::Runtime::LoggingOptions + end + + type logging_filter_level = 'TRACE' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' + + class LoggingFilterOptions + attr_accessor core_level: logging_filter_level + attr_accessor other_level: logging_filter_level + + def initialize: ( + ?core_level: logging_filter_level, + ?other_level: logging_filter_level + ) -> void + + def _to_bridge: -> String + end + + class MetricsOptions + attr_accessor opentelemetry: OpenTelemetryMetricsOptions? + attr_accessor prometheus: PrometheusMetricsOptions? + attr_accessor attach_service_name: bool + attr_accessor global_tags: Hash[String, String]? + attr_accessor metric_prefix: String? + + def initialize: ( + ?opentelemetry: OpenTelemetryMetricsOptions?, + ?prometheus: PrometheusMetricsOptions?, + ?attach_service_name: bool, + ?global_tags: Hash[String, String]?, + ?metric_prefix: String? + ) -> void + + def _to_bridge: -> Internal::Bridge::Runtime::MetricsOptions + end + + class OpenTelemetryMetricsOptions + module MetricTemporality + CUMULATIVE: 1 + DELTA: 2 + + type enum = 1 | 2 + end + + attr_accessor url: String + attr_accessor headers: Hash[String, String]? + attr_accessor metric_periodicity: Float? + attr_accessor metric_temporality: MetricTemporality + attr_accessor durations_as_seconds: bool + + def initialize: ( + url: String, + ?headers: Hash[String, String]?, + ?metric_periodicity: Float?, + ?metric_temporality: MetricTemporality, + ?durations_as_seconds: bool + ) -> void + + def _to_bridge: -> Internal::Bridge::Runtime::OpenTelemetryMetricsOptions + end + + class PrometheusMetricsOptions + attr_accessor bind_address: String + attr_accessor counters_total_suffix: bool + attr_accessor unit_suffix: bool + attr_accessor durations_as_seconds: bool + + def initialize: ( + bind_address: String, + ?counters_total_suffix: bool, + ?unit_suffix: bool, + ?durations_as_seconds: bool + ) -> void + + def _to_bridge: -> Internal::Bridge::Runtime::PrometheusMetricsOptions + end + + def self.default: -> Runtime + def self.default=: (Runtime runtime) -> void + + def initialize: (?telemetry: TelemetryOptions) -> void + + def _core_runtime: -> Internal::Bridge::Runtime + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/search_attributes.rbs b/temporalio/sig/temporalio/search_attributes.rbs new file mode 100644 index 00000000..8905d0d9 --- /dev/null +++ b/temporalio/sig/temporalio/search_attributes.rbs @@ -0,0 +1,59 @@ +module Temporalio + class SearchAttributes + class Key + attr_reader name: String + attr_reader type: Integer + + def initialize: (String name, Integer type) -> void + + def validate_value: (Object value) -> void + + def value_set: (Object value) -> Update + def value_unset: -> Update + end + + class Update + attr_reader key: Key + attr_reader value: Object? + + def initialize: (Key key, Object? value) -> void + end + + def self.from_proto: (untyped proto) -> SearchAttributes + + def initialize: (SearchAttributes existing) -> void + | (Hash[Key, Object] existing) -> void + | -> void + + def []=: (Key key, Object? value) -> void + def []: (Key key) -> Object? + + def delete: (Key key) -> void + | (String key) -> void + + def each: { (Key key, Object value) -> void } -> self + + def to_h: -> Hash[Key, Object] + + def dup: -> SearchAttributes + + def update: (*Update updates) -> SearchAttributes + + def update!: (*Update updates) -> void + + def to_proto: -> untyped + + module IndexedValueType + TEXT: Integer + KEYWORD: Integer + INTEGER: Integer + FLOAT: Integer + BOOLEAN: Integer + TIME: Integer + KEYWORD_LIST: Integer + + PROTO_NAMES: Hash[Integer, String] + PROTO_VALUES: Hash[String, Integer] + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/testing.rbs b/temporalio/sig/temporalio/testing.rbs new file mode 100644 index 00000000..db1ee4cb --- /dev/null +++ b/temporalio/sig/temporalio/testing.rbs @@ -0,0 +1,4 @@ +module Temporalio + module Testing + end +end diff --git a/temporalio/sig/temporalio/testing/workflow_environment.rbs b/temporalio/sig/temporalio/testing/workflow_environment.rbs new file mode 100644 index 00000000..c88467f9 --- /dev/null +++ b/temporalio/sig/temporalio/testing/workflow_environment.rbs @@ -0,0 +1,48 @@ +module Temporalio + module Testing + class WorkflowEnvironment + attr_reader client: Client + + def self.start_local: ( + ?namespace: String, + ?data_converter: Converters::DataConverter, + ?interceptors: Array[Client::Interceptor], + ?ip: String, + ?port: Integer?, + ?ui: bool, + ?runtime: Runtime, + ?dev_server_existing_path: String?, + ?dev_server_database_filename: String?, + ?dev_server_log_format: String, + ?dev_server_log_level: String, + ?dev_server_download_version: String, + ?dev_server_download_dest_dir: String?, + ?dev_server_extra_args: Array[String] + ) -> WorkflowEnvironment + | [T] ( + ?namespace: String, + ?data_converter: Converters::DataConverter, + ?interceptors: Array[Client::Interceptor], + ?ip: String, + ?port: Integer?, + ?ui: bool, + ?runtime: Runtime, + ?dev_server_existing_path: String?, + ?dev_server_database_filename: String?, + ?dev_server_log_format: String, + ?dev_server_log_level: String, + ?dev_server_download_version: String, + ?dev_server_download_dest_dir: String?, + ?dev_server_extra_args: Array[String] + ) { (WorkflowEnvironment) -> T } -> T + + def initialize: (Client client) -> void + + def shutdown: -> void + + class Ephemeral < WorkflowEnvironment + def initialize: (Client client, untyped core_server) -> void + end + end + end +end \ No newline at end of file diff --git a/temporalio/sig/temporalio/version.rbs b/temporalio/sig/temporalio/version.rbs new file mode 100644 index 00000000..ae4011bd --- /dev/null +++ b/temporalio/sig/temporalio/version.rbs @@ -0,0 +1,3 @@ +module Temporalio + VERSION: String +end diff --git a/temporalio/temporalio.gemspec b/temporalio/temporalio.gemspec index 2c22f58d..56cc74fa 100644 --- a/temporalio/temporalio.gemspec +++ b/temporalio/temporalio.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest' spec.add_development_dependency 'rake' spec.add_development_dependency 'rake-compiler' - spec.add_development_dependency 'rbs', '~> 3.5.2' + spec.add_development_dependency 'rbs', '~> 3.5.3' spec.add_development_dependency 'rb_sys', '~> 0.9.63' spec.add_development_dependency 'rubocop' spec.add_development_dependency 'steep', '~> 1.7.1' diff --git a/temporalio/test/client_test.rb b/temporalio/test/client_test.rb index a513251b..5f4b4813 100644 --- a/temporalio/test/client_test.rb +++ b/temporalio/test/client_test.rb @@ -3,11 +3,9 @@ require 'async' require 'temporalio/client' require 'temporalio/testing' -require 'test_helper' - -class ClientTest < Minitest::Test - include TestHelper +require 'test' +class ClientTest < Test def test_version_number assert !Temporalio::VERSION.nil? end diff --git a/temporalio/test/sig/client_test.rbs b/temporalio/test/sig/client_test.rbs new file mode 100644 index 00000000..e7011028 --- /dev/null +++ b/temporalio/test/sig/client_test.rbs @@ -0,0 +1,3 @@ +class ClientTest < Test + def start_simple_workflows: -> void +end \ No newline at end of file diff --git a/temporalio/test/sig/test.rbs b/temporalio/test/sig/test.rbs new file mode 100644 index 00000000..5a325f71 --- /dev/null +++ b/temporalio/test/sig/test.rbs @@ -0,0 +1,22 @@ +class Test < Minitest::Test + def env: -> TestEnvironment + + class TestEnvironment + include Singleton + + # Need manual instance method: https://github.com/ruby/rbs/issues/1498 + def self.instance: -> TestEnvironment + + attr_reader server: Temporalio::Testing::WorkflowEnvironment + + def client: -> Temporalio::Client + + def with_kitchen_sink_worker: [T] ( + ?Temporalio::Client worker_client + ) { (String task_queue) -> T } -> T + + def kitchen_sink_exe: -> String + + def ensure_search_attribute_keys: (*Temporalio::SearchAttributes::Key keys) -> void + end +end \ No newline at end of file diff --git a/temporalio/test/sig/test_helper.rbs b/temporalio/test/sig/test_helper.rbs deleted file mode 100644 index e69de29b..00000000 diff --git a/temporalio/test/test_helper.rb b/temporalio/test/test.rb similarity index 88% rename from temporalio/test/test_helper.rb rename to temporalio/test/test.rb index f9d882a2..a87f409b 100644 --- a/temporalio/test/test_helper.rb +++ b/temporalio/test/test.rb @@ -3,7 +3,7 @@ require 'minitest/autorun' require 'singleton' -module TestHelper +class Test < Minitest::Test def env TestEnvironment.instance end @@ -27,10 +27,10 @@ def client def with_kitchen_sink_worker(worker_client = client) # Run the golangworker task_queue = "tq-#{SecureRandom.uuid}" - pid = Process.spawn( + pid = spawn( kitchen_sink_exe, worker_client.connection.target_host, worker_client.namespace, task_queue, - { chdir: File.join(__dir__ || '', 'golangworker') } + chdir: File.join(__dir__ || '', 'golangworker') ) begin yield task_queue @@ -47,9 +47,9 @@ def kitchen_sink_exe # Build the executable. We can't use "go run" because it can't forward kill # signal - pid = Process.spawn( + pid = spawn( 'go', 'build', '-o', 'golangworker', '.', - { chdir: File.join(__dir__ || '', 'golangworker') } + chdir: File.join(__dir__ || '', 'golangworker') ) begin Timeout.timeout(100) { Process.wait(pid) } @@ -57,7 +57,7 @@ def kitchen_sink_exe Process.kill('KILL', pid) raise end - raise "Go build failed with #{$?.exitstatus}" unless $?.exitstatus.zero? # rubocop:disable Style/SpecialGlobalVars + raise "Go build failed with #{$?&.exitstatus}" unless $?&.exitstatus&.zero? # rubocop:disable Style/SpecialGlobalVars @kitchen_sink_exe = File.join(__dir__ || '', 'golangworker', 'golangworker') end