Skip to content

Commit 212f846

Browse files
committed
Reorganize
1 parent 9b044d2 commit 212f846

15 files changed

Lines changed: 52 additions & 66 deletions

File tree

hello_nexus/README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
# Nexus
1+
This sample shows how to define a Nexus service, implement the operation handlers, and
2+
call the operations from a workflow.
23

3-
Temporal Nexus is a feature of the Temporal platform designed to connect durable executions across team, namespace,
4-
region, and cloud boundaries. It promotes a more modular architecture for sharing a subset of your team’s capabilities
5-
via well-defined service API contracts for other teams to use. These can abstract underlying Temporal primitives such as
6-
Workflows, or execute arbitrary code.
4+
### Sample directory structure
75

8-
Learn more at [temporal.io/nexus](https://temporal.io/nexus).
6+
- [service.py](./service.py) - shared Nexus service definition
7+
- [caller](./caller) - a caller workflow that executes Nexus operations, together with a worker and starter code
8+
- [handler](./handler) - Nexus operation handlers, together with a workflow used by one of the Nexus operations, and a worker that polls for both workflow and Nexus tasks.
99

10-
The samples in this directory form an introduction to Nexus.
1110

12-
### Samples
11+
### Instructions
1312

14-
- [basic](./basic) - Nexus service definition, operation handlers, and calling workflows.
13+
Start a Temporal server. (See the main samples repo [README](../README.md)).
14+
15+
Run the following:
16+
17+
```
18+
temporal operator namespace create --namespace hello-nexus-basic-handler-namespace
19+
temporal operator namespace create --namespace hello-nexus-basic-caller-namespace
20+
21+
temporal operator nexus endpoint create \
22+
--name hello-nexus-basic-nexus-endpoint \
23+
--target-namespace hello-nexus-basic-handler-namespace \
24+
--target-task-queue my-handler-task-queue \
25+
--description-file endpoint_description.md
26+
```
27+
28+
In one terminal, in this directory, run the Temporal worker in the handler namespace:
29+
```
30+
uv run handler/worker.py
31+
```
32+
33+
In another terminal, in this directory, run the Temporal worker in the caller namespace and start the caller
34+
workflow:
35+
```
36+
uv run caller/app.py
37+
```

hello_nexus/basic/README.md

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

hello_nexus/basic/handler/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from temporalio.client import Client
66
from temporalio.worker import UnsandboxedWorkflowRunner, Worker
77

8-
from hello_nexus.basic.caller.workflows import CallerWorkflow
9-
from hello_nexus.basic.service import MyOutput
8+
from hello_nexus.caller.workflows import CallerWorkflow
9+
from hello_nexus.service import MyOutput
1010

1111
NAMESPACE = "hello-nexus-basic-caller-namespace"
1212
TASK_QUEUE = "hello-nexus-basic-caller-task-queue"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from temporalio.workflow import NexusClient
33

44
with workflow.unsafe.imports_passed_through():
5-
from hello_nexus.basic.service import MyInput, MyNexusService, MyOutput
5+
from hello_nexus.service import MyInput, MyNexusService, MyOutput
66

77
NEXUS_ENDPOINT = "hello-nexus-basic-nexus-endpoint"
88

hello_nexus/basic/handler/service_handler.py renamed to hello_nexus/handler/service_handler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
from temporalio import nexus
1111
from temporalio.nexus import WorkflowRunOperationContext, workflow_run_operation
1212

13-
from hello_nexus.basic.handler.db_client import MyDBClient
14-
from hello_nexus.basic.handler.workflows import WorkflowStartedByNexusOperation
15-
from hello_nexus.basic.service import MyInput, MyNexusService, MyOutput
13+
from hello_nexus.handler.db_client import MyDBClient
14+
from hello_nexus.handler.workflows import WorkflowStartedByNexusOperation
15+
from hello_nexus.service import MyInput, MyNexusService, MyOutput
1616

1717

1818
@service_handler(service=MyNexusService)

0 commit comments

Comments
 (0)