Skip to content

Commit eb66e79

Browse files
committed
Moved the Workflow writes to the regenerated Workflow modules.
The Workflow target moved under `system.workflow`, and its `Stream` takes `created`. The write Activities send their own append and close requests, since the generated client no longer does.
1 parent a5b360a commit eb66e79

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

‎temporalio/common/_streams/_extension.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
from temporalio.common._streams._handle import StreamHandle, workflow_owner
3131
from temporalio.common._streams._plugin import StreamBackend
3232
from temporalio.common._streams.proto import v1 as ext_pb
33-
from temporalio.common._streams.system import _system_nexus_interceptor as system_nexus
3433
from temporalio.common._streams.system import models
34+
from temporalio.common._streams.system.workflow import (
35+
_system_nexus_interceptor as system_nexus,
36+
)
3537
from temporalio.worker.workflow_sandbox import SandboxedWorkflowRunner
3638

3739
logger = logging.getLogger(__name__)

‎temporalio/common/_streams/_workflow.py‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@
4040
from temporalio.common._streams._items import close_failure
4141
from temporalio.common._streams._writer import WriteFuture, unretrieved_error
4242
from temporalio.common._streams.system import models
43-
from temporalio.common._streams.system._resources import Stream as GeneratedStream
44-
from temporalio.common._streams.system._resources import stream as generated_stream
45-
from temporalio.common._streams.system.operations import (
43+
from temporalio.common._streams.system.workflow._resources import (
44+
Stream as GeneratedStream,
45+
)
46+
from temporalio.common._streams.system.workflow._resources import (
47+
stream as generated_stream,
48+
)
49+
from temporalio.common._streams.system.workflow.operations import (
4650
create_stream as generated_create,
4751
)
4852
from temporalio.workflow._streams import WorkflowStream
@@ -503,7 +507,7 @@ async def close(
503507
"""Close the Stream after the writes before it, once the Workflow Task commits."""
504508
# The generated Workflow API makes the call, and the Worker's interceptor runs it as the
505509
# write Local Activity.
506-
await GeneratedStream(_generated_handle(handle)).close(
510+
await GeneratedStream(_generated_handle(handle), None).close(
507511
result=result, failure=failure
508512
)
509513

‎temporalio/common/_streams/_writes.py‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@
1515
import temporalio.api.stream.v1 as stream_v1
1616
import temporalio.api.streamservice.v1 as stream_pb
1717
import temporalio.common
18-
from temporalio.common._streams import _activity, _errors, _ids
18+
from temporalio.common._streams import _activity, _backend, _errors, _ids
1919
from temporalio.common._streams._workflow import (
2020
APPEND_ACTIVITY,
2121
CLOSE_ACTIVITY,
2222
CREATE_ACTIVITY,
2323
)
24-
from temporalio.common._streams.system import client as service_client
2524
from temporalio.common._streams.system import models
2625

2726

28-
def _context() -> tuple[
29-
_activity.ActivityStreams, service_client.StreamServiceClientExtension
30-
]:
27+
def _context() -> tuple[_activity.ActivityStreams, _backend.StreamServiceCalls]:
3128
streams = _activity.current.get()
3229
if streams is None:
3330
raise _errors.StreamConfigError("No Stream backend runs this Local Activity")
@@ -219,7 +216,7 @@ async def append_records(
219216
answer = encoded.answers.get(index)
220217
if answer is None:
221218
try:
222-
response = await service._stream_service_append_records(
219+
response = await service.send_append_records(
223220
models.AppendRecordsRequest(
224221
handle=_model_handle(request.handle),
225222
producer=producer,
@@ -270,7 +267,7 @@ async def close_stream(request: stream_pb.CloseStreamRequest) -> int:
270267
failure = streams.converter.failure_converter.from_failure(
271268
request.failure, streams.converter.payload_converter
272269
)
273-
await service._stream_service_close_stream(
270+
await service.send_close_stream(
274271
models.CloseStreamRequest(
275272
handle=_model_handle(request.handle),
276273
producer=models.Producer(

‎tests/contrib/streams/test_workflow_module.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from temporalio.common._streams import _workflow, _writes
2323
from temporalio.common._streams._backend import _ExtensionCalls
2424
from temporalio.common._streams._handle import workflow_owner
25-
from temporalio.common._streams.system._resources.stream import (
25+
from temporalio.common._streams.system.workflow._resources.stream import (
2626
stream as generated_stream,
2727
)
2828
from temporalio.contrib.stream.testing import MemoryStreamBackend

0 commit comments

Comments
 (0)