Skip to content

Commit eabdfe8

Browse files
authored
Remove Ractor expectations and enable Linux ARM in CI (#200)
1 parent bbd6842 commit eabdfe8

File tree

13 files changed

+35
-141
lines changed

13 files changed

+35
-141
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
# TODO(cretz): Enable Linux ARM. It's not natively supported with setup-ruby (see
15-
# https://github.com/ruby/setup-ruby#supported-platforms and https://github.com/ruby/setup-ruby/issues/577).
16-
# So we need to set ruby-version to 'none' per
17-
# https://github.com/oxidize-rb/actions/tree/main/setup-ruby-and-rust and install Ruby ourselves maybe. See
18-
# https://github.com/ruby/setup-ruby?tab=readme-ov-file#using-self-hosted-runners. The error states:
19-
# Error: The current runner (ubuntu-24.04-arm64) was detected as self-hosted because the platform does not match a GitHub-hosted runner image (or that image is deprecated and no longer supported).
20-
# In such a case, you should install Ruby in the $RUNNER_TOOL_CACHE yourself, for example using https://github.com/rbenv/ruby-build
21-
# You can take inspiration from this workflow for more details: https://github.com/ruby/ruby-builder/blob/master/.github/workflows/build.yml
22-
#
14+
# TODO(cretz): Enable ubuntu-24.04-arm when oxidize-rb/actions/setup-ruby-and-rust
15+
# supports it
16+
#
2317
# TODO(cretz): Enable x64-mingw-ucrt if we can figure out Windows issue, see
2418
# https://github.com/temporalio/sdk-ruby/issues/172
2519
os: [ubuntu-latest, macos-latest]
@@ -28,7 +22,7 @@ jobs:
2822

2923
include:
3024
- os: ubuntu-latest
31-
rubyVersion: "3.3"
25+
rubyVersion: "3.4"
3226
checkTarget: true
3327
runs-on: ${{ matrix.os }}
3428
steps:

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ worker = Temporalio::Worker.new(
152152
task_queue: 'my-task-queue',
153153
workflows: [SayHelloWorkflow],
154154
# There are various forms an activity can take, see "Activities" section for details
155-
activities: [SayHelloActivity],
156-
# During the beta period, this must be provided explicitly, see "Workers" section for details
157-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default
155+
activities: [SayHelloActivity]
158156
)
159157

160158
# Run the worker until SIGINT. This can be done in many ways, see "Workers" section for details.
@@ -357,9 +355,7 @@ worker = Temporalio::Worker.new(
357355
task_queue: 'my-task-queue',
358356
workflows: [MyModule::MyWorkflow],
359357
# There are various forms an activity can take, see "Activities" section for details
360-
activities: [MyModule::MyActivity],
361-
# During the beta period, this must be provided explicitly, see below for details
362-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default
358+
activities: [MyModule::MyActivity]
363359
)
364360

365361
# Run the worker until block complete
@@ -372,9 +368,6 @@ Notes about the above code:
372368

373369
* A worker uses the same client that is used for other Temporal things.
374370
* This just shows providing an activity class, but there are other forms, see the "Activities" section for details.
375-
* The `workflow_executor` defaults to `Temporalio::Worker::WorkflowExecutor::Ractor.instance` which intentionally does
376-
not work during this beta period. Therefore, during this beta period, opting in to
377-
`Temporalio::Worker::WorkflowExecutor::ThreadPool.default` is required explicitly.
378371
* The worker `run` method accepts an optional `Temporalio::Cancellation` object that can be used to cancel instead or in
379372
addition to providing a block that waits for completion.
380373
* The worker `run` method accepts a `shutdown_signals` array which will trap the signal and start shutdown when
@@ -994,6 +987,13 @@ it will raise the error raised in the activity.
994987
The constructor of the environment has multiple keyword arguments that can be set to affect the activity context for the
995988
activity.
996989

990+
### Ractors
991+
992+
It was an original goal to have workflows actually be Ractors for deterministic state isolation and have the library
993+
support Ractors in general. However, due to the SDK's heavy use of the Google Protobuf library which
994+
[is not Ractor-safe](https://github.com/protocolbuffers/protobuf/issues/19321), the Temporal Ruby SDK does not currently
995+
work with Ractors.
996+
997997
### Platform Support
998998

999999
This SDK is backed by a Ruby C extension written in Rust leveraging the

temporalio/lib/temporalio/converters/data_converter.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ module Temporalio
88
module Converters
99
# Data converter for converting/encoding payloads to/from Ruby values.
1010
class DataConverter
11-
# @return [PayloadConverter] Payload converter. This must be Ractor shareable.
11+
# @return [PayloadConverter] Payload converter.
1212
attr_reader :payload_converter
1313

14-
# @return [FailureConverter] Failure converter. This must be Ractor shareable.
14+
# @return [FailureConverter] Failure converter.
1515
attr_reader :failure_converter
1616

1717
# @return [PayloadCodec, nil] Optional codec for encoding/decoding payload bytes such as for encryption.
@@ -24,17 +24,14 @@ def self.default
2424

2525
# Create data converter.
2626
#
27-
# @param payload_converter [PayloadConverter] Payload converter to use. This must be Ractor shareable.
28-
# @param failure_converter [FailureConverter] Failure converter to use. This must be Ractor shareable.
27+
# @param payload_converter [PayloadConverter] Payload converter to use.
28+
# @param failure_converter [FailureConverter] Failure converter to use.
2929
# @param payload_codec [PayloadCodec, nil] Payload codec to use.
3030
def initialize(
3131
payload_converter: PayloadConverter.default,
3232
failure_converter: FailureConverter.default,
3333
payload_codec: nil
3434
)
35-
raise 'Payload converter not shareable' unless Ractor.shareable?(payload_converter)
36-
raise 'Failure converter not shareable' unless Ractor.shareable?(failure_converter)
37-
3835
@payload_converter = payload_converter
3936
@failure_converter = failure_converter
4037
@payload_codec = payload_codec

temporalio/lib/temporalio/converters/failure_converter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Converters
1010
class FailureConverter
1111
# @return [FailureConverter] Default failure converter.
1212
def self.default
13-
@default ||= Ractor.make_shareable(FailureConverter.new)
13+
@default ||= FailureConverter.new
1414
end
1515

1616
# @return [Boolean] If +true+, the message and stack trace of the failure will be moved into the encoded attribute

temporalio/lib/temporalio/converters/payload_converter.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ def self.default
2222
# @param json_generate_options [Hash] Options for {::JSON.generate}.
2323
# @return [PayloadConverter::Composite] Created payload converter.
2424
def self.new_with_defaults(json_parse_options: { create_additions: true }, json_generate_options: {})
25-
Ractor.make_shareable(
26-
PayloadConverter::Composite.new(
27-
PayloadConverter::BinaryNull.new,
28-
PayloadConverter::BinaryPlain.new,
29-
PayloadConverter::JSONProtobuf.new,
30-
PayloadConverter::BinaryProtobuf.new,
31-
PayloadConverter::JSONPlain.new(parse_options: json_parse_options, generate_options: json_generate_options)
32-
)
25+
PayloadConverter::Composite.new(
26+
PayloadConverter::BinaryNull.new,
27+
PayloadConverter::BinaryPlain.new,
28+
PayloadConverter::JSONProtobuf.new,
29+
PayloadConverter::BinaryProtobuf.new,
30+
PayloadConverter::JSONPlain.new(parse_options: json_parse_options, generate_options: json_generate_options)
3331
)
3432
end
3533

temporalio/lib/temporalio/worker.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ def self.default_illegal_workflow_calls
286286
# @param workflows [Array<Class<Workflow::Definition>>] Workflows for this worker.
287287
# @param tuner [Tuner] Tuner that controls the amount of concurrent activities/workflows that run at a time.
288288
# @param activity_executors [Hash<Symbol, Worker::ActivityExecutor>] Executors that activities can run within.
289-
# @param workflow_executor [WorkflowExecutor] Workflow executor that workflow tasks run within.
289+
# @param workflow_executor [WorkflowExecutor] Workflow executor that workflow tasks run within. This must be a
290+
# {WorkflowExecutor::ThreadPool} currently.
290291
# @param interceptors [Array<Interceptor::Activity, Interceptor::Workflow>] Interceptors specific to this worker.
291292
# Note, interceptors set on the client that include the {Interceptor::Activity} or {Interceptor::Workflow} module
292293
# are automatically included here, so no need to specify them again.
@@ -352,7 +353,7 @@ def initialize(
352353
workflows: [],
353354
tuner: Tuner.create_fixed,
354355
activity_executors: ActivityExecutor.defaults,
355-
workflow_executor: WorkflowExecutor::Ractor.instance,
356+
workflow_executor: WorkflowExecutor::ThreadPool.default,
356357
interceptors: [],
357358
build_id: Worker.default_build_id,
358359
identity: nil,

temporalio/lib/temporalio/worker/workflow_executor.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# frozen_string_literal: true
22

3-
require 'temporalio/worker/workflow_executor/ractor'
43
require 'temporalio/worker/workflow_executor/thread_pool'
54

65
module Temporalio
76
class Worker
87
# Workflow executor that executes workflow tasks. Unlike {ActivityExecutor}, this class is not meant for user
9-
# implementation. Instead, either {WorkflowExecutor::ThreadPool} or {WorkflowExecutor::Ractor} should be used.
8+
# implementation. The only implementation that is currently accepted is {WorkflowExecutor::ThreadPool}.
109
class WorkflowExecutor
1110
# @!visibility private
1211
def initialize

temporalio/lib/temporalio/worker/workflow_executor/ractor.rb

Lines changed: 0 additions & 69 deletions
This file was deleted.

temporalio/sig/temporalio/worker/workflow_executor/ractor.rbs

Lines changed: 0 additions & 9 deletions
This file was deleted.

temporalio/test/converters/data_converter_test.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ module Converters
1111
class DataConverterTest < Test
1212
def test_with_codec
1313
converter = Temporalio::Converters::DataConverter.new(
14-
failure_converter: Ractor.make_shareable(
15-
Temporalio::Converters::FailureConverter.new(encode_common_attributes: true)
16-
),
14+
failure_converter: Temporalio::Converters::FailureConverter.new(encode_common_attributes: true),
1715
payload_codec: Base64Codec.new
1816
)
1917

temporalio/test/testing/workflow_environment_test.rb

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ def test_time_skipping_auto
3838
worker = Temporalio::Worker.new(
3939
client: env.client,
4040
task_queue: "tq-#{SecureRandom.uuid}",
41-
workflows: [SlowWorkflow],
42-
# TODO(cretz): Ractor support not currently working
43-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default
41+
workflows: [SlowWorkflow]
4442
)
4543
worker.run do
4644
# Check that timestamp is around now
@@ -63,9 +61,7 @@ def test_time_skipping_manual
6361
worker = Temporalio::Worker.new(
6462
client: env.client,
6563
task_queue: "tq-#{SecureRandom.uuid}",
66-
workflows: [SlowWorkflow],
67-
# TODO(cretz): Ractor support not currently working
68-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default
64+
workflows: [SlowWorkflow]
6965
)
7066
worker.run do
7167
# Start workflow
@@ -121,9 +117,7 @@ def test_time_skipping_heartbeat_timeout
121117
client: env.client,
122118
task_queue: "tq-#{SecureRandom.uuid}",
123119
workflows: [HeartbeatTimeoutWorkflow],
124-
activities: [HeartbeatTimeoutActivity.new(env)],
125-
# TODO(cretz): Ractor support not currently working
126-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default
120+
activities: [HeartbeatTimeoutActivity.new(env)]
127121
)
128122
worker.run do
129123
# Run workflow and confirm it got heartbeat timeout

temporalio/test/worker_workflow_test.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,9 +1114,7 @@ def test_payload_codec
11141114
# Workflow failure with failure encoding
11151115
new_options = env.client.options.with(
11161116
data_converter: Temporalio::Converters::DataConverter.new(
1117-
failure_converter: Ractor.make_shareable(
1118-
Temporalio::Converters::FailureConverter.new(encode_common_attributes: true)
1119-
),
1117+
failure_converter: Temporalio::Converters::FailureConverter.new(encode_common_attributes: true),
11201118
payload_codec: Base64Codec.new
11211119
)
11221120
)
@@ -1164,9 +1162,7 @@ def test_dynamic
11641162
worker = Temporalio::Worker.new(
11651163
client: env.client,
11661164
task_queue: "tq-#{SecureRandom.uuid}",
1167-
workflows: [DynamicWorkflow, NonDynamicWorkflow],
1168-
# TODO(cretz): Ractor support not currently working
1169-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default
1165+
workflows: [DynamicWorkflow, NonDynamicWorkflow]
11701166
)
11711167
worker.run do
11721168
# Non-dynamic
@@ -1670,9 +1666,7 @@ def do_update(arg)
16701666

16711667
def test_fail_workflow_payload_converter
16721668
new_options = env.client.options.with(
1673-
data_converter: Temporalio::Converters::DataConverter.new(
1674-
payload_converter: Ractor.make_shareable(FailWorkflowPayloadConverter.new)
1675-
)
1669+
data_converter: Temporalio::Converters::DataConverter.new(payload_converter: FailWorkflowPayloadConverter.new)
16761670
)
16771671
client = Temporalio::Client.new(**new_options.to_h)
16781672

@@ -1746,7 +1740,6 @@ def test_confirm_garbage_collect
17461740

17471741
# TODO(cretz): To test
17481742
# * Common
1749-
# * Ractor with global state
17501743
# * Eager workflow start
17511744
# * Unawaited futures that have exceptions, need to log warning like Java does
17521745
# * Enhanced stack trace?

temporalio/test/workflow_utils.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ def execute_workflow(
3434
task_queue:,
3535
activities:,
3636
workflows: [workflow] + more_workflows,
37-
# TODO(cretz): Ractor support not currently working
38-
workflow_executor: Temporalio::Worker::WorkflowExecutor::ThreadPool.default,
3937
workflow_failure_exception_types:,
4038
max_cached_workflows:,
4139
logger: logger || client.options.logger,

0 commit comments

Comments
 (0)