Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions temporalio/Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target :lib do
signature 'sig'
check 'lib'
ignore 'lib/temporalio/api', 'lib/temporalio/internal/bridge/api'
library 'uri', 'objspace'
library 'uri', 'objspace', 'etc'
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for Etc.nprocessors usage in thread_pool.rb

configure_code_diagnostics do |hash|
hash.update(common_diagnostics)
end
Expand All @@ -24,7 +24,7 @@ end
target :test do
signature 'sig', 'test/sig'
check 'test'
library 'uri', 'objspace'
library 'uri', 'objspace', 'etc'
configure_code_diagnostics do |hash|
hash.update(common_diagnostics)
# Steep cannot infer some things, so we can ignore them in tests
Expand Down
2 changes: 1 addition & 1 deletion temporalio/lib/temporalio/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def self._validate_plugins!(plugins)
def initialize(
connection:,
namespace:,
data_converter: DataConverter.default,
data_converter: Converters::DataConverter.default,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was flat out broken, but most calls go through Client.connect instead of this directly

plugins: [],
interceptors: [],
logger: Logger.new($stdout, level: Logger::WARN),
Expand Down
14 changes: 7 additions & 7 deletions temporalio/lib/temporalio/contrib/open_telemetry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ def start_update_with_start_workflow(input)
# @!visibility private
def signal_with_start_workflow(input)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were 2 bugs in this implementation:

  • It used input.workflow which doesn't exist
  • It passed input into _with_started_pan for header forwarding which would also cause a crash since headers don't exist on the input type.

@root._with_started_span(
name: "SignalWithStartWorkflow:#{input.workflow}",
name: "SignalWithStartWorkflow:#{input.start_workflow_operation.options.workflow}",
kind: :client,
attributes: { 'temporalWorkflowID' => input.start_workflow_operation.options.id },
outbound_input: input
attributes: { 'temporalWorkflowID' => input.start_workflow_operation.options.id }
) do
# Also add to start headers
if input.headers[@header_key]
input.start_workflow_operation.options.headers[@header_key] = input.headers[@header_key]
end
# SignalWithStartWorkflowInput has no top-level headers field and instead uses
# start_workflow_operation.options.headers.
# So tracing context must be injected explicitly instead of relying
# on _with_started_span.
@root._apply_context_to_headers(input.start_workflow_operation.options.headers)
super
end
end
Expand Down
47 changes: 47 additions & 0 deletions temporalio/sig/open_telemetry.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module OpenTelemetry
module Context
def self.current: -> untyped
def self.attach: (untyped context) -> untyped
def self.detach: (untyped token) -> void

module Propagation
class CompositeTextMapPropagator
def self.compose_propagators: (Array[untyped] propagators) -> untyped
end
end
end

module Baggage
module Propagation
class TextMapPropagator
def initialize: -> void
end
end
end

module Trace
def self.with_span: [T] (untyped span) { -> T } -> T
def self.current_span: (?untyped context) -> untyped
def self.context_with_span: (untyped span) -> untyped

class Link
def initialize: (untyped context) -> void
end

module Status
def self.error: (String description) -> untyped
end

module Propagation
module TraceContext
class TextMapPropagator
def initialize: -> void
end
end
end

class Span
INVALID: untyped
end
end
end
8 changes: 8 additions & 0 deletions temporalio/sig/temporalio/contrib/open_telemetry.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ module Temporalio
) { () -> T } -> T
def _always_create_workflow_spans: -> bool

class ClientOutbound < Client::Interceptor::Outbound
def initialize: (TracingInterceptor root, Client::Interceptor::Outbound next_interceptor) -> void
end

class ActivityInbound < Worker::Interceptor::Activity::Inbound
def initialize: (TracingInterceptor root, Worker::Interceptor::Activity::Inbound next_interceptor) -> void
end

class WorkflowInbound < Worker::Interceptor::Workflow::Inbound
def initialize: (TracingInterceptor root, Worker::Interceptor::Workflow::Inbound next_interceptor) -> void

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Temporalio
module Converters
class PayloadConverter
class BinaryNull < Encoding
ENCODING: String
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Temporalio
module Converters
class PayloadConverter
class BinaryPlain < Encoding
ENCODING: String
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ module Temporalio
module Converters
class PayloadConverter
class BinaryProtobuf < Encoding
ENCODING: String
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module Temporalio
module Converters
class PayloadConverter
class JsonPlain < Encoding
class JSONPlain < Encoding
ENCODING: String

def initialize: (
?Hash[Symbol, untyped] parse_options,
?Hash[Symbol, untyped] generate_options
?parse_options: Hash[Symbol, untyped],
?generate_options: Hash[Symbol, untyped]
) -> void
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module Temporalio
module Converters
class PayloadConverter
class JsonProtobuf < Encoding
class JSONProtobuf < Encoding
ENCODING: String
end
end
end
end
end
4 changes: 2 additions & 2 deletions temporalio/sig/temporalio/error.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Temporalio

module Code
OK: 0
CANCELLED: 1
CANCELED: 1
UNKNOWN: 2
INVALID_ARGUMENT: 3
DEADLINE_EXCEEDED: 4
Expand All @@ -81,4 +81,4 @@ module Temporalio
end
end
end
end
end
21 changes: 20 additions & 1 deletion temporalio/sig/temporalio/internal/bridge.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ module Temporalio
def self.assert_fiber_compatibility!: -> void
def self.fibers_supported: -> bool

module EnvConfig
def self.load_client_connect_config: (
String? profile,
String? path,
String? data,
bool disable_file,
bool disable_env,
bool config_file_strict,
Hash[String, String]? override_env_vars
) -> Hash[Symbol, untyped]

def self.load_client_config: (
String? path,
String? data,
bool config_file_strict,
Hash[String, String]? override_env_vars
) -> Hash[String, Hash[Symbol, untyped]]
end

# Defined in Rust

class Error < StandardError
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module Temporalio
module Internal
module Worker
class ActivityWorker
LOG_TASKS: bool

attr_reader worker: Temporalio::Worker
attr_reader bridge_worker: Bridge::Worker

Expand Down Expand Up @@ -59,4 +61,4 @@ module Temporalio
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ module Temporalio

def initialize: (error: Exception) -> void
end

class ShutdownSignalReceived < Event
end
end

class InjectEventForTesting < Temporalio::Error
Expand All @@ -126,4 +129,4 @@ module Temporalio
end
end
end
end
end
29 changes: 28 additions & 1 deletion temporalio/sig/temporalio/testing/activity_environment.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ module Temporalio
Activity::Definition | singleton(Activity::Definition) | Activity::Definition::Info activity,
*Object? args
) -> untyped

class Context < Activity::Context
attr_reader info: Activity::Info
attr_reader instance: untyped
attr_reader cancellation: Cancellation
attr_reader worker_shutdown_cancellation: Cancellation
attr_reader payload_converter: Converters::PayloadConverter
attr_reader logger: Logger

def initialize: (
info: Activity::Info,
instance: untyped,
on_heartbeat: Proc?,
cancellation: Cancellation,
on_cancellation_details: Proc,
worker_shutdown_cancellation: Cancellation,
payload_converter: Converters::PayloadConverter,
logger: Logger,
metric_meter: Metric::Meter?,
client: Client?
) -> void

def heartbeat: (*untyped details) -> untyped
def metric_meter: -> Metric::Meter
def client: -> Client
def cancellation_details: -> Activity::CancellationDetails?
end
end
end
end
end
24 changes: 12 additions & 12 deletions temporalio/sig/temporalio/worker/poller_behavior.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ module Temporalio
class Worker
class PollerBehavior
def _to_bridge_options: -> untyped
end
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super easy to tell from the diff, but we want these to be nested e.g. Worker::PollerBehavior::SimpleMaximum, which they are in the Ruby file, but not in RBS


class SimpleMaximum < PollerBehavior
attr_reader maximum: Integer
class SimpleMaximum < PollerBehavior
attr_reader maximum: Integer

def initialize: (Integer) -> void
def _to_bridge_options: -> Internal::Bridge::Worker::PollerBehaviorSimpleMaximum
end
def initialize: (Integer) -> void
def _to_bridge_options: -> Internal::Bridge::Worker::PollerBehaviorSimpleMaximum
end

class Autoscaling < PollerBehavior
attr_reader minimum: Integer
attr_reader maximum: Integer
attr_reader initial: Integer
class Autoscaling < PollerBehavior
attr_reader minimum: Integer
attr_reader maximum: Integer
attr_reader initial: Integer

def initialize: (?minimum: Integer, ?maximum: Integer, ?initial: Integer) -> void
def _to_bridge_options: -> Internal::Bridge::Worker::PollerBehaviorAutoscaling
def initialize: (?minimum: Integer, ?maximum: Integer, ?initial: Integer) -> void
def _to_bridge_options: -> Internal::Bridge::Worker::PollerBehaviorAutoscaling
end
end
end
end
11 changes: 11 additions & 0 deletions temporalio/sig/temporalio/workflow/definition.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ module Temporalio

def _with_validator_to_invoke: (Symbol | Proc | nil validator_to_invoke) -> Update
end

end

class DefinitionOptions
attr_reader failure_exception_types: Array[singleton(Exception)]?
attr_reader versioning_behavior: VersioningBehavior::enum?

def initialize: (
?failure_exception_types: Array[singleton(Exception)]?,
?versioning_behavior: VersioningBehavior::enum?
) -> void
end
end
end
7 changes: 5 additions & 2 deletions temporalio/test/api/payload_visitor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_basics
end

# Basic check including search attributes
visitor = Temporalio::Api::PayloadVisitor.new(&mutator)
visitor = Temporalio::Api::PayloadVisitor.new(&mutator) # steep:ignore BlockTypeMismatch
mutated_act = act.class.decode(act.class.encode(act))
mutated_succ = succ.class.decode(succ.class.encode(succ))
visitor.run(mutated_act)
Expand All @@ -84,7 +84,10 @@ def test_basics
assert_equal 'samap-single', upsert_sa.indexed_fields['sakey'].data

# Skip search attributes
visitor = Temporalio::Api::PayloadVisitor.new(skip_search_attributes: true, &mutator)
visitor = Temporalio::Api::PayloadVisitor.new(
skip_search_attributes: true,
&mutator # steep:ignore BlockTypeMismatch
)
mutated_act = act.class.decode(act.class.encode(act))
mutated_succ = succ.class.decode(succ.class.encode(succ))
visitor.run(mutated_act)
Expand Down
Loading
Loading