Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/added/steady-stream-heron.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add experimental Streams for clients, Activities, and Workflows, with configurable Stores, buffered appends, client interceptor hooks, and replay support.
63 changes: 63 additions & 0 deletions temporalio/bridge/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions temporalio/bridge/_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,26 @@ async def _visit_coresdk_workflow_activation_ResolveStreamAppend(
if o.HasField("failed"):
await self._visit_temporal_api_failure_v1_Failure(fs, o.failed)

async def _visit_temporal_api_stream_v1_StreamRecord(
self, fs: VisitorFunctions, o: Any
):
if o.HasField("body"):
await self._visit_temporal_api_common_v1_Payload(fs, o.body)

async def _visit_coresdk_workflow_activation_StreamPage(
self, fs: VisitorFunctions, o: Any
):
for v in o.records:
await self._visit_temporal_api_stream_v1_StreamRecord(fs, v)

async def _visit_coresdk_workflow_activation_ResolveStreamRead(
self, fs: VisitorFunctions, o: Any
):
if o.HasField("page"):
await self._visit_coresdk_workflow_activation_StreamPage(fs, o.page)
elif o.HasField("failed"):
await self._visit_temporal_api_failure_v1_Failure(fs, o.failed)

async def _visit_coresdk_workflow_activation_WorkflowActivationJob(
self, fs: VisitorFunctions, o: Any
):
Expand Down Expand Up @@ -363,6 +383,10 @@ async def _visit_coresdk_workflow_activation_WorkflowActivationJob(
await self._visit_coresdk_workflow_activation_ResolveStreamAppend(
fs, o.resolve_stream_append
)
elif o.HasField("resolve_stream_read"):
await self._visit_coresdk_workflow_activation_ResolveStreamRead(
fs, o.resolve_stream_read
)

async def _visit_coresdk_workflow_activation_WorkflowActivation(
self, fs: VisitorFunctions, o: Any
Expand Down Expand Up @@ -690,12 +714,6 @@ async def _visit_temporal_api_sdk_v1_ReadRecordsRequest(
) -> None:
pass

async def _visit_temporal_api_stream_v1_StreamRecord(
self, fs: VisitorFunctions, o: Any
):
if o.HasField("body"):
await self._visit_temporal_api_common_v1_Payload(fs, o.body)

async def _visit_temporal_api_streamservice_v1_ReadRecordsResponse(
self, fs: VisitorFunctions, o: Any
):
Expand Down
6 changes: 6 additions & 0 deletions temporalio/bridge/proto/external_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
StreamAppendOrigin,
StreamAppendResult,
StreamFailure,
StreamReadMarkerData,
StreamReadPage,
StreamReadResult,
)

__all__ = [
Expand All @@ -18,4 +21,7 @@
"StreamAppendOrigin",
"StreamAppendResult",
"StreamFailure",
"StreamReadMarkerData",
"StreamReadPage",
"StreamReadResult",
]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

142 changes: 142 additions & 0 deletions temporalio/bridge/proto/external_data/external_data_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,145 @@ class StreamFailure(google.protobuf.message.Message):
) -> None: ...

global___StreamFailure = StreamFailure

@typing.final
class StreamReadMarkerData(google.protobuf.message.Message):
"""The data of a `core_stream_read` marker. Core records one in each activation in which Workflow
code got the page of a read. An empty marker keeps a task with an open read and no open append
apart from the next task when chunking is on. The marker keeps the starting offset, Record count
and digest of each page so replay can verify the Records it reads from the Store.
Its JSON has `bytes` fields in lower-case hex, as for appends.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor

READS_FIELD_NUMBER: builtins.int
@property
def reads(
self,
) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[
global___StreamReadResult
]: ...
def __init__(
self,
*,
reads: collections.abc.Iterable[global___StreamReadResult] | None = ...,
) -> None: ...
def ClearField(self, field_name: typing.Literal["reads", b"reads"]) -> None: ...

global___StreamReadMarkerData = StreamReadMarkerData

@typing.final
class StreamReadResult(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor

SEQ_FIELD_NUMBER: builtins.int
STREAM_ID_FIELD_NUMBER: builtins.int
STORE_FIELD_NUMBER: builtins.int
ACTIVATION_INDEX_FIELD_NUMBER: builtins.int
AFTER_OFFSET_FIELD_NUMBER: builtins.int
PAGE_FIELD_NUMBER: builtins.int
FAILURE_FIELD_NUMBER: builtins.int
seq: builtins.int
stream_id: builtins.str
store: builtins.str
"""The name of the Store that the read used. For a ref with no Store name, it is the empty name
if the Worker has a Stream runtime under it, else the name of its only runtime.
"""
activation_index: builtins.int
"""The index of the activation, within its Workflow Task, in which Workflow code got the result."""
after_offset: builtins.bytes
"""The `after_offset` of the read. A replay reads the Records of the page after it."""
@property
def page(self) -> global___StreamReadPage: ...
@property
def failure(self) -> global___StreamFailure: ...
def __init__(
self,
*,
seq: builtins.int = ...,
stream_id: builtins.str = ...,
store: builtins.str = ...,
activation_index: builtins.int = ...,
after_offset: builtins.bytes = ...,
page: global___StreamReadPage | None = ...,
failure: global___StreamFailure | None = ...,
) -> None: ...
def HasField(
self,
field_name: typing.Literal[
"failure", b"failure", "page", b"page", "result", b"result"
],
) -> builtins.bool: ...
def ClearField(
self,
field_name: typing.Literal[
"activation_index",
b"activation_index",
"after_offset",
b"after_offset",
"failure",
b"failure",
"page",
b"page",
"result",
b"result",
"seq",
b"seq",
"store",
b"store",
"stream_id",
b"stream_id",
],
) -> None: ...
def WhichOneof(
self, oneof_group: typing.Literal["result", b"result"]
) -> typing.Literal["page", "failure"] | None: ...

global___StreamReadResult = StreamReadResult

@typing.final
class StreamReadPage(google.protobuf.message.Message):
"""A page that a read gave Workflow code, without its Records."""

DESCRIPTOR: google.protobuf.descriptor.Descriptor

RECORD_COUNT_FIELD_NUMBER: builtins.int
DIGEST_FIELD_NUMBER: builtins.int
RECORD_BYTES_FIELD_NUMBER: builtins.int
WAIT_CUT_FIELD_NUMBER: builtins.int
record_count: builtins.int
digest: builtins.bytes
"""The first 16 bytes of SHA-256 over the Records in a Core-owned encoding. New markers prefix
these bytes with version 1. Original markers contain just the legacy hash.
Empty for no Records.
"""
record_bytes: builtins.int
"""The size of the Records, as the `max_bytes` of a read measures it. A replay asks the Store for
this much.
"""
wait_cut: builtins.bool
"""The `wait_cut` that Workflow code got with the page."""
def __init__(
self,
*,
record_count: builtins.int = ...,
digest: builtins.bytes = ...,
record_bytes: builtins.int = ...,
wait_cut: builtins.bool = ...,
) -> None: ...
def ClearField(
self,
field_name: typing.Literal[
"digest",
b"digest",
"record_bytes",
b"record_bytes",
"record_count",
b"record_count",
"wait_cut",
b"wait_cut",
],
) -> None: ...

global___StreamReadPage = StreamReadPage
4 changes: 4 additions & 0 deletions temporalio/bridge/proto/workflow_activation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
ResolveRequestCancelExternalWorkflow,
ResolveSignalExternalWorkflow,
ResolveStreamAppend,
ResolveStreamRead,
SignalWorkflow,
StreamAppended,
StreamPage,
UpdateRandomSeed,
WorkflowActivation,
WorkflowActivationJob,
Expand All @@ -43,8 +45,10 @@
"ResolveRequestCancelExternalWorkflow",
"ResolveSignalExternalWorkflow",
"ResolveStreamAppend",
"ResolveStreamRead",
"SignalWorkflow",
"StreamAppended",
"StreamPage",
"UpdateRandomSeed",
"WorkflowActivation",
"WorkflowActivationJob",
Expand Down
Loading
Loading