Skip to content

Commit b2bfdba

Browse files
committed
Changes from code reviews
1 parent 5add8fb commit b2bfdba

4 files changed

Lines changed: 23 additions & 20 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Some examples require extra dependencies. See each sample's directory for specif
7575
* [message_passing/introduction](message_passing/introduction/) - Introduction to queries, signals, and updates.
7676
* [message_passing/safe_message_handlers](message_passing/safe_message_handlers/) - Safely handling updates and signals.
7777
* [message_passing/update_with_start/lazy_initialization](message_passing/update_with_start/lazy_initialization/) - Use update-with-start to update a Shopping Cart, starting it if it does not exist.
78+
* [Nexus Messaging](nexus_messaging): Demonstrates how send signal, update and query messages through Nexus.
79+
This contains two samples, one sending messages to an existing workflow and a second that creates a workflow through Nexus
80+
and sends messages to it.
7881
* [open_telemetry](open_telemetry) - Trace workflows with OpenTelemetry.
7982
* [patching](patching) - Alter workflows safely with `patch` and `deprecate_patch`.
8083
* [polling](polling) - Recommended implementation of an activity that needs to periodically poll an external resource waiting its successful completion.

nexus_messaging/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
This sample shows how to expose a long-running workflow's queries, updates, and signals as Nexus
1+
This sample shows how to expose a long-running Workflow's queries, updates, and signals as Nexus
22
operations. There are two self-contained examples, each in its own directory:
33

4-
| | `callerpattern/` | `ondemandpattern/` |
5-
|---|---|---|
6-
| **Pattern** | Signal an existing workflow | Create and run workflows on demand, and send signals to them |
7-
| **Who creates the workflow?** | The handler worker starts it on boot | The caller starts it via a Nexus operation |
8-
| **Who knows the workflow ID?** | Only the handler | The caller chooses and passes it in every operation |
9-
| **Nexus service** | `NexusGreetingService` | `NexusRemoteGreetingService` |
4+
| | `callerpattern/` | `ondemandpattern/` |
5+
|--------------------------------|--------------------------------------|--------------------------------------------------------------|
6+
| **Pattern** | Signal an existing Workflow | Create and run Workflows on demand, and send signals to them |
7+
| **Who creates the Workflow?** | The handler worker starts it on boot | The caller starts it via a Nexus operation |
8+
| **Who knows the Workflow ID?** | Only the handler | The caller chooses and passes it in every operation |
9+
| **Nexus service** | `NexusGreetingService` | `NexusRemoteGreetingService` |
1010

1111
Each directory is fully self-contained for clarity. The `GreetingWorkflow`, activity, and
1212
`Language` enum are **identical** between the two -- only the Nexus service definition and its
13-
handler implementation differ. This highlights that the same workflow can be exposed through
13+
handler implementation differ. This highlights that the same Workflow can be exposed through
1414
Nexus in different ways depending on whether the caller needs lifecycle control.
1515

1616
See each directory's README for running instructions.

nexus_messaging/callerpattern/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
## Caller pattern
22

3-
The handler worker starts a `GreetingWorkflow` for a user ID.
3+
The handler worker starts a `GreetingWorkflow` for a User ID.
44
`NexusGreetingServiceHandler` holds that ID and routes every Nexus operation to it.
5-
The caller's input does not have that workflow ID as the caller doesn't know it -- but the caller
6-
sends in the User ID, and `NexusGreetingServiceHandler` knows how to get the desired workflow ID
5+
The caller's input does not have that Workflow ID as the caller doesn't know it -- but the caller
6+
sends in the User ID, and `NexusGreetingServiceHandler` knows how to get the desired Workflow ID
77
from that User ID (see the `get_workflow_id` call).
88

9-
The handler worker uses the same `get_workflow_id` call to generate a workflow ID from a user ID
10-
when it launches the workflow.
9+
The handler worker uses the same `get_workflow_id` call to generate a Workflow ID from a Wser ID
10+
when it launches the Workflow.
1111

12-
The caller workflow:
12+
The caller Workflow:
1313
1. Queries for supported languages (`get_languages` -- backed by a `@workflow.query`)
1414
2. Changes the language to Arabic (`set_language` -- backed by a `@workflow.update` that calls an activity)
1515
3. Confirms the change via a second query (`get_language`)
16-
4. Approves the workflow (`approve` -- backed by a `@workflow.signal`)
16+
4. Approves the Workflow (`approve` -- backed by a `@workflow.signal`)
1717

1818
### Running
1919

@@ -41,7 +41,7 @@ In one terminal, start the handler worker:
4141
uv run python -m nexus_messaging.callerpattern.handler.worker
4242
```
4343

44-
In another terminal, run the caller workflow:
44+
In another terminal, run the following command to start the example:
4545

4646
```bash
4747
uv run python -m nexus_messaging.callerpattern.caller.app

nexus_messaging/ondemandpattern/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
## On-demand pattern
22

3-
No workflow is pre-started. The caller creates and controls workflow instances through Nexus
3+
No Workflow is pre-started. The caller creates and controls Workflow instances through Nexus
44
operations. `NexusRemoteGreetingService` adds a `run_from_remote` operation that starts a new
55
`GreetingWorkflow`, and every other operation includes a `user_id` so the handler knows which
66
instance to target.
77

8-
The caller workflow:
8+
The caller Workflow:
99
1. Starts two remote `GreetingWorkflow` instances via `run_from_remote` (backed by `workflow_run_operation`)
1010
2. Queries each for supported languages
1111
3. Changes the language on each (Arabic and Hindi)
1212
4. Confirms the changes via queries
13-
5. Approves both workflows
13+
5. Approves both Workflows
1414
6. Waits for each to complete and returns their results
1515

1616
### Running
@@ -39,7 +39,7 @@ In one terminal, start the handler worker:
3939
uv run python -m nexus_messaging.ondemandpattern.handler.worker
4040
```
4141

42-
In another terminal, run the caller workflow:
42+
In another terminal, run the following command to start the example:
4343

4444
```bash
4545
uv run python -m nexus_messaging.ondemandpattern.caller.app

0 commit comments

Comments
 (0)