@@ -45,7 +45,7 @@ until the SDK is marked stable.
4545 - [ Invoking Activities] ( #invoking-activities )
4646 - [ Invoking Child Workflows] ( #invoking-child-workflows )
4747 - [ Timers and Conditions] ( #timers-and-conditions )
48- - [ Workflow Task Scheduling and Cancellation] ( #workflow-task -scheduling-and-cancellation )
48+ - [ Workflow Fiber Scheduling and Cancellation] ( #workflow-fiber -scheduling-and-cancellation )
4949 - [ Workflow Futures] ( #workflow-futures )
5050 - [ Workflow Utilities] ( #workflow-utilities )
5151 - [ Workflow Exceptions] ( #workflow-exceptions )
@@ -146,23 +146,22 @@ require_relative 'say_hello_workflow'
146146# Create a client
147147client = Temporalio ::Client .connect(' localhost:7233' , ' my-namespace' )
148148
149- # Create a worker with the client and activities
149+ # Create a worker with the client, activities, and workflows
150150worker = Temporalio ::Worker .new (
151151 client: ,
152152 task_queue: ' my-task-queue' ,
153153 workflows: [SayHelloWorkflow ],
154- # There are various forms an activity can take, see "Activities" section for details.
154+ # There are various forms an activity can take, see "Activities" section for details
155155 activities: [SayHelloActivity ],
156- # During the beta period, this must be provided explicitly, see "Workers" section for details.
156+ # During the beta period, this must be provided explicitly, see "Workers" section for details
157157 workflow_executor: Temporalio ::Worker ::WorkflowExecutor ::ThreadPool .default
158158)
159159
160- # Run the worker until SIGINT. This can be done in many ways, see specific
161- # section for details.
160+ # Run the worker until SIGINT. This can be done in many ways, see "Workers" section for details.
162161worker.run(shutdown_signals: [' SIGINT' ])
163162```
164163
165- Running that will run the worker until Ctrl+C pressed.
164+ Running that will run the worker until Ctrl+C is pressed.
166165
167166### Executing a Workflow
168167
@@ -179,7 +178,7 @@ client = Temporalio::Client.connect('localhost:7233', 'my-namespace')
179178# Run workflow
180179result = client.execute_workflow(
181180 SayHelloWorkflow ,
182- Temporal ,
181+ ' Temporal' ,
183182 id: ' my-workflow-id' ,
184183 task_queue: ' my-task-queue'
185184)
@@ -352,14 +351,14 @@ require 'my_module'
352351# Create a client
353352client = Temporalio ::Client .connect(' localhost:7233' , ' my-namespace' )
354353
355- # Create a worker with the client and activities
354+ # Create a worker with the client, activities, and workflows
356355worker = Temporalio ::Worker .new (
357356 client: ,
358357 task_queue: ' my-task-queue' ,
359358 workflows: [MyModule ::MyWorkflow ],
360- # There are various forms an activity can take, see "Activities" section for details.
359+ # There are various forms an activity can take, see "Activities" section for details
361360 activities: [MyModule ::MyActivity ],
362- # During the beta period, this must be provided explicitly, see below for details.
361+ # During the beta period, this must be provided explicitly, see below for details
363362 workflow_executor: Temporalio ::Worker ::WorkflowExecutor ::ThreadPool .default
364363)
365364
@@ -378,14 +377,14 @@ Notes about the above code:
378377 ` Temporalio::Worker::WorkflowExecutor::ThreadPool.default ` is required explicitly.
379378* The worker ` run ` method accepts an optional ` Temporalio::Cancellation ` object that can be used to cancel instead or in
380379 addition to providing a block that waits for completion.
381- * The worker ` run ` method accepts an ` shutdown_signals ` array which will trap the signal and start shutdown when
380+ * The worker ` run ` method accepts a ` shutdown_signals ` array which will trap the signal and start shutdown when
382381 received.
383382* Workers work with threads or fibers (but fiber compatibility only supported for Ruby 3.3+ at this time). Fiber-based
384383 activities (see "Activities" section) only work if the worker is created within a fiber.
385384* The ` run ` method does not return until the worker is shut down. This means even if shutdown is triggered (e.g. via
386385 ` Cancellation ` or block completion), it may not return immediately. Activities not completing may hang worker
387386 shutdown, see the "Activities" section.
388- * Workers can have many more options not shown here (e.g. data converters and interceptors).
387+ * Workers can have many more options not shown here (e.g. tuners and interceptors).
389388* The ` Temporalio::Worker.run_all ` class method is available for running multiple workers concurrently.
390389
391390### Workflows
@@ -466,7 +465,7 @@ workflow definition/behavior:
466465 _ and_ ` workflow_query ` . This means it is a superset of ` attr_reader ` and will not work if also using ` attr_reader ` or
467466 ` attr_accessor ` . If a writer is needed alongside this, use ` attr_writer ` .
468467
469- The following protected class methods that can be called just before defining instance methods to customize the
468+ The following protected class methods can be called just before defining instance methods to customize the
470469definition/behavior of the method:
471470
472471* ` workflow_init ` - Mark an ` initialize ` method as needing the workflow start arguments. Otherwise, ` initialize ` must
@@ -531,7 +530,7 @@ Some things to note about the above code:
531530
532531#### Invoking Activities
533532
534- * Activities are executed with ` Temporalio::Workflow.execute_activity ` which accepts the activity class or a
533+ * Activities are executed with ` Temporalio::Workflow.execute_activity ` , which accepts the activity class or a
535534 string/symbol activity name.
536535* Activity options are kwargs on the ` execute_activity ` method. Either ` schedule_to_close_timeout ` or
537536 ` start_to_close_timeout ` must be set.
@@ -543,7 +542,7 @@ Some things to note about the above code:
543542
544543#### Invoking Child Workflows
545544
546- * Child workflows are started with ` Temporalio::Workflow.start_child_workflow ` which accepts the workflow class or
545+ * Child workflows are started with ` Temporalio::Workflow.start_child_workflow ` , which accepts the workflow class or
547546 string/symbol name, arguments, and other options.
548547* Result for ` start_child_workflow ` is a ` Temporalio::Workflow::ChildWorkflowHandle ` which has the ` id ` , the ability to
549548 wait on the ` result ` , and the ability to ` signal ` the child.
@@ -557,15 +556,16 @@ Some things to note about the above code:
557556 * _ Technically_ ` Kernel.sleep ` and ` Timeout.timeout ` also delegate to the above calls, but the more explicit workflow
558557 forms are encouraged because they accept more options and are not subject to Ruby standard library implementation
559558 changes.
560- * Timers accept a ` Cancellation ` , but if none given, it defaults to ` Temporalio::Workflow.cancellation ` .
559+ * Each timer accepts a ` Cancellation ` , but if none is given, it defaults to ` Temporalio::Workflow.cancellation ` .
561560* ` Temporalio::Workflow.wait_condition ` accepts a block that waits until the evaluated block result is truthy, then
562561 returns the value.
563562 * This function is invoked on each iteration of the internal event loop. This means it cannot have any side effects.
564563 * This is commonly used for checking if a variable is changed from some other part of a workflow (e.g. a signal
565564 handler).
566- * Wait conditions accept a ` Cancellation ` , but if none given, it defaults to ` Temporalio::Workflow.cancellation ` .
565+ * Each wait conditions accepts a ` Cancellation ` , but if none is given, it defaults to
566+ ` Temporalio::Workflow.cancellation ` .
567567
568- #### Workflow Task Scheduling and Cancellation
568+ #### Workflow Fiber Scheduling and Cancellation
569569
570570Workflows are backed by a custom, deterministic ` Fiber::Scheduler ` . All fiber calls inside a workflow use this scheduler
571571to ensure coroutines run deterministically.
@@ -588,7 +588,7 @@ before it even started.
588588` Temporalio::Workflow::Future ` can be used for running things in the background or concurrently. This is basically a
589589safe wrapper around ` Fiber.schedule ` for starting and ` Workflow.wait_condition ` for waiting.
590590
591- Nothing uses futures by default but they work with all workflow code/constructs. For instance, to run 3 activities and
591+ Nothing uses futures by default, but they work with all workflow code/constructs. For instance, to run 3 activities and
592592wait for them all to complete, something like this can be written:
593593
594594``` ruby
@@ -629,7 +629,7 @@ raise Temporalio::Error::ApplicationError, 'Timer expired' if sleep_fut.done?
629629puts " Act result: #{ act_result } "
630630```
631631
632- There are several other details not covered here about futures such as how exceptions are handled, how to use a setter
632+ There are several other details not covered here about futures, such as how exceptions are handled, how to use a setter
633633proc instead of a block, etc. See the API documentation for details.
634634
635635#### Workflow Utilities
@@ -689,7 +689,7 @@ entire-workflow-failure situation.
689689
690690#### Workflow Logic Constraints
691691
692- Temporal Workflows [ must be deterministic] ( https://docs.temporal.io/workflows#deterministic-constraints ) which includes
692+ Temporal Workflows [ must be deterministic] ( https://docs.temporal.io/workflows#deterministic-constraints ) , which includes
693693Ruby workflows. This means there are several things workflows cannot do such as:
694694
695695* Perform IO (network, disk, stdio, etc)
@@ -701,7 +701,7 @@ Ruby workflows. This means there are several things workflows cannot do such as:
701701
702702#### Workflow Testing
703703
704- Workflow testing can be done in an integration-test fashion against a real server, however it is hard to simulate
704+ Workflow testing can be done in an integration-test fashion against a real server. However, it is hard to simulate
705705timeouts and other long time-based code. Using the time-skipping workflow test environment can help there.
706706
707707A non-time-skipping ` Temporalio::Testing::WorkflowEnvironment ` can be started via ` start_local ` which supports all
@@ -717,7 +717,7 @@ built-in x64 translation in macOS.
717717
718718##### Automatic Time Skipping
719719
720- Anytime a workflow result is waiting on, the time-skipping server automatically advances to the next event it can. To
720+ Anytime a workflow result is waited on, the time-skipping server automatically advances to the next event it can. To
721721manually advance time before waiting on the result of the workflow, the ` WorkflowEnvironment.sleep ` method can be used
722722on the environment itself. If an activity is running, time-skipping is disabled.
723723
@@ -846,6 +846,9 @@ class MyTest < Minitest::Test
846846end
847847```
848848
849+ This test will run almost instantly. The ` env.sleep(50) ` manually skips 50 seconds of time, allowing the timeout to be
850+ triggered without actually waiting the full 45 seconds to time out.
851+
849852##### Mocking Activities
850853
851854When testing workflows, often you don't want to actually run the activities. Activities are just classes that extend
0 commit comments