|
13 | 13 | from tests.helpers.nexus import create_nexus_endpoint, make_nexus_endpoint_name |
14 | 14 |
|
15 | 15 |
|
| 16 | +@nexusrpc.handler.service_handler |
| 17 | +class NexusService: |
| 18 | + @nexusrpc.handler.sync_operation |
| 19 | + async def op_that_never_returns( |
| 20 | + self, _ctx: nexusrpc.handler.StartOperationContext, id: None |
| 21 | + ) -> None: |
| 22 | + await asyncio.Event().wait() |
| 23 | + |
| 24 | + |
16 | 25 | @workflow.defn |
17 | 26 | class NexusCallerWorkflow: |
18 | | - """Workflow that calls a Nexus operation.""" |
19 | | - |
20 | 27 | @workflow.run |
21 | 28 | async def run(self) -> None: |
22 | 29 | nexus_client = workflow.create_nexus_client( |
23 | 30 | endpoint=make_nexus_endpoint_name(workflow.info().task_queue), |
24 | | - service="MaxConcurrentTestService", |
| 31 | + service=NexusService, |
25 | 32 | ) |
26 | | - |
27 | 33 | await nexus_client.execute_operation( |
28 | | - "op", None, schedule_to_close_timeout=timedelta(seconds=60) |
| 34 | + NexusService.op_that_never_returns, |
| 35 | + None, |
| 36 | + schedule_to_close_timeout=timedelta(seconds=10), |
29 | 37 | ) |
30 | 38 |
|
31 | 39 |
|
32 | 40 | async def test_nexus_timeout(env: WorkflowEnvironment): |
33 | 41 | if env.supports_time_skipping: |
34 | 42 | pytest.skip("Nexus tests don't work with Javas test server") |
35 | 43 |
|
36 | | - @nexusrpc.handler.service_handler |
37 | | - class MaxConcurrentTestService: |
38 | | - @nexusrpc.handler.sync_operation |
39 | | - async def op( |
40 | | - self, _ctx: nexusrpc.handler.StartOperationContext, id: None |
41 | | - ) -> None: |
42 | | - await asyncio.Event().wait() |
43 | | - |
44 | 44 | async with new_worker( |
45 | 45 | env.client, |
46 | 46 | NexusCallerWorkflow, |
47 | | - nexus_service_handlers=[MaxConcurrentTestService()], |
| 47 | + nexus_service_handlers=[NexusService()], |
48 | 48 | ) as worker: |
49 | 49 | await create_nexus_endpoint(worker.task_queue, env.client) |
50 | 50 |
|
|
0 commit comments