Skip to content

Commit 0e23c43

Browse files
committed
Minimal example
1 parent 3d36c84 commit 0e23c43

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

hello_nexus/simple.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from datetime import timedelta
2+
3+
import nexusrpc
4+
from temporalio import workflow
5+
from temporalio.workflow import NexusClient
6+
7+
8+
# TODO(dan): make this decorator usable without parens
9+
@nexusrpc.handler.service()
10+
class MyNexusService:
11+
@nexusrpc.handler.sync_operation
12+
async def my_op(self, input: str, _: nexusrpc.handler.StartOperationOptions) -> str:
13+
return f"{input}-result"
14+
15+
16+
@workflow.run
17+
async def run(self, message: str) -> str:
18+
nexus_client = NexusClient(
19+
MyNexusService,
20+
"my-endpoint",
21+
schedule_to_close_timeout=timedelta(seconds=30),
22+
)
23+
return await nexus_client.execute_operation(MyNexusService.my_op, message)

0 commit comments

Comments
 (0)