From 9bccb27a28aab549891cdddf8cb36d4fec7eaa09 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Fri, 13 Nov 2026 17:38:38 -0700 Subject: [PATCH 01/24] Added the generated code of the Streams API. These are the files that `poe gen-protos` writes for the Stream service. They are in a PR of their own, so that the hand-written change shows alone. --- temporalio/api/enums/v1/__init__.py | 4 + temporalio/api/enums/v1/stream_pb2.py | 31 + temporalio/api/enums/v1/stream_pb2.pyi | 175 +++ temporalio/api/stream/__init__.py | 0 temporalio/api/stream/v1/__init__.py | 29 + temporalio/api/stream/v1/message_pb2.py | 58 + temporalio/api/stream/v1/message_pb2.pyi | 465 ++++++ temporalio/api/streamservice/__init__.py | 0 temporalio/api/streamservice/v1/__init__.py | 25 + .../streamservice/v1/request_response_pb2.py | 54 + .../streamservice/v1/request_response_pb2.pyi | 446 ++++++ .../v1/request_response_pb2_grpc.py | 4 + .../v1/request_response_pb2_grpc.pyi | 21 + temporalio/bridge/_visitor.py | 64 + .../nexus/system/stream_service/__init__.py | 71 + .../_resource_context_manager.py | 93 ++ .../system/stream_service/client/__init__.py | 11 + .../stream_service/client/_extensions.py | 180 +++ .../system/stream_service/client/_poll.py | 77 + .../client/_resources/__init__.py | 3 + .../client/_resources/stream.py | 261 ++++ .../nexus/system/stream_service/models.py | 1371 +++++++++++++++++ .../nexus/system/stream_service/services.py | 53 + .../stream_service/workflow/__init__.py | 77 + .../workflow/_resources/__init__.py | 9 + .../workflow/_resources/stream.py | 101 ++ .../workflow/_system_nexus_interceptor.py | 299 ++++ .../workflow/operations/__init__.py | 3 + .../workflow/operations/create_stream.py | 90 ++ temporalio/workflow/__init__.py | 6 + 30 files changed, 4081 insertions(+) create mode 100644 temporalio/api/enums/v1/stream_pb2.py create mode 100644 temporalio/api/enums/v1/stream_pb2.pyi create mode 100644 temporalio/api/stream/__init__.py create mode 100644 temporalio/api/stream/v1/__init__.py create mode 100644 temporalio/api/stream/v1/message_pb2.py create mode 100644 temporalio/api/stream/v1/message_pb2.pyi create mode 100644 temporalio/api/streamservice/__init__.py create mode 100644 temporalio/api/streamservice/v1/__init__.py create mode 100644 temporalio/api/streamservice/v1/request_response_pb2.py create mode 100644 temporalio/api/streamservice/v1/request_response_pb2.pyi create mode 100644 temporalio/api/streamservice/v1/request_response_pb2_grpc.py create mode 100644 temporalio/api/streamservice/v1/request_response_pb2_grpc.pyi create mode 100644 temporalio/nexus/system/stream_service/__init__.py create mode 100644 temporalio/nexus/system/stream_service/_resource_context_manager.py create mode 100644 temporalio/nexus/system/stream_service/client/__init__.py create mode 100644 temporalio/nexus/system/stream_service/client/_extensions.py create mode 100644 temporalio/nexus/system/stream_service/client/_poll.py create mode 100644 temporalio/nexus/system/stream_service/client/_resources/__init__.py create mode 100644 temporalio/nexus/system/stream_service/client/_resources/stream.py create mode 100644 temporalio/nexus/system/stream_service/models.py create mode 100644 temporalio/nexus/system/stream_service/services.py create mode 100644 temporalio/nexus/system/stream_service/workflow/__init__.py create mode 100644 temporalio/nexus/system/stream_service/workflow/_resources/__init__.py create mode 100644 temporalio/nexus/system/stream_service/workflow/_resources/stream.py create mode 100644 temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py create mode 100644 temporalio/nexus/system/stream_service/workflow/operations/__init__.py create mode 100644 temporalio/nexus/system/stream_service/workflow/operations/create_stream.py diff --git a/temporalio/api/enums/v1/__init__.py b/temporalio/api/enums/v1/__init__.py index f1e9a53005..0efbca2cfc 100644 --- a/temporalio/api/enums/v1/__init__.py +++ b/temporalio/api/enums/v1/__init__.py @@ -49,6 +49,7 @@ from .query_pb2 import QueryRejectCondition, QueryResultType from .reset_pb2 import ResetReapplyExcludeType, ResetReapplyType, ResetType from .schedule_pb2 import ScheduleOverlapPolicy +from .stream_pb2 import StreamErrorReason, StreamIdConflictPolicy, StreamStatus from .task_queue_pb2 import ( BuildIdTaskReachability, DescribeTaskQueueMode, @@ -126,6 +127,9 @@ "Severity", "SignalExternalWorkflowExecutionFailedCause", "StartChildWorkflowExecutionFailedCause", + "StreamErrorReason", + "StreamIdConflictPolicy", + "StreamStatus", "SuggestContinueAsNewReason", "TaskQueueKind", "TaskQueueType", diff --git a/temporalio/api/enums/v1/stream_pb2.py b/temporalio/api/enums/v1/stream_pb2.py new file mode 100644 index 0000000000..b2e79a0e96 --- /dev/null +++ b/temporalio/api/enums/v1/stream_pb2.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: temporal/api/enums/v1/stream.proto +"""Generated protocol buffer code.""" + +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*z\n\x0cStreamStatus\x12\x1d\n\x19STREAM_STATUS_UNSPECIFIED\x10\x00\x12\x16\n\x12STREAM_STATUS_OPEN\x10\x01\x12\x18\n\x14STREAM_STATUS_CLOSED\x10\x02\x12\x19\n\x15STREAM_STATUS_EXPIRED\x10\x03*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xe8\x04\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_CLOSED\x10\x03\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x04\x12(\n$STREAM_ERROR_REASON_SEQUENCE_TOO_LOW\x10\x05\x12%\n!STREAM_ERROR_REASON_SEQ_DIVERGENT\x10\x06\x12!\n\x1dSTREAM_ERROR_REASON_NOT_OWNER\x10\x07\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x08\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\t\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\n\x12\x1f\n\x1bSTREAM_ERROR_REASON_INVALID\x10\x0b\x12+\n\'STREAM_ERROR_REASON_STORAGE_UNAVAILABLE\x10\x0c\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\r\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\x0e\x12\'\n#STREAM_ERROR_REASON_STORAGE_CORRUPT\x10\x0f\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' +) + +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, __name__, globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b"\n\030io.temporal.api.enums.v1B\013StreamProtoP\001Z!go.temporal.io/api/enums/v1;enums\252\002\027Temporalio.Api.Enums.V1\352\002\032Temporalio::Api::Enums::V1" + _STREAMSTATUS._serialized_start = 61 + _STREAMSTATUS._serialized_end = 183 + _STREAMIDCONFLICTPOLICY._serialized_start = 186 + _STREAMIDCONFLICTPOLICY._serialized_end = 333 + _STREAMERRORREASON._serialized_start = 336 + _STREAMERRORREASON._serialized_end = 952 +# @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/enums/v1/stream_pb2.pyi b/temporalio/api/enums/v1/stream_pb2.pyi new file mode 100644 index 0000000000..ac57ccd183 --- /dev/null +++ b/temporalio/api/enums/v1/stream_pb2.pyi @@ -0,0 +1,175 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import builtins +import sys +import typing + +import google.protobuf.descriptor +import google.protobuf.internal.enum_type_wrapper + +if sys.version_info >= (3, 10): + import typing as typing_extensions +else: + import typing_extensions + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +class _StreamStatus: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + +class _StreamStatusEnumTypeWrapper( + google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[ + _StreamStatus.ValueType + ], + builtins.type, +): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + STREAM_STATUS_UNSPECIFIED: _StreamStatus.ValueType # 0 + STREAM_STATUS_OPEN: _StreamStatus.ValueType # 1 + STREAM_STATUS_CLOSED: _StreamStatus.ValueType # 2 + STREAM_STATUS_EXPIRED: _StreamStatus.ValueType # 3 + +class StreamStatus(_StreamStatus, metaclass=_StreamStatusEnumTypeWrapper): + """Experimental. Might change in the future. + The state of a Stream, as a describe gives it. + (-- api-linter: core::0216::synonyms=disabled + aip.dev/not-precedent: Named consistently with WorkflowExecutionStatus. --) + """ + +STREAM_STATUS_UNSPECIFIED: StreamStatus.ValueType # 0 +STREAM_STATUS_OPEN: StreamStatus.ValueType # 1 +STREAM_STATUS_CLOSED: StreamStatus.ValueType # 2 +STREAM_STATUS_EXPIRED: StreamStatus.ValueType # 3 +global___StreamStatus = StreamStatus + +class _StreamIdConflictPolicy: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + +class _StreamIdConflictPolicyEnumTypeWrapper( + google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[ + _StreamIdConflictPolicy.ValueType + ], + builtins.type, +): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + STREAM_ID_CONFLICT_POLICY_UNSPECIFIED: _StreamIdConflictPolicy.ValueType # 0 + STREAM_ID_CONFLICT_POLICY_FAIL: _StreamIdConflictPolicy.ValueType # 1 + """The create fails with ALREADY_EXISTS.""" + STREAM_ID_CONFLICT_POLICY_USE_EXISTING: _StreamIdConflictPolicy.ValueType # 2 + """The create gets the open Stream, which keeps its own Retention.""" + +class StreamIdConflictPolicy( + _StreamIdConflictPolicy, metaclass=_StreamIdConflictPolicyEnumTypeWrapper +): + """Experimental. Might change in the future. + What a create does when its Stream exists. Unspecified is FAIL, as for a Workflow start. + """ + +STREAM_ID_CONFLICT_POLICY_UNSPECIFIED: StreamIdConflictPolicy.ValueType # 0 +STREAM_ID_CONFLICT_POLICY_FAIL: StreamIdConflictPolicy.ValueType # 1 +"""The create fails with ALREADY_EXISTS.""" +STREAM_ID_CONFLICT_POLICY_USE_EXISTING: StreamIdConflictPolicy.ValueType # 2 +"""The create gets the open Stream, which keeps its own Retention.""" +global___StreamIdConflictPolicy = StreamIdConflictPolicy + +class _StreamErrorReason: + ValueType = typing.NewType("ValueType", builtins.int) + V: typing_extensions.TypeAlias = ValueType + +class _StreamErrorReasonEnumTypeWrapper( + google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[ + _StreamErrorReason.ValueType + ], + builtins.type, +): + DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor + STREAM_ERROR_REASON_UNSPECIFIED: _StreamErrorReason.ValueType # 0 + STREAM_ERROR_REASON_NOT_FOUND: _StreamErrorReason.ValueType # 1 + """Nobody created the Stream. NOT_FOUND.""" + STREAM_ERROR_REASON_EXPIRED: _StreamErrorReason.ValueType # 2 + """The Stream's Retention or its last-write TTL passed. NOT_FOUND.""" + STREAM_ERROR_REASON_CLOSED: _StreamErrorReason.ValueType # 3 + """The Stream is closed. FAILED_PRECONDITION.""" + STREAM_ERROR_REASON_FENCED: _StreamErrorReason.ValueType # 4 + """The Producer's epoch is lower than the newest one. FAILED_PRECONDITION.""" + STREAM_ERROR_REASON_SEQUENCE_TOO_LOW: _StreamErrorReason.ValueType # 5 + """The batch has a lower `sequence` than the last one of its epoch. FAILED_PRECONDITION.""" + STREAM_ERROR_REASON_SEQ_DIVERGENT: _StreamErrorReason.ValueType # 6 + """The batch has the `sequence` of the last one of its epoch, and other content. + FAILED_PRECONDITION. + """ + STREAM_ERROR_REASON_NOT_OWNER: _StreamErrorReason.ValueType # 7 + """The caller may not create or close this Stream. FAILED_PRECONDITION.""" + STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 8 + """A newer format version wrote the Stream. FAILED_PRECONDITION.""" + STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 9 + """The offset is past the newest offset, for example after a failover lost the newest Records. + A read from it works again once the Stream has Records up to it. OUT_OF_RANGE. + """ + STREAM_ERROR_REASON_TOO_LARGE: _StreamErrorReason.ValueType # 10 + """A Record or a batch is over the Store's limit. INVALID_ARGUMENT.""" + STREAM_ERROR_REASON_INVALID: _StreamErrorReason.ValueType # 11 + """The request is malformed. INVALID_ARGUMENT.""" + STREAM_ERROR_REASON_STORAGE_UNAVAILABLE: _StreamErrorReason.ValueType # 12 + """The Store failed or did not answer. A retry can succeed. UNAVAILABLE.""" + STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 13 + """The Store lacks a capability that the call needs. UNIMPLEMENTED.""" + STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 14 + """A create with the FAIL conflict policy is for a Stream that exists. ALREADY_EXISTS.""" + STREAM_ERROR_REASON_STORAGE_CORRUPT: _StreamErrorReason.ValueType # 15 + """The Store gave back data that isn't valid, such as a stored value with the wrong length. A + retry reads the same data. DATA_LOSS. + """ + +class StreamErrorReason( + _StreamErrorReason, metaclass=_StreamErrorReasonEnumTypeWrapper +): + """Experimental. Might change in the future. + Why a Stream call failed. Each reason has one gRPC status code, and several reasons share a + code. So code matches on the reason, and not on the status code. An SDK raises one error type + that carries the reason. + """ + +STREAM_ERROR_REASON_UNSPECIFIED: StreamErrorReason.ValueType # 0 +STREAM_ERROR_REASON_NOT_FOUND: StreamErrorReason.ValueType # 1 +"""Nobody created the Stream. NOT_FOUND.""" +STREAM_ERROR_REASON_EXPIRED: StreamErrorReason.ValueType # 2 +"""The Stream's Retention or its last-write TTL passed. NOT_FOUND.""" +STREAM_ERROR_REASON_CLOSED: StreamErrorReason.ValueType # 3 +"""The Stream is closed. FAILED_PRECONDITION.""" +STREAM_ERROR_REASON_FENCED: StreamErrorReason.ValueType # 4 +"""The Producer's epoch is lower than the newest one. FAILED_PRECONDITION.""" +STREAM_ERROR_REASON_SEQUENCE_TOO_LOW: StreamErrorReason.ValueType # 5 +"""The batch has a lower `sequence` than the last one of its epoch. FAILED_PRECONDITION.""" +STREAM_ERROR_REASON_SEQ_DIVERGENT: StreamErrorReason.ValueType # 6 +"""The batch has the `sequence` of the last one of its epoch, and other content. +FAILED_PRECONDITION. +""" +STREAM_ERROR_REASON_NOT_OWNER: StreamErrorReason.ValueType # 7 +"""The caller may not create or close this Stream. FAILED_PRECONDITION.""" +STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 8 +"""A newer format version wrote the Stream. FAILED_PRECONDITION.""" +STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 9 +"""The offset is past the newest offset, for example after a failover lost the newest Records. +A read from it works again once the Stream has Records up to it. OUT_OF_RANGE. +""" +STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 10 +"""A Record or a batch is over the Store's limit. INVALID_ARGUMENT.""" +STREAM_ERROR_REASON_INVALID: StreamErrorReason.ValueType # 11 +"""The request is malformed. INVALID_ARGUMENT.""" +STREAM_ERROR_REASON_STORAGE_UNAVAILABLE: StreamErrorReason.ValueType # 12 +"""The Store failed or did not answer. A retry can succeed. UNAVAILABLE.""" +STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 13 +"""The Store lacks a capability that the call needs. UNIMPLEMENTED.""" +STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 14 +"""A create with the FAIL conflict policy is for a Stream that exists. ALREADY_EXISTS.""" +STREAM_ERROR_REASON_STORAGE_CORRUPT: StreamErrorReason.ValueType # 15 +"""The Store gave back data that isn't valid, such as a stored value with the wrong length. A +retry reads the same data. DATA_LOSS. +""" +global___StreamErrorReason = StreamErrorReason diff --git a/temporalio/api/stream/__init__.py b/temporalio/api/stream/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/temporalio/api/stream/v1/__init__.py b/temporalio/api/stream/v1/__init__.py new file mode 100644 index 0000000000..73024c06b8 --- /dev/null +++ b/temporalio/api/stream/v1/__init__.py @@ -0,0 +1,29 @@ +from .message_pb2 import ( + ActivityEpoch, + ActivityProducer, + AppendRecord, + ClientProducer, + LocalActivityEpoch, + LocalActivityProducer, + Producer, + StreamErrorDetails, + StreamRecord, + StreamRef, + WorkflowProducer, + WorkflowTaskEpoch, +) + +__all__ = [ + "ActivityEpoch", + "ActivityProducer", + "AppendRecord", + "ClientProducer", + "LocalActivityEpoch", + "LocalActivityProducer", + "Producer", + "StreamErrorDetails", + "StreamRecord", + "StreamRef", + "WorkflowProducer", + "WorkflowTaskEpoch", +] diff --git a/temporalio/api/stream/v1/message_pb2.py b/temporalio/api/stream/v1/message_pb2.py new file mode 100644 index 0000000000..5bac69d283 --- /dev/null +++ b/temporalio/api/stream/v1/message_pb2.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: temporal/api/stream/v1/message.proto +"""Generated protocol buffer code.""" + +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + +from temporalio.api.common.v1 import ( + message_pb2 as temporal_dot_api_dot_common_dot_v1_dot_message__pb2, +) +from temporalio.api.enums.v1 import ( + stream_pb2 as temporal_dot_api_dot_enums_dot_v1_dot_stream__pb2, +) + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"p\n\x11WorkflowTaskEpoch\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"^\n\x12LocalActivityEpoch\x12\x37\n\x04task\x18\x01 \x01(\x0b\x32).temporal.api.stream.v1.WorkflowTaskEpoch\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\\\n\rActivityEpoch\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\\\n\x10WorkflowProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x38\n\x05\x65poch\x18\x02 \x01(\x0b\x32).temporal.api.stream.v1.WorkflowTaskEpoch"b\n\x15LocalActivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x39\n\x05\x65poch\x18\x02 \x01(\x0b\x32*.temporal.api.stream.v1.LocalActivityEpoch"X\n\x10\x41\x63tivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x34\n\x05\x65poch\x18\x02 \x01(\x0b\x32%.temporal.api.stream.v1.ActivityEpoch"\x10\n\x0e\x43lientProducer"\xef\x02\n\x08Producer\x12\n\n\x02id\x18\x01 \x01(\t\x12<\n\x08workflow\x18\x02 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x03 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12\x45\n\x11workflow_activity\x18\x04 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12G\n\x13standalone_activity\x18\x05 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x06 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' +) + +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, __name__, globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b"\n\031io.temporal.api.stream.v1B\014MessageProtoP\001Z#go.temporal.io/api/stream/v1;stream\252\002\030Temporalio.Api.Stream.V1\352\002\033Temporalio::Api::Stream::V1" + _STREAMREF._serialized_start = 171 + _STREAMREF._serialized_end = 209 + _WORKFLOWTASKEPOCH._serialized_start = 211 + _WORKFLOWTASKEPOCH._serialized_end = 323 + _LOCALACTIVITYEPOCH._serialized_start = 325 + _LOCALACTIVITYEPOCH._serialized_end = 419 + _ACTIVITYEPOCH._serialized_start = 421 + _ACTIVITYEPOCH._serialized_end = 513 + _WORKFLOWPRODUCER._serialized_start = 515 + _WORKFLOWPRODUCER._serialized_end = 607 + _LOCALACTIVITYPRODUCER._serialized_start = 609 + _LOCALACTIVITYPRODUCER._serialized_end = 707 + _ACTIVITYPRODUCER._serialized_start = 709 + _ACTIVITYPRODUCER._serialized_end = 797 + _CLIENTPRODUCER._serialized_start = 799 + _CLIENTPRODUCER._serialized_end = 815 + _PRODUCER._serialized_start = 818 + _PRODUCER._serialized_end = 1185 + _APPENDRECORD._serialized_start = 1187 + _APPENDRECORD._serialized_end = 1248 + _STREAMRECORD._serialized_start = 1251 + _STREAMRECORD._serialized_end = 1380 + _STREAMERRORDETAILS._serialized_start = 1382 + _STREAMERRORDETAILS._serialized_end = 1460 +# @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi new file mode 100644 index 0000000000..1d01036026 --- /dev/null +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -0,0 +1,465 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import builtins +import typing + +import google.protobuf.descriptor +import google.protobuf.message +import google.protobuf.timestamp_pb2 + +import temporalio.api.common.v1.message_pb2 +import temporalio.api.enums.v1.stream_pb2 + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +@typing.final +class StreamRef(google.protobuf.message.Message): + """Experimental. Might change in the future. + Identifies one Stream. The id is opaque to callers. A Stream has no incarnations. A create of a + closed or expired Stream fails, and it doesn't make a second Stream with the same id. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + STORE_FIELD_NUMBER: builtins.int + id: builtins.str + store: builtins.str + """The name of the Store that holds the Stream, as the Worker and client config register it, + so every process routes a ref it receives. With no name, the SDK picks the Store from its + config. Only an SDK sets and reads it, since only the SDK knows the name that its config + gives a Store. A request carries the whole ref, and the server and a Store ignore this + field. + """ + def __init__( + self, + *, + id: builtins.str = ..., + store: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["id", b"id", "store", b"store"] + ) -> None: ... + +global___StreamRef = StreamRef + +@typing.final +class WorkflowTaskEpoch(google.protobuf.message.Message): + """Experimental. Might change in the future. + One Workflow Task attempt of a run. It orders by started_event_id, then attempt, then + started_time. An epoch orders the attempts of one Producer only, and a Producer belongs to one + run. So a reset run and the next run of a chain have other Producers, and their epochs start + again. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + STARTED_EVENT_ID_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int + STARTED_TIME_FIELD_NUMBER: builtins.int + started_event_id: builtins.int + """Required.""" + attempt: builtins.int + """Required. 1 or more.""" + @property + def started_time(self) -> google.protobuf.timestamp_pb2.Timestamp: + """Tells a reused started event id apart, for example after a dropped speculative task. Core + leaves it empty when the server gave the task no started time. + """ + + def __init__( + self, + *, + started_event_id: builtins.int = ..., + attempt: builtins.int = ..., + started_time: google.protobuf.timestamp_pb2.Timestamp | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["started_time", b"started_time"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "attempt", + b"attempt", + "started_event_id", + b"started_event_id", + "started_time", + b"started_time", + ], + ) -> None: ... + +global___WorkflowTaskEpoch = WorkflowTaskEpoch + +@typing.final +class LocalActivityEpoch(google.protobuf.message.Message): + """Experimental. Might change in the future. + The attempt of a Local Activity. It orders by task, then attempt, so the same call in a later + Workflow Task is a higher epoch. The Producer carries the run. Records of two runs have no + order by epoch, only their order in the Stream. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + TASK_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int + attempt: builtins.int + """Required. The Local Activity's own attempt in that Workflow Task, 1 or more.""" + @property + def task(self) -> global___WorkflowTaskEpoch: + """Required. The Workflow Task attempt that dispatched the Local Activity.""" + + def __init__( + self, + *, + task: global___WorkflowTaskEpoch | None = ..., + attempt: builtins.int = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["task", b"task"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["attempt", b"attempt", "task", b"task"] + ) -> None: ... + +global___LocalActivityEpoch = LocalActivityEpoch + +@typing.final +class ActivityEpoch(google.protobuf.message.Message): + """Experimental. Might change in the future. + The attempt of an Activity. It orders by attempt_scheduled_time, then attempt. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ATTEMPT_SCHEDULED_TIME_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int + attempt: builtins.int + """Required. 1 or more.""" + @property + def attempt_scheduled_time(self) -> google.protobuf.timestamp_pb2.Timestamp: + """Required. When the server scheduled this attempt. An Activity reset starts the attempt count + again, so only this time orders the attempts across a reset. + """ + + def __init__( + self, + *, + attempt_scheduled_time: google.protobuf.timestamp_pb2.Timestamp | None = ..., + attempt: builtins.int = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal["attempt_scheduled_time", b"attempt_scheduled_time"], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "attempt", b"attempt", "attempt_scheduled_time", b"attempt_scheduled_time" + ], + ) -> None: ... + +global___ActivityEpoch = ActivityEpoch + +@typing.final +class WorkflowProducer(google.protobuf.message.Message): + """Experimental. Might change in the future. + A Workflow run Producer. On the server's Streams, a Workflow writes as this Producer in its + Workflow Task. On a Store, Workflow code writes through a Local Activity, so its writes carry a + Local Activity Producer. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RUN_ID_FIELD_NUMBER: builtins.int + EPOCH_FIELD_NUMBER: builtins.int + run_id: builtins.str + """Required. The run id of the Workflow run, not of its chain. Each run is its own Producer.""" + @property + def epoch(self) -> global___WorkflowTaskEpoch: + """The Workflow Task of the write.""" + + def __init__( + self, + *, + run_id: builtins.str = ..., + epoch: global___WorkflowTaskEpoch | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["epoch", b"epoch"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["epoch", b"epoch", "run_id", b"run_id"] + ) -> None: ... + +global___WorkflowProducer = WorkflowProducer + +@typing.final +class LocalActivityProducer(google.protobuf.message.Message): + """Experimental. Might change in the future. + A Local Activity Producer, one for each call of a run. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RUN_ID_FIELD_NUMBER: builtins.int + EPOCH_FIELD_NUMBER: builtins.int + run_id: builtins.str + """Required. The run id of the Workflow run.""" + @property + def epoch(self) -> global___LocalActivityEpoch: + """Required.""" + + def __init__( + self, + *, + run_id: builtins.str = ..., + epoch: global___LocalActivityEpoch | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["epoch", b"epoch"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["epoch", b"epoch", "run_id", b"run_id"] + ) -> None: ... + +global___LocalActivityProducer = LocalActivityProducer + +@typing.final +class ActivityProducer(google.protobuf.message.Message): + """Experimental. Might change in the future. + An Activity Producer, for an Activity of a Workflow or a Standalone Activity. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RUN_ID_FIELD_NUMBER: builtins.int + EPOCH_FIELD_NUMBER: builtins.int + run_id: builtins.str + """The run id of the Workflow run that scheduled the Activity. Empty for a Standalone + Activity, whose own run id is in the Producer id. + """ + @property + def epoch(self) -> global___ActivityEpoch: + """Required.""" + + def __init__( + self, + *, + run_id: builtins.str = ..., + epoch: global___ActivityEpoch | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["epoch", b"epoch"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["epoch", b"epoch", "run_id", b"run_id"] + ) -> None: ... + +global___ActivityProducer = ActivityProducer + +@typing.final +class ClientProducer(google.protobuf.message.Message): + """Experimental. Might change in the future. + A client Producer. A client has no run and no epoch. So nothing fences a client's writes, and a + reader never hides them. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + +global___ClientProducer = ClientProducer + +@typing.final +class Producer(google.protobuf.message.Message): + """Experimental. Might change in the future. + The code that wrote a batch, which is one unit of work. Its id stays the same across attempts, + and an epoch is one attempt. The kind's case orders its epochs. After a write of a higher epoch, + a write of a lower epoch of the same Producer fails with FENCED, and a reader may hide the + Records of the lower epoch. The rule is the same for every kind that has an epoch. A client has + none. The epochs of two Producers never compare. A new run has new Producers, so no write + fences or supersedes the Records of an earlier run, such as the base run of a reset. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + WORKFLOW_FIELD_NUMBER: builtins.int + LOCAL_ACTIVITY_FIELD_NUMBER: builtins.int + WORKFLOW_ACTIVITY_FIELD_NUMBER: builtins.int + STANDALONE_ACTIVITY_FIELD_NUMBER: builtins.int + CLIENT_FIELD_NUMBER: builtins.int + id: builtins.str + """Required. Stable across attempts, such as `wf:` for the Workflow Producer of a run. + It is unique in one Stream. The id of a run-based kind has its run id, so it stays unique + when Producers of more than one namespace write to one Stream. + """ + @property + def workflow(self) -> global___WorkflowProducer: ... + @property + def local_activity(self) -> global___LocalActivityProducer: ... + @property + def workflow_activity(self) -> global___ActivityProducer: + """An Activity that a Workflow scheduled.""" + + @property + def standalone_activity(self) -> global___ActivityProducer: + """An Activity with no Workflow. Both Activity cases order their epochs the same way. The + case tells which identity the Producer has, since only the first has a Workflow run. + """ + + @property + def client(self) -> global___ClientProducer: ... + def __init__( + self, + *, + id: builtins.str = ..., + workflow: global___WorkflowProducer | None = ..., + local_activity: global___LocalActivityProducer | None = ..., + workflow_activity: global___ActivityProducer | None = ..., + standalone_activity: global___ActivityProducer | None = ..., + client: global___ClientProducer | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "client", + b"client", + "kind", + b"kind", + "local_activity", + b"local_activity", + "standalone_activity", + b"standalone_activity", + "workflow", + b"workflow", + "workflow_activity", + b"workflow_activity", + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "client", + b"client", + "id", + b"id", + "kind", + b"kind", + "local_activity", + b"local_activity", + "standalone_activity", + b"standalone_activity", + "workflow", + b"workflow", + "workflow_activity", + b"workflow_activity", + ], + ) -> None: ... + def WhichOneof( + self, oneof_group: typing.Literal["kind", b"kind"] + ) -> ( + typing.Literal[ + "workflow", + "local_activity", + "workflow_activity", + "standalone_activity", + "client", + ] + | None + ): ... + +global___Producer = Producer + +@typing.final +class AppendRecord(google.protobuf.message.Message): + """Experimental. Might change in the future. + One Record of a batch to append. The Store adds the batch's Producer and an offset. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + BODY_FIELD_NUMBER: builtins.int + @property + def body(self) -> temporalio.api.common.v1.message_pb2.Payload: + """Required.""" + + def __init__( + self, + *, + body: temporalio.api.common.v1.message_pb2.Payload | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["body", b"body"] + ) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["body", b"body"]) -> None: ... + +global___AppendRecord = AppendRecord + +@typing.final +class StreamRecord(google.protobuf.message.Message): + """Experimental. Might change in the future. + One Record that a Producer appended, as a read gives it. A read gives only Records. A close + stores no Record, so a read tells of it with the done flag of its response. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + PRODUCER_FIELD_NUMBER: builtins.int + BODY_FIELD_NUMBER: builtins.int + OFFSET_FIELD_NUMBER: builtins.int + offset: builtins.bytes + """Required. The Record's offset. An offset is ordered and unique in one Stream, and it is + sparse. Offsets have gaps, so they don't count Records. Two offsets of one Stream compare + bytewise, as unsigned bytes, in the order of their Records. So a reader, a Store and the + server order them without decoding them. An offset is never empty. A read gives its + Stream, so the read checks the offset against that Stream. + """ + @property + def producer(self) -> global___Producer: ... + @property + def body(self) -> temporalio.api.common.v1.message_pb2.Payload: ... + def __init__( + self, + *, + producer: global___Producer | None = ..., + body: temporalio.api.common.v1.message_pb2.Payload | None = ..., + offset: builtins.bytes = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["body", b"body", "producer", b"producer"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "body", b"body", "offset", b"offset", "producer", b"producer" + ], + ) -> None: ... + +global___StreamRecord = StreamRecord + +@typing.final +class StreamErrorDetails(google.protobuf.message.Message): + """Experimental. Might change in the future. + The details of a failed Stream call, in the gRPC status details and in the details of the + application failure of a Nexus operation. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REASON_FIELD_NUMBER: builtins.int + reason: temporalio.api.enums.v1.stream_pb2.StreamErrorReason.ValueType + def __init__( + self, + *, + reason: temporalio.api.enums.v1.stream_pb2.StreamErrorReason.ValueType = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["reason", b"reason"]) -> None: ... + +global___StreamErrorDetails = StreamErrorDetails diff --git a/temporalio/api/streamservice/__init__.py b/temporalio/api/streamservice/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/temporalio/api/streamservice/v1/__init__.py b/temporalio/api/streamservice/v1/__init__.py new file mode 100644 index 0000000000..40801cf9a5 --- /dev/null +++ b/temporalio/api/streamservice/v1/__init__.py @@ -0,0 +1,25 @@ +from .request_response_pb2 import ( + AppendRecordsRequest, + AppendRecordsResponse, + CloseStreamRequest, + CloseStreamResponse, + CreateStreamRequest, + CreateStreamResponse, + DescribeStreamRequest, + DescribeStreamResponse, + ReadRecordsRequest, + ReadRecordsResponse, +) + +__all__ = [ + "AppendRecordsRequest", + "AppendRecordsResponse", + "CloseStreamRequest", + "CloseStreamResponse", + "CreateStreamRequest", + "CreateStreamResponse", + "DescribeStreamRequest", + "DescribeStreamResponse", + "ReadRecordsRequest", + "ReadRecordsResponse", +] diff --git a/temporalio/api/streamservice/v1/request_response_pb2.py b/temporalio/api/streamservice/v1/request_response_pb2.py new file mode 100644 index 0000000000..161aa0c07b --- /dev/null +++ b/temporalio/api/streamservice/v1/request_response_pb2.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: temporal/api/streamservice/v1/request_response.proto +"""Generated protocol buffer code.""" + +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 + +from temporalio.api.enums.v1 import ( + stream_pb2 as temporal_dot_api_dot_enums_dot_v1_dot_stream__pb2, +) +from temporalio.api.stream.v1 import ( + message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, +) + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\xbe\x01\n\x13\x43reateStreamRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x35\n\nstream_ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x03 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy\x12\x12\n\nrequest_id\x18\x04 \x01(\t"W\n\x14\x43reateStreamResponse\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xd6\x01\n\x14\x41ppendRecordsRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x03 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x10\n\x08sequence\x18\x04 \x01(\x03\x12\x35\n\x07records\x18\x05 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"\x8b\x01\n\x12\x43loseStreamRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x03 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\xbd\x01\n\x12ReadRecordsRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x04 \x01(\x05\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x11\n\tmax_bytes\x18\x06 \x01(\x03"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"Z\n\x15\x44\x65scribeStreamRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' +) + +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, __name__, globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'\n io.temporal.api.streamservice.v1B\024RequestResponseProtoP\001Z1go.temporal.io/api/streamservice/v1;streamservice\252\002\037Temporalio.Api.StreamService.V1\352\002"Temporalio::Api::StreamService::V1' + _CREATESTREAMREQUEST._serialized_start = 194 + _CREATESTREAMREQUEST._serialized_end = 384 + _CREATESTREAMRESPONSE._serialized_start = 386 + _CREATESTREAMRESPONSE._serialized_end = 473 + _APPENDRECORDSREQUEST._serialized_start = 476 + _APPENDRECORDSREQUEST._serialized_end = 690 + _APPENDRECORDSRESPONSE._serialized_start = 692 + _APPENDRECORDSRESPONSE._serialized_end = 758 + _CLOSESTREAMREQUEST._serialized_start = 761 + _CLOSESTREAMREQUEST._serialized_end = 900 + _CLOSESTREAMRESPONSE._serialized_start = 902 + _CLOSESTREAMRESPONSE._serialized_end = 923 + _READRECORDSREQUEST._serialized_start = 926 + _READRECORDSREQUEST._serialized_end = 1115 + _READRECORDSRESPONSE._serialized_start = 1117 + _READRECORDSRESPONSE._serialized_end = 1228 + _DESCRIBESTREAMREQUEST._serialized_start = 1230 + _DESCRIBESTREAMREQUEST._serialized_end = 1320 + _DESCRIBESTREAMRESPONSE._serialized_start = 1322 + _DESCRIBESTREAMRESPONSE._serialized_end = 1420 +# @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi new file mode 100644 index 0000000000..5ae5b08e50 --- /dev/null +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -0,0 +1,446 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import builtins +import collections.abc +import typing + +import google.protobuf.descriptor +import google.protobuf.duration_pb2 +import google.protobuf.internal.containers +import google.protobuf.message + +import temporalio.api.enums.v1.stream_pb2 +import temporalio.api.stream.v1.message_pb2 + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +@typing.final +class CreateStreamRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + Creates the Stream. When the Stream exists, FAIL fails with ALREADY_EXISTS, and USE_EXISTING + gets it with created false. A retry of the create that made the Stream, with the same + request_id, gets created true. Each policy fails with CLOSED on a closed Stream and EXPIRED on + an expired one. A create takes no Retention. The Store config holds it, as a namespace holds + the Retention of its Workflows. + (-- api-linter: core::0133=disabled + aip.dev/not-precedent: The request identifies a Stream by namespace and ref. --) + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + STREAM_REF_FIELD_NUMBER: builtins.int + ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int + REQUEST_ID_FIELD_NUMBER: builtins.int + namespace: builtins.str + """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't + read it. + """ + id_conflict_policy: ( + temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType + ) + """What the create does when the Stream exists. Unspecified is FAIL.""" + request_id: builtins.str + """Unique for each create call, and the same on its retries. The Store keeps the request_id of + the create that made the Stream, so a retry after a lost answer doesn't get ALREADY_EXISTS. + """ + @property + def stream_ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required. The ref of the Stream to create. Its id is the Stream id, and is never empty.""" + + def __init__( + self, + *, + namespace: builtins.str = ..., + stream_ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + id_conflict_policy: temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType = ..., + request_id: builtins.str = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream_ref", b"stream_ref"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "id_conflict_policy", + b"id_conflict_policy", + "namespace", + b"namespace", + "request_id", + b"request_id", + "stream_ref", + b"stream_ref", + ], + ) -> None: ... + +global___CreateStreamRequest = CreateStreamRequest + +@typing.final +class CreateStreamResponse(google.protobuf.message.Message): + """Experimental. Might change in the future. + The Stream that a create made or got. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REF_FIELD_NUMBER: builtins.int + CREATED_FIELD_NUMBER: builtins.int + created: builtins.bool + """False when USE_EXISTING got a Stream that existed.""" + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """The ref of the Stream, which the caller passes on as data. The SDK sets the name of the + Store that it picked, also when the request left the name empty. The server gives the ref + back as the request had it, since it doesn't know that name. + """ + + def __init__( + self, + *, + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + created: builtins.bool = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["created", b"created", "ref", b"ref"] + ) -> None: ... + +global___CreateStreamResponse = CreateStreamResponse + +@typing.final +class AppendRecordsRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + Appends one batch of Records as one Producer. The Store writes a resent batch, with the same + Producer, epoch and sequence, only once. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + PRODUCER_FIELD_NUMBER: builtins.int + SEQUENCE_FIELD_NUMBER: builtins.int + RECORDS_FIELD_NUMBER: builtins.int + namespace: builtins.str + """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't + read it. + """ + sequence: builtins.int + """The batch number in this epoch. With the Producer and epoch it is the dedupe key. Zero takes + the next number of the epoch. Such a batch has no dedupe, so a retry writes it again. + """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + + @property + def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: + """Required. The Producer of the batch. An append and a close of one Producer carry the same + Producer, so the Store orders each write the same way. + """ + + @property + def records( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + temporalio.api.stream.v1.message_pb2.AppendRecord + ]: ... + def __init__( + self, + *, + namespace: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., + sequence: builtins.int = ..., + records: collections.abc.Iterable[ + temporalio.api.stream.v1.message_pb2.AppendRecord + ] + | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "namespace", + b"namespace", + "producer", + b"producer", + "records", + b"records", + "ref", + b"ref", + "sequence", + b"sequence", + ], + ) -> None: ... + +global___AppendRecordsRequest = AppendRecordsRequest + +@typing.final +class AppendRecordsResponse(google.protobuf.message.Message): + """Experimental. Might change in the future. + Where the batch's Records are in the Stream. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + FIRST_OFFSET_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + first_offset: builtins.bytes + last_offset: builtins.bytes + def __init__( + self, + *, + first_offset: builtins.bytes = ..., + last_offset: builtins.bytes = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "first_offset", b"first_offset", "last_offset", b"last_offset" + ], + ) -> None: ... + +global___AppendRecordsResponse = AppendRecordsResponse + +@typing.final +class CloseStreamRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + Closes a Stream. Readers drain what is left, then end, and later appends fail with CLOSED. A + close writes no Record and carries no value, so code that has a last value publishes it first. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + PRODUCER_FIELD_NUMBER: builtins.int + namespace: builtins.str + """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't + read it. + """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + + @property + def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: + """Required. The Producer that closes the Stream.""" + + def __init__( + self, + *, + namespace: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "namespace", b"namespace", "producer", b"producer", "ref", b"ref" + ], + ) -> None: ... + +global___CloseStreamRequest = CloseStreamRequest + +@typing.final +class CloseStreamResponse(google.protobuf.message.Message): + """Experimental. Might change in the future. + A close answers when the Store has the close. It gives nothing back. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + +global___CloseStreamResponse = CloseStreamResponse + +@typing.final +class ReadRecordsRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + Reads one page of Records after an offset. At the end of the Stream, the read waits for a new + Record, so readers long poll. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + FROM_OFFSET_FIELD_NUMBER: builtins.int + MAX_RECORDS_FIELD_NUMBER: builtins.int + WAIT_FIELD_NUMBER: builtins.int + MAX_BYTES_FIELD_NUMBER: builtins.int + namespace: builtins.str + """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't + read it. + """ + from_offset: builtins.bytes + """Read after this offset. It fails with OFFSET_TOO_HIGH if it is past the newest offset. + Leave empty to read from the beginning. To read only new Records, a caller gets last_offset + from a describe and reads after it. + (-- api-linter: core::0140::prepositions=disabled + aip.dev/not-precedent: "from" marks the start of a range of offsets. --) + """ + max_records: builtins.int + """The most Records in one page. Zero is 1000.""" + max_bytes: builtins.int + """The most Record bytes in one page, so a page fits the caller's limit, such as a History + marker. A larger Record still comes alone, so the read always moves on. Zero is no cap. + """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + + @property + def wait(self) -> google.protobuf.duration_pb2.Duration: + """How long the read waits for a new Record before it answers with an empty page. Empty answers + at once, and a wait longer than 60 s waits 60 s. + """ + + def __init__( + self, + *, + namespace: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + from_offset: builtins.bytes = ..., + max_records: builtins.int = ..., + wait: google.protobuf.duration_pb2.Duration | None = ..., + max_bytes: builtins.int = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["ref", b"ref", "wait", b"wait"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "from_offset", + b"from_offset", + "max_bytes", + b"max_bytes", + "max_records", + b"max_records", + "namespace", + b"namespace", + "ref", + b"ref", + "wait", + b"wait", + ], + ) -> None: ... + +global___ReadRecordsRequest = ReadRecordsRequest + +@typing.final +class ReadRecordsResponse(google.protobuf.message.Message): + """Experimental. Might change in the future. + One page of a read. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RECORDS_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + DONE_FIELD_NUMBER: builtins.int + last_offset: builtins.bytes + """The last offset that this read covered, which is the offset of the newest Record of the + page. The next read gives it as from_offset and starts after it. An empty page gives the + request's from_offset, and that is empty when the request had none. So it is always + known, and an empty value means that the next read starts as this one did. + """ + done: builtins.bool + """True when the Stream is closed and this read gave its last Record. It is the only sign of a + close in a read, since a close stores no Record. A read of a closed Stream with no Record + left answers at once with done. + """ + @property + def records( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + temporalio.api.stream.v1.message_pb2.StreamRecord + ]: ... + def __init__( + self, + *, + records: collections.abc.Iterable[ + temporalio.api.stream.v1.message_pb2.StreamRecord + ] + | None = ..., + last_offset: builtins.bytes = ..., + done: builtins.bool = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "done", b"done", "last_offset", b"last_offset", "records", b"records" + ], + ) -> None: ... + +global___ReadRecordsResponse = ReadRecordsResponse + +@typing.final +class DescribeStreamRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + Gets the status and the newest offset of a Stream. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + namespace: builtins.str + """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't + read it. + """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + + def __init__( + self, + *, + namespace: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["namespace", b"namespace", "ref", b"ref"] + ) -> None: ... + +global___DescribeStreamRequest = DescribeStreamRequest + +@typing.final +class DescribeStreamResponse(google.protobuf.message.Message): + """Experimental. Might change in the future. + The state of a Stream. It has no Retention, since the Retention is a setting of the Store and + not of one Stream. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + STATUS_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + status: temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType + last_offset: builtins.bytes + """The newest offset, of a Record. Empty when the Stream has none.""" + def __init__( + self, + *, + status: temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType = ..., + last_offset: builtins.bytes = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal["last_offset", b"last_offset", "status", b"status"], + ) -> None: ... + +global___DescribeStreamResponse = DescribeStreamResponse diff --git a/temporalio/api/streamservice/v1/request_response_pb2_grpc.py b/temporalio/api/streamservice/v1/request_response_pb2_grpc.py new file mode 100644 index 0000000000..bf947056a2 --- /dev/null +++ b/temporalio/api/streamservice/v1/request_response_pb2_grpc.py @@ -0,0 +1,4 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" + +import grpc diff --git a/temporalio/api/streamservice/v1/request_response_pb2_grpc.pyi b/temporalio/api/streamservice/v1/request_response_pb2_grpc.pyi new file mode 100644 index 0000000000..de236ac811 --- /dev/null +++ b/temporalio/api/streamservice/v1/request_response_pb2_grpc.pyi @@ -0,0 +1,21 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import abc +import collections.abc +import typing + +import grpc +import grpc.aio + +_T = typing.TypeVar("_T") + +class _MaybeAsyncIterator( + collections.abc.AsyncIterator[_T], + collections.abc.Iterator[_T], + metaclass=abc.ABCMeta, +): ... +class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] + ... diff --git a/temporalio/bridge/_visitor.py b/temporalio/bridge/_visitor.py index ead09a986f..8832b56bc4 100644 --- a/temporalio/bridge/_visitor.py +++ b/temporalio/bridge/_visitor.py @@ -639,6 +639,70 @@ async def _visit_temporal_api_notificationservice_v1_OnCompleteResponse( ) -> None: pass + async def _visit_temporal_api_streamservice_v1_CreateStreamRequest( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + + async def _visit_temporal_api_streamservice_v1_CreateStreamResponse( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + + async def _visit_temporal_api_stream_v1_AppendRecord( + 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_AppendRecordsRequest( + self, fs: VisitorFunctions, o: Any + ): + for v in o.records: + await self._visit_temporal_api_stream_v1_AppendRecord(fs, v) + + async def _visit_temporal_api_streamservice_v1_AppendRecordsResponse( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + + async def _visit_temporal_api_streamservice_v1_CloseStreamRequest( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + + async def _visit_temporal_api_streamservice_v1_CloseStreamResponse( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + + async def _visit_temporal_api_streamservice_v1_ReadRecordsRequest( + self, fs: VisitorFunctions, o: Any + ) -> 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 + ): + for v in o.records: + await self._visit_temporal_api_stream_v1_StreamRecord(fs, v) + + async def _visit_temporal_api_streamservice_v1_DescribeStreamRequest( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + + async def _visit_temporal_api_streamservice_v1_DescribeStreamResponse( + self, fs: VisitorFunctions, o: Any + ) -> None: + pass + async def _visit_temporal_api_common_v1_Header(self, fs: VisitorFunctions, o: Any): for v in o.fields.values(): await self._visit_temporal_api_common_v1_Payload(fs, v) diff --git a/temporalio/nexus/system/stream_service/__init__.py b/temporalio/nexus/system/stream_service/__init__.py new file mode 100644 index 0000000000..35b198843c --- /dev/null +++ b/temporalio/nexus/system/stream_service/__init__.py @@ -0,0 +1,71 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +from .models import ( + ActivityEpoch, + ActivityProducer, + AppendRecord, + AppendRecordsRequest, + AppendRecordsResponse, + ClientProducer, + CloseStreamRequest, + CloseStreamResponse, + CreateStreamRequest, + CreateStreamResult, + DescribeStreamRequest, + DescribeStreamResponse, + LocalActivityEpoch, + LocalActivityProducer, + Producer, + ProducerKind, + ProducerKindClient, + ProducerKindLocalActivity, + ProducerKindStandaloneActivity, + ProducerKindWorkflow, + ProducerKindWorkflowActivity, + ReadRecordsRequest, + ReadRecordsResponse, + StreamIdConflictPolicy, + StreamRecord, + StreamRef, + StreamStatus, + Timestamp, + WorkflowProducer, + WorkflowTaskEpoch, +) +from .services import StreamService + +__all__ = [ + "ActivityEpoch", + "ActivityProducer", + "AppendRecord", + "AppendRecordsRequest", + "AppendRecordsResponse", + "ClientProducer", + "CloseStreamRequest", + "CloseStreamResponse", + "CreateStreamRequest", + "CreateStreamResult", + "DescribeStreamRequest", + "DescribeStreamResponse", + "LocalActivityEpoch", + "LocalActivityProducer", + "Producer", + "ProducerKind", + "ProducerKindWorkflow", + "ProducerKindLocalActivity", + "ProducerKindWorkflowActivity", + "ProducerKindStandaloneActivity", + "ProducerKindClient", + "ReadRecordsRequest", + "ReadRecordsResponse", + "StreamIdConflictPolicy", + "StreamRecord", + "StreamRef", + "StreamStatus", + "Timestamp", + "WorkflowProducer", + "WorkflowTaskEpoch", + "StreamService", +] diff --git a/temporalio/nexus/system/stream_service/_resource_context_manager.py b/temporalio/nexus/system/stream_service/_resource_context_manager.py new file mode 100644 index 0000000000..86dd499669 --- /dev/null +++ b/temporalio/nexus/system/stream_service/_resource_context_manager.py @@ -0,0 +1,93 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import collections.abc +import functools +import types +import typing + +import typing_extensions + + +class _Closable(typing.Protocol): + async def __aenter__(self) -> object: ... + + async def __aexit__( + self, + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: types.TracebackType | None, + ) -> None: ... + + +_ResourceT = typing.TypeVar("_ResourceT", bound=_Closable) +_P = typing_extensions.ParamSpec("_P") + + +@typing.final +class ResourceContextManager( + collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT], + typing.Generic[_ResourceT], +): + """The create call. You can use it two ways. Await it to get the resource and manage it + yourself. Or open it with ``async with`` to get the resource and close it at the end of the + block. The ``async with`` form does the create for you, so you do not add a separate await.""" + + def __init__( + self, call: collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT] + ) -> None: + self._call: collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT] = call + self._resource: _ResourceT | None = None + self.__name__: str = getattr(call, "__name__", type(self).__name__) + self.__qualname__: str = getattr(call, "__qualname__", self.__name__) + + @typing_extensions.override + def __await__(self) -> collections.abc.Generator[typing.Any, None, _ResourceT]: + return self._call.__await__() + + @typing_extensions.override + def send(self, value: typing.Any) -> typing.Any: + return self._call.send(value) + + @typing_extensions.override + def throw( + self, + typ: typing.Any, + val: typing.Any = None, + tb: types.TracebackType | None = None, + ) -> typing.Any: + return self._call.throw(typ, val, tb) + + @typing_extensions.override + def close(self) -> None: + self._call.close() + + async def __aenter__(self) -> _ResourceT: + resource = await self._call + _ = await resource.__aenter__() + self._resource = resource + return resource + + async def __aexit__( + self, + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: types.TracebackType | None, + ) -> None: + if self._resource is not None: + await self._resource.__aexit__(exc_type, exc, tb) + + +def resource_context_manager( + function: collections.abc.Callable[ + _P, collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT] + ], +) -> collections.abc.Callable[_P, ResourceContextManager[_ResourceT]]: + """Wraps a call that returns a closable resource in a ``ResourceContextManager``.""" + + @functools.wraps(function) + def call(*args: _P.args, **kwargs: _P.kwargs) -> ResourceContextManager[_ResourceT]: + return ResourceContextManager(function(*args, **kwargs)) + + return call diff --git a/temporalio/nexus/system/stream_service/client/__init__.py b/temporalio/nexus/system/stream_service/client/__init__.py new file mode 100644 index 0000000000..d2df633d4e --- /dev/null +++ b/temporalio/nexus/system/stream_service/client/__init__.py @@ -0,0 +1,11 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +from ._extensions import StreamServiceClientExtension +from ._resources.stream import Stream + +__all__ = [ + "StreamServiceClientExtension", + "Stream", +] diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py new file mode 100644 index 0000000000..c96bb985f8 --- /dev/null +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -0,0 +1,180 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import abc +import collections.abc +import datetime +import typing +import uuid as _uuid + +import temporalio.nexus.system + +if typing.TYPE_CHECKING: + import temporalio.client + +import temporalio.nexus.system._support as _support + +from .._resource_context_manager import resource_context_manager +from ..models import ( + CreateStreamRequest, + CreateStreamResult, + StreamIdConflictPolicy, + StreamRef, +) +from ..services import StreamService +from ._resources.stream import Stream + +_NexusServiceT = typing.TypeVar("_NexusServiceT") +BodyT = typing.TypeVar("BodyT") + + +class StreamServiceClientExtension(abc.ABC): + """Starts the operations of ``StreamService`` from code outside a Workflow. + + A client class inherits this class and provides the SDK's ``create_nexus_client`` + method. + + .. warning:: + This API is experimental and subject to change. + """ + + @abc.abstractmethod + def create_nexus_client( + self, + service: type[_NexusServiceT] | str, + endpoint: str, + ) -> temporalio.client.NexusClient[_NexusServiceT]: + """Return the Nexus client that starts the operations of ``service``.""" + ... + + @typing.overload + def get_stream( + self, + ref: StreamRef[BodyT], + *, + created: bool | None = None, + body_type: None = None, + ) -> Stream[BodyT]: ... + @typing.overload + def get_stream( + self, + ref: StreamRef[BodyT] | StreamRef[object], + *, + created: bool | None = None, + body_type: type[BodyT], + ) -> Stream[BodyT]: ... + def get_stream( + self, + ref: StreamRef[typing.Any], + *, + created: bool | None = None, + body_type: typing.Any = None, + ) -> Stream[typing.Any]: + """Return the ``Stream`` handle for this ref.""" + arguments = typing.get_args(getattr(ref, "__orig_class__", None)) + # None means no explicit type, so use the ref's type argument, else object. + if body_type is None: + body_type = arguments[0] if arguments else object + elif arguments and arguments[0] is not object and arguments[0] != body_type: + raise TypeError("The decoding type must match the typed ref") + if arguments != (body_type,): + ref = StreamRef[body_type](id=ref.id, store=ref.store) + return Stream[body_type]( + self.create_nexus_client( + service=StreamService, + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ), + ref=ref, + created=created, + ) + + async def _stream_service_create_stream( + self, + request: CreateStreamRequest[BodyT], + body_type: type[BodyT], + *, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> Stream[BodyT]: + nexus_client = self.create_nexus_client( + service=StreamService, + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ) + handle = await nexus_client.start_operation( + operation="CreateStream", + arg=request, + id=f"{_uuid.uuid4()}", + result_type=CreateStreamResult[body_type], + rpc_metadata=rpc_metadata or {}, + rpc_timeout=rpc_timeout, + ) + result = await handle.result() + if result.ref is None: + raise RuntimeError("CreateStream answered without `ref`") + resource = Stream[body_type]( + nexus_client, + ref=result.ref, + created=result.created or None, + ) + return resource + + @typing.overload + @resource_context_manager + async def create_stream( + self, + *, + id: str, + store: str | None = None, + id_conflict_policy: StreamIdConflictPolicy | None = None, + body_type: type[BodyT], + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> Stream[BodyT]: ... + + @typing.overload + @resource_context_manager + async def create_stream( + self, + *, + id: str, + store: str | None = None, + id_conflict_policy: StreamIdConflictPolicy | None = None, + body_type: None = None, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> Stream[object]: ... + + @resource_context_manager + async def create_stream( + self, + *, + id: str, + store: str | None = None, + id_conflict_policy: StreamIdConflictPolicy | None = None, + body_type: typing.Any = None, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> Stream[typing.Any]: + """ + Args: + id: The Stream id, 1 to 4096 bytes. + store: Registered Store name. With none, the SDK picks one. Only an SDK + reads it. + id_conflict_policy: What the create does when the Stream exists. Unspecified + is fail. + """ + if body_type is None: + body_type = typing.Any + stream_ref = StreamRef( + id=id, + store=store, + ) + request = CreateStreamRequest( + stream_ref=stream_ref, + id_conflict_policy=id_conflict_policy, + request_id=_support.request_id(), + ) + return await self._stream_service_create_stream( + request, body_type, rpc_metadata=rpc_metadata, rpc_timeout=rpc_timeout + ) diff --git a/temporalio/nexus/system/stream_service/client/_poll.py b/temporalio/nexus/system/stream_service/client/_poll.py new file mode 100644 index 0000000000..a653d84f93 --- /dev/null +++ b/temporalio/nexus/system/stream_service/client/_poll.py @@ -0,0 +1,77 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import collections +import collections.abc +import typing + +_PollRequestT = typing.TypeVar("_PollRequestT") +_PollResponseT = typing.TypeVar("_PollResponseT") +_PollItemT = typing.TypeVar("_PollItemT") + + +@typing.final +class PollIterator(typing.Generic[_PollRequestT, _PollItemT]): + """Yields each item of the pages of a poll. + + ``next_request`` is the request to resume with. After an item, the resume helper gives + it. Without a resume helper, it reads the item's page again. After a page's last item, + it is the page helper's request, which is ``None`` after the last page. + """ + + def __init__( + self, + request: _PollRequestT, + pages: collections.abc.AsyncIterator[_PollResponseT], + items: collections.abc.Callable[ + [_PollResponseT], collections.abc.Sequence[_PollItemT] | None + ], + next_page: collections.abc.Callable[ + [_PollRequestT, _PollResponseT], _PollRequestT | None + ], + resume: collections.abc.Callable[[_PollRequestT, _PollItemT], _PollRequestT] + | None, + ) -> None: + async def read( + page_request: _PollRequestT, + ) -> tuple[_PollRequestT | None, collections.deque[_PollItemT]]: + response = await anext(pages) + # The page iterator keeps its requests to itself, so the page helper runs here + # again. It runs before the caller gets an item, so a changed item can't change + # the next request. + return next_page(page_request, response), collections.deque( + items(response) or () + ) + + self.next_request: _PollRequestT | None = request + self._read: collections.abc.Callable[ + [_PollRequestT], + collections.abc.Awaitable[ + tuple[_PollRequestT | None, collections.deque[_PollItemT]] + ], + ] = read + self._resume: ( + collections.abc.Callable[[_PollRequestT, _PollItemT], _PollRequestT] | None + ) = resume + self._page: collections.deque[_PollItemT] = collections.deque() + self._page_request: _PollRequestT = request + self._page_next: _PollRequestT | None = None + + def __aiter__(self) -> PollIterator[_PollRequestT, _PollItemT]: + return self + + async def __anext__(self) -> _PollItemT: + while not self._page: + if self.next_request is None: + raise StopAsyncIteration + self._page_request = self.next_request + self._page_next, self._page = await self._read(self._page_request) + if not self._page: + self.next_request = self._page_next + item = self._page.popleft() + if not self._page: + self.next_request = self._page_next + elif self._resume is not None: + self.next_request = self._resume(self._page_request, item) + return item diff --git a/temporalio/nexus/system/stream_service/client/_resources/__init__.py b/temporalio/nexus/system/stream_service/client/_resources/__init__.py new file mode 100644 index 0000000000..250b6a42b7 --- /dev/null +++ b/temporalio/nexus/system/stream_service/client/_resources/__init__.py @@ -0,0 +1,3 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py new file mode 100644 index 0000000000..c3fa617b6d --- /dev/null +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -0,0 +1,261 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import collections.abc +import datetime +import types +import typing +import uuid as _uuid + +import typing_extensions + +if typing.TYPE_CHECKING: + import temporalio.client + +import temporalio.nexus.system._support as _support + +from ...models import ( + AppendRecord, + AppendRecordsRequest, + AppendRecordsResponse, + CloseStreamRequest, + DescribeStreamRequest, + DescribeStreamResponse, + Producer, + ReadRecordsRequest, + ReadRecordsResponse, + StreamRecord, + StreamRef, +) +from ...services import StreamService +from .._poll import PollIterator + +BodyT = typing.TypeVar("BodyT") + + +class Stream(typing.Generic[BodyT]): + """One Stream. Build it from a stream-ref, or get it from a create.""" + + ref: StreamRef[BodyT] + created: bool | None + + def __init__( + self, + nexus_client: temporalio.client.NexusClient[typing.Any], + /, + *, + ref: StreamRef[BodyT], + created: bool | None, + ) -> None: + self._nexus_client: temporalio.client.NexusClient[typing.Any] = nexus_client + if type(self) is not Stream: + raise TypeError("Generic resource subclasses are not supported") + self.ref = ref + self.created = created + + @property + def body_type(self) -> type[BodyT]: + arguments = typing.get_args(getattr(self.ref, "__orig_class__", None)) + return typing.cast("type[BodyT]", arguments[0] if arguments else object) + + async def __aenter__(self) -> typing_extensions.Self: + return self + + async def __aexit__( + self, + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: types.TracebackType | None, + ) -> None: + await self.close() + + async def append( + self, + *records: BodyT, + producer: Producer | None = None, + sequence: int | None = None, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> AppendRecordsResponse: + """Append values, and return the offsets of the batch.""" + request = AppendRecordsRequest( + ref=self.ref, + producer=((_support.default_producer()) if producer is None else producer), + sequence=sequence, + records=[AppendRecord(body=value) for value in records], + ) + handle = await self._nexus_client.start_operation( + operation=StreamService.append_records, + arg=request, + id=f"{_uuid.uuid4()}", + rpc_metadata=rpc_metadata or {}, + rpc_timeout=rpc_timeout, + ) + return await handle.result() + + async def close( + self, + producer: Producer | None = None, + *, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> None: + """Close the Stream. Readers drain what is left, then end.""" + request = CloseStreamRequest( + ref=self.ref, + producer=((_support.default_producer()) if producer is None else producer), + ) + handle = await self._nexus_client.start_operation( + operation=StreamService.close_stream, + arg=request, + id=f"{_uuid.uuid4()}", + rpc_metadata=rpc_metadata or {}, + rpc_timeout=rpc_timeout, + ) + _ = await handle.result() + + async def read( + self, + from_offset: bytes | None = None, + max_records: int | None = None, + wait: datetime.timedelta | None = None, + max_bytes: int | None = None, + *, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> ReadRecordsResponse[BodyT]: + """Read one page of Records. The poll iterator reads them all.""" + request = ReadRecordsRequest( + ref=self.ref, + from_offset=from_offset, + max_records=max_records, + wait=wait, + max_bytes=max_bytes, + ) + handle = await self._nexus_client.start_operation( + operation="ReadRecords", + arg=request, + id=f"{_uuid.uuid4()}", + result_type=ReadRecordsResponse[self.body_type], + rpc_metadata=rpc_metadata or {}, + rpc_timeout=rpc_timeout, + ) + return await handle.result() + + async def iter_read( + self, + from_offset: bytes | None = None, + max_records: int | None = None, + wait: datetime.timedelta | None = None, + max_bytes: int | None = None, + *, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: + """Yield each response of ``read`` until the poll helper stops. + + Read one page of Records. The poll iterator reads them all. + + Args: + from_offset: Read after this offset. Empty is the beginning. A too high + offset fails. + max_records: About this many Records per page, 1 to 1000. + wait: How long to wait for a new Record before an empty answer. At most 60 + s. + max_bytes: The maximum Record bytes in a page. A larger Record is still + returned alone. + """ + request = ReadRecordsRequest( + ref=self.ref, + from_offset=from_offset, + max_records=max_records, + wait=wait, + max_bytes=max_bytes, + ) + nexus_client = self._nexus_client + while True: + operation_handle = await nexus_client.start_operation( + operation="ReadRecords", + arg=request, + id=f"{_uuid.uuid4()}", + result_type=ReadRecordsResponse[self.body_type], + rpc_metadata=rpc_metadata or {}, + rpc_timeout=rpc_timeout, + ) + response = await operation_handle.result() + next_request = _support.next_read_request(request, response) + yield response + if next_request is None: + return + request = next_request + + def iter_read_items( + self, + from_offset: bytes | None = None, + max_records: int | None = None, + wait: datetime.timedelta | None = None, + max_bytes: int | None = None, + *, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> PollIterator[ReadRecordsRequest[BodyT], StreamRecord[BodyT]]: + """Yield each item of ``iter_read``, page by page. + + ``next_request`` resumes after the last item that the iterator yielded. It is + ``None`` after the last page. + + Read one page of Records. The poll iterator reads them all. + + Args: + from_offset: Read after this offset. Empty is the beginning. A too high + offset fails. + max_records: About this many Records per page, 1 to 1000. + wait: How long to wait for a new Record before an empty answer. At most 60 + s. + max_bytes: The maximum Record bytes in a page. A larger Record is still + returned alone. + """ + request = ReadRecordsRequest( + ref=self.ref, + from_offset=from_offset, + max_records=max_records, + wait=wait, + max_bytes=max_bytes, + ) + return PollIterator( + request, + self.iter_read( + from_offset=from_offset, + max_records=max_records, + wait=wait, + max_bytes=max_bytes, + rpc_metadata=rpc_metadata, + rpc_timeout=rpc_timeout, + ), + lambda response: response.records, + _support.next_read_request, + _support.resume_read_request, + ) + + async def describe( + self, + *, + rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, + rpc_timeout: datetime.timedelta | None = None, + ) -> DescribeStreamResponse: + """Describe the Stream's status and newest offset.""" + request = DescribeStreamRequest( + ref=self.ref, + ) + handle = await self._nexus_client.start_operation( + operation=StreamService.describe_stream, + arg=request, + id=f"{_uuid.uuid4()}", + rpc_metadata=rpc_metadata or {}, + rpc_timeout=rpc_timeout, + ) + return await handle.result() + + +__all__ = ["Stream"] diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py new file mode 100644 index 0000000000..4848a2ea58 --- /dev/null +++ b/temporalio/nexus/system/stream_service/models.py @@ -0,0 +1,1371 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import dataclasses +import datetime +import enum +import typing + +import google.protobuf.timestamp_pb2 +import typing_extensions + +import temporalio.api.enums.v1.stream_pb2 +import temporalio.api.stream.v1.message_pb2 +import temporalio.api.streamservice.v1.request_response_pb2 +import temporalio.converter +import temporalio.nexus.system._support as _support + + +class StreamIdConflictPolicy(enum.IntEnum): + StreamIdConflictPolicyUnspecified = 0 + StreamIdConflictPolicyFail = 1 + StreamIdConflictPolicyUseExisting = 2 + + +class StreamStatus(enum.IntEnum): + StreamStatusUnspecified = 0 + StreamStatusOpen = 1 + StreamStatusClosed = 2 + StreamStatusExpired = 3 + + +def _stream_status_from_proto(value: int) -> StreamStatus: + try: + return StreamStatus(value) + except ValueError: + # A newer peer can send a case that this enum doesn't know. + return StreamStatus.StreamStatusUnspecified + + +BodyT = typing.TypeVar("BodyT") +_BodyT = typing_extensions.TypeVar("_BodyT", default=object) + + +@dataclasses.dataclass(slots=True) +class CreateStreamRequest(typing.Generic[BodyT]): + """Create a Stream. If it exists, fail, or with use-existing get the open one.""" + + stream_ref: StreamRef[BodyT] + id_conflict_policy: StreamIdConflictPolicy | None = None + request_id: str | None = None + + +class _CreateStreamRequestTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + CreateStreamRequest[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest, + type_hint: type[CreateStreamRequest[BodyT]], + ) -> CreateStreamRequest[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("stream_ref"): + raise ValueError("missing required field CreateStreamRequest.stream_ref") + stream_ref = typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.stream_ref, StreamRef[body_type] + ), + ) + return CreateStreamRequest( + stream_ref=stream_ref, + id_conflict_policy=StreamIdConflictPolicy(value.id_conflict_policy) + if value.id_conflict_policy != 0 + else None, + request_id=value.request_id if bool(value.request_id) else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: CreateStreamRequest[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest() + ) + message.stream_ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.stream_ref) + ) + if value.id_conflict_policy is not None: + message.id_conflict_policy = ( + temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType( + value.id_conflict_policy + ) + ) + if value.request_id is not None: + message.request_id = value.request_id + return message + + +temporalio.converter.transfer_type_convertible( + _CreateStreamRequestTransferTypeConverter[typing.Any] +)(CreateStreamRequest) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass +class StreamRef(typing.Generic[_BodyT]): + """Identifies one Stream. The id is opaque to callers.""" + + id: str + store: str | None = None + + +class _StreamRefTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + StreamRef[BodyT], temporalio.api.stream.v1.message_pb2.StreamRef + ] +): + transfer_type: type[temporalio.api.stream.v1.message_pb2.StreamRef] | None = ( + temporalio.api.stream.v1.message_pb2.StreamRef + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.StreamRef, + type_hint: type[StreamRef[BodyT]], + ) -> StreamRef[BodyT]: + (_body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.id: + raise ValueError("missing required field StreamRef.id") + id = value.id + return type_hint( + id=id, + store=value.store if bool(value.store) else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: StreamRef[BodyT], + ) -> temporalio.api.stream.v1.message_pb2.StreamRef: + message = temporalio.api.stream.v1.message_pb2.StreamRef() + message.id = value.id + if value.store is not None: + message.store = value.store + return message + + +temporalio.converter.transfer_type_convertible( + _StreamRefTransferTypeConverter[typing.Any] +)(StreamRef) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class CreateStreamResult(typing.Generic[BodyT]): + ref: StreamRef[BodyT] | None = None + created: bool | None = None + + +class _CreateStreamResultTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + CreateStreamResult[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, + type_hint: type[CreateStreamResult[BodyT]], + ) -> CreateStreamResult[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + return CreateStreamResult( + ref=typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), + ) + if value.HasField("ref") + else None, + created=value.created if bool(value.created) else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: CreateStreamResult[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse() + ) + if value.ref is not None: + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) + if value.created is not None: + message.created = value.created + return message + + +temporalio.converter.transfer_type_convertible( + _CreateStreamResultTransferTypeConverter[typing.Any] +)(CreateStreamResult) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class AppendRecordsRequest(typing.Generic[BodyT]): + """Append one batch. The Store keeps a resent batch once, by Producer, epoch and + sequence. + """ + + ref: StreamRef[BodyT] + records: list[AppendRecord[BodyT]] + producer: Producer + sequence: int | None = None + + +class _AppendRecordsRequestTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + AppendRecordsRequest[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest, + type_hint: type[AppendRecordsRequest[BodyT]], + ) -> AppendRecordsRequest[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("ref"): + raise ValueError("missing required field AppendRecordsRequest.ref") + ref = typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), + ) + records = [ + typing.cast( + AppendRecord[BodyT], + _AppendRecordTransferTypeConverter().from_transfer_type( + item, AppendRecord[body_type] + ), + ) + for item in value.records + ] + if not value.HasField("producer"): + raise ValueError("missing required field AppendRecordsRequest.producer") + producer = _ProducerTransferTypeConverter().from_transfer_type( + value.producer, Producer + ) + return AppendRecordsRequest( + ref=ref, + records=records, + producer=producer, + sequence=value.sequence if value.sequence != 0 else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: AppendRecordsRequest[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest() + ) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) + for element in value.records: + item = message.records.add() + item.CopyFrom( + _AppendRecordTransferTypeConverter().to_transfer_type(element) + ) + message.producer.CopyFrom( + _ProducerTransferTypeConverter().to_transfer_type(value.producer) + ) + if value.sequence is not None: + message.sequence = value.sequence + return message + + +temporalio.converter.transfer_type_convertible( + _AppendRecordsRequestTransferTypeConverter[typing.Any] +)(AppendRecordsRequest) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class AppendRecord(typing.Generic[BodyT]): + """One Record to append.""" + + body: BodyT + + +class _AppendRecordTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + AppendRecord[BodyT], temporalio.api.stream.v1.message_pb2.AppendRecord + ] +): + transfer_type: type[temporalio.api.stream.v1.message_pb2.AppendRecord] | None = ( + temporalio.api.stream.v1.message_pb2.AppendRecord + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.AppendRecord, + type_hint: type[AppendRecord[BodyT]], + ) -> AppendRecord[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("body"): + raise ValueError("missing required field AppendRecord.body") + body = typing.cast(BodyT, _support.payload_from_proto(value.body, body_type)) + return AppendRecord( + body=body, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: AppendRecord[BodyT], + ) -> temporalio.api.stream.v1.message_pb2.AppendRecord: + message = temporalio.api.stream.v1.message_pb2.AppendRecord() + message.body.CopyFrom(_support.payload_to_proto(value.body)) + return message + + +temporalio.converter.transfer_type_convertible( + _AppendRecordTransferTypeConverter[typing.Any] +)(AppendRecord) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class Producer: + """The code that wrote a batch. A higher epoch fences and supersedes a lower one.""" + + id: str + kind: ProducerKind | None = None + + +class _ProducerTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + Producer, temporalio.api.stream.v1.message_pb2.Producer + ] +): + transfer_type: type[temporalio.api.stream.v1.message_pb2.Producer] | None = ( + temporalio.api.stream.v1.message_pb2.Producer + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.Producer, + type_hint: type[Producer], + ) -> Producer: + if not value.id: + raise ValueError("missing required field Producer.id") + id = value.id + _oneof_kind: ( + ProducerKindWorkflow + | ProducerKindLocalActivity + | ProducerKindWorkflowActivity + | ProducerKindStandaloneActivity + | ProducerKindClient + | None + ) + match value.WhichOneof("kind"): + case "workflow": + _oneof_kind = ProducerKindWorkflow( + _WorkflowProducerTransferTypeConverter().from_transfer_type( + value.workflow, WorkflowProducer + ) + ) + case "local_activity": + _oneof_kind = ProducerKindLocalActivity( + _LocalActivityProducerTransferTypeConverter().from_transfer_type( + value.local_activity, LocalActivityProducer + ) + ) + case "workflow_activity": + _oneof_kind = ProducerKindWorkflowActivity( + _ActivityProducerTransferTypeConverter().from_transfer_type( + value.workflow_activity, ActivityProducer + ) + ) + case "standalone_activity": + _oneof_kind = ProducerKindStandaloneActivity( + _ActivityProducerTransferTypeConverter().from_transfer_type( + value.standalone_activity, ActivityProducer + ) + ) + case "client": + _oneof_kind = ProducerKindClient( + _ClientProducerTransferTypeConverter().from_transfer_type( + value.client, ClientProducer + ) + ) + case None: + _oneof_kind = None + return Producer( + id=id, + kind=_oneof_kind, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: Producer, + ) -> temporalio.api.stream.v1.message_pb2.Producer: + message = temporalio.api.stream.v1.message_pb2.Producer() + message.id = value.id + if value.kind is not None: + match value.kind: + case ProducerKindWorkflow(): + message.workflow.CopyFrom( + _WorkflowProducerTransferTypeConverter().to_transfer_type( + value.kind.value + ) + ) + case ProducerKindLocalActivity(): + message.local_activity.CopyFrom( + _LocalActivityProducerTransferTypeConverter().to_transfer_type( + value.kind.value + ) + ) + case ProducerKindWorkflowActivity(): + message.workflow_activity.CopyFrom( + _ActivityProducerTransferTypeConverter().to_transfer_type( + value.kind.value + ) + ) + case ProducerKindStandaloneActivity(): + message.standalone_activity.CopyFrom( + _ActivityProducerTransferTypeConverter().to_transfer_type( + value.kind.value + ) + ) + case ProducerKindClient(): + message.client.CopyFrom( + _ClientProducerTransferTypeConverter().to_transfer_type( + value.kind.value + ) + ) + return message + + +temporalio.converter.transfer_type_convertible(_ProducerTransferTypeConverter)(Producer) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class WorkflowProducer: + """A Workflow run Producer.""" + + run_id: str + epoch: WorkflowTaskEpoch | None = None + + +class _WorkflowProducerTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + WorkflowProducer, temporalio.api.stream.v1.message_pb2.WorkflowProducer + ] +): + transfer_type: ( + type[temporalio.api.stream.v1.message_pb2.WorkflowProducer] | None + ) = temporalio.api.stream.v1.message_pb2.WorkflowProducer + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.WorkflowProducer, + type_hint: type[WorkflowProducer], + ) -> WorkflowProducer: + if not value.run_id: + raise ValueError("missing required field WorkflowProducer.run_id") + run_id = value.run_id + return WorkflowProducer( + run_id=run_id, + epoch=_WorkflowTaskEpochTransferTypeConverter().from_transfer_type( + value.epoch, WorkflowTaskEpoch + ) + if value.HasField("epoch") + else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: WorkflowProducer, + ) -> temporalio.api.stream.v1.message_pb2.WorkflowProducer: + message = temporalio.api.stream.v1.message_pb2.WorkflowProducer() + message.run_id = value.run_id + if value.epoch is not None: + message.epoch.CopyFrom( + _WorkflowTaskEpochTransferTypeConverter().to_transfer_type(value.epoch) + ) + return message + + +temporalio.converter.transfer_type_convertible(_WorkflowProducerTransferTypeConverter)( + WorkflowProducer +) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class WorkflowTaskEpoch: + """A Workflow Task attempt of the run.""" + + started_event_id: int + attempt: int + started_time: Timestamp | None = None + + +class _WorkflowTaskEpochTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + WorkflowTaskEpoch, temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch + ] +): + transfer_type: ( + type[temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch] | None + ) = temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch, + type_hint: type[WorkflowTaskEpoch], + ) -> WorkflowTaskEpoch: + started_event_id = value.started_event_id + attempt = value.attempt + return WorkflowTaskEpoch( + started_event_id=started_event_id, + attempt=attempt, + started_time=_TimestampTransferTypeConverter().from_transfer_type( + value.started_time, Timestamp + ) + if value.HasField("started_time") + else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: WorkflowTaskEpoch, + ) -> temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch: + message = temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch() + message.started_event_id = value.started_event_id + message.attempt = value.attempt + if value.started_time is not None: + message.started_time.CopyFrom( + _TimestampTransferTypeConverter().to_transfer_type(value.started_time) + ) + return message + + +temporalio.converter.transfer_type_convertible(_WorkflowTaskEpochTransferTypeConverter)( + WorkflowTaskEpoch +) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class Timestamp: + seconds: int + nanos: int + + +class _TimestampTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + Timestamp, google.protobuf.timestamp_pb2.Timestamp + ] +): + transfer_type: type[google.protobuf.timestamp_pb2.Timestamp] | None = ( + google.protobuf.timestamp_pb2.Timestamp + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: google.protobuf.timestamp_pb2.Timestamp, + type_hint: type[Timestamp], + ) -> Timestamp: + seconds = value.seconds + nanos = value.nanos + return Timestamp( + seconds=seconds, + nanos=nanos, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: Timestamp, + ) -> google.protobuf.timestamp_pb2.Timestamp: + message = google.protobuf.timestamp_pb2.Timestamp() + message.seconds = value.seconds + message.nanos = value.nanos + return message + + +temporalio.converter.transfer_type_convertible(_TimestampTransferTypeConverter)( + Timestamp +) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class LocalActivityProducer: + """A Local Activity Producer.""" + + run_id: str + epoch: LocalActivityEpoch + + +class _LocalActivityProducerTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + LocalActivityProducer, + temporalio.api.stream.v1.message_pb2.LocalActivityProducer, + ] +): + transfer_type: ( + type[temporalio.api.stream.v1.message_pb2.LocalActivityProducer] | None + ) = temporalio.api.stream.v1.message_pb2.LocalActivityProducer + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.LocalActivityProducer, + type_hint: type[LocalActivityProducer], + ) -> LocalActivityProducer: + if not value.run_id: + raise ValueError("missing required field LocalActivityProducer.run_id") + run_id = value.run_id + if not value.HasField("epoch"): + raise ValueError("missing required field LocalActivityProducer.epoch") + epoch = _LocalActivityEpochTransferTypeConverter().from_transfer_type( + value.epoch, LocalActivityEpoch + ) + return LocalActivityProducer( + run_id=run_id, + epoch=epoch, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: LocalActivityProducer, + ) -> temporalio.api.stream.v1.message_pb2.LocalActivityProducer: + message = temporalio.api.stream.v1.message_pb2.LocalActivityProducer() + message.run_id = value.run_id + message.epoch.CopyFrom( + _LocalActivityEpochTransferTypeConverter().to_transfer_type(value.epoch) + ) + return message + + +temporalio.converter.transfer_type_convertible( + _LocalActivityProducerTransferTypeConverter +)(LocalActivityProducer) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class LocalActivityEpoch: + """A Local Activity attempt. Its Workflow Task orders it first.""" + + task: WorkflowTaskEpoch + attempt: int + + +class _LocalActivityEpochTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + LocalActivityEpoch, temporalio.api.stream.v1.message_pb2.LocalActivityEpoch + ] +): + transfer_type: ( + type[temporalio.api.stream.v1.message_pb2.LocalActivityEpoch] | None + ) = temporalio.api.stream.v1.message_pb2.LocalActivityEpoch + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.LocalActivityEpoch, + type_hint: type[LocalActivityEpoch], + ) -> LocalActivityEpoch: + if not value.HasField("task"): + raise ValueError("missing required field LocalActivityEpoch.task") + task = _WorkflowTaskEpochTransferTypeConverter().from_transfer_type( + value.task, WorkflowTaskEpoch + ) + attempt = value.attempt + return LocalActivityEpoch( + task=task, + attempt=attempt, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: LocalActivityEpoch, + ) -> temporalio.api.stream.v1.message_pb2.LocalActivityEpoch: + message = temporalio.api.stream.v1.message_pb2.LocalActivityEpoch() + message.task.CopyFrom( + _WorkflowTaskEpochTransferTypeConverter().to_transfer_type(value.task) + ) + message.attempt = value.attempt + return message + + +temporalio.converter.transfer_type_convertible( + _LocalActivityEpochTransferTypeConverter +)(LocalActivityEpoch) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True, kw_only=True) +class ActivityProducer: + """An Activity Producer.""" + + run_id: str | None = None + epoch: ActivityEpoch + + +class _ActivityProducerTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + ActivityProducer, temporalio.api.stream.v1.message_pb2.ActivityProducer + ] +): + transfer_type: ( + type[temporalio.api.stream.v1.message_pb2.ActivityProducer] | None + ) = temporalio.api.stream.v1.message_pb2.ActivityProducer + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.ActivityProducer, + type_hint: type[ActivityProducer], + ) -> ActivityProducer: + if not value.HasField("epoch"): + raise ValueError("missing required field ActivityProducer.epoch") + epoch = _ActivityEpochTransferTypeConverter().from_transfer_type( + value.epoch, ActivityEpoch + ) + return ActivityProducer( + run_id=value.run_id if bool(value.run_id) else None, + epoch=epoch, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: ActivityProducer, + ) -> temporalio.api.stream.v1.message_pb2.ActivityProducer: + message = temporalio.api.stream.v1.message_pb2.ActivityProducer() + if value.run_id is not None: + message.run_id = value.run_id + message.epoch.CopyFrom( + _ActivityEpochTransferTypeConverter().to_transfer_type(value.epoch) + ) + return message + + +temporalio.converter.transfer_type_convertible(_ActivityProducerTransferTypeConverter)( + ActivityProducer +) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class ActivityEpoch: + """An Activity or Standalone Activity attempt.""" + + attempt_scheduled_time: Timestamp + attempt: int + + +class _ActivityEpochTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + ActivityEpoch, temporalio.api.stream.v1.message_pb2.ActivityEpoch + ] +): + transfer_type: type[temporalio.api.stream.v1.message_pb2.ActivityEpoch] | None = ( + temporalio.api.stream.v1.message_pb2.ActivityEpoch + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.ActivityEpoch, + type_hint: type[ActivityEpoch], + ) -> ActivityEpoch: + if not value.HasField("attempt_scheduled_time"): + raise ValueError( + "missing required field ActivityEpoch.attempt_scheduled_time" + ) + attempt_scheduled_time = _TimestampTransferTypeConverter().from_transfer_type( + value.attempt_scheduled_time, Timestamp + ) + attempt = value.attempt + return ActivityEpoch( + attempt_scheduled_time=attempt_scheduled_time, + attempt=attempt, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: ActivityEpoch, + ) -> temporalio.api.stream.v1.message_pb2.ActivityEpoch: + message = temporalio.api.stream.v1.message_pb2.ActivityEpoch() + message.attempt_scheduled_time.CopyFrom( + _TimestampTransferTypeConverter().to_transfer_type( + value.attempt_scheduled_time + ) + ) + message.attempt = value.attempt + return message + + +temporalio.converter.transfer_type_convertible(_ActivityEpochTransferTypeConverter)( + ActivityEpoch +) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class ClientProducer: + """A client Producer. It has no run and no epoch, so nothing fences it.""" + + pass + + +class _ClientProducerTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + ClientProducer, temporalio.api.stream.v1.message_pb2.ClientProducer + ] +): + transfer_type: type[temporalio.api.stream.v1.message_pb2.ClientProducer] | None = ( + temporalio.api.stream.v1.message_pb2.ClientProducer + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.ClientProducer, + type_hint: type[ClientProducer], + ) -> ClientProducer: + return ClientProducer() + + @typing_extensions.override + def to_transfer_type( + self, + value: ClientProducer, + ) -> temporalio.api.stream.v1.message_pb2.ClientProducer: + message = temporalio.api.stream.v1.message_pb2.ClientProducer() + return message + + +temporalio.converter.transfer_type_convertible(_ClientProducerTransferTypeConverter)( + ClientProducer +) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class AppendRecordsResponse: + first_offset: bytes | None = None + last_offset: bytes | None = None + + +class _AppendRecordsResponseTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + AppendRecordsResponse, + temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsResponse, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsResponse] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsResponse + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsResponse, + type_hint: type[AppendRecordsResponse], + ) -> AppendRecordsResponse: + return AppendRecordsResponse( + first_offset=value.first_offset if bool(value.first_offset) else None, + last_offset=value.last_offset if bool(value.last_offset) else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: AppendRecordsResponse, + ) -> temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsResponse: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsResponse() + ) + if value.first_offset is not None: + message.first_offset = value.first_offset + if value.last_offset is not None: + message.last_offset = value.last_offset + return message + + +temporalio.converter.transfer_type_convertible( + _AppendRecordsResponseTransferTypeConverter +)(AppendRecordsResponse) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class CloseStreamRequest(typing.Generic[BodyT]): + """Close a Stream. Readers drain what is left, then end. Later appends are refused.""" + + ref: StreamRef[BodyT] + producer: Producer + + +class _CloseStreamRequestTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + CloseStreamRequest[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest, + type_hint: type[CloseStreamRequest[BodyT]], + ) -> CloseStreamRequest[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("ref"): + raise ValueError("missing required field CloseStreamRequest.ref") + ref = typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), + ) + if not value.HasField("producer"): + raise ValueError("missing required field CloseStreamRequest.producer") + producer = _ProducerTransferTypeConverter().from_transfer_type( + value.producer, Producer + ) + return CloseStreamRequest( + ref=ref, + producer=producer, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: CloseStreamRequest[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest() + ) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) + message.producer.CopyFrom( + _ProducerTransferTypeConverter().to_transfer_type(value.producer) + ) + return message + + +temporalio.converter.transfer_type_convertible( + _CloseStreamRequestTransferTypeConverter[typing.Any] +)(CloseStreamRequest) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class CloseStreamResponse: + pass + + +class _CloseStreamResponseTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + CloseStreamResponse, + temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse, + type_hint: type[CloseStreamResponse], + ) -> CloseStreamResponse: + return CloseStreamResponse() + + @typing_extensions.override + def to_transfer_type( + self, + value: CloseStreamResponse, + ) -> temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse() + ) + return message + + +temporalio.converter.transfer_type_convertible( + _CloseStreamResponseTransferTypeConverter +)(CloseStreamResponse) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class ReadRecordsRequest(typing.Generic[BodyT]): + """Read Records after an offset.""" + + ref: StreamRef[BodyT] + from_offset: bytes | None = None + max_records: int | None = None + wait: datetime.timedelta | None = None + max_bytes: int | None = None + + +class _ReadRecordsRequestTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + ReadRecordsRequest[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest, + type_hint: type[ReadRecordsRequest[BodyT]], + ) -> ReadRecordsRequest[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("ref"): + raise ValueError("missing required field ReadRecordsRequest.ref") + ref = typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), + ) + return ReadRecordsRequest( + ref=ref, + from_offset=value.from_offset if bool(value.from_offset) else None, + max_records=value.max_records if value.max_records != 0 else None, + wait=_support.duration_from_proto(value.wait) + if value.HasField("wait") + else None, + max_bytes=value.max_bytes if value.max_bytes != 0 else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: ReadRecordsRequest[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest() + ) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) + if value.from_offset is not None: + message.from_offset = value.from_offset + if value.max_records is not None: + message.max_records = value.max_records + if value.wait is not None: + message.wait.CopyFrom(_support.duration_to_proto(value.wait)) + if value.max_bytes is not None: + message.max_bytes = value.max_bytes + return message + + +temporalio.converter.transfer_type_convertible( + _ReadRecordsRequestTransferTypeConverter[typing.Any] +)(ReadRecordsRequest) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True, kw_only=True) +class ReadRecordsResponse(typing.Generic[BodyT]): + records: list[StreamRecord[BodyT]] + last_offset: bytes | None = None + done: bool + + +class _ReadRecordsResponseTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + ReadRecordsResponse[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsResponse, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsResponse] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsResponse + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsResponse, + type_hint: type[ReadRecordsResponse[BodyT]], + ) -> ReadRecordsResponse[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + records = [ + typing.cast( + StreamRecord[BodyT], + _StreamRecordTransferTypeConverter().from_transfer_type( + item, StreamRecord[body_type] + ), + ) + for item in value.records + ] + done = value.done + return ReadRecordsResponse( + records=records, + last_offset=value.last_offset if bool(value.last_offset) else None, + done=done, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: ReadRecordsResponse[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsResponse: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsResponse() + ) + for element in value.records: + item = message.records.add() + item.CopyFrom( + _StreamRecordTransferTypeConverter().to_transfer_type(element) + ) + if value.last_offset is not None: + message.last_offset = value.last_offset + message.done = value.done + return message + + +temporalio.converter.transfer_type_convertible( + _ReadRecordsResponseTransferTypeConverter[typing.Any] +)(ReadRecordsResponse) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True, kw_only=True) +class StreamRecord(typing.Generic[BodyT]): + """One Record that a Producer appended, as a read gives it.""" + + body: BodyT + producer: Producer | None = None + offset: bytes + + +class _StreamRecordTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + StreamRecord[BodyT], temporalio.api.stream.v1.message_pb2.StreamRecord + ] +): + transfer_type: type[temporalio.api.stream.v1.message_pb2.StreamRecord] | None = ( + temporalio.api.stream.v1.message_pb2.StreamRecord + ) + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.StreamRecord, + type_hint: type[StreamRecord[BodyT]], + ) -> StreamRecord[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("body"): + raise ValueError("missing required field StreamRecord.body") + body = typing.cast(BodyT, _support.payload_from_proto(value.body, body_type)) + if not value.offset: + raise ValueError("missing required field StreamRecord.offset") + offset = value.offset + return StreamRecord( + body=body, + producer=_ProducerTransferTypeConverter().from_transfer_type( + value.producer, Producer + ) + if value.HasField("producer") + else None, + offset=offset, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: StreamRecord[BodyT], + ) -> temporalio.api.stream.v1.message_pb2.StreamRecord: + message = temporalio.api.stream.v1.message_pb2.StreamRecord() + message.body.CopyFrom(_support.payload_to_proto(value.body)) + if value.producer is not None: + message.producer.CopyFrom( + _ProducerTransferTypeConverter().to_transfer_type(value.producer) + ) + message.offset = value.offset + return message + + +temporalio.converter.transfer_type_convertible( + _StreamRecordTransferTypeConverter[typing.Any] +)(StreamRecord) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class DescribeStreamRequest(typing.Generic[BodyT]): + ref: StreamRef[BodyT] + + +class _DescribeStreamRequestTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + DescribeStreamRequest[BodyT], + temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest, + ] +): + transfer_type: ( + type[temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest, + type_hint: type[DescribeStreamRequest[BodyT]], + ) -> DescribeStreamRequest[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) + if not value.HasField("ref"): + raise ValueError("missing required field DescribeStreamRequest.ref") + ref = typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), + ) + return DescribeStreamRequest( + ref=ref, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: DescribeStreamRequest[BodyT], + ) -> temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest: + message = ( + temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest() + ) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) + return message + + +temporalio.converter.transfer_type_convertible( + _DescribeStreamRequestTransferTypeConverter[typing.Any] +)(DescribeStreamRequest) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class DescribeStreamResponse: + status: StreamStatus | None = None + last_offset: bytes | None = None + + +class _DescribeStreamResponseTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + DescribeStreamResponse, + temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse, + ] +): + transfer_type: ( + type[ + temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse + ] + | None + ) = temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse, + type_hint: type[DescribeStreamResponse], + ) -> DescribeStreamResponse: + return DescribeStreamResponse( + status=_stream_status_from_proto(value.status) + if value.status != 0 + else None, + last_offset=value.last_offset if bool(value.last_offset) else None, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: DescribeStreamResponse, + ) -> temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse: + message = temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse() + if value.status is not None: + message.status = temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType( + value.status + ) + if value.last_offset is not None: + message.last_offset = value.last_offset + return message + + +temporalio.converter.transfer_type_convertible( + _DescribeStreamResponseTransferTypeConverter +)(DescribeStreamResponse) # pyright: ignore[reportUnusedCallResult] + + +@dataclasses.dataclass(slots=True) +class ProducerKindWorkflow: + value: WorkflowProducer + + +@dataclasses.dataclass(slots=True) +class ProducerKindLocalActivity: + value: LocalActivityProducer + + +@dataclasses.dataclass(slots=True) +class ProducerKindWorkflowActivity: + value: ActivityProducer + + +@dataclasses.dataclass(slots=True) +class ProducerKindStandaloneActivity: + value: ActivityProducer + + +@dataclasses.dataclass(slots=True) +class ProducerKindClient: + value: ClientProducer + + +ProducerKind = ( + ProducerKindWorkflow + | ProducerKindLocalActivity + | ProducerKindWorkflowActivity + | ProducerKindStandaloneActivity + | ProducerKindClient +) +"""The kind of a Producer, with its run and epoch.""" diff --git a/temporalio/nexus/system/stream_service/services.py b/temporalio/nexus/system/stream_service/services.py new file mode 100644 index 0000000000..76231c5505 --- /dev/null +++ b/temporalio/nexus/system/stream_service/services.py @@ -0,0 +1,53 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import typing + +from nexusrpc import Operation, service + +from .models import ( + AppendRecordsRequest, + AppendRecordsResponse, + CloseStreamRequest, + CloseStreamResponse, + CreateStreamRequest, + CreateStreamResult, + DescribeStreamRequest, + DescribeStreamResponse, + ReadRecordsRequest, + ReadRecordsResponse, +) + + +@service(name="temporal.api.streamservice.v1.StreamService") +class StreamService: + """ + .. warning:: + This API is experimental and subject to change. + """ + + create_stream: Operation[ + CreateStreamRequest[typing.Any], + CreateStreamResult[typing.Any], + ] = Operation(name="CreateStream") + + append_records: Operation[ + AppendRecordsRequest[typing.Any], + AppendRecordsResponse, + ] = Operation(name="AppendRecords") + + close_stream: Operation[ + CloseStreamRequest[typing.Any], + CloseStreamResponse, + ] = Operation(name="CloseStream") + + read_records: Operation[ + ReadRecordsRequest[typing.Any], + ReadRecordsResponse[typing.Any], + ] = Operation(name="ReadRecords") + + describe_stream: Operation[ + DescribeStreamRequest[typing.Any], + DescribeStreamResponse, + ] = Operation(name="DescribeStream") diff --git a/temporalio/nexus/system/stream_service/workflow/__init__.py b/temporalio/nexus/system/stream_service/workflow/__init__.py new file mode 100644 index 0000000000..12b9baa97e --- /dev/null +++ b/temporalio/nexus/system/stream_service/workflow/__init__.py @@ -0,0 +1,77 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import collections.abc +import typing + +import nexusrpc + +import temporalio.converter + +from .. import services as _services +from ._resources.stream import get_stream +from .operations.create_stream import create_stream + +__all__ = [ + "create_stream", + "get_stream", +] + + +_InputT = typing.TypeVar("_InputT") +_OutputT = typing.TypeVar("_OutputT") + + +_SerializationContextFactory = collections.abc.Callable[ + [_InputT], temporalio.converter.SerializationContext +] + + +class _NexusOperationInfo(typing.Generic[_InputT, _OutputT]): + def __init__( + self, + *, + operation: nexusrpc.Operation[_InputT, _OutputT], + serialization_context: _SerializationContextFactory[_InputT] | None = None, + ) -> None: + self.operation: nexusrpc.Operation[_InputT, _OutputT] = operation + self.serialization_context: _SerializationContextFactory[_InputT] | None = ( + serialization_context + ) + + +__nexus_operation_registry__: dict[ + tuple[str, str], _NexusOperationInfo[typing.Any, typing.Any] +] = { + ( + "temporal.api.streamservice.v1.StreamService", + "CreateStream", + ): _NexusOperationInfo( + operation=_services.StreamService.create_stream, + ), + ( + "temporal.api.streamservice.v1.StreamService", + "AppendRecords", + ): _NexusOperationInfo( + operation=_services.StreamService.append_records, + ), + ( + "temporal.api.streamservice.v1.StreamService", + "CloseStream", + ): _NexusOperationInfo( + operation=_services.StreamService.close_stream, + ), + ( + "temporal.api.streamservice.v1.StreamService", + "ReadRecords", + ): _NexusOperationInfo( + operation=_services.StreamService.read_records, + ), + ( + "temporal.api.streamservice.v1.StreamService", + "DescribeStream", + ): _NexusOperationInfo( + operation=_services.StreamService.describe_stream, + ), +} diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py b/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py new file mode 100644 index 0000000000..04fda4c2bc --- /dev/null +++ b/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py @@ -0,0 +1,9 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +from .stream import Stream + +__all__ = [ + "Stream", +] diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py new file mode 100644 index 0000000000..4cf06445e5 --- /dev/null +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -0,0 +1,101 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import typing + +import temporalio.nexus.system +import temporalio.workflow + +from ...models import ( + DescribeStreamRequest, + DescribeStreamResponse, + StreamRef, +) + +BodyT = typing.TypeVar("BodyT") + + +class Stream(typing.Generic[BodyT]): + """One Stream. Build it from a stream-ref, or get it from a create.""" + + ref: StreamRef[BodyT] + created: bool | None + + def __init__( + self, + ref: StreamRef[BodyT], + created: bool | None, + ) -> None: + if type(self) is not Stream: + raise TypeError("Generic resource subclasses are not supported") + self.ref = ref + self.created = created + + @property + def body_type(self) -> type[BodyT]: + arguments = typing.get_args(getattr(self.ref, "__orig_class__", None)) + return typing.cast("type[BodyT]", arguments[0] if arguments else object) + + async def describe( + self, + ) -> DescribeStreamResponse: + """Describe the Stream's status and newest offset.""" + request = DescribeStreamRequest( + ref=self.ref, + ) + handle = await _describe_stream(request) + return await handle + + +@typing.overload +def get_stream( + ref: StreamRef[BodyT], + *, + created: bool | None = None, + body_type: None = None, +) -> Stream[BodyT]: ... + + +@typing.overload +def get_stream( + ref: StreamRef[BodyT] | StreamRef[object], + *, + created: bool | None = None, + body_type: type[BodyT], +) -> Stream[BodyT]: ... + + +def get_stream( + ref: StreamRef[typing.Any], + *, + created: bool | None = None, + body_type: typing.Any = None, +) -> Stream[typing.Any]: + """Return the ``Stream`` handle for this ref.""" + arguments = typing.get_args(getattr(ref, "__orig_class__", None)) + # None means no explicit type, so use the ref's type argument, else object. + if body_type is None: + body_type = arguments[0] if arguments else object + elif arguments and arguments[0] is not object and arguments[0] != body_type: + raise TypeError("The decoding type must match the typed ref") + if arguments != (body_type,): + ref = StreamRef[body_type](id=ref.id, store=ref.store) + return Stream[body_type]( + ref=ref, + created=created, + ) + + +async def _describe_stream( + request: DescribeStreamRequest[BodyT], +) -> temporalio.workflow.NexusOperationHandle[DescribeStreamResponse,]: + nexus_client = temporalio.workflow.create_nexus_client( + service="temporal.api.streamservice.v1.StreamService", + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ) + return await nexus_client.start_operation( + operation="DescribeStream", + input=request, + output_type=DescribeStreamResponse, + ) diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py new file mode 100644 index 0000000000..fa1196c89d --- /dev/null +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -0,0 +1,299 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import abc +import typing + +from .. import models + +if typing.TYPE_CHECKING: + import temporalio.workflow + from temporalio.worker._interceptor import StartNexusOperationInput + + +__all__ = [ + "_start_system_nexus_operation", + "_SystemNexusWorkflowOutboundInterceptorBase", + "_SystemNexusWorkflowOutboundInterceptorTerminal", +] + + +_InputT = typing.TypeVar("_InputT") +_OutputT = typing.TypeVar("_OutputT") + + +async def _start_system_nexus_operation( + interceptor: _SystemNexusWorkflowOutboundInterceptorBase, + input: StartNexusOperationInput[_InputT, _OutputT], +) -> temporalio.workflow.NexusOperationHandle[_OutputT]: + if ( + input.service == "temporal.api.streamservice.v1.StreamService" + and input.operation_name == "CreateStream" + ): + typed_input = typing.cast( + "StartNexusOperationInput[models.CreateStreamRequest[typing.Any], models.CreateStreamResult[typing.Any]]", + input, + ) + # The dispatch check above establishes that this operation's response type is _OutputT. + return typing.cast( + "temporalio.workflow.NexusOperationHandle[_OutputT]", + await interceptor.start_create_stream( + typed_input.input, typed_input.output_type + ), + ) + if ( + input.service == "temporal.api.streamservice.v1.StreamService" + and input.operation_name == "AppendRecords" + ): + typed_input = typing.cast( + "StartNexusOperationInput[models.AppendRecordsRequest[typing.Any], models.AppendRecordsResponse]", + input, + ) + # The dispatch check above establishes that this operation's response type is _OutputT. + return typing.cast( + "temporalio.workflow.NexusOperationHandle[_OutputT]", + await interceptor.start_append_records(typed_input.input), + ) + if ( + input.service == "temporal.api.streamservice.v1.StreamService" + and input.operation_name == "CloseStream" + ): + typed_input = typing.cast( + "StartNexusOperationInput[models.CloseStreamRequest[typing.Any], models.CloseStreamResponse]", + input, + ) + # The dispatch check above establishes that this operation's response type is _OutputT. + return typing.cast( + "temporalio.workflow.NexusOperationHandle[_OutputT]", + await interceptor.start_close_stream(typed_input.input), + ) + if ( + input.service == "temporal.api.streamservice.v1.StreamService" + and input.operation_name == "ReadRecords" + ): + typed_input = typing.cast( + "StartNexusOperationInput[models.ReadRecordsRequest[typing.Any], models.ReadRecordsResponse[typing.Any]]", + input, + ) + # The dispatch check above establishes that this operation's response type is _OutputT. + return typing.cast( + "temporalio.workflow.NexusOperationHandle[_OutputT]", + await interceptor.start_read_records( + typed_input.input, typed_input.output_type + ), + ) + if ( + input.service == "temporal.api.streamservice.v1.StreamService" + and input.operation_name == "DescribeStream" + ): + typed_input = typing.cast( + "StartNexusOperationInput[models.DescribeStreamRequest[typing.Any], models.DescribeStreamResponse]", + input, + ) + # The dispatch check above establishes that this operation's response type is _OutputT. + return typing.cast( + "temporalio.workflow.NexusOperationHandle[_OutputT]", + await interceptor.start_describe_stream(typed_input.input), + ) + return await interceptor.start_system_nexus_operation(input) + + +class _SystemNexusWorkflowOutboundInterceptorBase(abc.ABC): + @abc.abstractmethod + def _next_system_nexus_interceptor( + self, + ) -> _SystemNexusWorkflowOutboundInterceptorBase: ... + + @abc.abstractmethod + async def start_system_nexus_operation( + self, + input: StartNexusOperationInput[_InputT, _OutputT], + ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: + """Intercept a System Nexus operation through the generic hook.""" + ... + + async def start_create_stream( + self, + request: models.CreateStreamRequest[typing.Any], + output_type: type[models.CreateStreamResult[typing.Any]] | None = None, + ) -> temporalio.workflow.NexusOperationHandle[ + models.CreateStreamResult[typing.Any] + ]: + """Intercept the CreateStream operation.""" + return await self._next_system_nexus_interceptor().start_create_stream( + request, output_type + ) + + async def start_append_records( + self, request: models.AppendRecordsRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.AppendRecordsResponse]: + """Intercept the AppendRecords operation.""" + return await self._next_system_nexus_interceptor().start_append_records(request) + + async def start_close_stream( + self, request: models.CloseStreamRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.CloseStreamResponse]: + """Intercept the CloseStream operation.""" + return await self._next_system_nexus_interceptor().start_close_stream(request) + + async def start_read_records( + self, + request: models.ReadRecordsRequest[typing.Any], + output_type: type[models.ReadRecordsResponse[typing.Any]] | None = None, + ) -> temporalio.workflow.NexusOperationHandle[ + models.ReadRecordsResponse[typing.Any] + ]: + """Intercept the ReadRecords operation.""" + return await self._next_system_nexus_interceptor().start_read_records( + request, output_type + ) + + async def start_describe_stream( + self, request: models.DescribeStreamRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.DescribeStreamResponse]: + """Intercept the DescribeStream operation.""" + return await self._next_system_nexus_interceptor().start_describe_stream( + request + ) + + +class _SystemNexusWorkflowOutboundInterceptorTerminal(abc.ABC): + @abc.abstractmethod + async def _intercept_system_nexus_operation( + self, + input: StartNexusOperationInput[_InputT, _OutputT], + ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: ... + + async def start_create_stream( + self, + request: models.CreateStreamRequest[typing.Any], + output_type: type[models.CreateStreamResult[typing.Any]] | None = None, + ) -> temporalio.workflow.NexusOperationHandle[ + models.CreateStreamResult[typing.Any] + ]: + from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT + from temporalio.worker._interceptor import StartNexusOperationInput + from temporalio.workflow import NexusOperationCancellationType + + return await self._intercept_system_nexus_operation( + StartNexusOperationInput( + endpoint=TEMPORAL_SYSTEM_ENDPOINT, + service="temporal.api.streamservice.v1.StreamService", + operation="CreateStream", + input=request, + output_type=typing.cast( + "type[models.CreateStreamResult[typing.Any]]", + models.CreateStreamResult, + ) + if output_type is None + else output_type, + schedule_to_close_timeout=None, + schedule_to_start_timeout=None, + start_to_close_timeout=None, + cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, + headers=None, + summary=None, + ) + ) + + async def start_append_records( + self, request: models.AppendRecordsRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.AppendRecordsResponse]: + from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT + from temporalio.worker._interceptor import StartNexusOperationInput + from temporalio.workflow import NexusOperationCancellationType + + return await self._intercept_system_nexus_operation( + StartNexusOperationInput( + endpoint=TEMPORAL_SYSTEM_ENDPOINT, + service="temporal.api.streamservice.v1.StreamService", + operation="AppendRecords", + input=request, + output_type=models.AppendRecordsResponse, + schedule_to_close_timeout=None, + schedule_to_start_timeout=None, + start_to_close_timeout=None, + cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, + headers=None, + summary=None, + ) + ) + + async def start_close_stream( + self, request: models.CloseStreamRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.CloseStreamResponse]: + from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT + from temporalio.worker._interceptor import StartNexusOperationInput + from temporalio.workflow import NexusOperationCancellationType + + return await self._intercept_system_nexus_operation( + StartNexusOperationInput( + endpoint=TEMPORAL_SYSTEM_ENDPOINT, + service="temporal.api.streamservice.v1.StreamService", + operation="CloseStream", + input=request, + output_type=models.CloseStreamResponse, + schedule_to_close_timeout=None, + schedule_to_start_timeout=None, + start_to_close_timeout=None, + cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, + headers=None, + summary=None, + ) + ) + + async def start_read_records( + self, + request: models.ReadRecordsRequest[typing.Any], + output_type: type[models.ReadRecordsResponse[typing.Any]] | None = None, + ) -> temporalio.workflow.NexusOperationHandle[ + models.ReadRecordsResponse[typing.Any] + ]: + from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT + from temporalio.worker._interceptor import StartNexusOperationInput + from temporalio.workflow import NexusOperationCancellationType + + return await self._intercept_system_nexus_operation( + StartNexusOperationInput( + endpoint=TEMPORAL_SYSTEM_ENDPOINT, + service="temporal.api.streamservice.v1.StreamService", + operation="ReadRecords", + input=request, + output_type=typing.cast( + "type[models.ReadRecordsResponse[typing.Any]]", + models.ReadRecordsResponse, + ) + if output_type is None + else output_type, + schedule_to_close_timeout=None, + schedule_to_start_timeout=None, + start_to_close_timeout=None, + cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, + headers=None, + summary=None, + ) + ) + + async def start_describe_stream( + self, request: models.DescribeStreamRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.DescribeStreamResponse]: + from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT + from temporalio.worker._interceptor import StartNexusOperationInput + from temporalio.workflow import NexusOperationCancellationType + + return await self._intercept_system_nexus_operation( + StartNexusOperationInput( + endpoint=TEMPORAL_SYSTEM_ENDPOINT, + service="temporal.api.streamservice.v1.StreamService", + operation="DescribeStream", + input=request, + output_type=models.DescribeStreamResponse, + schedule_to_close_timeout=None, + schedule_to_start_timeout=None, + start_to_close_timeout=None, + cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, + headers=None, + summary=None, + ) + ) diff --git a/temporalio/nexus/system/stream_service/workflow/operations/__init__.py b/temporalio/nexus/system/stream_service/workflow/operations/__init__.py new file mode 100644 index 0000000000..250b6a42b7 --- /dev/null +++ b/temporalio/nexus/system/stream_service/workflow/operations/__init__.py @@ -0,0 +1,3 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py new file mode 100644 index 0000000000..c06679d195 --- /dev/null +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -0,0 +1,90 @@ +# Generated by nexgen v0.2.12. DO NOT EDIT! + +from __future__ import annotations + +import typing + +import temporalio.nexus.system +import temporalio.nexus.system._support as _support +import temporalio.workflow + +from ...models import ( + CreateStreamRequest, + CreateStreamResult, + StreamIdConflictPolicy, + StreamRef, +) +from .._resources import Stream + +BodyT = typing.TypeVar("BodyT") + + +async def _create_stream( + request: CreateStreamRequest[BodyT], + body_type: type[BodyT], +) -> Stream[BodyT]: + nexus_client = temporalio.workflow.create_nexus_client( + service="temporal.api.streamservice.v1.StreamService", + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ) + handle = await nexus_client.start_operation( + operation="CreateStream", + input=request, + output_type=CreateStreamResult[body_type], + ) + result = await handle + if result.ref is None: + raise RuntimeError("CreateStream answered without `ref`") + return Stream[body_type]( + ref=result.ref, + created=result.created or None, + ) + + +@typing.overload +async def create_stream( + *, + id: str, + store: str | None = None, + id_conflict_policy: StreamIdConflictPolicy | None = None, + body_type: type[BodyT], +) -> Stream[BodyT]: ... + + +@typing.overload +async def create_stream( + *, + id: str, + store: str | None = None, + id_conflict_policy: StreamIdConflictPolicy | None = None, + body_type: None = None, +) -> Stream[object]: ... + + +async def create_stream( + *, + id: str, + store: str | None = None, + id_conflict_policy: StreamIdConflictPolicy | None = None, + body_type: typing.Any = None, +) -> Stream[typing.Any]: + """ + Args: + id: The Stream id, 1 to 4096 bytes. + store: Registered Store name. With none, the SDK picks one. Only an SDK reads + it. + id_conflict_policy: What the create does when the Stream exists. Unspecified is + fail. + """ + if body_type is None: + body_type = typing.Any + stream_ref = StreamRef( + id=id, + store=store, + ) + request = CreateStreamRequest( + stream_ref=stream_ref, + id_conflict_policy=id_conflict_policy, + request_id=_support.request_id(), + ) + return await _create_stream(request, body_type) diff --git a/temporalio/workflow/__init__.py b/temporalio/workflow/__init__.py index c631fd88e8..60b02cc543 100644 --- a/temporalio/workflow/__init__.py +++ b/temporalio/workflow/__init__.py @@ -3,6 +3,10 @@ from __future__ import annotations # BEGIN GENERATED NEXUS SYSTEM EXPORTS +from temporalio.nexus.system.stream_service.workflow import ( + create_stream, + get_stream, +) from temporalio.nexus.system.workflow_service import ( signal_with_start_workflow, ) @@ -329,6 +333,8 @@ "ReturnType", "SelfType", # BEGIN GENERATED NEXUS SYSTEM __ALL__ + "create_stream", + "get_stream", "signal_with_start_workflow", # END GENERATED NEXUS SYSTEM __ALL__ ] From c65cf7a77fa9251b911e9239617afaa0f5c82543 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Fri, 13 Nov 2026 18:55:23 -0700 Subject: [PATCH 02/24] Regenerated the Streams API with append and close on the Workflow Stream. The new Stream WIT gives the Workflow target `append` and `close`, so the generated Workflow `Stream` has them and `async with` closes it. --- .../workflow/_resources/stream.py | 77 +++++++++++++++++++ .../workflow/operations/create_stream.py | 4 + 2 files changed, 81 insertions(+) diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 4cf06445e5..df548d2528 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -2,14 +2,24 @@ from __future__ import annotations +import types import typing +import typing_extensions + import temporalio.nexus.system +import temporalio.nexus.system._support as _support import temporalio.workflow from ...models import ( + AppendRecord, + AppendRecordsRequest, + AppendRecordsResponse, + CloseStreamRequest, + CloseStreamResponse, DescribeStreamRequest, DescribeStreamResponse, + Producer, StreamRef, ) @@ -37,6 +47,45 @@ def body_type(self) -> type[BodyT]: arguments = typing.get_args(getattr(self.ref, "__orig_class__", None)) return typing.cast("type[BodyT]", arguments[0] if arguments else object) + async def __aenter__(self) -> typing_extensions.Self: + return self + + async def __aexit__( + self, + exc_type: type[BaseException] | None, + exc: BaseException | None, + tb: types.TracebackType | None, + ) -> None: + await self.close() + + async def append( + self, + *records: BodyT, + producer: Producer | None = None, + sequence: int | None = None, + ) -> AppendRecordsResponse: + """Append values, and return the offsets of the batch.""" + request = AppendRecordsRequest( + ref=self.ref, + producer=((_support.workflow_producer()) if producer is None else producer), + sequence=sequence, + records=[AppendRecord(body=value) for value in records], + ) + handle = await _append_records(request) + return await handle + + async def close( + self, + producer: Producer | None = None, + ) -> None: + """Close the Stream. Readers drain what is left, then end.""" + request = CloseStreamRequest( + ref=self.ref, + producer=((_support.workflow_producer()) if producer is None else producer), + ) + handle = await _close_stream(request) + await handle + async def describe( self, ) -> DescribeStreamResponse: @@ -87,6 +136,34 @@ def get_stream( ) +async def _append_records( + request: AppendRecordsRequest[BodyT], +) -> temporalio.workflow.NexusOperationHandle[AppendRecordsResponse,]: + nexus_client = temporalio.workflow.create_nexus_client( + service="temporal.api.streamservice.v1.StreamService", + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ) + return await nexus_client.start_operation( + operation="AppendRecords", + input=request, + output_type=AppendRecordsResponse, + ) + + +async def _close_stream( + request: CloseStreamRequest[BodyT], +) -> temporalio.workflow.NexusOperationHandle[CloseStreamResponse,]: + nexus_client = temporalio.workflow.create_nexus_client( + service="temporal.api.streamservice.v1.StreamService", + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ) + return await nexus_client.start_operation( + operation="CloseStream", + input=request, + output_type=CloseStreamResponse, + ) + + async def _describe_stream( request: DescribeStreamRequest[BodyT], ) -> temporalio.workflow.NexusOperationHandle[DescribeStreamResponse,]: diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index c06679d195..12e5f6b466 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -8,6 +8,7 @@ import temporalio.nexus.system._support as _support import temporalio.workflow +from ..._resource_context_manager import resource_context_manager from ...models import ( CreateStreamRequest, CreateStreamResult, @@ -42,6 +43,7 @@ async def _create_stream( @typing.overload +@resource_context_manager async def create_stream( *, id: str, @@ -52,6 +54,7 @@ async def create_stream( @typing.overload +@resource_context_manager async def create_stream( *, id: str, @@ -61,6 +64,7 @@ async def create_stream( ) -> Stream[object]: ... +@resource_context_manager async def create_stream( *, id: str, From 6635c7033dfd6a16f4a5e0d814dbd4fffb24e023 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Tue, 17 Nov 2026 18:26:46 -0700 Subject: [PATCH 03/24] Regenerated the Streams API with the new names of a polled read. With nexgen commit 07b565b6, `read` yields Records, `read_pages` yields pages and `read_page` sends one request. `PollIterator` moves to one `_poll.py` next to the models. The Workflow interceptor terminal calls `_schedule_system_nexus_operation` and drops the generic hook, as upstream nexgen does. --- .../stream_service/{client => }/_poll.py | 0 .../client/_resources/stream.py | 14 +++++------ .../workflow/_system_nexus_interceptor.py | 24 +++++++------------ 3 files changed, 16 insertions(+), 22 deletions(-) rename temporalio/nexus/system/stream_service/{client => }/_poll.py (100%) diff --git a/temporalio/nexus/system/stream_service/client/_poll.py b/temporalio/nexus/system/stream_service/_poll.py similarity index 100% rename from temporalio/nexus/system/stream_service/client/_poll.py rename to temporalio/nexus/system/stream_service/_poll.py diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index c3fa617b6d..a8e320c6f7 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -15,6 +15,7 @@ import temporalio.nexus.system._support as _support +from ..._poll import PollIterator from ...models import ( AppendRecord, AppendRecordsRequest, @@ -29,7 +30,6 @@ StreamRef, ) from ...services import StreamService -from .._poll import PollIterator BodyT = typing.TypeVar("BodyT") @@ -115,7 +115,7 @@ async def close( ) _ = await handle.result() - async def read( + async def read_page( self, from_offset: bytes | None = None, max_records: int | None = None, @@ -143,7 +143,7 @@ async def read( ) return await handle.result() - async def iter_read( + async def read_pages( self, from_offset: bytes | None = None, max_records: int | None = None, @@ -153,7 +153,7 @@ async def iter_read( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: - """Yield each response of ``read`` until the poll helper stops. + """Yield each response of ``read_page`` until the poll helper stops. Read one page of Records. The poll iterator reads them all. @@ -190,7 +190,7 @@ async def iter_read( return request = next_request - def iter_read_items( + def read( self, from_offset: bytes | None = None, max_records: int | None = None, @@ -200,7 +200,7 @@ def iter_read_items( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> PollIterator[ReadRecordsRequest[BodyT], StreamRecord[BodyT]]: - """Yield each item of ``iter_read``, page by page. + """Yield each item of ``read_pages``, page by page. ``next_request`` resumes after the last item that the iterator yielded. It is ``None`` after the last page. @@ -225,7 +225,7 @@ def iter_read_items( ) return PollIterator( request, - self.iter_read( + self.read_pages( from_offset=from_offset, max_records=max_records, wait=wait, diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py index fa1196c89d..399fd18966 100644 --- a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -96,7 +96,9 @@ async def _start_system_nexus_operation( "temporalio.workflow.NexusOperationHandle[_OutputT]", await interceptor.start_describe_stream(typed_input.input), ) - return await interceptor.start_system_nexus_operation(input) + raise ValueError( + f"unsupported System Nexus operation: {input.service}/{input.operation_name}" + ) class _SystemNexusWorkflowOutboundInterceptorBase(abc.ABC): @@ -105,14 +107,6 @@ def _next_system_nexus_interceptor( self, ) -> _SystemNexusWorkflowOutboundInterceptorBase: ... - @abc.abstractmethod - async def start_system_nexus_operation( - self, - input: StartNexusOperationInput[_InputT, _OutputT], - ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: - """Intercept a System Nexus operation through the generic hook.""" - ... - async def start_create_stream( self, request: models.CreateStreamRequest[typing.Any], @@ -160,7 +154,7 @@ async def start_describe_stream( class _SystemNexusWorkflowOutboundInterceptorTerminal(abc.ABC): @abc.abstractmethod - async def _intercept_system_nexus_operation( + async def _schedule_system_nexus_operation( self, input: StartNexusOperationInput[_InputT, _OutputT], ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: ... @@ -176,7 +170,7 @@ async def start_create_stream( from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType - return await self._intercept_system_nexus_operation( + return await self._schedule_system_nexus_operation( StartNexusOperationInput( endpoint=TEMPORAL_SYSTEM_ENDPOINT, service="temporal.api.streamservice.v1.StreamService", @@ -204,7 +198,7 @@ async def start_append_records( from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType - return await self._intercept_system_nexus_operation( + return await self._schedule_system_nexus_operation( StartNexusOperationInput( endpoint=TEMPORAL_SYSTEM_ENDPOINT, service="temporal.api.streamservice.v1.StreamService", @@ -227,7 +221,7 @@ async def start_close_stream( from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType - return await self._intercept_system_nexus_operation( + return await self._schedule_system_nexus_operation( StartNexusOperationInput( endpoint=TEMPORAL_SYSTEM_ENDPOINT, service="temporal.api.streamservice.v1.StreamService", @@ -254,7 +248,7 @@ async def start_read_records( from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType - return await self._intercept_system_nexus_operation( + return await self._schedule_system_nexus_operation( StartNexusOperationInput( endpoint=TEMPORAL_SYSTEM_ENDPOINT, service="temporal.api.streamservice.v1.StreamService", @@ -282,7 +276,7 @@ async def start_describe_stream( from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType - return await self._intercept_system_nexus_operation( + return await self._schedule_system_nexus_operation( StartNexusOperationInput( endpoint=TEMPORAL_SYSTEM_ENDPOINT, service="temporal.api.streamservice.v1.StreamService", From e0ba1911bb4d744e3d86a8d04150ca831d2ef195 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Fri, 20 Nov 2026 12:10:04 -0700 Subject: [PATCH 04/24] Regenerate the Streams API from the API's attempt names The API changes `epoch` to `attempt`, gives the Workflow `Stream` a read, passes the client to the default Producer of a client Stream, and drops `namespace` from the requests. This commit follows `temporalio/api` `7964b905` with nexgen 0.2.13. --- temporalio/api/enums/v1/stream_pb2.py | 12 +- temporalio/api/enums/v1/stream_pb2.pyi | 120 +++++------ temporalio/api/stream/v1/__init__.py | 12 +- temporalio/api/stream/v1/message_pb2.py | 46 ++--- temporalio/api/stream/v1/message_pb2.pyi | 167 ++++++++-------- .../streamservice/v1/request_response_pb2.py | 40 ++-- .../streamservice/v1/request_response_pb2.pyi | 147 ++++++-------- .../nexus/system/stream_service/__init__.py | 14 +- .../nexus/system/stream_service/_poll.py | 2 +- .../_resource_context_manager.py | 2 +- .../system/stream_service/client/__init__.py | 2 +- .../stream_service/client/_extensions.py | 9 +- .../client/_resources/__init__.py | 2 +- .../client/_resources/stream.py | 46 +++-- .../nexus/system/stream_service/models.py | 187 +++++++++--------- .../nexus/system/stream_service/services.py | 2 +- .../stream_service/workflow/__init__.py | 2 +- .../workflow/_resources/__init__.py | 2 +- .../workflow/_resources/stream.py | 122 +++++++++++- .../workflow/_system_nexus_interceptor.py | 2 +- .../workflow/operations/__init__.py | 2 +- .../workflow/operations/create_stream.py | 9 +- 22 files changed, 527 insertions(+), 422 deletions(-) diff --git a/temporalio/api/enums/v1/stream_pb2.py b/temporalio/api/enums/v1/stream_pb2.py index b2e79a0e96..021a38e1aa 100644 --- a/temporalio/api/enums/v1/stream_pb2.py +++ b/temporalio/api/enums/v1/stream_pb2.py @@ -14,7 +14,7 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*z\n\x0cStreamStatus\x12\x1d\n\x19STREAM_STATUS_UNSPECIFIED\x10\x00\x12\x16\n\x12STREAM_STATUS_OPEN\x10\x01\x12\x18\n\x14STREAM_STATUS_CLOSED\x10\x02\x12\x19\n\x15STREAM_STATUS_EXPIRED\x10\x03*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xe8\x04\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_CLOSED\x10\x03\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x04\x12(\n$STREAM_ERROR_REASON_SEQUENCE_TOO_LOW\x10\x05\x12%\n!STREAM_ERROR_REASON_SEQ_DIVERGENT\x10\x06\x12!\n\x1dSTREAM_ERROR_REASON_NOT_OWNER\x10\x07\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x08\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\t\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\n\x12\x1f\n\x1bSTREAM_ERROR_REASON_INVALID\x10\x0b\x12+\n\'STREAM_ERROR_REASON_STORAGE_UNAVAILABLE\x10\x0c\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\r\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\x0e\x12\'\n#STREAM_ERROR_REASON_STORAGE_CORRUPT\x10\x0f\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' + b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*_\n\x0cStreamStatus\x12\x1d\n\x19STREAM_STATUS_UNSPECIFIED\x10\x00\x12\x16\n\x12STREAM_STATUS_OPEN\x10\x01\x12\x18\n\x14STREAM_STATUS_CLOSED\x10\x02*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xca\x04\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_CLOSED\x10\x03\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x04\x12(\n$STREAM_ERROR_REASON_SEQUENCE_TOO_LOW\x10\x05\x12%\n!STREAM_ERROR_REASON_SEQ_DIVERGENT\x10\x06\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x08\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\t\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\n\x12(\n$STREAM_ERROR_REASON_INVALID_ARGUMENT\x10\x0b\x12)\n%STREAM_ERROR_REASON_STORE_UNAVAILABLE\x10\x0c\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\r\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\x0e\x12%\n!STREAM_ERROR_REASON_STORE_CORRUPT\x10\x0f\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -23,9 +23,9 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\030io.temporal.api.enums.v1B\013StreamProtoP\001Z!go.temporal.io/api/enums/v1;enums\252\002\027Temporalio.Api.Enums.V1\352\002\032Temporalio::Api::Enums::V1" _STREAMSTATUS._serialized_start = 61 - _STREAMSTATUS._serialized_end = 183 - _STREAMIDCONFLICTPOLICY._serialized_start = 186 - _STREAMIDCONFLICTPOLICY._serialized_end = 333 - _STREAMERRORREASON._serialized_start = 336 - _STREAMERRORREASON._serialized_end = 952 + _STREAMSTATUS._serialized_end = 156 + _STREAMIDCONFLICTPOLICY._serialized_start = 159 + _STREAMIDCONFLICTPOLICY._serialized_end = 306 + _STREAMERRORREASON._serialized_start = 309 + _STREAMERRORREASON._serialized_end = 895 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/enums/v1/stream_pb2.pyi b/temporalio/api/enums/v1/stream_pb2.pyi index ac57ccd183..bf71e998b3 100644 --- a/temporalio/api/enums/v1/stream_pb2.pyi +++ b/temporalio/api/enums/v1/stream_pb2.pyi @@ -30,20 +30,23 @@ class _StreamStatusEnumTypeWrapper( DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor STREAM_STATUS_UNSPECIFIED: _StreamStatus.ValueType # 0 STREAM_STATUS_OPEN: _StreamStatus.ValueType # 1 + """The Stream accepts appends.""" STREAM_STATUS_CLOSED: _StreamStatus.ValueType # 2 - STREAM_STATUS_EXPIRED: _StreamStatus.ValueType # 3 + """The Stream is closed. It accepts no append, and a read ends after its last Record.""" class StreamStatus(_StreamStatus, metaclass=_StreamStatusEnumTypeWrapper): """Experimental. Might change in the future. - The state of a Stream, as a describe gives it. + The status of a Stream, as a describe returns it. A describe of an expired Stream fails with + the reason `EXPIRED`, so it has no status. (-- api-linter: core::0216::synonyms=disabled - aip.dev/not-precedent: Named consistently with WorkflowExecutionStatus. --) + aip.dev/not-precedent: It has the same form as WorkflowExecutionStatus. --) """ STREAM_STATUS_UNSPECIFIED: StreamStatus.ValueType # 0 STREAM_STATUS_OPEN: StreamStatus.ValueType # 1 +"""The Stream accepts appends.""" STREAM_STATUS_CLOSED: StreamStatus.ValueType # 2 -STREAM_STATUS_EXPIRED: StreamStatus.ValueType # 3 +"""The Stream is closed. It accepts no append, and a read ends after its last Record.""" global___StreamStatus = StreamStatus class _StreamIdConflictPolicy: @@ -59,22 +62,23 @@ class _StreamIdConflictPolicyEnumTypeWrapper( DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor STREAM_ID_CONFLICT_POLICY_UNSPECIFIED: _StreamIdConflictPolicy.ValueType # 0 STREAM_ID_CONFLICT_POLICY_FAIL: _StreamIdConflictPolicy.ValueType # 1 - """The create fails with ALREADY_EXISTS.""" + """The create fails with `ALREADY_EXISTS`.""" STREAM_ID_CONFLICT_POLICY_USE_EXISTING: _StreamIdConflictPolicy.ValueType # 2 - """The create gets the open Stream, which keeps its own Retention.""" + """The create returns the open Stream, and the Retention of that Stream doesn't change.""" class StreamIdConflictPolicy( _StreamIdConflictPolicy, metaclass=_StreamIdConflictPolicyEnumTypeWrapper ): """Experimental. Might change in the future. - What a create does when its Stream exists. Unspecified is FAIL, as for a Workflow start. + What a create does if its Stream already exists. Unspecified means `FAIL`, as it does for a + Workflow start. """ STREAM_ID_CONFLICT_POLICY_UNSPECIFIED: StreamIdConflictPolicy.ValueType # 0 STREAM_ID_CONFLICT_POLICY_FAIL: StreamIdConflictPolicy.ValueType # 1 -"""The create fails with ALREADY_EXISTS.""" +"""The create fails with `ALREADY_EXISTS`.""" STREAM_ID_CONFLICT_POLICY_USE_EXISTING: StreamIdConflictPolicy.ValueType # 2 -"""The create gets the open Stream, which keeps its own Retention.""" +"""The create returns the open Stream, and the Retention of that Stream doesn't change.""" global___StreamIdConflictPolicy = StreamIdConflictPolicy class _StreamErrorReason: @@ -90,86 +94,90 @@ class _StreamErrorReasonEnumTypeWrapper( DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor STREAM_ERROR_REASON_UNSPECIFIED: _StreamErrorReason.ValueType # 0 STREAM_ERROR_REASON_NOT_FOUND: _StreamErrorReason.ValueType # 1 - """Nobody created the Stream. NOT_FOUND.""" + """The Stream was never created (`NOT_FOUND`).""" STREAM_ERROR_REASON_EXPIRED: _StreamErrorReason.ValueType # 2 - """The Stream's Retention or its last-write TTL passed. NOT_FOUND.""" + """The Retention of the Stream or its Producer idle TTL has passed (`NOT_FOUND`).""" STREAM_ERROR_REASON_CLOSED: _StreamErrorReason.ValueType # 3 - """The Stream is closed. FAILED_PRECONDITION.""" + """The Stream is closed (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_FENCED: _StreamErrorReason.ValueType # 4 - """The Producer's epoch is lower than the newest one. FAILED_PRECONDITION.""" + """A later attempt of the same Producer has already written, and the Store fences + (`FAILED_PRECONDITION`). + """ STREAM_ERROR_REASON_SEQUENCE_TOO_LOW: _StreamErrorReason.ValueType # 5 - """The batch has a lower `sequence` than the last one of its epoch. FAILED_PRECONDITION.""" + """The `sequence` of an append is lower than the `sequence` of the last batch of its attempt + (`FAILED_PRECONDITION`). + """ STREAM_ERROR_REASON_SEQ_DIVERGENT: _StreamErrorReason.ValueType # 6 - """The batch has the `sequence` of the last one of its epoch, and other content. - FAILED_PRECONDITION. + """The batch has the same `sequence` as the last one of its attempt, but different content + (`FAILED_PRECONDITION`). """ - STREAM_ERROR_REASON_NOT_OWNER: _StreamErrorReason.ValueType # 7 - """The caller may not create or close this Stream. FAILED_PRECONDITION.""" STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 8 - """A newer format version wrote the Stream. FAILED_PRECONDITION.""" + """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 9 - """The offset is past the newest offset, for example after a failover lost the newest Records. - A read from it works again once the Stream has Records up to it. OUT_OF_RANGE. + """The offset is past the newest one, for example after a failover lost the newest Records. A + read from it works again once the Stream has Records up to that offset (`OUT_OF_RANGE`). """ STREAM_ERROR_REASON_TOO_LARGE: _StreamErrorReason.ValueType # 10 - """A Record or a batch is over the Store's limit. INVALID_ARGUMENT.""" - STREAM_ERROR_REASON_INVALID: _StreamErrorReason.ValueType # 11 - """The request is malformed. INVALID_ARGUMENT.""" - STREAM_ERROR_REASON_STORAGE_UNAVAILABLE: _StreamErrorReason.ValueType # 12 - """The Store failed or did not answer. A retry can succeed. UNAVAILABLE.""" + """A Record or a batch is larger than the Store allows (`INVALID_ARGUMENT`).""" + STREAM_ERROR_REASON_INVALID_ARGUMENT: _StreamErrorReason.ValueType # 11 + """The request is malformed (`INVALID_ARGUMENT`).""" + STREAM_ERROR_REASON_STORE_UNAVAILABLE: _StreamErrorReason.ValueType # 12 + """The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 13 - """The Store lacks a capability that the call needs. UNIMPLEMENTED.""" + """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 14 - """A create with the FAIL conflict policy is for a Stream that exists. ALREADY_EXISTS.""" - STREAM_ERROR_REASON_STORAGE_CORRUPT: _StreamErrorReason.ValueType # 15 - """The Store gave back data that isn't valid, such as a stored value with the wrong length. A - retry reads the same data. DATA_LOSS. + """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" + STREAM_ERROR_REASON_STORE_CORRUPT: _StreamErrorReason.ValueType # 15 + """The Store returned data that isn't valid, such as a stored value of the wrong length. A + retry reads the same data (`DATA_LOSS`). """ class StreamErrorReason( _StreamErrorReason, metaclass=_StreamErrorReasonEnumTypeWrapper ): """Experimental. Might change in the future. - Why a Stream call failed. Each reason has one gRPC status code, and several reasons share a - code. So code matches on the reason, and not on the status code. An SDK raises one error type - that carries the reason. + Why a Stream call failed. Each reason maps to one gRPC status code, shown in parentheses, and + several reasons share a code. So callers check the reason and not the status code. An SDK + raises one error type with the reason in it. """ STREAM_ERROR_REASON_UNSPECIFIED: StreamErrorReason.ValueType # 0 STREAM_ERROR_REASON_NOT_FOUND: StreamErrorReason.ValueType # 1 -"""Nobody created the Stream. NOT_FOUND.""" +"""The Stream was never created (`NOT_FOUND`).""" STREAM_ERROR_REASON_EXPIRED: StreamErrorReason.ValueType # 2 -"""The Stream's Retention or its last-write TTL passed. NOT_FOUND.""" +"""The Retention of the Stream or its Producer idle TTL has passed (`NOT_FOUND`).""" STREAM_ERROR_REASON_CLOSED: StreamErrorReason.ValueType # 3 -"""The Stream is closed. FAILED_PRECONDITION.""" +"""The Stream is closed (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_FENCED: StreamErrorReason.ValueType # 4 -"""The Producer's epoch is lower than the newest one. FAILED_PRECONDITION.""" +"""A later attempt of the same Producer has already written, and the Store fences +(`FAILED_PRECONDITION`). +""" STREAM_ERROR_REASON_SEQUENCE_TOO_LOW: StreamErrorReason.ValueType # 5 -"""The batch has a lower `sequence` than the last one of its epoch. FAILED_PRECONDITION.""" +"""The `sequence` of an append is lower than the `sequence` of the last batch of its attempt +(`FAILED_PRECONDITION`). +""" STREAM_ERROR_REASON_SEQ_DIVERGENT: StreamErrorReason.ValueType # 6 -"""The batch has the `sequence` of the last one of its epoch, and other content. -FAILED_PRECONDITION. +"""The batch has the same `sequence` as the last one of its attempt, but different content +(`FAILED_PRECONDITION`). """ -STREAM_ERROR_REASON_NOT_OWNER: StreamErrorReason.ValueType # 7 -"""The caller may not create or close this Stream. FAILED_PRECONDITION.""" STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 8 -"""A newer format version wrote the Stream. FAILED_PRECONDITION.""" +"""The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 9 -"""The offset is past the newest offset, for example after a failover lost the newest Records. -A read from it works again once the Stream has Records up to it. OUT_OF_RANGE. +"""The offset is past the newest one, for example after a failover lost the newest Records. A +read from it works again once the Stream has Records up to that offset (`OUT_OF_RANGE`). """ STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 10 -"""A Record or a batch is over the Store's limit. INVALID_ARGUMENT.""" -STREAM_ERROR_REASON_INVALID: StreamErrorReason.ValueType # 11 -"""The request is malformed. INVALID_ARGUMENT.""" -STREAM_ERROR_REASON_STORAGE_UNAVAILABLE: StreamErrorReason.ValueType # 12 -"""The Store failed or did not answer. A retry can succeed. UNAVAILABLE.""" +"""A Record or a batch is larger than the Store allows (`INVALID_ARGUMENT`).""" +STREAM_ERROR_REASON_INVALID_ARGUMENT: StreamErrorReason.ValueType # 11 +"""The request is malformed (`INVALID_ARGUMENT`).""" +STREAM_ERROR_REASON_STORE_UNAVAILABLE: StreamErrorReason.ValueType # 12 +"""The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 13 -"""The Store lacks a capability that the call needs. UNIMPLEMENTED.""" +"""The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 14 -"""A create with the FAIL conflict policy is for a Stream that exists. ALREADY_EXISTS.""" -STREAM_ERROR_REASON_STORAGE_CORRUPT: StreamErrorReason.ValueType # 15 -"""The Store gave back data that isn't valid, such as a stored value with the wrong length. A -retry reads the same data. DATA_LOSS. +"""A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" +STREAM_ERROR_REASON_STORE_CORRUPT: StreamErrorReason.ValueType # 15 +"""The Store returned data that isn't valid, such as a stored value of the wrong length. A +retry reads the same data (`DATA_LOSS`). """ global___StreamErrorReason = StreamErrorReason diff --git a/temporalio/api/stream/v1/__init__.py b/temporalio/api/stream/v1/__init__.py index 73024c06b8..df6cae9436 100644 --- a/temporalio/api/stream/v1/__init__.py +++ b/temporalio/api/stream/v1/__init__.py @@ -1,29 +1,29 @@ from .message_pb2 import ( - ActivityEpoch, + ActivityAttempt, ActivityProducer, AppendRecord, ClientProducer, - LocalActivityEpoch, + LocalActivityAttempt, LocalActivityProducer, Producer, StreamErrorDetails, StreamRecord, StreamRef, WorkflowProducer, - WorkflowTaskEpoch, + WorkflowTaskAttempt, ) __all__ = [ - "ActivityEpoch", + "ActivityAttempt", "ActivityProducer", "AppendRecord", "ClientProducer", - "LocalActivityEpoch", + "LocalActivityAttempt", "LocalActivityProducer", "Producer", "StreamErrorDetails", "StreamRecord", "StreamRef", "WorkflowProducer", - "WorkflowTaskEpoch", + "WorkflowTaskAttempt", ] diff --git a/temporalio/api/stream/v1/message_pb2.py b/temporalio/api/stream/v1/message_pb2.py index 5bac69d283..444f9d2f18 100644 --- a/temporalio/api/stream/v1/message_pb2.py +++ b/temporalio/api/stream/v1/message_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"p\n\x11WorkflowTaskEpoch\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"^\n\x12LocalActivityEpoch\x12\x37\n\x04task\x18\x01 \x01(\x0b\x32).temporal.api.stream.v1.WorkflowTaskEpoch\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\\\n\rActivityEpoch\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\\\n\x10WorkflowProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x38\n\x05\x65poch\x18\x02 \x01(\x0b\x32).temporal.api.stream.v1.WorkflowTaskEpoch"b\n\x15LocalActivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x39\n\x05\x65poch\x18\x02 \x01(\x0b\x32*.temporal.api.stream.v1.LocalActivityEpoch"X\n\x10\x41\x63tivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x34\n\x05\x65poch\x18\x02 \x01(\x0b\x32%.temporal.api.stream.v1.ActivityEpoch"\x10\n\x0e\x43lientProducer"\xef\x02\n\x08Producer\x12\n\n\x02id\x18\x01 \x01(\t\x12<\n\x08workflow\x18\x02 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x03 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12\x45\n\x11workflow_activity\x18\x04 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12G\n\x13standalone_activity\x18\x05 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x06 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' + b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"`\n\x10WorkflowProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12<\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"f\n\x15LocalActivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12=\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\\\n\x10\x41\x63tivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x10\n\x0e\x43lientProducer"\xef\x02\n\x08Producer\x12\n\n\x02id\x18\x01 \x01(\t\x12<\n\x08workflow\x18\x02 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x03 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12\x45\n\x11workflow_activity\x18\x04 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12G\n\x13standalone_activity\x18\x05 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x06 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -33,26 +33,26 @@ DESCRIPTOR._serialized_options = b"\n\031io.temporal.api.stream.v1B\014MessageProtoP\001Z#go.temporal.io/api/stream/v1;stream\252\002\030Temporalio.Api.Stream.V1\352\002\033Temporalio::Api::Stream::V1" _STREAMREF._serialized_start = 171 _STREAMREF._serialized_end = 209 - _WORKFLOWTASKEPOCH._serialized_start = 211 - _WORKFLOWTASKEPOCH._serialized_end = 323 - _LOCALACTIVITYEPOCH._serialized_start = 325 - _LOCALACTIVITYEPOCH._serialized_end = 419 - _ACTIVITYEPOCH._serialized_start = 421 - _ACTIVITYEPOCH._serialized_end = 513 - _WORKFLOWPRODUCER._serialized_start = 515 - _WORKFLOWPRODUCER._serialized_end = 607 - _LOCALACTIVITYPRODUCER._serialized_start = 609 - _LOCALACTIVITYPRODUCER._serialized_end = 707 - _ACTIVITYPRODUCER._serialized_start = 709 - _ACTIVITYPRODUCER._serialized_end = 797 - _CLIENTPRODUCER._serialized_start = 799 - _CLIENTPRODUCER._serialized_end = 815 - _PRODUCER._serialized_start = 818 - _PRODUCER._serialized_end = 1185 - _APPENDRECORD._serialized_start = 1187 - _APPENDRECORD._serialized_end = 1248 - _STREAMRECORD._serialized_start = 1251 - _STREAMRECORD._serialized_end = 1380 - _STREAMERRORDETAILS._serialized_start = 1382 - _STREAMERRORDETAILS._serialized_end = 1460 + _WORKFLOWTASKATTEMPT._serialized_start = 211 + _WORKFLOWTASKATTEMPT._serialized_end = 325 + _LOCALACTIVITYATTEMPT._serialized_start = 327 + _LOCALACTIVITYATTEMPT._serialized_end = 425 + _ACTIVITYATTEMPT._serialized_start = 427 + _ACTIVITYATTEMPT._serialized_end = 521 + _WORKFLOWPRODUCER._serialized_start = 523 + _WORKFLOWPRODUCER._serialized_end = 619 + _LOCALACTIVITYPRODUCER._serialized_start = 621 + _LOCALACTIVITYPRODUCER._serialized_end = 723 + _ACTIVITYPRODUCER._serialized_start = 725 + _ACTIVITYPRODUCER._serialized_end = 817 + _CLIENTPRODUCER._serialized_start = 819 + _CLIENTPRODUCER._serialized_end = 835 + _PRODUCER._serialized_start = 838 + _PRODUCER._serialized_end = 1205 + _APPENDRECORD._serialized_start = 1207 + _APPENDRECORD._serialized_end = 1268 + _STREAMRECORD._serialized_start = 1271 + _STREAMRECORD._serialized_end = 1400 + _STREAMERRORDETAILS._serialized_start = 1402 + _STREAMERRORDETAILS._serialized_end = 1480 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 1d01036026..0d4d8c0674 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -18,8 +18,8 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class StreamRef(google.protobuf.message.Message): """Experimental. Might change in the future. - Identifies one Stream. The id is opaque to callers. A Stream has no incarnations. A create of a - closed or expired Stream fails, and it doesn't make a second Stream with the same id. + A reference to one Stream. Callers treat the id as opaque. An id is never used for a second + Stream, so a create for a closed or expired Stream fails. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -28,11 +28,10 @@ class StreamRef(google.protobuf.message.Message): STORE_FIELD_NUMBER: builtins.int id: builtins.str store: builtins.str - """The name of the Store that holds the Stream, as the Worker and client config register it, - so every process routes a ref it receives. With no name, the SDK picks the Store from its - config. Only an SDK sets and reads it, since only the SDK knows the name that its config - gives a Store. A request carries the whole ref, and the server and a Store ignore this - field. + """The name under which the client and Worker config registered the Store of this Stream. An + SDK uses it to send a call on this ref to the right Store. When it's empty, the SDK picks + the Store from its config. Only an SDK sets and reads this field. The server and a Store + ignore it. """ def __init__( self, @@ -47,12 +46,12 @@ class StreamRef(google.protobuf.message.Message): global___StreamRef = StreamRef @typing.final -class WorkflowTaskEpoch(google.protobuf.message.Message): +class WorkflowTaskAttempt(google.protobuf.message.Message): """Experimental. Might change in the future. - One Workflow Task attempt of a run. It orders by started_event_id, then attempt, then - started_time. An epoch orders the attempts of one Producer only, and a Producer belongs to one - run. So a reset run and the next run of a chain have other Producers, and their epochs start - again. + One attempt of a Workflow Task. Two attempts of the same Producer compare by + `started_event_id`, then `attempt`, then `started_time`. Attempts of different Producers have + no order. A Producer is for one run, so the attempts of a reset run or of the next run in a + chain have no order with the attempts of this run. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -63,11 +62,14 @@ class WorkflowTaskEpoch(google.protobuf.message.Message): started_event_id: builtins.int """Required.""" attempt: builtins.int - """Required. 1 or more.""" + """Required. The attempt number of the task, starting at 1. Every task starts at 1 again, so + this number alone can't order the writes of a run. + """ @property def started_time(self) -> google.protobuf.timestamp_pb2.Timestamp: - """Tells a reused started event id apart, for example after a dropped speculative task. Core - leaves it empty when the server gave the task no started time. + """When this attempt started. The server can use a started event id for a second task, for + example after it drops a speculative task, and this time distinguishes the two. It's empty + when the server sent no started time for the task. """ def __init__( @@ -92,14 +94,14 @@ class WorkflowTaskEpoch(google.protobuf.message.Message): ], ) -> None: ... -global___WorkflowTaskEpoch = WorkflowTaskEpoch +global___WorkflowTaskAttempt = WorkflowTaskAttempt @typing.final -class LocalActivityEpoch(google.protobuf.message.Message): +class LocalActivityAttempt(google.protobuf.message.Message): """Experimental. Might change in the future. - The attempt of a Local Activity. It orders by task, then attempt, so the same call in a later - Workflow Task is a higher epoch. The Producer carries the run. Records of two runs have no - order by epoch, only their order in the Stream. + One attempt of a Local Activity. Two attempts compare by `task`, then `attempt`, so the same + call in a later Workflow Task is a later attempt. Attempts of two runs have no order. Their + Records have only their order in the Stream. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -107,15 +109,15 @@ class LocalActivityEpoch(google.protobuf.message.Message): TASK_FIELD_NUMBER: builtins.int ATTEMPT_FIELD_NUMBER: builtins.int attempt: builtins.int - """Required. The Local Activity's own attempt in that Workflow Task, 1 or more.""" + """Required. The Local Activity's own attempt number within that Workflow Task, starting at 1.""" @property - def task(self) -> global___WorkflowTaskEpoch: + def task(self) -> global___WorkflowTaskAttempt: """Required. The Workflow Task attempt that dispatched the Local Activity.""" def __init__( self, *, - task: global___WorkflowTaskEpoch | None = ..., + task: global___WorkflowTaskAttempt | None = ..., attempt: builtins.int = ..., ) -> None: ... def HasField( @@ -125,12 +127,12 @@ class LocalActivityEpoch(google.protobuf.message.Message): self, field_name: typing.Literal["attempt", b"attempt", "task", b"task"] ) -> None: ... -global___LocalActivityEpoch = LocalActivityEpoch +global___LocalActivityAttempt = LocalActivityAttempt @typing.final -class ActivityEpoch(google.protobuf.message.Message): +class ActivityAttempt(google.protobuf.message.Message): """Experimental. Might change in the future. - The attempt of an Activity. It orders by attempt_scheduled_time, then attempt. + One attempt of an Activity. Two attempts compare by `attempt_scheduled_time`, then `attempt`. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -138,11 +140,11 @@ class ActivityEpoch(google.protobuf.message.Message): ATTEMPT_SCHEDULED_TIME_FIELD_NUMBER: builtins.int ATTEMPT_FIELD_NUMBER: builtins.int attempt: builtins.int - """Required. 1 or more.""" + """Required. The attempt number, starting at 1.""" @property def attempt_scheduled_time(self) -> google.protobuf.timestamp_pb2.Timestamp: - """Required. When the server scheduled this attempt. An Activity reset starts the attempt count - again, so only this time orders the attempts across a reset. + """Required. When the server scheduled this attempt. A reset of the Activity starts the + attempt number at 1 again, so this time is what orders the attempts across a reset. """ def __init__( @@ -162,37 +164,41 @@ class ActivityEpoch(google.protobuf.message.Message): ], ) -> None: ... -global___ActivityEpoch = ActivityEpoch +global___ActivityAttempt = ActivityAttempt @typing.final class WorkflowProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - A Workflow run Producer. On the server's Streams, a Workflow writes as this Producer in its - Workflow Task. On a Store, Workflow code writes through a Local Activity, so its writes carry a - Local Activity Producer. + The Producer of a Workflow run. Workflow code writes as this Producer when it appends or + closes in a Workflow Task. A write from one of its Local Activities uses a + `LocalActivityProducer`. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor RUN_ID_FIELD_NUMBER: builtins.int - EPOCH_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int run_id: builtins.str - """Required. The run id of the Workflow run, not of its chain. Each run is its own Producer.""" + """Required. The id of this run, not the first run id of its chain. Each run is a separate + Producer. + """ @property - def epoch(self) -> global___WorkflowTaskEpoch: - """The Workflow Task of the write.""" + def attempt(self) -> global___WorkflowTaskAttempt: + """The Workflow Task attempt that makes the write. Workflow code leaves it empty, and the SDK + sets it before it sends the write to the Store. + """ def __init__( self, *, run_id: builtins.str = ..., - epoch: global___WorkflowTaskEpoch | None = ..., + attempt: global___WorkflowTaskAttempt | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["epoch", b"epoch"] + self, field_name: typing.Literal["attempt", b"attempt"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["epoch", b"epoch", "run_id", b"run_id"] + self, field_name: typing.Literal["attempt", b"attempt", "run_id", b"run_id"] ) -> None: ... global___WorkflowProducer = WorkflowProducer @@ -200,30 +206,30 @@ global___WorkflowProducer = WorkflowProducer @typing.final class LocalActivityProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - A Local Activity Producer, one for each call of a run. + The Producer of one Local Activity call of a Workflow run. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor RUN_ID_FIELD_NUMBER: builtins.int - EPOCH_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int run_id: builtins.str - """Required. The run id of the Workflow run.""" + """Required. The id of the Workflow run that made the call.""" @property - def epoch(self) -> global___LocalActivityEpoch: + def attempt(self) -> global___LocalActivityAttempt: """Required.""" def __init__( self, *, run_id: builtins.str = ..., - epoch: global___LocalActivityEpoch | None = ..., + attempt: global___LocalActivityAttempt | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["epoch", b"epoch"] + self, field_name: typing.Literal["attempt", b"attempt"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["epoch", b"epoch", "run_id", b"run_id"] + self, field_name: typing.Literal["attempt", b"attempt", "run_id", b"run_id"] ) -> None: ... global___LocalActivityProducer = LocalActivityProducer @@ -231,32 +237,32 @@ global___LocalActivityProducer = LocalActivityProducer @typing.final class ActivityProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - An Activity Producer, for an Activity of a Workflow or a Standalone Activity. + The Producer of an Activity that a Workflow scheduled, or of a Standalone Activity. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor RUN_ID_FIELD_NUMBER: builtins.int - EPOCH_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int run_id: builtins.str - """The run id of the Workflow run that scheduled the Activity. Empty for a Standalone - Activity, whose own run id is in the Producer id. + """The id of the Workflow run that scheduled the Activity. It's empty for a Standalone + Activity, whose own run id is part of the Producer id. """ @property - def epoch(self) -> global___ActivityEpoch: + def attempt(self) -> global___ActivityAttempt: """Required.""" def __init__( self, *, run_id: builtins.str = ..., - epoch: global___ActivityEpoch | None = ..., + attempt: global___ActivityAttempt | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["epoch", b"epoch"] + self, field_name: typing.Literal["attempt", b"attempt"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["epoch", b"epoch", "run_id", b"run_id"] + self, field_name: typing.Literal["attempt", b"attempt", "run_id", b"run_id"] ) -> None: ... global___ActivityProducer = ActivityProducer @@ -264,8 +270,8 @@ global___ActivityProducer = ActivityProducer @typing.final class ClientProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - A client Producer. A client has no run and no epoch. So nothing fences a client's writes, and a - reader never hides them. + The Producer of a client. A client has no run and no attempt, so a Store never fences its + writes and a reader never hides them. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -279,12 +285,16 @@ global___ClientProducer = ClientProducer @typing.final class Producer(google.protobuf.message.Message): """Experimental. Might change in the future. - The code that wrote a batch, which is one unit of work. Its id stays the same across attempts, - and an epoch is one attempt. The kind's case orders its epochs. After a write of a higher epoch, - a write of a lower epoch of the same Producer fails with FENCED, and a reader may hide the - Records of the lower epoch. The rule is the same for every kind that has an epoch. A client has - none. The epochs of two Producers never compare. A new run has new Producers, so no write - fences or supersedes the Records of an earlier run, such as the base run of a reset. + The writer of a batch of Records. A Producer is one unit of work, such as one Activity or one + Workflow run. Its `id` is the same on every attempt, and every kind except a client also has + the attempt that made the write. + + A Store that fences fails a write with `FENCED` when a later attempt of the same Producer has + already written. A Store that doesn't fence accepts the write. Each Record has its Producer + and attempt either way, so a reader can hide the Records of an earlier attempt. + + Attempts of different Producers have no order. A new run has new Producers, so no write fences + or supersedes the Records of an earlier run, such as the base run of a reset. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -296,9 +306,9 @@ class Producer(google.protobuf.message.Message): STANDALONE_ACTIVITY_FIELD_NUMBER: builtins.int CLIENT_FIELD_NUMBER: builtins.int id: builtins.str - """Required. Stable across attempts, such as `wf:` for the Workflow Producer of a run. - It is unique in one Stream. The id of a run-based kind has its run id, so it stays unique - when Producers of more than one namespace write to one Stream. + """Required. The same on every attempt, for example `wf:` for the Producer of a + Workflow run. It's unique within one Stream. The id of a kind with a run contains the run + id, so it stays unique when Producers from several namespaces write to one Stream. """ @property def workflow(self) -> global___WorkflowProducer: ... @@ -310,8 +320,8 @@ class Producer(google.protobuf.message.Message): @property def standalone_activity(self) -> global___ActivityProducer: - """An Activity with no Workflow. Both Activity cases order their epochs the same way. The - case tells which identity the Producer has, since only the first has a Workflow run. + """A Standalone Activity. Its attempts compare as those of a Workflow's Activity do. It's a + separate case because it has no Workflow run. """ @property @@ -380,7 +390,8 @@ global___Producer = Producer @typing.final class AppendRecord(google.protobuf.message.Message): """Experimental. Might change in the future. - One Record of a batch to append. The Store adds the batch's Producer and an offset. + One Record of a batch to append. The Store stores it with the Producer of the batch and + assigns its offset. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -405,8 +416,8 @@ global___AppendRecord = AppendRecord @typing.final class StreamRecord(google.protobuf.message.Message): """Experimental. Might change in the future. - One Record that a Producer appended, as a read gives it. A read gives only Records. A close - stores no Record, so a read tells of it with the done flag of its response. + One Record of a Stream, as a read returns it. A read returns only Records. A close stores no + Record, so a read reports it with `done` in its response. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -415,11 +426,11 @@ class StreamRecord(google.protobuf.message.Message): BODY_FIELD_NUMBER: builtins.int OFFSET_FIELD_NUMBER: builtins.int offset: builtins.bytes - """Required. The Record's offset. An offset is ordered and unique in one Stream, and it is - sparse. Offsets have gaps, so they don't count Records. Two offsets of one Stream compare - bytewise, as unsigned bytes, in the order of their Records. So a reader, a Store and the - server order them without decoding them. An offset is never empty. A read gives its - Stream, so the read checks the offset against that Stream. + """Required. The position of this Record in its Stream. It's never empty. Offsets are unique + and ordered within one Stream, but they have gaps, so they don't count Records. Two offsets + of one Stream compare as unsigned bytes, in the order of their Records, so a reader, a + Store and the server can order them without decoding them. An offset doesn't identify + its Stream, so a read checks it against the Stream of the request. """ @property def producer(self) -> global___Producer: ... @@ -447,8 +458,8 @@ global___StreamRecord = StreamRecord @typing.final class StreamErrorDetails(google.protobuf.message.Message): """Experimental. Might change in the future. - The details of a failed Stream call, in the gRPC status details and in the details of the - application failure of a Nexus operation. + The details of a failed Stream call. They're in the gRPC status details, and in the details + of the application failure when the call is a Nexus operation. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/temporalio/api/streamservice/v1/request_response_pb2.py b/temporalio/api/streamservice/v1/request_response_pb2.py index 161aa0c07b..556762715f 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.py +++ b/temporalio/api/streamservice/v1/request_response_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\xbe\x01\n\x13\x43reateStreamRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x35\n\nstream_ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x03 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy\x12\x12\n\nrequest_id\x18\x04 \x01(\t"W\n\x14\x43reateStreamResponse\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xd6\x01\n\x14\x41ppendRecordsRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x03 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x10\n\x08sequence\x18\x04 \x01(\x03\x12\x35\n\x07records\x18\x05 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"\x8b\x01\n\x12\x43loseStreamRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x03 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\xbd\x01\n\x12ReadRecordsRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x04 \x01(\x05\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x11\n\tmax_bytes\x18\x06 \x01(\x03"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"Z\n\x15\x44\x65scribeStreamRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' + b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\xab\x01\n\x13\x43reateStreamRequest\x12\x35\n\nstream_ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy\x12\x12\n\nrequest_id\x18\x03 \x01(\t"W\n\x14\x43reateStreamResponse\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xc3\x01\n\x14\x41ppendRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x10\n\x08sequence\x18\x03 \x01(\x03\x12\x35\n\x07records\x18\x04 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"x\n\x12\x43loseStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\xaa\x01\n\x12ReadRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"G\n\x15\x44\x65scribeStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -32,23 +32,23 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n io.temporal.api.streamservice.v1B\024RequestResponseProtoP\001Z1go.temporal.io/api/streamservice/v1;streamservice\252\002\037Temporalio.Api.StreamService.V1\352\002"Temporalio::Api::StreamService::V1' _CREATESTREAMREQUEST._serialized_start = 194 - _CREATESTREAMREQUEST._serialized_end = 384 - _CREATESTREAMRESPONSE._serialized_start = 386 - _CREATESTREAMRESPONSE._serialized_end = 473 - _APPENDRECORDSREQUEST._serialized_start = 476 - _APPENDRECORDSREQUEST._serialized_end = 690 - _APPENDRECORDSRESPONSE._serialized_start = 692 - _APPENDRECORDSRESPONSE._serialized_end = 758 - _CLOSESTREAMREQUEST._serialized_start = 761 - _CLOSESTREAMREQUEST._serialized_end = 900 - _CLOSESTREAMRESPONSE._serialized_start = 902 - _CLOSESTREAMRESPONSE._serialized_end = 923 - _READRECORDSREQUEST._serialized_start = 926 - _READRECORDSREQUEST._serialized_end = 1115 - _READRECORDSRESPONSE._serialized_start = 1117 - _READRECORDSRESPONSE._serialized_end = 1228 - _DESCRIBESTREAMREQUEST._serialized_start = 1230 - _DESCRIBESTREAMREQUEST._serialized_end = 1320 - _DESCRIBESTREAMRESPONSE._serialized_start = 1322 - _DESCRIBESTREAMRESPONSE._serialized_end = 1420 + _CREATESTREAMREQUEST._serialized_end = 365 + _CREATESTREAMRESPONSE._serialized_start = 367 + _CREATESTREAMRESPONSE._serialized_end = 454 + _APPENDRECORDSREQUEST._serialized_start = 457 + _APPENDRECORDSREQUEST._serialized_end = 652 + _APPENDRECORDSRESPONSE._serialized_start = 654 + _APPENDRECORDSRESPONSE._serialized_end = 720 + _CLOSESTREAMREQUEST._serialized_start = 722 + _CLOSESTREAMREQUEST._serialized_end = 842 + _CLOSESTREAMRESPONSE._serialized_start = 844 + _CLOSESTREAMRESPONSE._serialized_end = 865 + _READRECORDSREQUEST._serialized_start = 868 + _READRECORDSREQUEST._serialized_end = 1038 + _READRECORDSRESPONSE._serialized_start = 1040 + _READRECORDSRESPONSE._serialized_end = 1151 + _DESCRIBESTREAMREQUEST._serialized_start = 1153 + _DESCRIBESTREAMREQUEST._serialized_end = 1224 + _DESCRIBESTREAMRESPONSE._serialized_start = 1226 + _DESCRIBESTREAMRESPONSE._serialized_end = 1324 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index 5ae5b08e50..e5a5d29a80 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -20,41 +20,39 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class CreateStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Creates the Stream. When the Stream exists, FAIL fails with ALREADY_EXISTS, and USE_EXISTING - gets it with created false. A retry of the create that made the Stream, with the same - request_id, gets created true. Each policy fails with CLOSED on a closed Stream and EXPIRED on - an expired one. A create takes no Retention. The Store config holds it, as a namespace holds - the Retention of its Workflows. + Creates a Stream. If the Stream already exists, the result depends on `id_conflict_policy`. + `FAIL` fails with `ALREADY_EXISTS`, and `USE_EXISTING` returns the Stream with `created` + false. A retry of the create that made the Stream, with the same `request_id`, returns + `created` true. Either policy fails with `CLOSED` for a closed Stream and with `EXPIRED` for + an expired one. + + A create has no Retention. Retention is a setting of the Store, as it's a setting of the + namespace for Workflows. (-- api-linter: core::0133=disabled - aip.dev/not-precedent: The request identifies a Stream by namespace and ref. --) + aip.dev/not-precedent: The request identifies a Stream by its ref. --) """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - NAMESPACE_FIELD_NUMBER: builtins.int STREAM_REF_FIELD_NUMBER: builtins.int ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int REQUEST_ID_FIELD_NUMBER: builtins.int - namespace: builtins.str - """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't - read it. - """ id_conflict_policy: ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType ) - """What the create does when the Stream exists. Unspecified is FAIL.""" + """What the create does if the Stream already exists. Unspecified means `FAIL`.""" request_id: builtins.str - """Unique for each create call, and the same on its retries. The Store keeps the request_id of - the create that made the Stream, so a retry after a lost answer doesn't get ALREADY_EXISTS. + """A value that's unique to this create call and the same on its retries. The Store remembers + the `request_id` of the create that made the Stream, so a retry after a lost response + doesn't fail with `ALREADY_EXISTS`. """ @property def stream_ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required. The ref of the Stream to create. Its id is the Stream id, and is never empty.""" + """Required. The Stream to create. Its `id` must not be empty.""" def __init__( self, *, - namespace: builtins.str = ..., stream_ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., id_conflict_policy: temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType = ..., request_id: builtins.str = ..., @@ -67,8 +65,6 @@ class CreateStreamRequest(google.protobuf.message.Message): field_name: typing.Literal[ "id_conflict_policy", b"id_conflict_policy", - "namespace", - b"namespace", "request_id", b"request_id", "stream_ref", @@ -81,7 +77,7 @@ global___CreateStreamRequest = CreateStreamRequest @typing.final class CreateStreamResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - The Stream that a create made or got. + The Stream that the create made or found. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -89,12 +85,12 @@ class CreateStreamResponse(google.protobuf.message.Message): REF_FIELD_NUMBER: builtins.int CREATED_FIELD_NUMBER: builtins.int created: builtins.bool - """False when USE_EXISTING got a Stream that existed.""" + """False when `USE_EXISTING` returned a Stream that already existed.""" @property def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """The ref of the Stream, which the caller passes on as data. The SDK sets the name of the - Store that it picked, also when the request left the name empty. The server gives the ref - back as the request had it, since it doesn't know that name. + """The ref of the Stream. The caller can pass it to other code as data. A Store and the server + return the ref as the request had it, because they don't know the Store names of an SDK. + The SDK then sets `store` to the Store that it picked, before the caller gets the ref. """ def __init__( @@ -113,24 +109,21 @@ global___CreateStreamResponse = CreateStreamResponse @typing.final class AppendRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Appends one batch of Records as one Producer. The Store writes a resent batch, with the same - Producer, epoch and sequence, only once. + Appends one batch of Records as one Producer. If the same batch arrives again, with the same + Producer, attempt and `sequence`, the Store writes it only once. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - NAMESPACE_FIELD_NUMBER: builtins.int REF_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int SEQUENCE_FIELD_NUMBER: builtins.int RECORDS_FIELD_NUMBER: builtins.int - namespace: builtins.str - """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't - read it. - """ sequence: builtins.int - """The batch number in this epoch. With the Producer and epoch it is the dedupe key. Zero takes - the next number of the epoch. Such a batch has no dedupe, so a retry writes it again. + """The idempotency number of this batch within its attempt. A caller that got no response + sends the batch again with the same number, and the Store uses the Producer, the attempt + and this number to write it only once. With zero, the Store assigns the next number, and a + retry of that batch is written again. """ @property def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: @@ -138,8 +131,8 @@ class AppendRecordsRequest(google.protobuf.message.Message): @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: - """Required. The Producer of the batch. An append and a close of one Producer carry the same - Producer, so the Store orders each write the same way. + """Required. The Producer that writes the batch. A Producer sends the same value in its + appends and in its close, so the Store orders all of its writes the same way. """ @property @@ -151,7 +144,6 @@ class AppendRecordsRequest(google.protobuf.message.Message): def __init__( self, *, - namespace: builtins.str = ..., ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., sequence: builtins.int = ..., @@ -166,8 +158,6 @@ class AppendRecordsRequest(google.protobuf.message.Message): def ClearField( self, field_name: typing.Literal[ - "namespace", - b"namespace", "producer", b"producer", "records", @@ -184,7 +174,7 @@ global___AppendRecordsRequest = AppendRecordsRequest @typing.final class AppendRecordsResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - Where the batch's Records are in the Stream. + The offsets of the first and the last Record of the batch. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -211,19 +201,15 @@ global___AppendRecordsResponse = AppendRecordsResponse @typing.final class CloseStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Closes a Stream. Readers drain what is left, then end, and later appends fail with CLOSED. A - close writes no Record and carries no value, so code that has a last value publishes it first. + Closes a Stream. Readers still get the Records that are left, and then their reads end. Later + appends fail with `CLOSED`. A close writes no Record and has no value, so code with a final + value appends it before the close. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - NAMESPACE_FIELD_NUMBER: builtins.int REF_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int - namespace: builtins.str - """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't - read it. - """ @property def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: """Required.""" @@ -235,7 +221,6 @@ class CloseStreamRequest(google.protobuf.message.Message): def __init__( self, *, - namespace: builtins.str = ..., ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., ) -> None: ... @@ -243,10 +228,7 @@ class CloseStreamRequest(google.protobuf.message.Message): self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] ) -> builtins.bool: ... def ClearField( - self, - field_name: typing.Literal[ - "namespace", b"namespace", "producer", b"producer", "ref", b"ref" - ], + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] ) -> None: ... global___CloseStreamRequest = CloseStreamRequest @@ -254,7 +236,7 @@ global___CloseStreamRequest = CloseStreamRequest @typing.final class CloseStreamResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - A close answers when the Store has the close. It gives nothing back. + The response to a close. The Store sends it after it has recorded the close. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -268,34 +250,31 @@ global___CloseStreamResponse = CloseStreamResponse @typing.final class ReadRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Reads one page of Records after an offset. At the end of the Stream, the read waits for a new - Record, so readers long poll. + Reads one page of Records after an offset. When no Record is left, the read waits for a new + one, so a reader long-polls. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - NAMESPACE_FIELD_NUMBER: builtins.int REF_FIELD_NUMBER: builtins.int FROM_OFFSET_FIELD_NUMBER: builtins.int MAX_RECORDS_FIELD_NUMBER: builtins.int - WAIT_FIELD_NUMBER: builtins.int MAX_BYTES_FIELD_NUMBER: builtins.int - namespace: builtins.str - """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't - read it. - """ + WAIT_FIELD_NUMBER: builtins.int from_offset: builtins.bytes - """Read after this offset. It fails with OFFSET_TOO_HIGH if it is past the newest offset. - Leave empty to read from the beginning. To read only new Records, a caller gets last_offset - from a describe and reads after it. + """The read returns the Records after this offset. Empty means from the beginning. An offset + past the newest one fails with `OFFSET_TOO_HIGH`. To read only new Records, a caller gets + `last_offset` from a describe and reads after it. (-- api-linter: core::0140::prepositions=disabled aip.dev/not-precedent: "from" marks the start of a range of offsets. --) """ max_records: builtins.int - """The most Records in one page. Zero is 1000.""" + """The maximum number of Records in one page. Zero means no limit.""" max_bytes: builtins.int - """The most Record bytes in one page, so a page fits the caller's limit, such as a History - marker. A larger Record still comes alone, so the read always moves on. Zero is no cap. + """The maximum total size of the Records in one page, in bytes. A caller sets it so that a + page fits a limit of its own, such as the size of a History marker. A Record larger than + this is still returned, alone in its page, so a read always makes progress. Zero means no + limit. """ @property def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: @@ -303,19 +282,18 @@ class ReadRecordsRequest(google.protobuf.message.Message): @property def wait(self) -> google.protobuf.duration_pb2.Duration: - """How long the read waits for a new Record before it answers with an empty page. Empty answers - at once, and a wait longer than 60 s waits 60 s. + """How long the read waits for a new Record before it returns an empty page. When it's unset, + the read returns immediately. The deadline of the request must be longer than this wait. """ def __init__( self, *, - namespace: builtins.str = ..., ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., from_offset: builtins.bytes = ..., max_records: builtins.int = ..., - wait: google.protobuf.duration_pb2.Duration | None = ..., max_bytes: builtins.int = ..., + wait: google.protobuf.duration_pb2.Duration | None = ..., ) -> None: ... def HasField( self, field_name: typing.Literal["ref", b"ref", "wait", b"wait"] @@ -329,8 +307,6 @@ class ReadRecordsRequest(google.protobuf.message.Message): b"max_bytes", "max_records", b"max_records", - "namespace", - b"namespace", "ref", b"ref", "wait", @@ -352,15 +328,14 @@ class ReadRecordsResponse(google.protobuf.message.Message): LAST_OFFSET_FIELD_NUMBER: builtins.int DONE_FIELD_NUMBER: builtins.int last_offset: builtins.bytes - """The last offset that this read covered, which is the offset of the newest Record of the - page. The next read gives it as from_offset and starts after it. An empty page gives the - request's from_offset, and that is empty when the request had none. So it is always - known, and an empty value means that the next read starts as this one did. + """The offset of the last Record in this page. The next read passes it as `from_offset`. For + an empty page it's the `from_offset` of the request, so it's empty only when the request + had none, and the next read then starts where this one did. """ done: builtins.bool - """True when the Stream is closed and this read gave its last Record. It is the only sign of a - close in a read, since a close stores no Record. A read of a closed Stream with no Record - left answers at once with done. + """True when the Stream is closed and this page has its last Record. A read has no other sign + of a close, because a close stores no Record. A read of a closed Stream with no Record left + returns immediately with `done`. """ @property def records( @@ -395,12 +370,7 @@ class DescribeStreamRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - NAMESPACE_FIELD_NUMBER: builtins.int REF_FIELD_NUMBER: builtins.int - namespace: builtins.str - """The caller's namespace. Only read by the server. The SDK sets it, and the SDK Stores don't - read it. - """ @property def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: """Required.""" @@ -408,21 +378,18 @@ class DescribeStreamRequest(google.protobuf.message.Message): def __init__( self, *, - namespace: builtins.str = ..., ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., ) -> None: ... def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["namespace", b"namespace", "ref", b"ref"] - ) -> None: ... + def ClearField(self, field_name: typing.Literal["ref", b"ref"]) -> None: ... global___DescribeStreamRequest = DescribeStreamRequest @typing.final class DescribeStreamResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - The state of a Stream. It has no Retention, since the Retention is a setting of the Store and - not of one Stream. + The state of a Stream. It doesn't include Retention, which is a setting of the Store and not + of one Stream. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -431,7 +398,7 @@ class DescribeStreamResponse(google.protobuf.message.Message): LAST_OFFSET_FIELD_NUMBER: builtins.int status: temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType last_offset: builtins.bytes - """The newest offset, of a Record. Empty when the Stream has none.""" + """The offset of the newest Record. It's empty when the Stream has no Record.""" def __init__( self, *, diff --git a/temporalio/nexus/system/stream_service/__init__.py b/temporalio/nexus/system/stream_service/__init__.py index 35b198843c..a115da5d4a 100644 --- a/temporalio/nexus/system/stream_service/__init__.py +++ b/temporalio/nexus/system/stream_service/__init__.py @@ -1,9 +1,9 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations from .models import ( - ActivityEpoch, + ActivityAttempt, ActivityProducer, AppendRecord, AppendRecordsRequest, @@ -15,7 +15,7 @@ CreateStreamResult, DescribeStreamRequest, DescribeStreamResponse, - LocalActivityEpoch, + LocalActivityAttempt, LocalActivityProducer, Producer, ProducerKind, @@ -32,12 +32,12 @@ StreamStatus, Timestamp, WorkflowProducer, - WorkflowTaskEpoch, + WorkflowTaskAttempt, ) from .services import StreamService __all__ = [ - "ActivityEpoch", + "ActivityAttempt", "ActivityProducer", "AppendRecord", "AppendRecordsRequest", @@ -49,7 +49,7 @@ "CreateStreamResult", "DescribeStreamRequest", "DescribeStreamResponse", - "LocalActivityEpoch", + "LocalActivityAttempt", "LocalActivityProducer", "Producer", "ProducerKind", @@ -66,6 +66,6 @@ "StreamStatus", "Timestamp", "WorkflowProducer", - "WorkflowTaskEpoch", + "WorkflowTaskAttempt", "StreamService", ] diff --git a/temporalio/nexus/system/stream_service/_poll.py b/temporalio/nexus/system/stream_service/_poll.py index a653d84f93..6910c0c5b9 100644 --- a/temporalio/nexus/system/stream_service/_poll.py +++ b/temporalio/nexus/system/stream_service/_poll.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/_resource_context_manager.py b/temporalio/nexus/system/stream_service/_resource_context_manager.py index 86dd499669..fa0c8b6fe9 100644 --- a/temporalio/nexus/system/stream_service/_resource_context_manager.py +++ b/temporalio/nexus/system/stream_service/_resource_context_manager.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/__init__.py b/temporalio/nexus/system/stream_service/client/__init__.py index d2df633d4e..2debc404b6 100644 --- a/temporalio/nexus/system/stream_service/client/__init__.py +++ b/temporalio/nexus/system/stream_service/client/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index c96bb985f8..87e0d44469 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations @@ -159,10 +159,9 @@ async def create_stream( """ Args: id: The Stream id, 1 to 4096 bytes. - store: Registered Store name. With none, the SDK picks one. Only an SDK - reads it. - id_conflict_policy: What the create does when the Stream exists. Unspecified - is fail. + store: The registered name of the Store. If empty, the SDK picks a Store. + id_conflict_policy: What the create does if the Stream already exists. + Unspecified means fail. """ if body_type is None: body_type = typing.Any diff --git a/temporalio/nexus/system/stream_service/client/_resources/__init__.py b/temporalio/nexus/system/stream_service/client/_resources/__init__.py index 250b6a42b7..c4e5635675 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/__init__.py +++ b/temporalio/nexus/system/stream_service/client/_resources/__init__.py @@ -1,3 +1,3 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index a8e320c6f7..90cdebd493 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations @@ -81,7 +81,11 @@ async def append( """Append values, and return the offsets of the batch.""" request = AppendRecordsRequest( ref=self.ref, - producer=((_support.default_producer()) if producer is None else producer), + producer=( + (_support.default_producer(self._nexus_client)) + if producer is None + else producer + ), sequence=sequence, records=[AppendRecord(body=value) for value in records], ) @@ -101,10 +105,14 @@ async def close( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> None: - """Close the Stream. Readers drain what is left, then end.""" + """Close the Stream. Readers get the Records that are left, then end.""" request = CloseStreamRequest( ref=self.ref, - producer=((_support.default_producer()) if producer is None else producer), + producer=( + (_support.default_producer(self._nexus_client)) + if producer is None + else producer + ), ) handle = await self._nexus_client.start_operation( operation=StreamService.close_stream, @@ -130,8 +138,8 @@ async def read_page( ref=self.ref, from_offset=from_offset, max_records=max_records, - wait=wait, max_bytes=max_bytes, + wait=wait, ) handle = await self._nexus_client.start_operation( operation="ReadRecords", @@ -158,20 +166,19 @@ async def read_pages( Read one page of Records. The poll iterator reads them all. Args: - from_offset: Read after this offset. Empty is the beginning. A too high - offset fails. - max_records: About this many Records per page, 1 to 1000. - wait: How long to wait for a new Record before an empty answer. At most 60 - s. - max_bytes: The maximum Record bytes in a page. A larger Record is still + from_offset: Read after this offset. Empty means from the beginning. + max_records: The maximum number of Records in one page. + wait: How long to wait for a new Record before the read returns an empty + page. + max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ request = ReadRecordsRequest( ref=self.ref, from_offset=from_offset, max_records=max_records, - wait=wait, max_bytes=max_bytes, + wait=wait, ) nexus_client = self._nexus_client while True: @@ -208,20 +215,19 @@ def read( Read one page of Records. The poll iterator reads them all. Args: - from_offset: Read after this offset. Empty is the beginning. A too high - offset fails. - max_records: About this many Records per page, 1 to 1000. - wait: How long to wait for a new Record before an empty answer. At most 60 - s. - max_bytes: The maximum Record bytes in a page. A larger Record is still + from_offset: Read after this offset. Empty means from the beginning. + max_records: The maximum number of Records in one page. + wait: How long to wait for a new Record before the read returns an empty + page. + max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ request = ReadRecordsRequest( ref=self.ref, from_offset=from_offset, max_records=max_records, - wait=wait, max_bytes=max_bytes, + wait=wait, ) return PollIterator( request, @@ -244,7 +250,7 @@ async def describe( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> DescribeStreamResponse: - """Describe the Stream's status and newest offset.""" + """Return the status and the newest offset of the Stream.""" request = DescribeStreamRequest( ref=self.ref, ) diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index 4848a2ea58..0d887ca39a 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations @@ -27,7 +27,6 @@ class StreamStatus(enum.IntEnum): StreamStatusUnspecified = 0 StreamStatusOpen = 1 StreamStatusClosed = 2 - StreamStatusExpired = 3 def _stream_status_from_proto(value: int) -> StreamStatus: @@ -44,7 +43,7 @@ def _stream_status_from_proto(value: int) -> StreamStatus: @dataclasses.dataclass(slots=True) class CreateStreamRequest(typing.Generic[BodyT]): - """Create a Stream. If it exists, fail, or with use-existing get the open one.""" + """Create a Stream. If it already exists, fail, or return it with use-existing.""" stream_ref: StreamRef[BodyT] id_conflict_policy: StreamIdConflictPolicy | None = None @@ -114,7 +113,7 @@ def to_transfer_type( @dataclasses.dataclass class StreamRef(typing.Generic[_BodyT]): - """Identifies one Stream. The id is opaque to callers.""" + """A reference to one Stream. Callers treat the id as opaque.""" id: str store: str | None = None @@ -221,9 +220,7 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class AppendRecordsRequest(typing.Generic[BodyT]): - """Append one batch. The Store keeps a resent batch once, by Producer, epoch and - sequence. - """ + """Append one batch. The Store writes a batch that arrives again only once.""" ref: StreamRef[BodyT] records: list[AppendRecord[BodyT]] @@ -354,7 +351,7 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class Producer: - """The code that wrote a batch. A higher epoch fences and supersedes a lower one.""" + """The writer of a batch. A later attempt supersedes an earlier one.""" id: str kind: ProducerKind | None = None @@ -471,10 +468,10 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class WorkflowProducer: - """A Workflow run Producer.""" + """The Producer of a Workflow run.""" run_id: str - epoch: WorkflowTaskEpoch | None = None + attempt: WorkflowTaskAttempt | None = None class _WorkflowProducerTransferTypeConverter( @@ -497,10 +494,10 @@ def from_transfer_type( run_id = value.run_id return WorkflowProducer( run_id=run_id, - epoch=_WorkflowTaskEpochTransferTypeConverter().from_transfer_type( - value.epoch, WorkflowTaskEpoch + attempt=_WorkflowTaskAttemptTransferTypeConverter().from_transfer_type( + value.attempt, WorkflowTaskAttempt ) - if value.HasField("epoch") + if value.HasField("attempt") else None, ) @@ -511,9 +508,11 @@ def to_transfer_type( ) -> temporalio.api.stream.v1.message_pb2.WorkflowProducer: message = temporalio.api.stream.v1.message_pb2.WorkflowProducer() message.run_id = value.run_id - if value.epoch is not None: - message.epoch.CopyFrom( - _WorkflowTaskEpochTransferTypeConverter().to_transfer_type(value.epoch) + if value.attempt is not None: + message.attempt.CopyFrom( + _WorkflowTaskAttemptTransferTypeConverter().to_transfer_type( + value.attempt + ) ) return message @@ -524,32 +523,32 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) -class WorkflowTaskEpoch: - """A Workflow Task attempt of the run.""" +class WorkflowTaskAttempt: + """One attempt of a Workflow Task.""" started_event_id: int attempt: int started_time: Timestamp | None = None -class _WorkflowTaskEpochTransferTypeConverter( +class _WorkflowTaskAttemptTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - WorkflowTaskEpoch, temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch + WorkflowTaskAttempt, temporalio.api.stream.v1.message_pb2.WorkflowTaskAttempt ] ): transfer_type: ( - type[temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch] | None - ) = temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch + type[temporalio.api.stream.v1.message_pb2.WorkflowTaskAttempt] | None + ) = temporalio.api.stream.v1.message_pb2.WorkflowTaskAttempt @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch, - type_hint: type[WorkflowTaskEpoch], - ) -> WorkflowTaskEpoch: + value: temporalio.api.stream.v1.message_pb2.WorkflowTaskAttempt, + type_hint: type[WorkflowTaskAttempt], + ) -> WorkflowTaskAttempt: started_event_id = value.started_event_id attempt = value.attempt - return WorkflowTaskEpoch( + return WorkflowTaskAttempt( started_event_id=started_event_id, attempt=attempt, started_time=_TimestampTransferTypeConverter().from_transfer_type( @@ -562,9 +561,9 @@ def from_transfer_type( @typing_extensions.override def to_transfer_type( self, - value: WorkflowTaskEpoch, - ) -> temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch: - message = temporalio.api.stream.v1.message_pb2.WorkflowTaskEpoch() + value: WorkflowTaskAttempt, + ) -> temporalio.api.stream.v1.message_pb2.WorkflowTaskAttempt: + message = temporalio.api.stream.v1.message_pb2.WorkflowTaskAttempt() message.started_event_id = value.started_event_id message.attempt = value.attempt if value.started_time is not None: @@ -574,9 +573,9 @@ def to_transfer_type( return message -temporalio.converter.transfer_type_convertible(_WorkflowTaskEpochTransferTypeConverter)( - WorkflowTaskEpoch -) # pyright: ignore[reportUnusedCallResult] +temporalio.converter.transfer_type_convertible( + _WorkflowTaskAttemptTransferTypeConverter +)(WorkflowTaskAttempt) # pyright: ignore[reportUnusedCallResult] @dataclasses.dataclass(slots=True) @@ -625,10 +624,10 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class LocalActivityProducer: - """A Local Activity Producer.""" + """The Producer of one Local Activity call.""" run_id: str - epoch: LocalActivityEpoch + attempt: LocalActivityAttempt class _LocalActivityProducerTransferTypeConverter( @@ -650,14 +649,14 @@ def from_transfer_type( if not value.run_id: raise ValueError("missing required field LocalActivityProducer.run_id") run_id = value.run_id - if not value.HasField("epoch"): - raise ValueError("missing required field LocalActivityProducer.epoch") - epoch = _LocalActivityEpochTransferTypeConverter().from_transfer_type( - value.epoch, LocalActivityEpoch + if not value.HasField("attempt"): + raise ValueError("missing required field LocalActivityProducer.attempt") + attempt = _LocalActivityAttemptTransferTypeConverter().from_transfer_type( + value.attempt, LocalActivityAttempt ) return LocalActivityProducer( run_id=run_id, - epoch=epoch, + attempt=attempt, ) @typing_extensions.override @@ -667,8 +666,8 @@ def to_transfer_type( ) -> temporalio.api.stream.v1.message_pb2.LocalActivityProducer: message = temporalio.api.stream.v1.message_pb2.LocalActivityProducer() message.run_id = value.run_id - message.epoch.CopyFrom( - _LocalActivityEpochTransferTypeConverter().to_transfer_type(value.epoch) + message.attempt.CopyFrom( + _LocalActivityAttemptTransferTypeConverter().to_transfer_type(value.attempt) ) return message @@ -679,35 +678,35 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) -class LocalActivityEpoch: - """A Local Activity attempt. Its Workflow Task orders it first.""" +class LocalActivityAttempt: + """One attempt of a Local Activity. Attempts compare by Workflow Task first.""" - task: WorkflowTaskEpoch + task: WorkflowTaskAttempt attempt: int -class _LocalActivityEpochTransferTypeConverter( +class _LocalActivityAttemptTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - LocalActivityEpoch, temporalio.api.stream.v1.message_pb2.LocalActivityEpoch + LocalActivityAttempt, temporalio.api.stream.v1.message_pb2.LocalActivityAttempt ] ): transfer_type: ( - type[temporalio.api.stream.v1.message_pb2.LocalActivityEpoch] | None - ) = temporalio.api.stream.v1.message_pb2.LocalActivityEpoch + type[temporalio.api.stream.v1.message_pb2.LocalActivityAttempt] | None + ) = temporalio.api.stream.v1.message_pb2.LocalActivityAttempt @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.stream.v1.message_pb2.LocalActivityEpoch, - type_hint: type[LocalActivityEpoch], - ) -> LocalActivityEpoch: + value: temporalio.api.stream.v1.message_pb2.LocalActivityAttempt, + type_hint: type[LocalActivityAttempt], + ) -> LocalActivityAttempt: if not value.HasField("task"): - raise ValueError("missing required field LocalActivityEpoch.task") - task = _WorkflowTaskEpochTransferTypeConverter().from_transfer_type( - value.task, WorkflowTaskEpoch + raise ValueError("missing required field LocalActivityAttempt.task") + task = _WorkflowTaskAttemptTransferTypeConverter().from_transfer_type( + value.task, WorkflowTaskAttempt ) attempt = value.attempt - return LocalActivityEpoch( + return LocalActivityAttempt( task=task, attempt=attempt, ) @@ -715,27 +714,27 @@ def from_transfer_type( @typing_extensions.override def to_transfer_type( self, - value: LocalActivityEpoch, - ) -> temporalio.api.stream.v1.message_pb2.LocalActivityEpoch: - message = temporalio.api.stream.v1.message_pb2.LocalActivityEpoch() + value: LocalActivityAttempt, + ) -> temporalio.api.stream.v1.message_pb2.LocalActivityAttempt: + message = temporalio.api.stream.v1.message_pb2.LocalActivityAttempt() message.task.CopyFrom( - _WorkflowTaskEpochTransferTypeConverter().to_transfer_type(value.task) + _WorkflowTaskAttemptTransferTypeConverter().to_transfer_type(value.task) ) message.attempt = value.attempt return message temporalio.converter.transfer_type_convertible( - _LocalActivityEpochTransferTypeConverter -)(LocalActivityEpoch) # pyright: ignore[reportUnusedCallResult] + _LocalActivityAttemptTransferTypeConverter +)(LocalActivityAttempt) # pyright: ignore[reportUnusedCallResult] @dataclasses.dataclass(slots=True, kw_only=True) class ActivityProducer: - """An Activity Producer.""" + """The Producer of an Activity.""" run_id: str | None = None - epoch: ActivityEpoch + attempt: ActivityAttempt class _ActivityProducerTransferTypeConverter( @@ -753,14 +752,14 @@ def from_transfer_type( value: temporalio.api.stream.v1.message_pb2.ActivityProducer, type_hint: type[ActivityProducer], ) -> ActivityProducer: - if not value.HasField("epoch"): - raise ValueError("missing required field ActivityProducer.epoch") - epoch = _ActivityEpochTransferTypeConverter().from_transfer_type( - value.epoch, ActivityEpoch + if not value.HasField("attempt"): + raise ValueError("missing required field ActivityProducer.attempt") + attempt = _ActivityAttemptTransferTypeConverter().from_transfer_type( + value.attempt, ActivityAttempt ) return ActivityProducer( run_id=value.run_id if bool(value.run_id) else None, - epoch=epoch, + attempt=attempt, ) @typing_extensions.override @@ -771,8 +770,8 @@ def to_transfer_type( message = temporalio.api.stream.v1.message_pb2.ActivityProducer() if value.run_id is not None: message.run_id = value.run_id - message.epoch.CopyFrom( - _ActivityEpochTransferTypeConverter().to_transfer_type(value.epoch) + message.attempt.CopyFrom( + _ActivityAttemptTransferTypeConverter().to_transfer_type(value.attempt) ) return message @@ -783,37 +782,37 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) -class ActivityEpoch: - """An Activity or Standalone Activity attempt.""" +class ActivityAttempt: + """One attempt of an Activity or a Standalone Activity.""" attempt_scheduled_time: Timestamp attempt: int -class _ActivityEpochTransferTypeConverter( +class _ActivityAttemptTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - ActivityEpoch, temporalio.api.stream.v1.message_pb2.ActivityEpoch + ActivityAttempt, temporalio.api.stream.v1.message_pb2.ActivityAttempt ] ): - transfer_type: type[temporalio.api.stream.v1.message_pb2.ActivityEpoch] | None = ( - temporalio.api.stream.v1.message_pb2.ActivityEpoch + transfer_type: type[temporalio.api.stream.v1.message_pb2.ActivityAttempt] | None = ( + temporalio.api.stream.v1.message_pb2.ActivityAttempt ) @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.stream.v1.message_pb2.ActivityEpoch, - type_hint: type[ActivityEpoch], - ) -> ActivityEpoch: + value: temporalio.api.stream.v1.message_pb2.ActivityAttempt, + type_hint: type[ActivityAttempt], + ) -> ActivityAttempt: if not value.HasField("attempt_scheduled_time"): raise ValueError( - "missing required field ActivityEpoch.attempt_scheduled_time" + "missing required field ActivityAttempt.attempt_scheduled_time" ) attempt_scheduled_time = _TimestampTransferTypeConverter().from_transfer_type( value.attempt_scheduled_time, Timestamp ) attempt = value.attempt - return ActivityEpoch( + return ActivityAttempt( attempt_scheduled_time=attempt_scheduled_time, attempt=attempt, ) @@ -821,9 +820,9 @@ def from_transfer_type( @typing_extensions.override def to_transfer_type( self, - value: ActivityEpoch, - ) -> temporalio.api.stream.v1.message_pb2.ActivityEpoch: - message = temporalio.api.stream.v1.message_pb2.ActivityEpoch() + value: ActivityAttempt, + ) -> temporalio.api.stream.v1.message_pb2.ActivityAttempt: + message = temporalio.api.stream.v1.message_pb2.ActivityAttempt() message.attempt_scheduled_time.CopyFrom( _TimestampTransferTypeConverter().to_transfer_type( value.attempt_scheduled_time @@ -833,14 +832,14 @@ def to_transfer_type( return message -temporalio.converter.transfer_type_convertible(_ActivityEpochTransferTypeConverter)( - ActivityEpoch +temporalio.converter.transfer_type_convertible(_ActivityAttemptTransferTypeConverter)( + ActivityAttempt ) # pyright: ignore[reportUnusedCallResult] @dataclasses.dataclass(slots=True) class ClientProducer: - """A client Producer. It has no run and no epoch, so nothing fences it.""" + """The Producer of a client. It has no run and no attempt.""" pass @@ -926,7 +925,7 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class CloseStreamRequest(typing.Generic[BodyT]): - """Close a Stream. Readers drain what is left, then end. Later appends are refused.""" + """Close a Stream. Readers get the Records that are left. Later appends fail.""" ref: StreamRef[BodyT] producer: Producer @@ -1037,8 +1036,8 @@ class ReadRecordsRequest(typing.Generic[BodyT]): ref: StreamRef[BodyT] from_offset: bytes | None = None max_records: int | None = None - wait: datetime.timedelta | None = None max_bytes: int | None = None + wait: datetime.timedelta | None = None class _ReadRecordsRequestTransferTypeConverter( @@ -1071,10 +1070,10 @@ def from_transfer_type( ref=ref, from_offset=value.from_offset if bool(value.from_offset) else None, max_records=value.max_records if value.max_records != 0 else None, + max_bytes=value.max_bytes if value.max_bytes != 0 else None, wait=_support.duration_from_proto(value.wait) if value.HasField("wait") else None, - max_bytes=value.max_bytes if value.max_bytes != 0 else None, ) @typing_extensions.override @@ -1092,10 +1091,10 @@ def to_transfer_type( message.from_offset = value.from_offset if value.max_records is not None: message.max_records = value.max_records - if value.wait is not None: - message.wait.CopyFrom(_support.duration_to_proto(value.wait)) if value.max_bytes is not None: message.max_bytes = value.max_bytes + if value.wait is not None: + message.wait.CopyFrom(_support.duration_to_proto(value.wait)) return message @@ -1171,7 +1170,7 @@ def to_transfer_type( @dataclasses.dataclass(slots=True, kw_only=True) class StreamRecord(typing.Generic[BodyT]): - """One Record that a Producer appended, as a read gives it.""" + """One Record of a Stream, as a read returns it.""" body: BodyT producer: Producer | None = None @@ -1368,4 +1367,4 @@ class ProducerKindClient: | ProducerKindStandaloneActivity | ProducerKindClient ) -"""The kind of a Producer, with its run and epoch.""" +"""The kind of a Producer, with its run and attempt.""" diff --git a/temporalio/nexus/system/stream_service/services.py b/temporalio/nexus/system/stream_service/services.py index 76231c5505..fba6e9c0b2 100644 --- a/temporalio/nexus/system/stream_service/services.py +++ b/temporalio/nexus/system/stream_service/services.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/__init__.py b/temporalio/nexus/system/stream_service/workflow/__init__.py index 12b9baa97e..3116066cfc 100644 --- a/temporalio/nexus/system/stream_service/workflow/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py b/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py index 04fda4c2bc..997e556b26 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index df548d2528..0a14071e8b 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -1,7 +1,9 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations +import collections.abc +import datetime import types import typing @@ -11,6 +13,7 @@ import temporalio.nexus.system._support as _support import temporalio.workflow +from ..._poll import PollIterator from ...models import ( AppendRecord, AppendRecordsRequest, @@ -20,6 +23,9 @@ DescribeStreamRequest, DescribeStreamResponse, Producer, + ReadRecordsRequest, + ReadRecordsResponse, + StreamRecord, StreamRef, ) @@ -78,7 +84,7 @@ async def close( self, producer: Producer | None = None, ) -> None: - """Close the Stream. Readers drain what is left, then end.""" + """Close the Stream. Readers get the Records that are left, then end.""" request = CloseStreamRequest( ref=self.ref, producer=((_support.workflow_producer()) if producer is None else producer), @@ -86,10 +92,105 @@ async def close( handle = await _close_stream(request) await handle + async def read_page( + self, + from_offset: bytes | None = None, + max_records: int | None = None, + wait: datetime.timedelta | None = None, + max_bytes: int | None = None, + ) -> ReadRecordsResponse[BodyT]: + """Read one page of Records. The poll iterator reads them all.""" + request = ReadRecordsRequest( + ref=self.ref, + from_offset=from_offset, + max_records=max_records, + max_bytes=max_bytes, + wait=wait, + ) + handle = await _read_records(request, self.body_type) + return await handle + + async def read_pages( + self, + from_offset: bytes | None = None, + max_records: int | None = None, + wait: datetime.timedelta | None = None, + max_bytes: int | None = None, + ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: + """Yield each response of ``read_page`` until the poll helper stops. + + Read one page of Records. The poll iterator reads them all. + + Args: + from_offset: Read after this offset. Empty means from the beginning. + max_records: The maximum number of Records in one page. + wait: How long to wait for a new Record before the read returns an empty + page. + max_bytes: The maximum bytes of Records in a page. A larger Record is + returned alone. + """ + request = ReadRecordsRequest( + ref=self.ref, + from_offset=from_offset, + max_records=max_records, + max_bytes=max_bytes, + wait=wait, + ) + while True: + handle = await _read_records(request, self.body_type) + response = await handle + next_request = _support.next_read_request(request, response) + yield response + if next_request is None: + return + request = next_request + + def read( + self, + from_offset: bytes | None = None, + max_records: int | None = None, + wait: datetime.timedelta | None = None, + max_bytes: int | None = None, + ) -> PollIterator[ReadRecordsRequest[BodyT], StreamRecord[BodyT]]: + """Yield each item of ``read_pages``, page by page. + + ``next_request`` resumes after the last item that the iterator yielded. It is + ``None`` after the last page. + + Read one page of Records. The poll iterator reads them all. + + Args: + from_offset: Read after this offset. Empty means from the beginning. + max_records: The maximum number of Records in one page. + wait: How long to wait for a new Record before the read returns an empty + page. + max_bytes: The maximum bytes of Records in a page. A larger Record is + returned alone. + """ + request = ReadRecordsRequest( + ref=self.ref, + from_offset=from_offset, + max_records=max_records, + max_bytes=max_bytes, + wait=wait, + ) + return PollIterator( + request, + self.read_pages( + from_offset=from_offset, + max_records=max_records, + wait=wait, + max_bytes=max_bytes, + ), + lambda response: response.records, + _support.next_read_request, + _support.resume_read_request, + ) + async def describe( self, ) -> DescribeStreamResponse: - """Describe the Stream's status and newest offset.""" + """Return the status and the newest offset of the Stream.""" request = DescribeStreamRequest( ref=self.ref, ) @@ -164,6 +265,21 @@ async def _close_stream( ) +async def _read_records( + request: ReadRecordsRequest[BodyT], + body_type: type[BodyT], +) -> temporalio.workflow.NexusOperationHandle[ReadRecordsResponse[BodyT],]: + nexus_client = temporalio.workflow.create_nexus_client( + service="temporal.api.streamservice.v1.StreamService", + endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, + ) + return await nexus_client.start_operation( + operation="ReadRecords", + input=request, + output_type=ReadRecordsResponse[body_type], + ) + + async def _describe_stream( request: DescribeStreamRequest[BodyT], ) -> temporalio.workflow.NexusOperationHandle[DescribeStreamResponse,]: diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py index 399fd18966..d87e5f8748 100644 --- a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/operations/__init__.py b/temporalio/nexus/system/stream_service/workflow/operations/__init__.py index 250b6a42b7..c4e5635675 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/__init__.py @@ -1,3 +1,3 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 12e5f6b466..16fcf65f08 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.12. DO NOT EDIT! +# Generated by nexgen v0.2.13. DO NOT EDIT! from __future__ import annotations @@ -75,10 +75,9 @@ async def create_stream( """ Args: id: The Stream id, 1 to 4096 bytes. - store: Registered Store name. With none, the SDK picks one. Only an SDK reads - it. - id_conflict_policy: What the create does when the Stream exists. Unspecified is - fail. + store: The registered name of the Store. If empty, the SDK picks a Store. + id_conflict_policy: What the create does if the Stream already exists. + Unspecified means fail. """ if body_type is None: body_type = typing.Any From 17c637e0ce9292ed58ffc6cf1aa741ea25ef5462 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Fri, 20 Nov 2026 17:50:43 -0700 Subject: [PATCH 05/24] Regenerate the Streams API with a request id and Stream ids The API takes a Stream id in each request and a request id on an append, and nexgen maps the ref of a request to its id with two helpers. --- temporalio/api/enums/v1/stream_pb2.py | 4 +- temporalio/api/enums/v1/stream_pb2.pyi | 48 +++---- temporalio/api/stream/v1/message_pb2.py | 2 +- temporalio/api/stream/v1/message_pb2.pyi | 7 +- .../streamservice/v1/request_response_pb2.py | 40 +++--- .../streamservice/v1/request_response_pb2.pyi | 117 +++++++----------- .../stream_service/client/_extensions.py | 12 +- .../client/_resources/stream.py | 3 +- .../nexus/system/stream_service/models.py | 92 +++++--------- .../nexus/system/stream_service/services.py | 2 +- .../workflow/_resources/stream.py | 3 +- .../workflow/_system_nexus_interceptor.py | 33 ++--- .../workflow/operations/create_stream.py | 10 +- 13 files changed, 138 insertions(+), 235 deletions(-) diff --git a/temporalio/api/enums/v1/stream_pb2.py b/temporalio/api/enums/v1/stream_pb2.py index 021a38e1aa..a272a2da88 100644 --- a/temporalio/api/enums/v1/stream_pb2.py +++ b/temporalio/api/enums/v1/stream_pb2.py @@ -14,7 +14,7 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*_\n\x0cStreamStatus\x12\x1d\n\x19STREAM_STATUS_UNSPECIFIED\x10\x00\x12\x16\n\x12STREAM_STATUS_OPEN\x10\x01\x12\x18\n\x14STREAM_STATUS_CLOSED\x10\x02*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xca\x04\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_CLOSED\x10\x03\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x04\x12(\n$STREAM_ERROR_REASON_SEQUENCE_TOO_LOW\x10\x05\x12%\n!STREAM_ERROR_REASON_SEQ_DIVERGENT\x10\x06\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x08\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\t\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\n\x12(\n$STREAM_ERROR_REASON_INVALID_ARGUMENT\x10\x0b\x12)\n%STREAM_ERROR_REASON_STORE_UNAVAILABLE\x10\x0c\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\r\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\x0e\x12%\n!STREAM_ERROR_REASON_STORE_CORRUPT\x10\x0f\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' + b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*_\n\x0cStreamStatus\x12\x1d\n\x19STREAM_STATUS_UNSPECIFIED\x10\x00\x12\x16\n\x12STREAM_STATUS_OPEN\x10\x01\x12\x18\n\x14STREAM_STATUS_CLOSED\x10\x02*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xf9\x03\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_CLOSED\x10\x03\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x04\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x05\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\x06\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\x07\x12(\n$STREAM_ERROR_REASON_INVALID_ARGUMENT\x10\x08\x12)\n%STREAM_ERROR_REASON_STORE_UNAVAILABLE\x10\t\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\n\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\x0b\x12%\n!STREAM_ERROR_REASON_STORE_CORRUPT\x10\x0c\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -27,5 +27,5 @@ _STREAMIDCONFLICTPOLICY._serialized_start = 159 _STREAMIDCONFLICTPOLICY._serialized_end = 306 _STREAMERRORREASON._serialized_start = 309 - _STREAMERRORREASON._serialized_end = 895 + _STREAMERRORREASON._serialized_end = 814 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/enums/v1/stream_pb2.pyi b/temporalio/api/enums/v1/stream_pb2.pyi index bf71e998b3..bf1d90918a 100644 --- a/temporalio/api/enums/v1/stream_pb2.pyi +++ b/temporalio/api/enums/v1/stream_pb2.pyi @@ -103,31 +103,23 @@ class _StreamErrorReasonEnumTypeWrapper( """A later attempt of the same Producer has already written, and the Store fences (`FAILED_PRECONDITION`). """ - STREAM_ERROR_REASON_SEQUENCE_TOO_LOW: _StreamErrorReason.ValueType # 5 - """The `sequence` of an append is lower than the `sequence` of the last batch of its attempt - (`FAILED_PRECONDITION`). - """ - STREAM_ERROR_REASON_SEQ_DIVERGENT: _StreamErrorReason.ValueType # 6 - """The batch has the same `sequence` as the last one of its attempt, but different content - (`FAILED_PRECONDITION`). - """ - STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 8 + STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 5 """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" - STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 9 + STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 6 """The offset is past the newest one, for example after a failover lost the newest Records. A read from it works again once the Stream has Records up to that offset (`OUT_OF_RANGE`). """ - STREAM_ERROR_REASON_TOO_LARGE: _StreamErrorReason.ValueType # 10 + STREAM_ERROR_REASON_TOO_LARGE: _StreamErrorReason.ValueType # 7 """A Record or a batch is larger than the Store allows (`INVALID_ARGUMENT`).""" - STREAM_ERROR_REASON_INVALID_ARGUMENT: _StreamErrorReason.ValueType # 11 + STREAM_ERROR_REASON_INVALID_ARGUMENT: _StreamErrorReason.ValueType # 8 """The request is malformed (`INVALID_ARGUMENT`).""" - STREAM_ERROR_REASON_STORE_UNAVAILABLE: _StreamErrorReason.ValueType # 12 + STREAM_ERROR_REASON_STORE_UNAVAILABLE: _StreamErrorReason.ValueType # 9 """The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" - STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 13 + STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 10 """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" - STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 14 + STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 11 """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" - STREAM_ERROR_REASON_STORE_CORRUPT: _StreamErrorReason.ValueType # 15 + STREAM_ERROR_REASON_STORE_CORRUPT: _StreamErrorReason.ValueType # 12 """The Store returned data that isn't valid, such as a stored value of the wrong length. A retry reads the same data (`DATA_LOSS`). """ @@ -152,31 +144,23 @@ STREAM_ERROR_REASON_FENCED: StreamErrorReason.ValueType # 4 """A later attempt of the same Producer has already written, and the Store fences (`FAILED_PRECONDITION`). """ -STREAM_ERROR_REASON_SEQUENCE_TOO_LOW: StreamErrorReason.ValueType # 5 -"""The `sequence` of an append is lower than the `sequence` of the last batch of its attempt -(`FAILED_PRECONDITION`). -""" -STREAM_ERROR_REASON_SEQ_DIVERGENT: StreamErrorReason.ValueType # 6 -"""The batch has the same `sequence` as the last one of its attempt, but different content -(`FAILED_PRECONDITION`). -""" -STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 8 +STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 5 """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" -STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 9 +STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 6 """The offset is past the newest one, for example after a failover lost the newest Records. A read from it works again once the Stream has Records up to that offset (`OUT_OF_RANGE`). """ -STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 10 +STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 7 """A Record or a batch is larger than the Store allows (`INVALID_ARGUMENT`).""" -STREAM_ERROR_REASON_INVALID_ARGUMENT: StreamErrorReason.ValueType # 11 +STREAM_ERROR_REASON_INVALID_ARGUMENT: StreamErrorReason.ValueType # 8 """The request is malformed (`INVALID_ARGUMENT`).""" -STREAM_ERROR_REASON_STORE_UNAVAILABLE: StreamErrorReason.ValueType # 12 +STREAM_ERROR_REASON_STORE_UNAVAILABLE: StreamErrorReason.ValueType # 9 """The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" -STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 13 +STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 10 """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" -STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 14 +STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 11 """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" -STREAM_ERROR_REASON_STORE_CORRUPT: StreamErrorReason.ValueType # 15 +STREAM_ERROR_REASON_STORE_CORRUPT: StreamErrorReason.ValueType # 12 """The Store returned data that isn't valid, such as a stored value of the wrong length. A retry reads the same data (`DATA_LOSS`). """ diff --git a/temporalio/api/stream/v1/message_pb2.py b/temporalio/api/stream/v1/message_pb2.py index 444f9d2f18..9599cfcf69 100644 --- a/temporalio/api/stream/v1/message_pb2.py +++ b/temporalio/api/stream/v1/message_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"`\n\x10WorkflowProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12<\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"f\n\x15LocalActivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12=\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\\\n\x10\x41\x63tivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x10\n\x0e\x43lientProducer"\xef\x02\n\x08Producer\x12\n\n\x02id\x18\x01 \x01(\t\x12<\n\x08workflow\x18\x02 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x03 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12\x45\n\x11workflow_activity\x18\x04 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12G\n\x13standalone_activity\x18\x05 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x06 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' + b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"`\n\x10WorkflowProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12<\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"f\n\x15LocalActivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12=\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\\\n\x10\x41\x63tivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x10\n\x0e\x43lientProducer"\xef\x02\n\x08Producer\x12\n\n\x02id\x18\x01 \x01(\t\x12<\n\x08workflow\x18\x02 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x03 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12\x45\n\x11workflow_activity\x18\x04 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12G\n\x13standalone_activity\x18\x05 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x06 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 0d4d8c0674..91fd88d6d5 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -18,8 +18,8 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class StreamRef(google.protobuf.message.Message): """Experimental. Might change in the future. - A reference to one Stream. Callers treat the id as opaque. An id is never used for a second - Stream, so a create for a closed or expired Stream fails. + A reference to one Stream, which code passes to other code as data. Only an SDK uses this + message. A request to a Store or to the server has the `id` alone. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -30,8 +30,7 @@ class StreamRef(google.protobuf.message.Message): store: builtins.str """The name under which the client and Worker config registered the Store of this Stream. An SDK uses it to send a call on this ref to the right Store. When it's empty, the SDK picks - the Store from its config. Only an SDK sets and reads this field. The server and a Store - ignore it. + the Store from its config. """ def __init__( self, diff --git a/temporalio/api/streamservice/v1/request_response_pb2.py b/temporalio/api/streamservice/v1/request_response_pb2.py index 556762715f..1d77998a79 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.py +++ b/temporalio/api/streamservice/v1/request_response_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\xab\x01\n\x13\x43reateStreamRequest\x12\x35\n\nstream_ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy\x12\x12\n\nrequest_id\x18\x03 \x01(\t"W\n\x14\x43reateStreamResponse\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xc3\x01\n\x14\x41ppendRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x10\n\x08sequence\x18\x03 \x01(\x03\x12\x35\n\x07records\x18\x04 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"x\n\x12\x43loseStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\xaa\x01\n\x12ReadRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"G\n\x15\x44\x65scribeStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' + b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\x87\x01\n\x13\x43reateStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy\x12\x12\n\nrequest_id\x18\x03 \x01(\t"\'\n\x14\x43reateStreamResponse\x12\x0f\n\x07\x63reated\x18\x01 \x01(\x08"\xa8\x01\n\x14\x41ppendRecordsRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x12\n\nrequest_id\x18\x03 \x01(\t\x12\x35\n\x07records\x18\x04 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"[\n\x12\x43loseStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\x8d\x01\n\x12ReadRecordsRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"*\n\x15\x44\x65scribeStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -32,23 +32,23 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n io.temporal.api.streamservice.v1B\024RequestResponseProtoP\001Z1go.temporal.io/api/streamservice/v1;streamservice\252\002\037Temporalio.Api.StreamService.V1\352\002"Temporalio::Api::StreamService::V1' _CREATESTREAMREQUEST._serialized_start = 194 - _CREATESTREAMREQUEST._serialized_end = 365 - _CREATESTREAMRESPONSE._serialized_start = 367 - _CREATESTREAMRESPONSE._serialized_end = 454 - _APPENDRECORDSREQUEST._serialized_start = 457 - _APPENDRECORDSREQUEST._serialized_end = 652 - _APPENDRECORDSRESPONSE._serialized_start = 654 - _APPENDRECORDSRESPONSE._serialized_end = 720 - _CLOSESTREAMREQUEST._serialized_start = 722 - _CLOSESTREAMREQUEST._serialized_end = 842 - _CLOSESTREAMRESPONSE._serialized_start = 844 - _CLOSESTREAMRESPONSE._serialized_end = 865 - _READRECORDSREQUEST._serialized_start = 868 - _READRECORDSREQUEST._serialized_end = 1038 - _READRECORDSRESPONSE._serialized_start = 1040 - _READRECORDSRESPONSE._serialized_end = 1151 - _DESCRIBESTREAMREQUEST._serialized_start = 1153 - _DESCRIBESTREAMREQUEST._serialized_end = 1224 - _DESCRIBESTREAMRESPONSE._serialized_start = 1226 - _DESCRIBESTREAMRESPONSE._serialized_end = 1324 + _CREATESTREAMREQUEST._serialized_end = 329 + _CREATESTREAMRESPONSE._serialized_start = 331 + _CREATESTREAMRESPONSE._serialized_end = 370 + _APPENDRECORDSREQUEST._serialized_start = 373 + _APPENDRECORDSREQUEST._serialized_end = 541 + _APPENDRECORDSRESPONSE._serialized_start = 543 + _APPENDRECORDSRESPONSE._serialized_end = 609 + _CLOSESTREAMREQUEST._serialized_start = 611 + _CLOSESTREAMREQUEST._serialized_end = 702 + _CLOSESTREAMRESPONSE._serialized_start = 704 + _CLOSESTREAMRESPONSE._serialized_end = 725 + _READRECORDSREQUEST._serialized_start = 728 + _READRECORDSREQUEST._serialized_end = 869 + _READRECORDSRESPONSE._serialized_start = 871 + _READRECORDSRESPONSE._serialized_end = 982 + _DESCRIBESTREAMREQUEST._serialized_start = 984 + _DESCRIBESTREAMREQUEST._serialized_end = 1026 + _DESCRIBESTREAMRESPONSE._serialized_start = 1028 + _DESCRIBESTREAMRESPONSE._serialized_end = 1126 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index e5a5d29a80..a728a6ce60 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -29,14 +29,18 @@ class CreateStreamRequest(google.protobuf.message.Message): A create has no Retention. Retention is a setting of the Store, as it's a setting of the namespace for Workflows. (-- api-linter: core::0133=disabled - aip.dev/not-precedent: The request identifies a Stream by its ref. --) + aip.dev/not-precedent: The request identifies a Stream by its id. --) """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int REQUEST_ID_FIELD_NUMBER: builtins.int + stream_id: builtins.str + """Required. The id of the Stream to create. Callers treat it as opaque. An id is never used + for a second Stream, so a create for a closed or expired Stream fails. + """ id_conflict_policy: ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType ) @@ -46,20 +50,13 @@ class CreateStreamRequest(google.protobuf.message.Message): the `request_id` of the create that made the Stream, so a retry after a lost response doesn't fail with `ALREADY_EXISTS`. """ - @property - def stream_ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required. The Stream to create. Its `id` must not be empty.""" - def __init__( self, *, - stream_ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., id_conflict_policy: temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType = ..., request_id: builtins.str = ..., ) -> None: ... - def HasField( - self, field_name: typing.Literal["stream_ref", b"stream_ref"] - ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ @@ -67,8 +64,8 @@ class CreateStreamRequest(google.protobuf.message.Message): b"id_conflict_policy", "request_id", b"request_id", - "stream_ref", - b"stream_ref", + "stream_id", + b"stream_id", ], ) -> None: ... @@ -82,27 +79,15 @@ class CreateStreamResponse(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int CREATED_FIELD_NUMBER: builtins.int created: builtins.bool """False when `USE_EXISTING` returned a Stream that already existed.""" - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """The ref of the Stream. The caller can pass it to other code as data. A Store and the server - return the ref as the request had it, because they don't know the Store names of an SDK. - The SDK then sets `store` to the Store that it picked, before the caller gets the ref. - """ - def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., created: builtins.bool = ..., ) -> None: ... - def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["created", b"created", "ref", b"ref"] - ) -> None: ... + def ClearField(self, field_name: typing.Literal["created", b"created"]) -> None: ... global___CreateStreamResponse = CreateStreamResponse @@ -110,25 +95,23 @@ global___CreateStreamResponse = CreateStreamResponse class AppendRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Appends one batch of Records as one Producer. If the same batch arrives again, with the same - Producer, attempt and `sequence`, the Store writes it only once. + Producer, attempt and `request_id`, the Store writes it only once. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int - SEQUENCE_FIELD_NUMBER: builtins.int + REQUEST_ID_FIELD_NUMBER: builtins.int RECORDS_FIELD_NUMBER: builtins.int - sequence: builtins.int - """The idempotency number of this batch within its attempt. A caller that got no response - sends the batch again with the same number, and the Store uses the Producer, the attempt - and this number to write it only once. With zero, the Store assigns the next number, and a - retry of that batch is written again. + stream_id: builtins.str + """Required.""" + request_id: builtins.str + """A value that's unique to this append call and the same on its retries. A caller that got no + response sends the batch again with the same value, and the Store returns the offsets of + the first write. A Store remembers the `request_id` of the last batch of each Producer, so + a Producer sends one batch at a time. When it's empty, a retry is written again. """ - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: """Required. The Producer that writes the batch. A Producer sends the same value in its @@ -144,16 +127,16 @@ class AppendRecordsRequest(google.protobuf.message.Message): def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., - sequence: builtins.int = ..., + request_id: builtins.str = ..., records: collections.abc.Iterable[ temporalio.api.stream.v1.message_pb2.AppendRecord ] | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + self, field_name: typing.Literal["producer", b"producer"] ) -> builtins.bool: ... def ClearField( self, @@ -162,10 +145,10 @@ class AppendRecordsRequest(google.protobuf.message.Message): b"producer", "records", b"records", - "ref", - b"ref", - "sequence", - b"sequence", + "request_id", + b"request_id", + "stream_id", + b"stream_id", ], ) -> None: ... @@ -208,12 +191,10 @@ class CloseStreamRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - + stream_id: builtins.str + """Required.""" @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: """Required. The Producer that closes the Stream.""" @@ -221,14 +202,15 @@ class CloseStreamRequest(google.protobuf.message.Message): def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + self, field_name: typing.Literal["producer", b"producer"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + self, + field_name: typing.Literal["producer", b"producer", "stream_id", b"stream_id"], ) -> None: ... global___CloseStreamRequest = CloseStreamRequest @@ -256,11 +238,13 @@ class ReadRecordsRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int FROM_OFFSET_FIELD_NUMBER: builtins.int MAX_RECORDS_FIELD_NUMBER: builtins.int MAX_BYTES_FIELD_NUMBER: builtins.int WAIT_FIELD_NUMBER: builtins.int + stream_id: builtins.str + """Required.""" from_offset: builtins.bytes """The read returns the Records after this offset. Empty means from the beginning. An offset past the newest one fails with `OFFSET_TOO_HIGH`. To read only new Records, a caller gets @@ -276,10 +260,6 @@ class ReadRecordsRequest(google.protobuf.message.Message): this is still returned, alone in its page, so a read always makes progress. Zero means no limit. """ - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - @property def wait(self) -> google.protobuf.duration_pb2.Duration: """How long the read waits for a new Record before it returns an empty page. When it's unset, @@ -289,14 +269,14 @@ class ReadRecordsRequest(google.protobuf.message.Message): def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., from_offset: builtins.bytes = ..., max_records: builtins.int = ..., max_bytes: builtins.int = ..., wait: google.protobuf.duration_pb2.Duration | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["ref", b"ref", "wait", b"wait"] + self, field_name: typing.Literal["wait", b"wait"] ) -> builtins.bool: ... def ClearField( self, @@ -307,8 +287,8 @@ class ReadRecordsRequest(google.protobuf.message.Message): b"max_bytes", "max_records", b"max_records", - "ref", - b"ref", + "stream_id", + b"stream_id", "wait", b"wait", ], @@ -370,18 +350,17 @@ class DescribeStreamRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - + STREAM_ID_FIELD_NUMBER: builtins.int + stream_id: builtins.str + """Required.""" def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["stream_id", b"stream_id"] ) -> None: ... - def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... - def ClearField(self, field_name: typing.Literal["ref", b"ref"]) -> None: ... global___DescribeStreamRequest = DescribeStreamRequest diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index 87e0d44469..0733e2882f 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -18,7 +18,6 @@ from .._resource_context_manager import resource_context_manager from ..models import ( CreateStreamRequest, - CreateStreamResult, StreamIdConflictPolicy, StreamRef, ) @@ -102,19 +101,16 @@ async def _stream_service_create_stream( endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, ) handle = await nexus_client.start_operation( - operation="CreateStream", + operation=StreamService.create_stream, arg=request, id=f"{_uuid.uuid4()}", - result_type=CreateStreamResult[body_type], rpc_metadata=rpc_metadata or {}, rpc_timeout=rpc_timeout, ) result = await handle.result() - if result.ref is None: - raise RuntimeError("CreateStream answered without `ref`") resource = Stream[body_type]( nexus_client, - ref=result.ref, + ref=request.ref, created=result.created or None, ) return resource @@ -165,12 +161,12 @@ async def create_stream( """ if body_type is None: body_type = typing.Any - stream_ref = StreamRef( + ref = StreamRef[body_type]( id=id, store=store, ) request = CreateStreamRequest( - stream_ref=stream_ref, + ref=ref, id_conflict_policy=id_conflict_policy, request_id=_support.request_id(), ) diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index 90cdebd493..c3d8f907cb 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -74,7 +74,6 @@ async def append( self, *records: BodyT, producer: Producer | None = None, - sequence: int | None = None, rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> AppendRecordsResponse: @@ -86,8 +85,8 @@ async def append( if producer is None else producer ), - sequence=sequence, records=[AppendRecord(body=value) for value in records], + request_id=_support.append_request_id(), ) handle = await self._nexus_client.start_operation( operation=StreamService.append_records, diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index 0d887ca39a..61ab1c005e 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -45,7 +45,7 @@ def _stream_status_from_proto(value: int) -> StreamStatus: class CreateStreamRequest(typing.Generic[BodyT]): """Create a Stream. If it already exists, fail, or return it with use-existing.""" - stream_ref: StreamRef[BodyT] + ref: StreamRef[BodyT] id_conflict_policy: StreamIdConflictPolicy | None = None request_id: str | None = None @@ -68,16 +68,14 @@ def from_transfer_type( type_hint: type[CreateStreamRequest[BodyT]], ) -> CreateStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.HasField("stream_ref"): - raise ValueError("missing required field CreateStreamRequest.stream_ref") - stream_ref = typing.cast( + if not value.stream_id: + raise ValueError("missing required field CreateStreamRequest.ref") + ref = typing.cast( StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.stream_ref, StreamRef[body_type] - ), + _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), ) return CreateStreamRequest( - stream_ref=stream_ref, + ref=ref, id_conflict_policy=StreamIdConflictPolicy(value.id_conflict_policy) if value.id_conflict_policy != 0 else None, @@ -92,9 +90,7 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest() ) - message.stream_ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.stream_ref) - ) + message.stream_id = _support.stream_ref_to_id(value.ref) if value.id_conflict_policy is not None: message.id_conflict_policy = ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType( @@ -161,14 +157,13 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) -class CreateStreamResult(typing.Generic[BodyT]): - ref: StreamRef[BodyT] | None = None +class CreateStreamResult: created: bool | None = None class _CreateStreamResultTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - CreateStreamResult[BodyT], + CreateStreamResult, temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, ] ): @@ -181,40 +176,27 @@ class _CreateStreamResultTransferTypeConverter( def from_transfer_type( self, value: temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, - type_hint: type[CreateStreamResult[BodyT]], - ) -> CreateStreamResult[BodyT]: - (body_type,) = typing.get_args(type_hint) or (typing.Any,) + type_hint: type[CreateStreamResult], + ) -> CreateStreamResult: return CreateStreamResult( - ref=typing.cast( - StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.ref, StreamRef[body_type] - ), - ) - if value.HasField("ref") - else None, created=value.created if bool(value.created) else None, ) @typing_extensions.override def to_transfer_type( self, - value: CreateStreamResult[BodyT], + value: CreateStreamResult, ) -> temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse: message = ( temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse() ) - if value.ref is not None: - message.ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.ref) - ) if value.created is not None: message.created = value.created return message temporalio.converter.transfer_type_convertible( - _CreateStreamResultTransferTypeConverter[typing.Any] + _CreateStreamResultTransferTypeConverter )(CreateStreamResult) # pyright: ignore[reportUnusedCallResult] @@ -225,7 +207,7 @@ class AppendRecordsRequest(typing.Generic[BodyT]): ref: StreamRef[BodyT] records: list[AppendRecord[BodyT]] producer: Producer - sequence: int | None = None + request_id: str | None = None class _AppendRecordsRequestTransferTypeConverter( @@ -246,13 +228,11 @@ def from_transfer_type( type_hint: type[AppendRecordsRequest[BodyT]], ) -> AppendRecordsRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.HasField("ref"): + if not value.stream_id: raise ValueError("missing required field AppendRecordsRequest.ref") ref = typing.cast( StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.ref, StreamRef[body_type] - ), + _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), ) records = [ typing.cast( @@ -272,7 +252,7 @@ def from_transfer_type( ref=ref, records=records, producer=producer, - sequence=value.sequence if value.sequence != 0 else None, + request_id=value.request_id if bool(value.request_id) else None, ) @typing_extensions.override @@ -283,9 +263,7 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest() ) - message.ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.ref) - ) + message.stream_id = _support.stream_ref_to_id(value.ref) for element in value.records: item = message.records.add() item.CopyFrom( @@ -294,8 +272,8 @@ def to_transfer_type( message.producer.CopyFrom( _ProducerTransferTypeConverter().to_transfer_type(value.producer) ) - if value.sequence is not None: - message.sequence = value.sequence + if value.request_id is not None: + message.request_id = value.request_id return message @@ -949,13 +927,11 @@ def from_transfer_type( type_hint: type[CloseStreamRequest[BodyT]], ) -> CloseStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.HasField("ref"): + if not value.stream_id: raise ValueError("missing required field CloseStreamRequest.ref") ref = typing.cast( StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.ref, StreamRef[body_type] - ), + _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), ) if not value.HasField("producer"): raise ValueError("missing required field CloseStreamRequest.producer") @@ -975,9 +951,7 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest() ) - message.ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.ref) - ) + message.stream_id = _support.stream_ref_to_id(value.ref) message.producer.CopyFrom( _ProducerTransferTypeConverter().to_transfer_type(value.producer) ) @@ -1058,13 +1032,11 @@ def from_transfer_type( type_hint: type[ReadRecordsRequest[BodyT]], ) -> ReadRecordsRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.HasField("ref"): + if not value.stream_id: raise ValueError("missing required field ReadRecordsRequest.ref") ref = typing.cast( StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.ref, StreamRef[body_type] - ), + _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), ) return ReadRecordsRequest( ref=ref, @@ -1084,9 +1056,7 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest() ) - message.ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.ref) - ) + message.stream_id = _support.stream_ref_to_id(value.ref) if value.from_offset is not None: message.from_offset = value.from_offset if value.max_records is not None: @@ -1252,13 +1222,11 @@ def from_transfer_type( type_hint: type[DescribeStreamRequest[BodyT]], ) -> DescribeStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.HasField("ref"): + if not value.stream_id: raise ValueError("missing required field DescribeStreamRequest.ref") ref = typing.cast( StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.ref, StreamRef[body_type] - ), + _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), ) return DescribeStreamRequest( ref=ref, @@ -1272,9 +1240,7 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest() ) - message.ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.ref) - ) + message.stream_id = _support.stream_ref_to_id(value.ref) return message diff --git a/temporalio/nexus/system/stream_service/services.py b/temporalio/nexus/system/stream_service/services.py index fba6e9c0b2..5ed3f95bdc 100644 --- a/temporalio/nexus/system/stream_service/services.py +++ b/temporalio/nexus/system/stream_service/services.py @@ -29,7 +29,7 @@ class StreamService: create_stream: Operation[ CreateStreamRequest[typing.Any], - CreateStreamResult[typing.Any], + CreateStreamResult, ] = Operation(name="CreateStream") append_records: Operation[ diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 0a14071e8b..25329fdc2d 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -68,14 +68,13 @@ async def append( self, *records: BodyT, producer: Producer | None = None, - sequence: int | None = None, ) -> AppendRecordsResponse: """Append values, and return the offsets of the batch.""" request = AppendRecordsRequest( ref=self.ref, producer=((_support.workflow_producer()) if producer is None else producer), - sequence=sequence, records=[AppendRecord(body=value) for value in records], + request_id=_support.append_request_id(), ) handle = await _append_records(request) return await handle diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py index d87e5f8748..78d36ba88e 100644 --- a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -32,15 +32,13 @@ async def _start_system_nexus_operation( and input.operation_name == "CreateStream" ): typed_input = typing.cast( - "StartNexusOperationInput[models.CreateStreamRequest[typing.Any], models.CreateStreamResult[typing.Any]]", + "StartNexusOperationInput[models.CreateStreamRequest[typing.Any], models.CreateStreamResult]", input, ) # The dispatch check above establishes that this operation's response type is _OutputT. return typing.cast( "temporalio.workflow.NexusOperationHandle[_OutputT]", - await interceptor.start_create_stream( - typed_input.input, typed_input.output_type - ), + await interceptor.start_create_stream(typed_input.input), ) if ( input.service == "temporal.api.streamservice.v1.StreamService" @@ -108,16 +106,10 @@ def _next_system_nexus_interceptor( ) -> _SystemNexusWorkflowOutboundInterceptorBase: ... async def start_create_stream( - self, - request: models.CreateStreamRequest[typing.Any], - output_type: type[models.CreateStreamResult[typing.Any]] | None = None, - ) -> temporalio.workflow.NexusOperationHandle[ - models.CreateStreamResult[typing.Any] - ]: + self, request: models.CreateStreamRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.CreateStreamResult]: """Intercept the CreateStream operation.""" - return await self._next_system_nexus_interceptor().start_create_stream( - request, output_type - ) + return await self._next_system_nexus_interceptor().start_create_stream(request) async def start_append_records( self, request: models.AppendRecordsRequest[typing.Any] @@ -160,12 +152,8 @@ async def _schedule_system_nexus_operation( ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: ... async def start_create_stream( - self, - request: models.CreateStreamRequest[typing.Any], - output_type: type[models.CreateStreamResult[typing.Any]] | None = None, - ) -> temporalio.workflow.NexusOperationHandle[ - models.CreateStreamResult[typing.Any] - ]: + self, request: models.CreateStreamRequest[typing.Any] + ) -> temporalio.workflow.NexusOperationHandle[models.CreateStreamResult]: from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType @@ -176,12 +164,7 @@ async def start_create_stream( service="temporal.api.streamservice.v1.StreamService", operation="CreateStream", input=request, - output_type=typing.cast( - "type[models.CreateStreamResult[typing.Any]]", - models.CreateStreamResult, - ) - if output_type is None - else output_type, + output_type=models.CreateStreamResult, schedule_to_close_timeout=None, schedule_to_start_timeout=None, start_to_close_timeout=None, diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 16fcf65f08..24a8eafb9a 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -31,13 +31,11 @@ async def _create_stream( handle = await nexus_client.start_operation( operation="CreateStream", input=request, - output_type=CreateStreamResult[body_type], + output_type=CreateStreamResult, ) result = await handle - if result.ref is None: - raise RuntimeError("CreateStream answered without `ref`") return Stream[body_type]( - ref=result.ref, + ref=request.ref, created=result.created or None, ) @@ -81,12 +79,12 @@ async def create_stream( """ if body_type is None: body_type = typing.Any - stream_ref = StreamRef( + ref = StreamRef[body_type]( id=id, store=store, ) request = CreateStreamRequest( - stream_ref=stream_ref, + ref=ref, id_conflict_policy=id_conflict_policy, request_id=_support.request_id(), ) From 983611e630dc89153f8e98c03dcd22b54c1ae47a Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Fri, 20 Nov 2026 21:02:14 -0700 Subject: [PATCH 06/24] Regenerate the Streams API with ids in each Producer kind The API gives each kind of Producer a namespace and its own ids, and the Producer has no id string. --- temporalio/api/stream/v1/__init__.py | 6 +- temporalio/api/stream/v1/message_pb2.py | 36 +-- temporalio/api/stream/v1/message_pb2.pyi | 178 ++++++++++++--- .../streamservice/v1/request_response_pb2.pyi | 8 +- .../nexus/system/stream_service/__init__.py | 6 +- .../nexus/system/stream_service/models.py | 216 ++++++++++++++---- 6 files changed, 355 insertions(+), 95 deletions(-) diff --git a/temporalio/api/stream/v1/__init__.py b/temporalio/api/stream/v1/__init__.py index df6cae9436..2757a8a4d8 100644 --- a/temporalio/api/stream/v1/__init__.py +++ b/temporalio/api/stream/v1/__init__.py @@ -1,29 +1,31 @@ from .message_pb2 import ( ActivityAttempt, - ActivityProducer, AppendRecord, ClientProducer, LocalActivityAttempt, LocalActivityProducer, Producer, + StandaloneActivityProducer, StreamErrorDetails, StreamRecord, StreamRef, + WorkflowActivityProducer, WorkflowProducer, WorkflowTaskAttempt, ) __all__ = [ "ActivityAttempt", - "ActivityProducer", "AppendRecord", "ClientProducer", "LocalActivityAttempt", "LocalActivityProducer", "Producer", + "StandaloneActivityProducer", "StreamErrorDetails", "StreamRecord", "StreamRef", + "WorkflowActivityProducer", "WorkflowProducer", "WorkflowTaskAttempt", ] diff --git a/temporalio/api/stream/v1/message_pb2.py b/temporalio/api/stream/v1/message_pb2.py index 9599cfcf69..a1d0900cdc 100644 --- a/temporalio/api/stream/v1/message_pb2.py +++ b/temporalio/api/stream/v1/message_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"`\n\x10WorkflowProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12<\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"f\n\x15LocalActivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12=\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\\\n\x10\x41\x63tivityProducer\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x02 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x10\n\x0e\x43lientProducer"\xef\x02\n\x08Producer\x12\n\n\x02id\x18\x01 \x01(\t\x12<\n\x08workflow\x18\x02 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x03 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12\x45\n\x11workflow_activity\x18\x04 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12G\n\x13standalone_activity\x18\x05 \x01(\x0b\x32(.temporal.api.stream.v1.ActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x06 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' + b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\x88\x01\n\x10WorkflowProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12<\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"\xa3\x01\n\x15LocalActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12=\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\xa1\x01\n\x18WorkflowActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x8e\x01\n\x1aStandaloneActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"/\n\x0e\x43lientProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t"\xf5\x02\n\x08Producer\x12<\n\x08workflow\x18\x01 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x02 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12M\n\x11workflow_activity\x18\x03 \x01(\x0b\x32\x30.temporal.api.stream.v1.WorkflowActivityProducerH\x00\x12Q\n\x13standalone_activity\x18\x04 \x01(\x0b\x32\x32.temporal.api.stream.v1.StandaloneActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x05 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -39,20 +39,22 @@ _LOCALACTIVITYATTEMPT._serialized_end = 425 _ACTIVITYATTEMPT._serialized_start = 427 _ACTIVITYATTEMPT._serialized_end = 521 - _WORKFLOWPRODUCER._serialized_start = 523 - _WORKFLOWPRODUCER._serialized_end = 619 - _LOCALACTIVITYPRODUCER._serialized_start = 621 - _LOCALACTIVITYPRODUCER._serialized_end = 723 - _ACTIVITYPRODUCER._serialized_start = 725 - _ACTIVITYPRODUCER._serialized_end = 817 - _CLIENTPRODUCER._serialized_start = 819 - _CLIENTPRODUCER._serialized_end = 835 - _PRODUCER._serialized_start = 838 - _PRODUCER._serialized_end = 1205 - _APPENDRECORD._serialized_start = 1207 - _APPENDRECORD._serialized_end = 1268 - _STREAMRECORD._serialized_start = 1271 - _STREAMRECORD._serialized_end = 1400 - _STREAMERRORDETAILS._serialized_start = 1402 - _STREAMERRORDETAILS._serialized_end = 1480 + _WORKFLOWPRODUCER._serialized_start = 524 + _WORKFLOWPRODUCER._serialized_end = 660 + _LOCALACTIVITYPRODUCER._serialized_start = 663 + _LOCALACTIVITYPRODUCER._serialized_end = 826 + _WORKFLOWACTIVITYPRODUCER._serialized_start = 829 + _WORKFLOWACTIVITYPRODUCER._serialized_end = 990 + _STANDALONEACTIVITYPRODUCER._serialized_start = 993 + _STANDALONEACTIVITYPRODUCER._serialized_end = 1135 + _CLIENTPRODUCER._serialized_start = 1137 + _CLIENTPRODUCER._serialized_end = 1184 + _PRODUCER._serialized_start = 1187 + _PRODUCER._serialized_end = 1560 + _APPENDRECORD._serialized_start = 1562 + _APPENDRECORD._serialized_end = 1623 + _STREAMRECORD._serialized_start = 1626 + _STREAMRECORD._serialized_end = 1755 + _STREAMERRORDETAILS._serialized_start = 1757 + _STREAMERRORDETAILS._serialized_end = 1835 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 91fd88d6d5..30026a9947 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -175,8 +175,14 @@ class WorkflowProducer(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + NAMESPACE_FIELD_NUMBER: builtins.int + WORKFLOW_ID_FIELD_NUMBER: builtins.int RUN_ID_FIELD_NUMBER: builtins.int ATTEMPT_FIELD_NUMBER: builtins.int + namespace: builtins.str + """Required.""" + workflow_id: builtins.str + """Required.""" run_id: builtins.str """Required. The id of this run, not the first run id of its chain. Each run is a separate Producer. @@ -190,6 +196,8 @@ class WorkflowProducer(google.protobuf.message.Message): def __init__( self, *, + namespace: builtins.str = ..., + workflow_id: builtins.str = ..., run_id: builtins.str = ..., attempt: global___WorkflowTaskAttempt | None = ..., ) -> None: ... @@ -197,7 +205,17 @@ class WorkflowProducer(google.protobuf.message.Message): self, field_name: typing.Literal["attempt", b"attempt"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["attempt", b"attempt", "run_id", b"run_id"] + self, + field_name: typing.Literal[ + "attempt", + b"attempt", + "namespace", + b"namespace", + "run_id", + b"run_id", + "workflow_id", + b"workflow_id", + ], ) -> None: ... global___WorkflowProducer = WorkflowProducer @@ -205,15 +223,24 @@ global___WorkflowProducer = WorkflowProducer @typing.final class LocalActivityProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - The Producer of one Local Activity call of a Workflow run. + The Producer of one Local Activity of a Workflow run. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor + NAMESPACE_FIELD_NUMBER: builtins.int + WORKFLOW_ID_FIELD_NUMBER: builtins.int RUN_ID_FIELD_NUMBER: builtins.int + ACTIVITY_ID_FIELD_NUMBER: builtins.int ATTEMPT_FIELD_NUMBER: builtins.int + namespace: builtins.str + """Required. The namespace of the Workflow that made the call.""" + workflow_id: builtins.str + """Required.""" run_id: builtins.str - """Required. The id of the Workflow run that made the call.""" + """Required.""" + activity_id: builtins.str + """Required.""" @property def attempt(self) -> global___LocalActivityAttempt: """Required.""" @@ -221,32 +248,109 @@ class LocalActivityProducer(google.protobuf.message.Message): def __init__( self, *, + namespace: builtins.str = ..., + workflow_id: builtins.str = ..., run_id: builtins.str = ..., + activity_id: builtins.str = ..., attempt: global___LocalActivityAttempt | None = ..., ) -> None: ... def HasField( self, field_name: typing.Literal["attempt", b"attempt"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["attempt", b"attempt", "run_id", b"run_id"] + self, + field_name: typing.Literal[ + "activity_id", + b"activity_id", + "attempt", + b"attempt", + "namespace", + b"namespace", + "run_id", + b"run_id", + "workflow_id", + b"workflow_id", + ], ) -> None: ... global___LocalActivityProducer = LocalActivityProducer @typing.final -class ActivityProducer(google.protobuf.message.Message): +class WorkflowActivityProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - The Producer of an Activity that a Workflow scheduled, or of a Standalone Activity. + The Producer of one Activity that a Workflow scheduled. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor + NAMESPACE_FIELD_NUMBER: builtins.int + WORKFLOW_ID_FIELD_NUMBER: builtins.int RUN_ID_FIELD_NUMBER: builtins.int + ACTIVITY_ID_FIELD_NUMBER: builtins.int ATTEMPT_FIELD_NUMBER: builtins.int + namespace: builtins.str + """Required. The namespace of the Workflow that scheduled the Activity.""" + workflow_id: builtins.str + """Required.""" run_id: builtins.str - """The id of the Workflow run that scheduled the Activity. It's empty for a Standalone - Activity, whose own run id is part of the Producer id. + """Required.""" + activity_id: builtins.str + """Required. A run can use an Activity id again after the first Activity ended. The second + Activity is then a later attempt of the same Producer. + """ + @property + def attempt(self) -> global___ActivityAttempt: + """Required.""" + + def __init__( + self, + *, + namespace: builtins.str = ..., + workflow_id: builtins.str = ..., + run_id: builtins.str = ..., + activity_id: builtins.str = ..., + attempt: global___ActivityAttempt | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["attempt", b"attempt"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "activity_id", + b"activity_id", + "attempt", + b"attempt", + "namespace", + b"namespace", + "run_id", + b"run_id", + "workflow_id", + b"workflow_id", + ], + ) -> None: ... + +global___WorkflowActivityProducer = WorkflowActivityProducer + +@typing.final +class StandaloneActivityProducer(google.protobuf.message.Message): + """Experimental. Might change in the future. + The Producer of a Standalone Activity. Its attempts compare as those of a Workflow's Activity + do. """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + NAMESPACE_FIELD_NUMBER: builtins.int + ACTIVITY_ID_FIELD_NUMBER: builtins.int + RUN_ID_FIELD_NUMBER: builtins.int + ATTEMPT_FIELD_NUMBER: builtins.int + namespace: builtins.str + """Required.""" + activity_id: builtins.str + """Required.""" + run_id: builtins.str + """Required. The run id of the Activity itself.""" @property def attempt(self) -> global___ActivityAttempt: """Required.""" @@ -254,6 +358,8 @@ class ActivityProducer(google.protobuf.message.Message): def __init__( self, *, + namespace: builtins.str = ..., + activity_id: builtins.str = ..., run_id: builtins.str = ..., attempt: global___ActivityAttempt | None = ..., ) -> None: ... @@ -261,10 +367,20 @@ class ActivityProducer(google.protobuf.message.Message): self, field_name: typing.Literal["attempt", b"attempt"] ) -> builtins.bool: ... def ClearField( - self, field_name: typing.Literal["attempt", b"attempt", "run_id", b"run_id"] + self, + field_name: typing.Literal[ + "activity_id", + b"activity_id", + "attempt", + b"attempt", + "namespace", + b"namespace", + "run_id", + b"run_id", + ], ) -> None: ... -global___ActivityProducer = ActivityProducer +global___StandaloneActivityProducer = StandaloneActivityProducer @typing.final class ClientProducer(google.protobuf.message.Message): @@ -275,8 +391,22 @@ class ClientProducer(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + NAMESPACE_FIELD_NUMBER: builtins.int + ID_FIELD_NUMBER: builtins.int + namespace: builtins.str + """Required.""" + id: builtins.str + """Required. The caller can set it, for example to the id of the Nexus operation that + writes. Without one, the SDK makes an id for each client object. + """ def __init__( self, + *, + namespace: builtins.str = ..., + id: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["id", b"id", "namespace", b"namespace"] ) -> None: ... global___ClientProducer = ClientProducer @@ -285,8 +415,9 @@ global___ClientProducer = ClientProducer class Producer(google.protobuf.message.Message): """Experimental. Might change in the future. The writer of a batch of Records. A Producer is one unit of work, such as one Activity or one - Workflow run. Its `id` is the same on every attempt, and every kind except a client also has - the attempt that made the write. + Workflow run. Two Producers are the same when they have the same kind and the same ids. + Every kind except a client also has the attempt that made the write, and the attempt is not + part of what identifies the Producer. A Store that fences fails a write with `FENCED` when a later attempt of the same Producer has already written. A Store that doesn't fence accepts the write. Each Record has its Producer @@ -298,41 +429,28 @@ class Producer(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - ID_FIELD_NUMBER: builtins.int WORKFLOW_FIELD_NUMBER: builtins.int LOCAL_ACTIVITY_FIELD_NUMBER: builtins.int WORKFLOW_ACTIVITY_FIELD_NUMBER: builtins.int STANDALONE_ACTIVITY_FIELD_NUMBER: builtins.int CLIENT_FIELD_NUMBER: builtins.int - id: builtins.str - """Required. The same on every attempt, for example `wf:` for the Producer of a - Workflow run. It's unique within one Stream. The id of a kind with a run contains the run - id, so it stays unique when Producers from several namespaces write to one Stream. - """ @property def workflow(self) -> global___WorkflowProducer: ... @property def local_activity(self) -> global___LocalActivityProducer: ... @property - def workflow_activity(self) -> global___ActivityProducer: - """An Activity that a Workflow scheduled.""" - + def workflow_activity(self) -> global___WorkflowActivityProducer: ... @property - def standalone_activity(self) -> global___ActivityProducer: - """A Standalone Activity. Its attempts compare as those of a Workflow's Activity do. It's a - separate case because it has no Workflow run. - """ - + def standalone_activity(self) -> global___StandaloneActivityProducer: ... @property def client(self) -> global___ClientProducer: ... def __init__( self, *, - id: builtins.str = ..., workflow: global___WorkflowProducer | None = ..., local_activity: global___LocalActivityProducer | None = ..., - workflow_activity: global___ActivityProducer | None = ..., - standalone_activity: global___ActivityProducer | None = ..., + workflow_activity: global___WorkflowActivityProducer | None = ..., + standalone_activity: global___StandaloneActivityProducer | None = ..., client: global___ClientProducer | None = ..., ) -> None: ... def HasField( @@ -357,8 +475,6 @@ class Producer(google.protobuf.message.Message): field_name: typing.Literal[ "client", b"client", - "id", - b"id", "kind", b"kind", "local_activity", diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index a728a6ce60..0ac1a68084 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -95,7 +95,7 @@ global___CreateStreamResponse = CreateStreamResponse class AppendRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Appends one batch of Records as one Producer. If the same batch arrives again, with the same - Producer, attempt and `request_id`, the Store writes it only once. + Producer, attempt and `request_id`, the Store writes it only once while it remembers the id. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -109,8 +109,10 @@ class AppendRecordsRequest(google.protobuf.message.Message): request_id: builtins.str """A value that's unique to this append call and the same on its retries. A caller that got no response sends the batch again with the same value, and the Store returns the offsets of - the first write. A Store remembers the `request_id` of the last batch of each Producer, so - a Producer sends one batch at a time. When it's empty, a retry is written again. + the first write. A Store remembers the `request_id` of the most recent batches of each + Producer of the Stream. How many it remembers is a setting of the Store, so a try that + arrives after more batches than that is written again. When it's empty, a retry is written + again. """ @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: diff --git a/temporalio/nexus/system/stream_service/__init__.py b/temporalio/nexus/system/stream_service/__init__.py index a115da5d4a..e3f70b11cd 100644 --- a/temporalio/nexus/system/stream_service/__init__.py +++ b/temporalio/nexus/system/stream_service/__init__.py @@ -4,7 +4,6 @@ from .models import ( ActivityAttempt, - ActivityProducer, AppendRecord, AppendRecordsRequest, AppendRecordsResponse, @@ -26,11 +25,13 @@ ProducerKindWorkflowActivity, ReadRecordsRequest, ReadRecordsResponse, + StandaloneActivityProducer, StreamIdConflictPolicy, StreamRecord, StreamRef, StreamStatus, Timestamp, + WorkflowActivityProducer, WorkflowProducer, WorkflowTaskAttempt, ) @@ -38,7 +39,6 @@ __all__ = [ "ActivityAttempt", - "ActivityProducer", "AppendRecord", "AppendRecordsRequest", "AppendRecordsResponse", @@ -60,11 +60,13 @@ "ProducerKindClient", "ReadRecordsRequest", "ReadRecordsResponse", + "StandaloneActivityProducer", "StreamIdConflictPolicy", "StreamRecord", "StreamRef", "StreamStatus", "Timestamp", + "WorkflowActivityProducer", "WorkflowProducer", "WorkflowTaskAttempt", "StreamService", diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index 61ab1c005e..0d455d0ef5 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -331,7 +331,6 @@ def to_transfer_type( class Producer: """The writer of a batch. A later attempt supersedes an earlier one.""" - id: str kind: ProducerKind | None = None @@ -350,9 +349,6 @@ def from_transfer_type( value: temporalio.api.stream.v1.message_pb2.Producer, type_hint: type[Producer], ) -> Producer: - if not value.id: - raise ValueError("missing required field Producer.id") - id = value.id _oneof_kind: ( ProducerKindWorkflow | ProducerKindLocalActivity @@ -376,14 +372,14 @@ def from_transfer_type( ) case "workflow_activity": _oneof_kind = ProducerKindWorkflowActivity( - _ActivityProducerTransferTypeConverter().from_transfer_type( - value.workflow_activity, ActivityProducer + _WorkflowActivityProducerTransferTypeConverter().from_transfer_type( + value.workflow_activity, WorkflowActivityProducer ) ) case "standalone_activity": _oneof_kind = ProducerKindStandaloneActivity( - _ActivityProducerTransferTypeConverter().from_transfer_type( - value.standalone_activity, ActivityProducer + _StandaloneActivityProducerTransferTypeConverter().from_transfer_type( + value.standalone_activity, StandaloneActivityProducer ) ) case "client": @@ -395,7 +391,6 @@ def from_transfer_type( case None: _oneof_kind = None return Producer( - id=id, kind=_oneof_kind, ) @@ -405,7 +400,6 @@ def to_transfer_type( value: Producer, ) -> temporalio.api.stream.v1.message_pb2.Producer: message = temporalio.api.stream.v1.message_pb2.Producer() - message.id = value.id if value.kind is not None: match value.kind: case ProducerKindWorkflow(): @@ -422,13 +416,13 @@ def to_transfer_type( ) case ProducerKindWorkflowActivity(): message.workflow_activity.CopyFrom( - _ActivityProducerTransferTypeConverter().to_transfer_type( + _WorkflowActivityProducerTransferTypeConverter().to_transfer_type( value.kind.value ) ) case ProducerKindStandaloneActivity(): message.standalone_activity.CopyFrom( - _ActivityProducerTransferTypeConverter().to_transfer_type( + _StandaloneActivityProducerTransferTypeConverter().to_transfer_type( value.kind.value ) ) @@ -448,6 +442,8 @@ def to_transfer_type( class WorkflowProducer: """The Producer of a Workflow run.""" + namespace: str + workflow_id: str run_id: str attempt: WorkflowTaskAttempt | None = None @@ -467,10 +463,18 @@ def from_transfer_type( value: temporalio.api.stream.v1.message_pb2.WorkflowProducer, type_hint: type[WorkflowProducer], ) -> WorkflowProducer: + if not value.namespace: + raise ValueError("missing required field WorkflowProducer.namespace") + namespace = value.namespace + if not value.workflow_id: + raise ValueError("missing required field WorkflowProducer.workflow_id") + workflow_id = value.workflow_id if not value.run_id: raise ValueError("missing required field WorkflowProducer.run_id") run_id = value.run_id return WorkflowProducer( + namespace=namespace, + workflow_id=workflow_id, run_id=run_id, attempt=_WorkflowTaskAttemptTransferTypeConverter().from_transfer_type( value.attempt, WorkflowTaskAttempt @@ -485,6 +489,8 @@ def to_transfer_type( value: WorkflowProducer, ) -> temporalio.api.stream.v1.message_pb2.WorkflowProducer: message = temporalio.api.stream.v1.message_pb2.WorkflowProducer() + message.namespace = value.namespace + message.workflow_id = value.workflow_id message.run_id = value.run_id if value.attempt is not None: message.attempt.CopyFrom( @@ -602,9 +608,12 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class LocalActivityProducer: - """The Producer of one Local Activity call.""" + """The Producer of one Local Activity of a Workflow run.""" + namespace: str + workflow_id: str run_id: str + activity_id: str attempt: LocalActivityAttempt @@ -624,16 +633,28 @@ def from_transfer_type( value: temporalio.api.stream.v1.message_pb2.LocalActivityProducer, type_hint: type[LocalActivityProducer], ) -> LocalActivityProducer: + if not value.namespace: + raise ValueError("missing required field LocalActivityProducer.namespace") + namespace = value.namespace + if not value.workflow_id: + raise ValueError("missing required field LocalActivityProducer.workflow_id") + workflow_id = value.workflow_id if not value.run_id: raise ValueError("missing required field LocalActivityProducer.run_id") run_id = value.run_id + if not value.activity_id: + raise ValueError("missing required field LocalActivityProducer.activity_id") + activity_id = value.activity_id if not value.HasField("attempt"): raise ValueError("missing required field LocalActivityProducer.attempt") attempt = _LocalActivityAttemptTransferTypeConverter().from_transfer_type( value.attempt, LocalActivityAttempt ) return LocalActivityProducer( + namespace=namespace, + workflow_id=workflow_id, run_id=run_id, + activity_id=activity_id, attempt=attempt, ) @@ -643,7 +664,10 @@ def to_transfer_type( value: LocalActivityProducer, ) -> temporalio.api.stream.v1.message_pb2.LocalActivityProducer: message = temporalio.api.stream.v1.message_pb2.LocalActivityProducer() + message.namespace = value.namespace + message.workflow_id = value.workflow_id message.run_id = value.run_id + message.activity_id = value.activity_id message.attempt.CopyFrom( _LocalActivityAttemptTransferTypeConverter().to_transfer_type(value.attempt) ) @@ -707,56 +731,83 @@ def to_transfer_type( )(LocalActivityAttempt) # pyright: ignore[reportUnusedCallResult] -@dataclasses.dataclass(slots=True, kw_only=True) -class ActivityProducer: - """The Producer of an Activity.""" +@dataclasses.dataclass(slots=True) +class WorkflowActivityProducer: + """The Producer of one Activity that a Workflow scheduled.""" - run_id: str | None = None + namespace: str + workflow_id: str + run_id: str + activity_id: str attempt: ActivityAttempt -class _ActivityProducerTransferTypeConverter( +class _WorkflowActivityProducerTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - ActivityProducer, temporalio.api.stream.v1.message_pb2.ActivityProducer + WorkflowActivityProducer, + temporalio.api.stream.v1.message_pb2.WorkflowActivityProducer, ] ): transfer_type: ( - type[temporalio.api.stream.v1.message_pb2.ActivityProducer] | None - ) = temporalio.api.stream.v1.message_pb2.ActivityProducer + type[temporalio.api.stream.v1.message_pb2.WorkflowActivityProducer] | None + ) = temporalio.api.stream.v1.message_pb2.WorkflowActivityProducer @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.stream.v1.message_pb2.ActivityProducer, - type_hint: type[ActivityProducer], - ) -> ActivityProducer: + value: temporalio.api.stream.v1.message_pb2.WorkflowActivityProducer, + type_hint: type[WorkflowActivityProducer], + ) -> WorkflowActivityProducer: + if not value.namespace: + raise ValueError( + "missing required field WorkflowActivityProducer.namespace" + ) + namespace = value.namespace + if not value.workflow_id: + raise ValueError( + "missing required field WorkflowActivityProducer.workflow_id" + ) + workflow_id = value.workflow_id + if not value.run_id: + raise ValueError("missing required field WorkflowActivityProducer.run_id") + run_id = value.run_id + if not value.activity_id: + raise ValueError( + "missing required field WorkflowActivityProducer.activity_id" + ) + activity_id = value.activity_id if not value.HasField("attempt"): - raise ValueError("missing required field ActivityProducer.attempt") + raise ValueError("missing required field WorkflowActivityProducer.attempt") attempt = _ActivityAttemptTransferTypeConverter().from_transfer_type( value.attempt, ActivityAttempt ) - return ActivityProducer( - run_id=value.run_id if bool(value.run_id) else None, + return WorkflowActivityProducer( + namespace=namespace, + workflow_id=workflow_id, + run_id=run_id, + activity_id=activity_id, attempt=attempt, ) @typing_extensions.override def to_transfer_type( self, - value: ActivityProducer, - ) -> temporalio.api.stream.v1.message_pb2.ActivityProducer: - message = temporalio.api.stream.v1.message_pb2.ActivityProducer() - if value.run_id is not None: - message.run_id = value.run_id + value: WorkflowActivityProducer, + ) -> temporalio.api.stream.v1.message_pb2.WorkflowActivityProducer: + message = temporalio.api.stream.v1.message_pb2.WorkflowActivityProducer() + message.namespace = value.namespace + message.workflow_id = value.workflow_id + message.run_id = value.run_id + message.activity_id = value.activity_id message.attempt.CopyFrom( _ActivityAttemptTransferTypeConverter().to_transfer_type(value.attempt) ) return message -temporalio.converter.transfer_type_convertible(_ActivityProducerTransferTypeConverter)( - ActivityProducer -) # pyright: ignore[reportUnusedCallResult] +temporalio.converter.transfer_type_convertible( + _WorkflowActivityProducerTransferTypeConverter +)(WorkflowActivityProducer) # pyright: ignore[reportUnusedCallResult] @dataclasses.dataclass(slots=True) @@ -815,11 +866,85 @@ def to_transfer_type( ) # pyright: ignore[reportUnusedCallResult] +@dataclasses.dataclass(slots=True) +class StandaloneActivityProducer: + """The Producer of a Standalone Activity.""" + + namespace: str + activity_id: str + run_id: str + attempt: ActivityAttempt + + +class _StandaloneActivityProducerTransferTypeConverter( + temporalio.converter.TransferTypeConverter[ + StandaloneActivityProducer, + temporalio.api.stream.v1.message_pb2.StandaloneActivityProducer, + ] +): + transfer_type: ( + type[temporalio.api.stream.v1.message_pb2.StandaloneActivityProducer] | None + ) = temporalio.api.stream.v1.message_pb2.StandaloneActivityProducer + + @typing_extensions.override + def from_transfer_type( + self, + value: temporalio.api.stream.v1.message_pb2.StandaloneActivityProducer, + type_hint: type[StandaloneActivityProducer], + ) -> StandaloneActivityProducer: + if not value.namespace: + raise ValueError( + "missing required field StandaloneActivityProducer.namespace" + ) + namespace = value.namespace + if not value.activity_id: + raise ValueError( + "missing required field StandaloneActivityProducer.activity_id" + ) + activity_id = value.activity_id + if not value.run_id: + raise ValueError("missing required field StandaloneActivityProducer.run_id") + run_id = value.run_id + if not value.HasField("attempt"): + raise ValueError( + "missing required field StandaloneActivityProducer.attempt" + ) + attempt = _ActivityAttemptTransferTypeConverter().from_transfer_type( + value.attempt, ActivityAttempt + ) + return StandaloneActivityProducer( + namespace=namespace, + activity_id=activity_id, + run_id=run_id, + attempt=attempt, + ) + + @typing_extensions.override + def to_transfer_type( + self, + value: StandaloneActivityProducer, + ) -> temporalio.api.stream.v1.message_pb2.StandaloneActivityProducer: + message = temporalio.api.stream.v1.message_pb2.StandaloneActivityProducer() + message.namespace = value.namespace + message.activity_id = value.activity_id + message.run_id = value.run_id + message.attempt.CopyFrom( + _ActivityAttemptTransferTypeConverter().to_transfer_type(value.attempt) + ) + return message + + +temporalio.converter.transfer_type_convertible( + _StandaloneActivityProducerTransferTypeConverter +)(StandaloneActivityProducer) # pyright: ignore[reportUnusedCallResult] + + @dataclasses.dataclass(slots=True) class ClientProducer: """The Producer of a client. It has no run and no attempt.""" - pass + namespace: str + id: str class _ClientProducerTransferTypeConverter( @@ -837,7 +962,16 @@ def from_transfer_type( value: temporalio.api.stream.v1.message_pb2.ClientProducer, type_hint: type[ClientProducer], ) -> ClientProducer: - return ClientProducer() + if not value.namespace: + raise ValueError("missing required field ClientProducer.namespace") + namespace = value.namespace + if not value.id: + raise ValueError("missing required field ClientProducer.id") + id = value.id + return ClientProducer( + namespace=namespace, + id=id, + ) @typing_extensions.override def to_transfer_type( @@ -845,6 +979,8 @@ def to_transfer_type( value: ClientProducer, ) -> temporalio.api.stream.v1.message_pb2.ClientProducer: message = temporalio.api.stream.v1.message_pb2.ClientProducer() + message.namespace = value.namespace + message.id = value.id return message @@ -1313,12 +1449,12 @@ class ProducerKindLocalActivity: @dataclasses.dataclass(slots=True) class ProducerKindWorkflowActivity: - value: ActivityProducer + value: WorkflowActivityProducer @dataclasses.dataclass(slots=True) class ProducerKindStandaloneActivity: - value: ActivityProducer + value: StandaloneActivityProducer @dataclasses.dataclass(slots=True) @@ -1333,4 +1469,4 @@ class ProducerKindClient: | ProducerKindStandaloneActivity | ProducerKindClient ) -"""The kind of a Producer, with its run and attempt.""" +"""The kind of a Producer, with its ids and its attempt.""" From 5b5bf8bf303ee17949baf77799cfc69530cc94a8 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Fri, 20 Nov 2026 23:24:20 -0700 Subject: [PATCH 07/24] Regenerate the Streams API with the API's comments on a Store's rules The API states the rules of a Store as the Stores keep them. Only docs change. --- .../streamservice/v1/request_response_pb2.pyi | 27 ++++++++++++------- .../client/_resources/stream.py | 4 +-- .../workflow/_resources/stream.py | 4 +-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index 0ac1a68084..cf9e568cbd 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -38,8 +38,9 @@ class CreateStreamRequest(google.protobuf.message.Message): ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int REQUEST_ID_FIELD_NUMBER: builtins.int stream_id: builtins.str - """Required. The id of the Stream to create. Callers treat it as opaque. An id is never used - for a second Stream, so a create for a closed or expired Stream fails. + """Required. The id of the Stream to create. Callers treat it as opaque. A create for a closed + or expired Stream fails. A Store can forget an expired Stream after a time of its choice, + and a create for its id succeeds after that. """ id_conflict_policy: ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType @@ -125,7 +126,9 @@ class AppendRecordsRequest(google.protobuf.message.Message): self, ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ temporalio.api.stream.v1.message_pb2.AppendRecord - ]: ... + ]: + """Required. A batch has at least one Record.""" + def __init__( self, *, @@ -235,7 +238,7 @@ global___CloseStreamResponse = CloseStreamResponse class ReadRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Reads one page of Records after an offset. When no Record is left, the read waits for a new - one, so a reader long-polls. + one or for the close of the Stream, so a reader long-polls. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -264,8 +267,9 @@ class ReadRecordsRequest(google.protobuf.message.Message): """ @property def wait(self) -> google.protobuf.duration_pb2.Duration: - """How long the read waits for a new Record before it returns an empty page. When it's unset, - the read returns immediately. The deadline of the request must be longer than this wait. + """How long the read waits for a new Record, or for the close of the Stream, before it returns + an empty page. When it's unset, the read returns immediately. The deadline of the request + must be longer than this wait. """ def __init__( @@ -310,9 +314,10 @@ class ReadRecordsResponse(google.protobuf.message.Message): LAST_OFFSET_FIELD_NUMBER: builtins.int DONE_FIELD_NUMBER: builtins.int last_offset: builtins.bytes - """The offset of the last Record in this page. The next read passes it as `from_offset`. For - an empty page it's the `from_offset` of the request, so it's empty only when the request - had none, and the next read then starts where this one did. + """Where the next read goes on. The next read passes it as `from_offset`. It's never before + the last Record in this page, and it never skips a Record, but it can be after entries of + the Store that aren't Records. For an empty page it can be the `from_offset` of the + request, which is empty when the request had none. """ done: builtins.bool """True when the Stream is closed and this page has its last Record. A read has no other sign @@ -379,7 +384,9 @@ class DescribeStreamResponse(google.protobuf.message.Message): LAST_OFFSET_FIELD_NUMBER: builtins.int status: temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType last_offset: builtins.bytes - """The offset of the newest Record. It's empty when the Stream has no Record.""" + """The offset of the newest Record, or an offset after it that skips no Record. A read from it + returns only the Records that come later. It's empty when the Stream has no Record. + """ def __init__( self, *, diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index c3d8f907cb..6a6f46c451 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -167,7 +167,7 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long to wait for a new Record before the read returns an empty + wait: How long the read waits for a new Record or a close before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. @@ -216,7 +216,7 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long to wait for a new Record before the read returns an empty + wait: How long the read waits for a new Record or a close before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 25329fdc2d..2ec7074865 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -123,7 +123,7 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long to wait for a new Record before the read returns an empty + wait: How long the read waits for a new Record or a close before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. @@ -161,7 +161,7 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long to wait for a new Record before the read returns an empty + wait: How long the read waits for a new Record or a close before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. From bd9690cc50c080893ae844ad3c6343bf80c99f84 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Sat, 21 Nov 2026 19:08:33 -0700 Subject: [PATCH 08/24] Leave the generated Stream code out of mypy mypy fails on the code that nexgen generates, and the package of the Workflow service is left out for that already. --- pyproject.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 54ea30212d..5b7890ab52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -177,11 +177,15 @@ exclude = [ # Ignore generated code 'temporalio/api', 'temporalio/bridge/proto', + 'temporalio/nexus/system/stream_service', 'temporalio/nexus/system/workflow_service', ] [[tool.mypy.overrides]] -module = "temporalio.nexus.system.workflow_service.*" +module = [ + "temporalio.nexus.system.stream_service.*", + "temporalio.nexus.system.workflow_service.*", +] ignore_errors = true [tool.pydocstyle] From cfad2eb5c83e193e764184bf2b8263645a9c48ed Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Sun, 22 Nov 2026 14:27:45 -0700 Subject: [PATCH 09/24] Regenerate the bridge protos and the payload visitor Core has Stream commands and jobs for Workflow code. Their generated files are in this commit, so that the hand-written part of the Streams API has no generated code. They come from the Core pointer and the visitor generator of that part. --- temporalio/bridge/_visitor.py | 59 ++- .../bridge/proto/external_data/__init__.py | 21 +- .../proto/external_data/external_data_pb2.py | 27 +- .../proto/external_data/external_data_pb2.pyi | 382 ++++++++++++++++++ .../proto/workflow_activation/__init__.py | 10 + .../workflow_activation_pb2.py | 119 +++--- .../workflow_activation_pb2.pyi | 272 ++++++++++++- .../proto/workflow_commands/__init__.py | 8 + .../workflow_commands_pb2.py | 145 ++++--- .../workflow_commands_pb2.pyi | 307 ++++++++++++++ 10 files changed, 1217 insertions(+), 133 deletions(-) diff --git a/temporalio/bridge/_visitor.py b/temporalio/bridge/_visitor.py index 8832b56bc4..4b02edbc65 100644 --- a/temporalio/bridge/_visitor.py +++ b/temporalio/bridge/_visitor.py @@ -308,6 +308,38 @@ async def _visit_coresdk_workflow_activation_ResolveNexusOperation( if o.HasField("result"): await self._visit_coresdk_nexus_NexusOperationResult(fs, o.result) + 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_ResolveStreamAppend( + self, fs: VisitorFunctions, o: Any + ): + if o.HasField("failed"): + await self._visit_temporal_api_failure_v1_Failure(fs, o.failed) + + async def _visit_coresdk_workflow_activation_ResolveStreamClose( + self, fs: VisitorFunctions, o: Any + ): + if 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 ): @@ -353,6 +385,18 @@ async def _visit_coresdk_workflow_activation_WorkflowActivationJob( await self._visit_coresdk_workflow_activation_ResolveNexusOperation( fs, o.resolve_nexus_operation ) + elif o.HasField("resolve_stream_read"): + await self._visit_coresdk_workflow_activation_ResolveStreamRead( + fs, o.resolve_stream_read + ) + elif o.HasField("resolve_stream_append"): + await self._visit_coresdk_workflow_activation_ResolveStreamAppend( + fs, o.resolve_stream_append + ) + elif o.HasField("resolve_stream_close"): + await self._visit_coresdk_workflow_activation_ResolveStreamClose( + fs, o.resolve_stream_close + ) async def _visit_coresdk_workflow_activation_WorkflowActivation( self, fs: VisitorFunctions, o: Any @@ -492,6 +536,11 @@ async def _visit_coresdk_workflow_commands_ScheduleNexusOperation( if o.HasField("input"): await self._visit_nexus_operation_input_payload(fs, o.input) + async def _visit_coresdk_workflow_commands_AppendToStream( + self, fs: VisitorFunctions, o: Any + ): + await self._visit_payload_container(fs, o.bodies) + async def _visit_coresdk_workflow_commands_WorkflowCommand( self, fs: VisitorFunctions, o: Any ): @@ -551,6 +600,10 @@ async def _visit_coresdk_workflow_commands_WorkflowCommand( await self._visit_coresdk_workflow_commands_ScheduleNexusOperation( fs, o.schedule_nexus_operation ) + elif o.HasField("append_to_stream"): + await self._visit_coresdk_workflow_commands_AppendToStream( + fs, o.append_to_stream + ) async def _visit_coresdk_workflow_completion_Success( self, fs: VisitorFunctions, o: Any @@ -681,12 +734,6 @@ async def _visit_temporal_api_streamservice_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 ): diff --git a/temporalio/bridge/proto/external_data/__init__.py b/temporalio/bridge/proto/external_data/__init__.py index 836e97ef43..c33e1cbe28 100644 --- a/temporalio/bridge/proto/external_data/__init__.py +++ b/temporalio/bridge/proto/external_data/__init__.py @@ -1,6 +1,25 @@ -from .external_data_pb2 import LocalActivityMarkerData, PatchedMarkerData +from .external_data_pb2 import ( + LocalActivityMarkerData, + PatchedMarkerData, + StreamAppendOffsets, + StreamAppendResult, + StreamCloseIntent, + StreamCloseResult, + StreamFailure, + StreamMarkerData, + StreamReadPage, + StreamReadResult, +) __all__ = [ "LocalActivityMarkerData", "PatchedMarkerData", + "StreamAppendOffsets", + "StreamAppendResult", + "StreamCloseIntent", + "StreamCloseResult", + "StreamFailure", + "StreamMarkerData", + "StreamReadPage", + "StreamReadResult", ] diff --git a/temporalio/bridge/proto/external_data/external_data_pb2.py b/temporalio/bridge/proto/external_data/external_data_pb2.py index 4bda6f5144..803c79c8e0 100644 --- a/temporalio/bridge/proto/external_data/external_data_pb2.py +++ b/temporalio/bridge/proto/external_data/external_data_pb2.py @@ -14,10 +14,11 @@ from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xb2\x02\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x10\x61\x63tivation_index\x18\x08 \x01(\x04H\x00\x88\x01\x01\x42\x13\n\x11_activation_index"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3' + b'\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xb2\x02\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x10\x61\x63tivation_index\x18\x08 \x01(\x04H\x00\x88\x01\x01\x42\x13\n\x11_activation_index"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\x81\x02\n\x10StreamMarkerData\x12?\n\rclose_intents\x18\x01 \x03(\x0b\x32(.coresdk.external_data.StreamCloseIntent\x12:\n\x07\x61ppends\x18\x02 \x03(\x0b\x32).coresdk.external_data.StreamAppendResult\x12\x38\n\x06\x63loses\x18\x03 \x03(\x0b\x32(.coresdk.external_data.StreamCloseResult\x12\x36\n\x05reads\x18\x04 \x03(\x0b\x32\'.coresdk.external_data.StreamReadResult"B\n\x11StreamCloseIntent\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"\xe0\x01\n\x12StreamAppendResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12>\n\x08\x61ppended\x18\x05 \x01(\x0b\x32*.coresdk.external_data.StreamAppendOffsetsH\x00\x12\x37\n\x07\x66\x61ilure\x18\x06 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x42\x08\n\x06result"@\n\x13StreamAppendOffsets\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"0\n\rStreamFailure\x12\x0e\n\x06reason\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t"q\n\x11StreamCloseResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x18\n\x10\x61\x63tivation_index\x18\x02 \x01(\x04\x12\x35\n\x07\x66\x61ilure\x18\x03 \x01(\x0b\x32$.coresdk.external_data.StreamFailure"\x97\x02\n\x10StreamReadResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12\x13\n\x0b\x66rom_offset\x18\x05 \x01(\x0c\x12\x35\n\x04page\x18\x06 \x01(\x0b\x32%.coresdk.external_data.StreamReadPageH\x00\x12\x37\n\x07\x66\x61ilure\x18\x07 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x12+\n\tcancelled\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06result"Z\n\x0eStreamReadPage\x12\x14\n\x0crecord_count\x18\x01 \x01(\r\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x0e\n\x06\x64igest\x18\x03 \x01(\x0c\x12\x14\n\x0crecord_bytes\x18\x04 \x01(\x04\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -27,8 +28,24 @@ DESCRIPTOR._serialized_options = ( b"\352\002/Temporalio::Internal::Bridge::Api::ExternalData" ) - _LOCALACTIVITYMARKERDATA._serialized_start = 144 - _LOCALACTIVITYMARKERDATA._serialized_end = 450 - _PATCHEDMARKERDATA._serialized_start = 452 - _PATCHEDMARKERDATA._serialized_end = 503 + _LOCALACTIVITYMARKERDATA._serialized_start = 173 + _LOCALACTIVITYMARKERDATA._serialized_end = 479 + _PATCHEDMARKERDATA._serialized_start = 481 + _PATCHEDMARKERDATA._serialized_end = 532 + _STREAMMARKERDATA._serialized_start = 535 + _STREAMMARKERDATA._serialized_end = 792 + _STREAMCLOSEINTENT._serialized_start = 794 + _STREAMCLOSEINTENT._serialized_end = 860 + _STREAMAPPENDRESULT._serialized_start = 863 + _STREAMAPPENDRESULT._serialized_end = 1087 + _STREAMAPPENDOFFSETS._serialized_start = 1089 + _STREAMAPPENDOFFSETS._serialized_end = 1153 + _STREAMFAILURE._serialized_start = 1155 + _STREAMFAILURE._serialized_end = 1203 + _STREAMCLOSERESULT._serialized_start = 1205 + _STREAMCLOSERESULT._serialized_end = 1318 + _STREAMREADRESULT._serialized_start = 1321 + _STREAMREADRESULT._serialized_end = 1600 + _STREAMREADPAGE._serialized_start = 1602 + _STREAMREADPAGE._serialized_end = 1692 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/external_data/external_data_pb2.pyi b/temporalio/bridge/proto/external_data/external_data_pb2.pyi index edcd4581a1..a8dbcbd5a8 100644 --- a/temporalio/bridge/proto/external_data/external_data_pb2.pyi +++ b/temporalio/bridge/proto/external_data/external_data_pb2.pyi @@ -4,10 +4,13 @@ isort:skip_file """ import builtins +import collections.abc import typing import google.protobuf.descriptor import google.protobuf.duration_pb2 +import google.protobuf.empty_pb2 +import google.protobuf.internal.containers import google.protobuf.message import google.protobuf.timestamp_pb2 @@ -139,3 +142,382 @@ class PatchedMarkerData(google.protobuf.message.Message): ) -> None: ... global___PatchedMarkerData = PatchedMarkerData + +@typing.final +class StreamMarkerData(google.protobuf.message.Message): + """The data of a `core_stream` marker. Core records one in each Workflow Task in which Workflow + code got a Stream result or asked for a close. The marker has these details: + * `data` has this message as JSON, with each `bytes` field as lower-case hex. + * `records` has the body of each Record of the reads with `records_in_history`, one payload for + each. They're in the order of `reads`, and those of one read in the order of its Stream. It's + absent if the marker has no such Record. + * `record_info` has one `binary/plain` payload with the rest of each of those Records, in the + same order. Each is its `temporalio.api.stream.v1.StreamRecord` with no body, with its length + before it as a varint. It's absent if `records` is. + + History keeps each marker, and every later version of Core reads it. So these rules hold for + each message of the marker: + * A field keeps its name, which is its key in the JSON. + * A new field is `optional`, since the markers of an earlier version don't have it. + * A new `repeated` field has `#[serde(default)]` in `build.rs`, for the same reason. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + CLOSE_INTENTS_FIELD_NUMBER: builtins.int + APPENDS_FIELD_NUMBER: builtins.int + CLOSES_FIELD_NUMBER: builtins.int + READS_FIELD_NUMBER: builtins.int + @property + def close_intents( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___StreamCloseIntent + ]: ... + @property + def appends( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___StreamAppendResult + ]: ... + @property + def closes( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___StreamCloseResult + ]: ... + @property + def reads( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___StreamReadResult + ]: ... + def __init__( + self, + *, + close_intents: collections.abc.Iterable[global___StreamCloseIntent] + | None = ..., + appends: collections.abc.Iterable[global___StreamAppendResult] | None = ..., + closes: collections.abc.Iterable[global___StreamCloseResult] | None = ..., + reads: collections.abc.Iterable[global___StreamReadResult] | None = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "appends", + b"appends", + "close_intents", + b"close_intents", + "closes", + b"closes", + "reads", + b"reads", + ], + ) -> None: ... + +global___StreamMarkerData = StreamMarkerData + +@typing.final +class StreamCloseIntent(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 + seq: builtins.int + stream_id: builtins.str + store: builtins.str + """The Store name of the Stream's ref.""" + def __init__( + self, + *, + seq: builtins.int = ..., + stream_id: builtins.str = ..., + store: builtins.str = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "seq", b"seq", "store", b"store", "stream_id", b"stream_id" + ], + ) -> None: ... + +global___StreamCloseIntent = StreamCloseIntent + +@typing.final +class StreamAppendResult(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 + APPENDED_FIELD_NUMBER: builtins.int + FAILURE_FIELD_NUMBER: builtins.int + seq: builtins.int + stream_id: builtins.str + store: builtins.str + """The Store name of the Stream's ref.""" + activation_index: builtins.int + """The index of the activation, within its Workflow Task, in which Workflow code got the result.""" + @property + def appended(self) -> global___StreamAppendOffsets: ... + @property + def failure(self) -> global___StreamFailure: ... + def __init__( + self, + *, + seq: builtins.int = ..., + stream_id: builtins.str = ..., + store: builtins.str = ..., + activation_index: builtins.int = ..., + appended: global___StreamAppendOffsets | None = ..., + failure: global___StreamFailure | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "appended", b"appended", "failure", b"failure", "result", b"result" + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "activation_index", + b"activation_index", + "appended", + b"appended", + "failure", + b"failure", + "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["appended", "failure"] | None: ... + +global___StreamAppendResult = StreamAppendResult + +@typing.final +class StreamAppendOffsets(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + FIRST_OFFSET_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + first_offset: builtins.bytes + last_offset: builtins.bytes + def __init__( + self, + *, + first_offset: builtins.bytes = ..., + last_offset: builtins.bytes = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "first_offset", b"first_offset", "last_offset", b"last_offset" + ], + ) -> None: ... + +global___StreamAppendOffsets = StreamAppendOffsets + +@typing.final +class StreamFailure(google.protobuf.message.Message): + """Why a Stream call failed. Core builds the failure that Workflow code gets from these two.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REASON_FIELD_NUMBER: builtins.int + MESSAGE_FIELD_NUMBER: builtins.int + reason: builtins.str + """The name of the `temporalio.api.enums.v1.StreamErrorReason`, such as + `STREAM_ERROR_REASON_CLOSED`. History has the name for good, so a reason keeps its name. + """ + message: builtins.str + """The message of the failure, of at most 4096 bytes.""" + def __init__( + self, + *, + reason: builtins.str = ..., + message: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["message", b"message", "reason", b"reason"] + ) -> None: ... + +global___StreamFailure = StreamFailure + +@typing.final +class StreamCloseResult(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + ACTIVATION_INDEX_FIELD_NUMBER: builtins.int + FAILURE_FIELD_NUMBER: builtins.int + seq: builtins.int + activation_index: builtins.int + """The index of the activation, within its Workflow Task, in which Workflow code got the result.""" + @property + def failure(self) -> global___StreamFailure: + """Unset if the Stream is closed.""" + + def __init__( + self, + *, + seq: builtins.int = ..., + activation_index: builtins.int = ..., + failure: global___StreamFailure | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["failure", b"failure"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "activation_index", + b"activation_index", + "failure", + b"failure", + "seq", + b"seq", + ], + ) -> None: ... + +global___StreamCloseResult = StreamCloseResult + +@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 + FROM_OFFSET_FIELD_NUMBER: builtins.int + PAGE_FIELD_NUMBER: builtins.int + FAILURE_FIELD_NUMBER: builtins.int + CANCELLED_FIELD_NUMBER: builtins.int + seq: builtins.int + stream_id: builtins.str + store: builtins.str + """The Store name of the Stream's ref.""" + activation_index: builtins.int + """The index of the activation, within its Workflow Task, in which Workflow code got the result.""" + from_offset: builtins.bytes + """The `from_offset` of the read. A replay reads the Records of a page after it.""" + @property + def page(self) -> global___StreamReadPage: ... + @property + def failure(self) -> global___StreamFailure: ... + @property + def cancelled(self) -> google.protobuf.empty_pb2.Empty: + """Workflow code cancelled the read before it got the job of the read.""" + + def __init__( + self, + *, + seq: builtins.int = ..., + stream_id: builtins.str = ..., + store: builtins.str = ..., + activation_index: builtins.int = ..., + from_offset: builtins.bytes = ..., + page: global___StreamReadPage | None = ..., + failure: global___StreamFailure | None = ..., + cancelled: google.protobuf.empty_pb2.Empty | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "cancelled", + b"cancelled", + "failure", + b"failure", + "page", + b"page", + "result", + b"result", + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "activation_index", + b"activation_index", + "cancelled", + b"cancelled", + "failure", + b"failure", + "from_offset", + b"from_offset", + "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", "cancelled"] | None: ... + +global___StreamReadResult = StreamReadResult + +@typing.final +class StreamReadPage(google.protobuf.message.Message): + """A page that a read gave Workflow code.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RECORD_COUNT_FIELD_NUMBER: builtins.int + DONE_FIELD_NUMBER: builtins.int + DIGEST_FIELD_NUMBER: builtins.int + RECORD_BYTES_FIELD_NUMBER: builtins.int + record_count: builtins.int + """The number of Records in the page.""" + done: builtins.bool + """True if the Stream was closed and had no Record after this page.""" + digest: builtins.bytes + """The first 16 bytes of the SHA-256 of the Records. It's empty for a read with + `records_in_history`, whose Records are in the details of the marker, or if the page has no + Record. + """ + record_bytes: builtins.int + """The bytes of the Records, each as a page of a read encodes it, with the tag and the length of + its field. That is the measure of the `max_bytes` of a read. It's set when `digest` is, so a + replay knows how much it reads. + """ + def __init__( + self, + *, + record_count: builtins.int = ..., + done: builtins.bool = ..., + digest: builtins.bytes = ..., + record_bytes: builtins.int = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "digest", + b"digest", + "done", + b"done", + "record_bytes", + b"record_bytes", + "record_count", + b"record_count", + ], + ) -> None: ... + +global___StreamReadPage = StreamReadPage diff --git a/temporalio/bridge/proto/workflow_activation/__init__.py b/temporalio/bridge/proto/workflow_activation/__init__.py index 5c178e2185..6db42d326e 100644 --- a/temporalio/bridge/proto/workflow_activation/__init__.py +++ b/temporalio/bridge/proto/workflow_activation/__init__.py @@ -16,7 +16,12 @@ ResolveNexusOperationStart, ResolveRequestCancelExternalWorkflow, ResolveSignalExternalWorkflow, + ResolveStreamAppend, + ResolveStreamClose, + ResolveStreamRead, SignalWorkflow, + StreamAppended, + StreamPage, UpdateRandomSeed, WorkflowActivation, WorkflowActivationJob, @@ -40,7 +45,12 @@ "ResolveNexusOperationStart", "ResolveRequestCancelExternalWorkflow", "ResolveSignalExternalWorkflow", + "ResolveStreamAppend", + "ResolveStreamClose", + "ResolveStreamRead", "SignalWorkflow", + "StreamAppended", + "StreamPage", "UpdateRandomSeed", "WorkflowActivation", "WorkflowActivationJob", diff --git a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py index 589119c72b..68fe115f44 100644 --- a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py +++ b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py @@ -32,6 +32,9 @@ from temporalio.api.nexus.v1 import ( message_pb2 as temporal_dot_api_dot_nexus_dot_v1_dot_message__pb2, ) +from temporalio.api.stream.v1 import ( + message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, +) from temporalio.api.update.v1 import ( message_pb2 as temporal_dot_api_dot_update_dot_v1_dot_message__pb2, ) @@ -49,7 +52,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n?temporal/sdk/core/workflow_activation/workflow_activation.proto\x12\x1b\x63oresdk.workflow_activation\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a%temporal/api/failure/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a$temporal/api/update/v1/message.proto\x1a$temporal/api/common/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a\x37temporal/sdk/core/activity_result/activity_result.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a#temporal/sdk/core/nexus/nexus.proto"\xa2\x04\n\x12WorkflowActivation\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0cis_replaying\x18\x03 \x01(\x08\x12\x16\n\x0ehistory_length\x18\x04 \x01(\r\x12@\n\x04jobs\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.WorkflowActivationJob\x12 \n\x18\x61vailable_internal_flags\x18\x06 \x03(\r\x12\x1a\n\x12history_size_bytes\x18\x07 \x01(\x04\x12!\n\x19\x63ontinue_as_new_suggested\x18\x08 \x01(\x08\x12T\n#deployment_version_for_current_task\x18\t \x01(\x0b\x32\'.coresdk.common.WorkerDeploymentVersion\x12\x18\n\x10last_sdk_version\x18\n \x01(\t\x12Z\n\x1fsuggest_continue_as_new_reasons\x18\x0b \x03(\x0e\x32\x31.temporal.api.enums.v1.SuggestContinueAsNewReason\x12\x30\n(target_worker_deployment_version_changed\x18\x0c \x01(\x08"\xe0\n\n\x15WorkflowActivationJob\x12N\n\x13initialize_workflow\x18\x01 \x01(\x0b\x32/.coresdk.workflow_activation.InitializeWorkflowH\x00\x12<\n\nfire_timer\x18\x02 \x01(\x0b\x32&.coresdk.workflow_activation.FireTimerH\x00\x12K\n\x12update_random_seed\x18\x04 \x01(\x0b\x32-.coresdk.workflow_activation.UpdateRandomSeedH\x00\x12\x44\n\x0equery_workflow\x18\x05 \x01(\x0b\x32*.coresdk.workflow_activation.QueryWorkflowH\x00\x12\x46\n\x0f\x63\x61ncel_workflow\x18\x06 \x01(\x0b\x32+.coresdk.workflow_activation.CancelWorkflowH\x00\x12\x46\n\x0fsignal_workflow\x18\x07 \x01(\x0b\x32+.coresdk.workflow_activation.SignalWorkflowH\x00\x12H\n\x10resolve_activity\x18\x08 \x01(\x0b\x32,.coresdk.workflow_activation.ResolveActivityH\x00\x12G\n\x10notify_has_patch\x18\t \x01(\x0b\x32+.coresdk.workflow_activation.NotifyHasPatchH\x00\x12q\n&resolve_child_workflow_execution_start\x18\n \x01(\x0b\x32?.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartH\x00\x12\x66\n resolve_child_workflow_execution\x18\x0b \x01(\x0b\x32:.coresdk.workflow_activation.ResolveChildWorkflowExecutionH\x00\x12\x66\n resolve_signal_external_workflow\x18\x0c \x01(\x0b\x32:.coresdk.workflow_activation.ResolveSignalExternalWorkflowH\x00\x12u\n(resolve_request_cancel_external_workflow\x18\r \x01(\x0b\x32\x41.coresdk.workflow_activation.ResolveRequestCancelExternalWorkflowH\x00\x12:\n\tdo_update\x18\x0e \x01(\x0b\x32%.coresdk.workflow_activation.DoUpdateH\x00\x12`\n\x1dresolve_nexus_operation_start\x18\x0f \x01(\x0b\x32\x37.coresdk.workflow_activation.ResolveNexusOperationStartH\x00\x12U\n\x17resolve_nexus_operation\x18\x10 \x01(\x0b\x32\x32.coresdk.workflow_activation.ResolveNexusOperationH\x00\x12I\n\x11remove_from_cache\x18\x32 \x01(\x0b\x32,.coresdk.workflow_activation.RemoveFromCacheH\x00\x42\t\n\x07variant"\xe3\x0b\n\x12InitializeWorkflow\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x17\n\x0frandomness_seed\x18\x04 \x01(\x04\x12M\n\x07headers\x18\x05 \x03(\x0b\x32<.coresdk.workflow_activation.InitializeWorkflow.HeadersEntry\x12\x10\n\x08identity\x18\x06 \x01(\t\x12I\n\x14parent_workflow_info\x18\x07 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12=\n\x1aworkflow_execution_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\'\n\x1f\x63ontinued_from_execution_run_id\x18\x0b \x01(\t\x12J\n\x13\x63ontinued_initiator\x18\x0c \x01(\x0e\x32-.temporal.api.enums.v1.ContinueAsNewInitiator\x12;\n\x11\x63ontinued_failure\x18\r \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12@\n\x16last_completion_result\x18\x0e \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x1e\n\x16\x66irst_execution_run_id\x18\x0f \x01(\t\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x0f\n\x07\x61ttempt\x18\x11 \x01(\x05\x12\x15\n\rcron_schedule\x18\x12 \x01(\t\x12\x46\n"workflow_execution_expiration_time\x18\x13 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x45\n"cron_schedule_to_schedule_interval\x18\x14 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x04memo\x18\x15 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\x12\x43\n\x11search_attributes\x18\x16 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12.\n\nstart_time\x18\x17 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\rroot_workflow\x18\x18 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x32\n\x08priority\x18\x19 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12!\n\x19original_execution_run_id\x18\x1a \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x1b \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x18\n\tFireTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"m\n\x0fResolveActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.activity_result.ActivityResolution\x12\x10\n\x08is_local\x18\x03 \x01(\x08"\xd1\x02\n"ResolveChildWorkflowExecutionStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12[\n\tsucceeded\x18\x02 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartSuccessH\x00\x12X\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartFailureH\x00\x12]\n\tcancelled\x18\x04 \x01(\x0b\x32H.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartCancelledH\x00\x42\x08\n\x06status";\n)ResolveChildWorkflowExecutionStartSuccess\x12\x0e\n\x06run_id\x18\x01 \x01(\t"\xa6\x01\n)ResolveChildWorkflowExecutionStartFailure\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12M\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32>.coresdk.child_workflow.StartChildWorkflowExecutionFailedCause"`\n+ResolveChildWorkflowExecutionStartCancelled\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"i\n\x1dResolveChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.child_workflow.ChildWorkflowResult"+\n\x10UpdateRandomSeed\x12\x17\n\x0frandomness_seed\x18\x01 \x01(\x04"\x84\x02\n\rQueryWorkflow\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12\x12\n\nquery_type\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12H\n\x07headers\x18\x05 \x03(\x0b\x32\x37.coresdk.workflow_activation.QueryWorkflow.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01" \n\x0e\x43\x61ncelWorkflow\x12\x0e\n\x06reason\x18\x01 \x01(\t"\xa1\x02\n\x0eSignalWorkflow\x12\x13\n\x0bsignal_name\x18\x01 \x01(\t\x12.\n\x05input\x18\x02 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x10\n\x08identity\x18\x03 \x01(\t\x12I\n\x07headers\x18\x05 \x03(\x0b\x32\x38.coresdk.workflow_activation.SignalWorkflow.HeadersEntry\x12\x1c\n\x14originating_event_id\x18\x06 \x01(\x03\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01""\n\x0eNotifyHasPatch\x12\x10\n\x08patch_id\x18\x01 \x01(\t"\xb1\x01\n\x1dResolveSignalExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.SignalExternalWorkflowExecutionFailedCause"\xb8\x01\n$ResolveRequestCancelExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.CancelExternalWorkflowExecutionFailedCause"\xb2\x03\n\x08\x44oUpdate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\x05input\x18\x04 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x43\n\x07headers\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.DoUpdate.HeadersEntry\x12*\n\x04meta\x18\x06 \x01(\x0b\x32\x1c.temporal.api.update.v1.Meta\x12\x15\n\rrun_validator\x18\x07 \x01(\x08\x12\x65\n&propagated_nexus_serialization_context\x18\x08 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x9a\x01\n\x1aResolveNexusOperationStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x19\n\x0foperation_token\x18\x02 \x01(\tH\x00\x12\x16\n\x0cstarted_sync\x18\x03 \x01(\x08H\x00\x12\x32\n\x06\x66\x61iled\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status"Y\n\x15ResolveNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x33\n\x06result\x18\x02 \x01(\x0b\x32#.coresdk.nexus.NexusOperationResult"\xe0\x02\n\x0fRemoveFromCache\x12\x0f\n\x07message\x18\x01 \x01(\t\x12K\n\x06reason\x18\x02 \x01(\x0e\x32;.coresdk.workflow_activation.RemoveFromCache.EvictionReason"\xee\x01\n\x0e\x45victionReason\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCACHE_FULL\x10\x01\x12\x0e\n\nCACHE_MISS\x10\x02\x12\x12\n\x0eNONDETERMINISM\x10\x03\x12\r\n\tLANG_FAIL\x10\x04\x12\x12\n\x0eLANG_REQUESTED\x10\x05\x12\x12\n\x0eTASK_NOT_FOUND\x10\x06\x12\x15\n\x11UNHANDLED_COMMAND\x10\x07\x12\t\n\x05\x46\x41TAL\x10\x08\x12\x1f\n\x1bPAGINATION_OR_HISTORY_FETCH\x10\t\x12\x1d\n\x19WORKFLOW_EXECUTION_ENDING\x10\nB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowActivationb\x06proto3' + b'\n?temporal/sdk/core/workflow_activation/workflow_activation.proto\x12\x1b\x63oresdk.workflow_activation\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a%temporal/api/failure/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a$temporal/api/update/v1/message.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/stream/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a\x37temporal/sdk/core/activity_result/activity_result.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a#temporal/sdk/core/nexus/nexus.proto"\xa2\x04\n\x12WorkflowActivation\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0cis_replaying\x18\x03 \x01(\x08\x12\x16\n\x0ehistory_length\x18\x04 \x01(\r\x12@\n\x04jobs\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.WorkflowActivationJob\x12 \n\x18\x61vailable_internal_flags\x18\x06 \x03(\r\x12\x1a\n\x12history_size_bytes\x18\x07 \x01(\x04\x12!\n\x19\x63ontinue_as_new_suggested\x18\x08 \x01(\x08\x12T\n#deployment_version_for_current_task\x18\t \x01(\x0b\x32\'.coresdk.common.WorkerDeploymentVersion\x12\x18\n\x10last_sdk_version\x18\n \x01(\t\x12Z\n\x1fsuggest_continue_as_new_reasons\x18\x0b \x03(\x0e\x32\x31.temporal.api.enums.v1.SuggestContinueAsNewReason\x12\x30\n(target_worker_deployment_version_changed\x18\x0c \x01(\x08"\xd3\x0c\n\x15WorkflowActivationJob\x12N\n\x13initialize_workflow\x18\x01 \x01(\x0b\x32/.coresdk.workflow_activation.InitializeWorkflowH\x00\x12<\n\nfire_timer\x18\x02 \x01(\x0b\x32&.coresdk.workflow_activation.FireTimerH\x00\x12K\n\x12update_random_seed\x18\x04 \x01(\x0b\x32-.coresdk.workflow_activation.UpdateRandomSeedH\x00\x12\x44\n\x0equery_workflow\x18\x05 \x01(\x0b\x32*.coresdk.workflow_activation.QueryWorkflowH\x00\x12\x46\n\x0f\x63\x61ncel_workflow\x18\x06 \x01(\x0b\x32+.coresdk.workflow_activation.CancelWorkflowH\x00\x12\x46\n\x0fsignal_workflow\x18\x07 \x01(\x0b\x32+.coresdk.workflow_activation.SignalWorkflowH\x00\x12H\n\x10resolve_activity\x18\x08 \x01(\x0b\x32,.coresdk.workflow_activation.ResolveActivityH\x00\x12G\n\x10notify_has_patch\x18\t \x01(\x0b\x32+.coresdk.workflow_activation.NotifyHasPatchH\x00\x12q\n&resolve_child_workflow_execution_start\x18\n \x01(\x0b\x32?.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartH\x00\x12\x66\n resolve_child_workflow_execution\x18\x0b \x01(\x0b\x32:.coresdk.workflow_activation.ResolveChildWorkflowExecutionH\x00\x12\x66\n resolve_signal_external_workflow\x18\x0c \x01(\x0b\x32:.coresdk.workflow_activation.ResolveSignalExternalWorkflowH\x00\x12u\n(resolve_request_cancel_external_workflow\x18\r \x01(\x0b\x32\x41.coresdk.workflow_activation.ResolveRequestCancelExternalWorkflowH\x00\x12:\n\tdo_update\x18\x0e \x01(\x0b\x32%.coresdk.workflow_activation.DoUpdateH\x00\x12`\n\x1dresolve_nexus_operation_start\x18\x0f \x01(\x0b\x32\x37.coresdk.workflow_activation.ResolveNexusOperationStartH\x00\x12U\n\x17resolve_nexus_operation\x18\x10 \x01(\x0b\x32\x32.coresdk.workflow_activation.ResolveNexusOperationH\x00\x12M\n\x13resolve_stream_read\x18\x11 \x01(\x0b\x32..coresdk.workflow_activation.ResolveStreamReadH\x00\x12Q\n\x15resolve_stream_append\x18\x12 \x01(\x0b\x32\x30.coresdk.workflow_activation.ResolveStreamAppendH\x00\x12O\n\x14resolve_stream_close\x18\x13 \x01(\x0b\x32/.coresdk.workflow_activation.ResolveStreamCloseH\x00\x12I\n\x11remove_from_cache\x18\x32 \x01(\x0b\x32,.coresdk.workflow_activation.RemoveFromCacheH\x00\x42\t\n\x07variant"\xe3\x0b\n\x12InitializeWorkflow\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x17\n\x0frandomness_seed\x18\x04 \x01(\x04\x12M\n\x07headers\x18\x05 \x03(\x0b\x32<.coresdk.workflow_activation.InitializeWorkflow.HeadersEntry\x12\x10\n\x08identity\x18\x06 \x01(\t\x12I\n\x14parent_workflow_info\x18\x07 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12=\n\x1aworkflow_execution_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\'\n\x1f\x63ontinued_from_execution_run_id\x18\x0b \x01(\t\x12J\n\x13\x63ontinued_initiator\x18\x0c \x01(\x0e\x32-.temporal.api.enums.v1.ContinueAsNewInitiator\x12;\n\x11\x63ontinued_failure\x18\r \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12@\n\x16last_completion_result\x18\x0e \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x1e\n\x16\x66irst_execution_run_id\x18\x0f \x01(\t\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x0f\n\x07\x61ttempt\x18\x11 \x01(\x05\x12\x15\n\rcron_schedule\x18\x12 \x01(\t\x12\x46\n"workflow_execution_expiration_time\x18\x13 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x45\n"cron_schedule_to_schedule_interval\x18\x14 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x04memo\x18\x15 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\x12\x43\n\x11search_attributes\x18\x16 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12.\n\nstart_time\x18\x17 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\rroot_workflow\x18\x18 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x32\n\x08priority\x18\x19 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12!\n\x19original_execution_run_id\x18\x1a \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x1b \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x18\n\tFireTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"m\n\x0fResolveActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.activity_result.ActivityResolution\x12\x10\n\x08is_local\x18\x03 \x01(\x08"\xd1\x02\n"ResolveChildWorkflowExecutionStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12[\n\tsucceeded\x18\x02 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartSuccessH\x00\x12X\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartFailureH\x00\x12]\n\tcancelled\x18\x04 \x01(\x0b\x32H.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartCancelledH\x00\x42\x08\n\x06status";\n)ResolveChildWorkflowExecutionStartSuccess\x12\x0e\n\x06run_id\x18\x01 \x01(\t"\xa6\x01\n)ResolveChildWorkflowExecutionStartFailure\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12M\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32>.coresdk.child_workflow.StartChildWorkflowExecutionFailedCause"`\n+ResolveChildWorkflowExecutionStartCancelled\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"i\n\x1dResolveChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.child_workflow.ChildWorkflowResult"+\n\x10UpdateRandomSeed\x12\x17\n\x0frandomness_seed\x18\x01 \x01(\x04"\x84\x02\n\rQueryWorkflow\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12\x12\n\nquery_type\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12H\n\x07headers\x18\x05 \x03(\x0b\x32\x37.coresdk.workflow_activation.QueryWorkflow.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01" \n\x0e\x43\x61ncelWorkflow\x12\x0e\n\x06reason\x18\x01 \x01(\t"\xa1\x02\n\x0eSignalWorkflow\x12\x13\n\x0bsignal_name\x18\x01 \x01(\t\x12.\n\x05input\x18\x02 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x10\n\x08identity\x18\x03 \x01(\t\x12I\n\x07headers\x18\x05 \x03(\x0b\x32\x38.coresdk.workflow_activation.SignalWorkflow.HeadersEntry\x12\x1c\n\x14originating_event_id\x18\x06 \x01(\x03\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01""\n\x0eNotifyHasPatch\x12\x10\n\x08patch_id\x18\x01 \x01(\t"\xb1\x01\n\x1dResolveSignalExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.SignalExternalWorkflowExecutionFailedCause"\xb8\x01\n$ResolveRequestCancelExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.CancelExternalWorkflowExecutionFailedCause"\xb2\x03\n\x08\x44oUpdate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\x05input\x18\x04 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x43\n\x07headers\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.DoUpdate.HeadersEntry\x12*\n\x04meta\x18\x06 \x01(\x0b\x32\x1c.temporal.api.update.v1.Meta\x12\x15\n\rrun_validator\x18\x07 \x01(\x08\x12\x65\n&propagated_nexus_serialization_context\x18\x08 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x9a\x01\n\x1aResolveNexusOperationStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x19\n\x0foperation_token\x18\x02 \x01(\tH\x00\x12\x16\n\x0cstarted_sync\x18\x03 \x01(\x08H\x00\x12\x32\n\x06\x66\x61iled\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status"Y\n\x15ResolveNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x33\n\x06result\x18\x02 \x01(\x0b\x32#.coresdk.nexus.NexusOperationResult"\xe0\x02\n\x0fRemoveFromCache\x12\x0f\n\x07message\x18\x01 \x01(\t\x12K\n\x06reason\x18\x02 \x01(\x0e\x32;.coresdk.workflow_activation.RemoveFromCache.EvictionReason"\xee\x01\n\x0e\x45victionReason\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCACHE_FULL\x10\x01\x12\x0e\n\nCACHE_MISS\x10\x02\x12\x12\n\x0eNONDETERMINISM\x10\x03\x12\r\n\tLANG_FAIL\x10\x04\x12\x12\n\x0eLANG_REQUESTED\x10\x05\x12\x12\n\x0eTASK_NOT_FOUND\x10\x06\x12\x15\n\x11UNHANDLED_COMMAND\x10\x07\x12\t\n\x05\x46\x41TAL\x10\x08\x12\x1f\n\x1bPAGINATION_OR_HISTORY_FETCH\x10\t\x12\x1d\n\x19WORKFLOW_EXECUTION_ENDING\x10\n"\xc4\x01\n\x11ResolveStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x37\n\x04page\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_activation.StreamPageH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12+\n\tcancelled\x18\x04 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06status"Q\n\nStreamPage\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08"\xa1\x01\n\x13ResolveStreamAppend\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12?\n\x08\x61ppended\x18\x02 \x01(\x0b\x32+.coresdk.workflow_activation.StreamAppendedH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status";\n\x0eStreamAppended\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"S\n\x12ResolveStreamClose\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x30\n\x06\x66\x61iled\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.FailureB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowActivationb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -67,56 +70,66 @@ _SIGNALWORKFLOW_HEADERSENTRY._serialized_options = b"8\001" _DOUPDATE_HEADERSENTRY._options = None _DOUPDATE_HEADERSENTRY._serialized_options = b"8\001" - _WORKFLOWACTIVATION._serialized_start = 611 - _WORKFLOWACTIVATION._serialized_end = 1157 - _WORKFLOWACTIVATIONJOB._serialized_start = 1160 - _WORKFLOWACTIVATIONJOB._serialized_end = 2536 - _INITIALIZEWORKFLOW._serialized_start = 2539 - _INITIALIZEWORKFLOW._serialized_end = 4046 - _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_start = 3967 - _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_end = 4046 - _FIRETIMER._serialized_start = 4048 - _FIRETIMER._serialized_end = 4072 - _RESOLVEACTIVITY._serialized_start = 4074 - _RESOLVEACTIVITY._serialized_end = 4183 - _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_start = 4186 - _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_end = 4523 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_start = 4525 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_end = 4584 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_start = 4587 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_end = 4753 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_start = 4755 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_end = 4851 - _RESOLVECHILDWORKFLOWEXECUTION._serialized_start = 4853 - _RESOLVECHILDWORKFLOWEXECUTION._serialized_end = 4958 - _UPDATERANDOMSEED._serialized_start = 4960 - _UPDATERANDOMSEED._serialized_end = 5003 - _QUERYWORKFLOW._serialized_start = 5006 - _QUERYWORKFLOW._serialized_end = 5266 - _QUERYWORKFLOW_HEADERSENTRY._serialized_start = 3967 - _QUERYWORKFLOW_HEADERSENTRY._serialized_end = 4046 - _CANCELWORKFLOW._serialized_start = 5268 - _CANCELWORKFLOW._serialized_end = 5300 - _SIGNALWORKFLOW._serialized_start = 5303 - _SIGNALWORKFLOW._serialized_end = 5592 - _SIGNALWORKFLOW_HEADERSENTRY._serialized_start = 3967 - _SIGNALWORKFLOW_HEADERSENTRY._serialized_end = 4046 - _NOTIFYHASPATCH._serialized_start = 5594 - _NOTIFYHASPATCH._serialized_end = 5628 - _RESOLVESIGNALEXTERNALWORKFLOW._serialized_start = 5631 - _RESOLVESIGNALEXTERNALWORKFLOW._serialized_end = 5808 - _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_start = 5811 - _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_end = 5995 - _DOUPDATE._serialized_start = 5998 - _DOUPDATE._serialized_end = 6432 - _DOUPDATE_HEADERSENTRY._serialized_start = 3967 - _DOUPDATE_HEADERSENTRY._serialized_end = 4046 - _RESOLVENEXUSOPERATIONSTART._serialized_start = 6435 - _RESOLVENEXUSOPERATIONSTART._serialized_end = 6589 - _RESOLVENEXUSOPERATION._serialized_start = 6591 - _RESOLVENEXUSOPERATION._serialized_end = 6680 - _REMOVEFROMCACHE._serialized_start = 6683 - _REMOVEFROMCACHE._serialized_end = 7035 - _REMOVEFROMCACHE_EVICTIONREASON._serialized_start = 6797 - _REMOVEFROMCACHE_EVICTIONREASON._serialized_end = 7035 + _WORKFLOWACTIVATION._serialized_start = 649 + _WORKFLOWACTIVATION._serialized_end = 1195 + _WORKFLOWACTIVATIONJOB._serialized_start = 1198 + _WORKFLOWACTIVATIONJOB._serialized_end = 2817 + _INITIALIZEWORKFLOW._serialized_start = 2820 + _INITIALIZEWORKFLOW._serialized_end = 4327 + _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_start = 4248 + _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_end = 4327 + _FIRETIMER._serialized_start = 4329 + _FIRETIMER._serialized_end = 4353 + _RESOLVEACTIVITY._serialized_start = 4355 + _RESOLVEACTIVITY._serialized_end = 4464 + _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_start = 4467 + _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_end = 4804 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_start = 4806 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_end = 4865 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_start = 4868 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_end = 5034 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_start = 5036 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_end = 5132 + _RESOLVECHILDWORKFLOWEXECUTION._serialized_start = 5134 + _RESOLVECHILDWORKFLOWEXECUTION._serialized_end = 5239 + _UPDATERANDOMSEED._serialized_start = 5241 + _UPDATERANDOMSEED._serialized_end = 5284 + _QUERYWORKFLOW._serialized_start = 5287 + _QUERYWORKFLOW._serialized_end = 5547 + _QUERYWORKFLOW_HEADERSENTRY._serialized_start = 4248 + _QUERYWORKFLOW_HEADERSENTRY._serialized_end = 4327 + _CANCELWORKFLOW._serialized_start = 5549 + _CANCELWORKFLOW._serialized_end = 5581 + _SIGNALWORKFLOW._serialized_start = 5584 + _SIGNALWORKFLOW._serialized_end = 5873 + _SIGNALWORKFLOW_HEADERSENTRY._serialized_start = 4248 + _SIGNALWORKFLOW_HEADERSENTRY._serialized_end = 4327 + _NOTIFYHASPATCH._serialized_start = 5875 + _NOTIFYHASPATCH._serialized_end = 5909 + _RESOLVESIGNALEXTERNALWORKFLOW._serialized_start = 5912 + _RESOLVESIGNALEXTERNALWORKFLOW._serialized_end = 6089 + _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_start = 6092 + _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_end = 6276 + _DOUPDATE._serialized_start = 6279 + _DOUPDATE._serialized_end = 6713 + _DOUPDATE_HEADERSENTRY._serialized_start = 4248 + _DOUPDATE_HEADERSENTRY._serialized_end = 4327 + _RESOLVENEXUSOPERATIONSTART._serialized_start = 6716 + _RESOLVENEXUSOPERATIONSTART._serialized_end = 6870 + _RESOLVENEXUSOPERATION._serialized_start = 6872 + _RESOLVENEXUSOPERATION._serialized_end = 6961 + _REMOVEFROMCACHE._serialized_start = 6964 + _REMOVEFROMCACHE._serialized_end = 7316 + _REMOVEFROMCACHE_EVICTIONREASON._serialized_start = 7078 + _REMOVEFROMCACHE_EVICTIONREASON._serialized_end = 7316 + _RESOLVESTREAMREAD._serialized_start = 7319 + _RESOLVESTREAMREAD._serialized_end = 7515 + _STREAMPAGE._serialized_start = 7517 + _STREAMPAGE._serialized_end = 7598 + _RESOLVESTREAMAPPEND._serialized_start = 7601 + _RESOLVESTREAMAPPEND._serialized_end = 7762 + _STREAMAPPENDED._serialized_start = 7764 + _STREAMAPPENDED._serialized_end = 7823 + _RESOLVESTREAMCLOSE._serialized_start = 7825 + _RESOLVESTREAMCLOSE._serialized_end = 7908 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi index e55917d810..1883c75fac 100644 --- a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi +++ b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi @@ -13,6 +13,7 @@ import typing import google.protobuf.descriptor import google.protobuf.duration_pb2 +import google.protobuf.empty_pb2 import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message @@ -23,6 +24,7 @@ import temporalio.api.enums.v1.failed_cause_pb2 import temporalio.api.enums.v1.workflow_pb2 import temporalio.api.failure.v1.message_pb2 import temporalio.api.nexus.v1.message_pb2 +import temporalio.api.stream.v1.message_pb2 import temporalio.api.update.v1.message_pb2 import temporalio.bridge.proto.activity_result.activity_result_pb2 import temporalio.bridge.proto.child_workflow.child_workflow_pb2 @@ -49,7 +51,7 @@ class WorkflowActivation(google.protobuf.message.Message): 3. random-seed-updates 4. signals/updates 5. all others - 6. local activity resolutions + 6. local activity resolutions, then Stream results 7. queries 8. evictions @@ -65,6 +67,11 @@ class WorkflowActivation(google.protobuf.message.Message): in that same activation (prime example: cancelling not-wait-for-cancel activities). So, we do this to ensure the LA resolution happens after that cancel (or whatever else it may be) as it normally would have when executing. + * The results of Stream calls go after the local activity resolutions, since a replay scans + ahead for their marker too. The appends come first, then the closes, and then the reads, each + kind by `seq`. A replay that gives the results of several activations in one keeps the order + of those activations among the results of Stream calls, and gives them after each local + activity resolution. * Queries always go last (and, in fact, always come in their own activation) * Evictions also always come in their own activation @@ -250,6 +257,9 @@ class WorkflowActivationJob(google.protobuf.message.Message): DO_UPDATE_FIELD_NUMBER: builtins.int RESOLVE_NEXUS_OPERATION_START_FIELD_NUMBER: builtins.int RESOLVE_NEXUS_OPERATION_FIELD_NUMBER: builtins.int + RESOLVE_STREAM_READ_FIELD_NUMBER: builtins.int + RESOLVE_STREAM_APPEND_FIELD_NUMBER: builtins.int + RESOLVE_STREAM_CLOSE_FIELD_NUMBER: builtins.int REMOVE_FROM_CACHE_FIELD_NUMBER: builtins.int @property def initialize_workflow(self) -> global___InitializeWorkflow: @@ -324,6 +334,18 @@ class WorkflowActivationJob(google.protobuf.message.Message): def resolve_nexus_operation(self) -> global___ResolveNexusOperation: """A nexus operation resolved.""" + @property + def resolve_stream_read(self) -> global___ResolveStreamRead: + """A read of a Stream finished.""" + + @property + def resolve_stream_append(self) -> global___ResolveStreamAppend: + """An append to a Stream finished.""" + + @property + def resolve_stream_close(self) -> global___ResolveStreamClose: + """A close of a Stream finished.""" + @property def remove_from_cache(self) -> global___RemoveFromCache: """Remove the workflow identified by the [WorkflowActivation] containing this job from the @@ -353,6 +375,9 @@ class WorkflowActivationJob(google.protobuf.message.Message): do_update: global___DoUpdate | None = ..., resolve_nexus_operation_start: global___ResolveNexusOperationStart | None = ..., resolve_nexus_operation: global___ResolveNexusOperation | None = ..., + resolve_stream_read: global___ResolveStreamRead | None = ..., + resolve_stream_append: global___ResolveStreamAppend | None = ..., + resolve_stream_close: global___ResolveStreamClose | None = ..., remove_from_cache: global___RemoveFromCache | None = ..., ) -> None: ... def HasField( @@ -386,6 +411,12 @@ class WorkflowActivationJob(google.protobuf.message.Message): b"resolve_request_cancel_external_workflow", "resolve_signal_external_workflow", b"resolve_signal_external_workflow", + "resolve_stream_append", + b"resolve_stream_append", + "resolve_stream_close", + b"resolve_stream_close", + "resolve_stream_read", + b"resolve_stream_read", "signal_workflow", b"signal_workflow", "update_random_seed", @@ -425,6 +456,12 @@ class WorkflowActivationJob(google.protobuf.message.Message): b"resolve_request_cancel_external_workflow", "resolve_signal_external_workflow", b"resolve_signal_external_workflow", + "resolve_stream_append", + b"resolve_stream_append", + "resolve_stream_close", + b"resolve_stream_close", + "resolve_stream_read", + b"resolve_stream_read", "signal_workflow", b"signal_workflow", "update_random_seed", @@ -452,6 +489,9 @@ class WorkflowActivationJob(google.protobuf.message.Message): "do_update", "resolve_nexus_operation_start", "resolve_nexus_operation", + "resolve_stream_read", + "resolve_stream_append", + "resolve_stream_close", "remove_from_cache", ] | None @@ -1645,3 +1685,233 @@ class RemoveFromCache(google.protobuf.message.Message): ) -> None: ... global___RemoveFromCache = RemoveFromCache + +@typing.final +class ResolveStreamRead(google.protobuf.message.Message): + """The result of a `ReadStream`. A read gets at most one, and a read that lang cancelled gets one + too. It gets none only in the four cases that `ReadStream` lists. What `ResolveStreamAppend` + says of its activation holds for it. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + PAGE_FIELD_NUMBER: builtins.int + FAILED_FIELD_NUMBER: builtins.int + CANCELLED_FIELD_NUMBER: builtins.int + seq: builtins.int + """The `seq` of the `ReadStream`.""" + @property + def page(self) -> global___StreamPage: ... + @property + def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: + """The failure of the read. It has the parts of the `failed` of a `ResolveStreamAppend`.""" + + @property + def cancelled(self) -> google.protobuf.empty_pb2.Empty: + """Core got a `RequestCancelStreamRead` for the read before lang got a job for it. The job + comes in the next activation after the cancel, or in the next Workflow Task if the task + in hand completes first. `RequestCancelStreamRead` says when a replay gives it. + """ + + def __init__( + self, + *, + seq: builtins.int = ..., + page: global___StreamPage | None = ..., + failed: temporalio.api.failure.v1.message_pb2.Failure | None = ..., + cancelled: google.protobuf.empty_pb2.Empty | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "cancelled", + b"cancelled", + "failed", + b"failed", + "page", + b"page", + "status", + b"status", + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "cancelled", + b"cancelled", + "failed", + b"failed", + "page", + b"page", + "seq", + b"seq", + "status", + b"status", + ], + ) -> None: ... + def WhichOneof( + self, oneof_group: typing.Literal["status", b"status"] + ) -> typing.Literal["page", "failed", "cancelled"] | None: ... + +global___ResolveStreamRead = ResolveStreamRead + +@typing.final +class StreamPage(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RECORDS_FIELD_NUMBER: builtins.int + DONE_FIELD_NUMBER: builtins.int + done: builtins.bool + """True if the Stream is closed and has no Record after this page. It's false if the page has + no Record because none came within the `wait` of the read. + """ + @property + def records( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + temporalio.api.stream.v1.message_pb2.StreamRecord + ]: + """The Records of the page, in the order of the Stream. It's empty if no Record came within the + `wait` of the read, or if the Stream is closed and has no Record after the `from_offset` of + the read. + """ + + def __init__( + self, + *, + records: collections.abc.Iterable[ + temporalio.api.stream.v1.message_pb2.StreamRecord + ] + | None = ..., + done: builtins.bool = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["done", b"done", "records", b"records"] + ) -> None: ... + +global___StreamPage = StreamPage + +@typing.final +class ResolveStreamAppend(google.protobuf.message.Message): + """The result of an `AppendToStream`. Core gives each result in the next activation after it comes, + so each result can cost an activation. + + A replay gives a result in the activation in which the first run gave it only if History has + the flag that turns workflow task chunking off. Without that flag a replay gives the results of + a task in the order of the first run, and it gives a result in another activation in two cases: + * A Workflow Task completes with no command, and the first activation of the next task has a + result. A replay takes the two tasks as one, and can give the results of the first two + activations of the second task in one. + * A Workflow Task starts with an Update that Workflow code rejects, which leaves no event. A + replay with no job to give then gives the results of History in the order of the first run, + up to the first one whose call Workflow code hasn't made, in one activation. + A task with only Stream calls replays in the activations of the same task with Local + Activities. In a task with both, a result waits for each result of the other kind that the + first run gave before it, so its activations can differ from those of Local Activities alone. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + APPENDED_FIELD_NUMBER: builtins.int + FAILED_FIELD_NUMBER: builtins.int + seq: builtins.int + """The `seq` of the `AppendToStream`.""" + @property + def appended(self) -> global___StreamAppended: ... + @property + def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: + """The failure of the append, with these parts: + * an `ApplicationFailureInfo` whose type is `stream_` and the reason of the Stream error + in snake case, such as `stream_closed`, and whose `non_retryable` is set + * in its details, one `binary/protobuf` payload of a + `temporalio.api.stream.v1.StreamErrorDetails` + * a message of at most 4096 bytes + """ + + def __init__( + self, + *, + seq: builtins.int = ..., + appended: global___StreamAppended | None = ..., + failed: temporalio.api.failure.v1.message_pb2.Failure | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "appended", b"appended", "failed", b"failed", "status", b"status" + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "appended", + b"appended", + "failed", + b"failed", + "seq", + b"seq", + "status", + b"status", + ], + ) -> None: ... + def WhichOneof( + self, oneof_group: typing.Literal["status", b"status"] + ) -> typing.Literal["appended", "failed"] | None: ... + +global___ResolveStreamAppend = ResolveStreamAppend + +@typing.final +class StreamAppended(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + FIRST_OFFSET_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + first_offset: builtins.bytes + last_offset: builtins.bytes + def __init__( + self, + *, + first_offset: builtins.bytes = ..., + last_offset: builtins.bytes = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "first_offset", b"first_offset", "last_offset", b"last_offset" + ], + ) -> None: ... + +global___StreamAppended = StreamAppended + +@typing.final +class ResolveStreamClose(google.protobuf.message.Message): + """The result of a `CloseStream`. What `ResolveStreamAppend` says of its activation holds for it.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + FAILED_FIELD_NUMBER: builtins.int + seq: builtins.int + """The `seq` of the `CloseStream`.""" + @property + def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: + """Unset if the Stream is closed, even if it was already closed before. If set, it has the parts + of the `failed` of a `ResolveStreamAppend`. + """ + + def __init__( + self, + *, + seq: builtins.int = ..., + failed: temporalio.api.failure.v1.message_pb2.Failure | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["failed", b"failed"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["failed", b"failed", "seq", b"seq"] + ) -> None: ... + +global___ResolveStreamClose = ResolveStreamClose diff --git a/temporalio/bridge/proto/workflow_commands/__init__.py b/temporalio/bridge/proto/workflow_commands/__init__.py index f599917afa..e2cc730d8d 100644 --- a/temporalio/bridge/proto/workflow_commands/__init__.py +++ b/temporalio/bridge/proto/workflow_commands/__init__.py @@ -1,19 +1,23 @@ from .workflow_commands_pb2 import ( ActivityCancellationType, + AppendToStream, CancelChildWorkflowExecution, CancelSignalWorkflow, CancelTimer, CancelWorkflowExecution, + CloseStream, CompleteWorkflowExecution, ContinueAsNewWorkflowExecution, FailWorkflowExecution, ModifyWorkflowProperties, QueryResult, QuerySuccess, + ReadStream, RequestCancelActivity, RequestCancelExternalWorkflowExecution, RequestCancelLocalActivity, RequestCancelNexusOperation, + RequestCancelStreamRead, ScheduleActivity, ScheduleLocalActivity, ScheduleNexusOperation, @@ -28,20 +32,24 @@ __all__ = [ "ActivityCancellationType", + "AppendToStream", "CancelChildWorkflowExecution", "CancelSignalWorkflow", "CancelTimer", "CancelWorkflowExecution", + "CloseStream", "CompleteWorkflowExecution", "ContinueAsNewWorkflowExecution", "FailWorkflowExecution", "ModifyWorkflowProperties", "QueryResult", "QuerySuccess", + "ReadStream", "RequestCancelActivity", "RequestCancelExternalWorkflowExecution", "RequestCancelLocalActivity", "RequestCancelNexusOperation", + "RequestCancelStreamRead", "ScheduleActivity", "ScheduleLocalActivity", "ScheduleNexusOperation", diff --git a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py index 3573f36b11..7c8d6682de 100644 --- a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py +++ b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py @@ -32,6 +32,9 @@ from temporalio.api.sdk.v1 import ( user_metadata_pb2 as temporal_dot_api_dot_sdk_dot_v1_dot_user__metadata__pb2, ) +from temporalio.api.stream.v1 import ( + message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, +) from temporalio.api.workflow.v1 import ( message_pb2 as temporal_dot_api_dot_workflow_dot_v1_dot_message__pb2, ) @@ -46,7 +49,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a,temporal/api/sdk/v1/event_group_marker.proto\x1a&temporal/api/workflow/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a#temporal/sdk/core/nexus/nexus.proto\x1a%temporal/sdk/core/common/common.proto"\xa9\x10\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12\x42\n\x13\x65vent_group_markers\x18\x65 \x03(\x0b\x32%.temporal.api.sdk.v1.EventGroupMarker\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x42\t\n\x07variant"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"\xb8\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x10 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x93\x06\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12#\n\x1binclude_arguments_in_marker\x18\x0e \x01(\x08\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"\x92\x07\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12\x43\n\x11search_attributes\x18\x08 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12[\n\x1binitial_versioning_behavior\x18\x0b \x01(\x0e\x32\x36.temporal.api.enums.v1.ContinueAsNewVersioningBehavior\x12\x39\n\x16\x62\x61\x63koff_start_interval\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"L\n\x17\x43\x61ncelWorkflowExecution\x12\x31\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32 .temporal.api.common.v1.Payloads"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xe1\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12\x43\n\x11search_attributes\x18\x11 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x14 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12I\n\x13versioning_override\x18\x15 \x01(\x0b\x32,.temporal.api.workflow.v1.VersioningOverride\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"J\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\x12\x0e\n\x06reason\x18\x02 \x01(\t"\x8e\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12\x0e\n\x06reason\x18\x03 \x01(\t"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r"e\n\x1eUpsertWorkflowSearchAttributes\x12\x43\n\x11search_attributes\x18\x01 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response"\x9a\x04\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x12H\n\x11\x63\x61ncellation_type\x18\x08 \x01(\x0e\x32-.coresdk.nexus.NexusOperationCancellationType\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3' + b'\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a,temporal/api/sdk/v1/event_group_marker.proto\x1a$temporal/api/stream/v1/message.proto\x1a&temporal/api/workflow/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a#temporal/sdk/core/nexus/nexus.proto\x1a%temporal/sdk/core/common/common.proto"\xc8\x12\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12\x42\n\x13\x65vent_group_markers\x18\x65 \x03(\x0b\x32%.temporal.api.sdk.v1.EventGroupMarker\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x12<\n\x0bread_stream\x18\x17 \x01(\x0b\x32%.coresdk.workflow_commands.ReadStreamH\x00\x12X\n\x1arequest_cancel_stream_read\x18\x18 \x01(\x0b\x32\x32.coresdk.workflow_commands.RequestCancelStreamReadH\x00\x12\x45\n\x10\x61ppend_to_stream\x18\x19 \x01(\x0b\x32).coresdk.workflow_commands.AppendToStreamH\x00\x12>\n\x0c\x63lose_stream\x18\x1a \x01(\x0b\x32&.coresdk.workflow_commands.CloseStreamH\x00\x42\t\n\x07variant"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"\xb8\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x10 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x93\x06\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12#\n\x1binclude_arguments_in_marker\x18\x0e \x01(\x08\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"\x92\x07\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12\x43\n\x11search_attributes\x18\x08 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12[\n\x1binitial_versioning_behavior\x18\x0b \x01(\x0e\x32\x36.temporal.api.enums.v1.ContinueAsNewVersioningBehavior\x12\x39\n\x16\x62\x61\x63koff_start_interval\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"L\n\x17\x43\x61ncelWorkflowExecution\x12\x31\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32 .temporal.api.common.v1.Payloads"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xe1\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12\x43\n\x11search_attributes\x18\x11 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x14 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12I\n\x13versioning_override\x18\x15 \x01(\x0b\x32,.temporal.api.workflow.v1.VersioningOverride\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"J\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\x12\x0e\n\x06reason\x18\x02 \x01(\t"\x8e\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12\x0e\n\x06reason\x18\x03 \x01(\t"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r"e\n\x1eUpsertWorkflowSearchAttributes\x12\x43\n\x11search_attributes\x18\x01 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response"\x9a\x04\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x12H\n\x11\x63\x61ncellation_type\x18\x08 \x01(\x0e\x32-.coresdk.nexus.NexusOperationCancellationType\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x81\x01\n\x0e\x41ppendToStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12/\n\x06\x62odies\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload"M\n\x0b\x43loseStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"\xce\x01\n\nReadStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\'\n\x04wait\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x1a\n\x12records_in_history\x18\x05 \x01(\x08\x12\x13\n\x0bmax_records\x18\x06 \x01(\x05\x12\x11\n\tmax_bytes\x18\x07 \x01(\x03"&\n\x17RequestCancelStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -72,70 +75,78 @@ _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_options = b"8\001" _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._options = None _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_options = b"8\001" - _ACTIVITYCANCELLATIONTYPE._serialized_start = 8785 - _ACTIVITYCANCELLATIONTYPE._serialized_end = 8873 - _WORKFLOWCOMMAND._serialized_start = 558 - _WORKFLOWCOMMAND._serialized_end = 2647 - _STARTTIMER._serialized_start = 2649 - _STARTTIMER._serialized_end = 2732 - _CANCELTIMER._serialized_start = 2734 - _CANCELTIMER._serialized_end = 2760 - _SCHEDULEACTIVITY._serialized_start = 2763 - _SCHEDULEACTIVITY._serialized_end = 3587 - _SCHEDULEACTIVITY_HEADERSENTRY._serialized_start = 3508 - _SCHEDULEACTIVITY_HEADERSENTRY._serialized_end = 3587 - _SCHEDULELOCALACTIVITY._serialized_start = 3590 - _SCHEDULELOCALACTIVITY._serialized_end = 4377 - _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_start = 3508 - _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_end = 3587 - _REQUESTCANCELACTIVITY._serialized_start = 4379 - _REQUESTCANCELACTIVITY._serialized_end = 4415 - _REQUESTCANCELLOCALACTIVITY._serialized_start = 4417 - _REQUESTCANCELLOCALACTIVITY._serialized_end = 4458 - _QUERYRESULT._serialized_start = 4461 - _QUERYRESULT._serialized_end = 4617 - _QUERYSUCCESS._serialized_start = 4619 - _QUERYSUCCESS._serialized_end = 4684 - _COMPLETEWORKFLOWEXECUTION._serialized_start = 4686 - _COMPLETEWORKFLOWEXECUTION._serialized_end = 4762 - _FAILWORKFLOWEXECUTION._serialized_start = 4764 - _FAILWORKFLOWEXECUTION._serialized_end = 4838 - _CONTINUEASNEWWORKFLOWEXECUTION._serialized_start = 4841 - _CONTINUEASNEWWORKFLOWEXECUTION._serialized_end = 5755 - _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5598 - _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5674 - _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3508 - _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3587 - _CANCELWORKFLOWEXECUTION._serialized_start = 5757 - _CANCELWORKFLOWEXECUTION._serialized_end = 5833 - _SETPATCHMARKER._serialized_start = 5835 - _SETPATCHMARKER._serialized_end = 5889 - _STARTCHILDWORKFLOWEXECUTION._serialized_start = 5892 - _STARTCHILDWORKFLOWEXECUTION._serialized_end = 7141 - _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3508 - _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3587 - _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5598 - _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5674 - _CANCELCHILDWORKFLOWEXECUTION._serialized_start = 7143 - _CANCELCHILDWORKFLOWEXECUTION._serialized_end = 7217 - _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_start = 7220 - _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_end = 7362 - _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_start = 7365 - _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_end = 7764 - _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3508 - _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3587 - _CANCELSIGNALWORKFLOW._serialized_start = 7766 - _CANCELSIGNALWORKFLOW._serialized_end = 7801 - _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_start = 7803 - _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_end = 7904 - _MODIFYWORKFLOWPROPERTIES._serialized_start = 7906 - _MODIFYWORKFLOWPROPERTIES._serialized_end = 7985 - _UPDATERESPONSE._serialized_start = 7988 - _UPDATERESPONSE._serialized_end = 8198 - _SCHEDULENEXUSOPERATION._serialized_start = 8201 - _SCHEDULENEXUSOPERATION._serialized_end = 8739 - _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_start = 8689 - _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_end = 8739 - _REQUESTCANCELNEXUSOPERATION._serialized_start = 8741 - _REQUESTCANCELNEXUSOPERATION._serialized_end = 8783 + _ACTIVITYCANCELLATIONTYPE._serialized_start = 9570 + _ACTIVITYCANCELLATIONTYPE._serialized_end = 9658 + _WORKFLOWCOMMAND._serialized_start = 596 + _WORKFLOWCOMMAND._serialized_end = 2972 + _STARTTIMER._serialized_start = 2974 + _STARTTIMER._serialized_end = 3057 + _CANCELTIMER._serialized_start = 3059 + _CANCELTIMER._serialized_end = 3085 + _SCHEDULEACTIVITY._serialized_start = 3088 + _SCHEDULEACTIVITY._serialized_end = 3912 + _SCHEDULEACTIVITY_HEADERSENTRY._serialized_start = 3833 + _SCHEDULEACTIVITY_HEADERSENTRY._serialized_end = 3912 + _SCHEDULELOCALACTIVITY._serialized_start = 3915 + _SCHEDULELOCALACTIVITY._serialized_end = 4702 + _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_start = 3833 + _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_end = 3912 + _REQUESTCANCELACTIVITY._serialized_start = 4704 + _REQUESTCANCELACTIVITY._serialized_end = 4740 + _REQUESTCANCELLOCALACTIVITY._serialized_start = 4742 + _REQUESTCANCELLOCALACTIVITY._serialized_end = 4783 + _QUERYRESULT._serialized_start = 4786 + _QUERYRESULT._serialized_end = 4942 + _QUERYSUCCESS._serialized_start = 4944 + _QUERYSUCCESS._serialized_end = 5009 + _COMPLETEWORKFLOWEXECUTION._serialized_start = 5011 + _COMPLETEWORKFLOWEXECUTION._serialized_end = 5087 + _FAILWORKFLOWEXECUTION._serialized_start = 5089 + _FAILWORKFLOWEXECUTION._serialized_end = 5163 + _CONTINUEASNEWWORKFLOWEXECUTION._serialized_start = 5166 + _CONTINUEASNEWWORKFLOWEXECUTION._serialized_end = 6080 + _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5923 + _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5999 + _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3833 + _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3912 + _CANCELWORKFLOWEXECUTION._serialized_start = 6082 + _CANCELWORKFLOWEXECUTION._serialized_end = 6158 + _SETPATCHMARKER._serialized_start = 6160 + _SETPATCHMARKER._serialized_end = 6214 + _STARTCHILDWORKFLOWEXECUTION._serialized_start = 6217 + _STARTCHILDWORKFLOWEXECUTION._serialized_end = 7466 + _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3833 + _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3912 + _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5923 + _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5999 + _CANCELCHILDWORKFLOWEXECUTION._serialized_start = 7468 + _CANCELCHILDWORKFLOWEXECUTION._serialized_end = 7542 + _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_start = 7545 + _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_end = 7687 + _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_start = 7690 + _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_end = 8089 + _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3833 + _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3912 + _CANCELSIGNALWORKFLOW._serialized_start = 8091 + _CANCELSIGNALWORKFLOW._serialized_end = 8126 + _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_start = 8128 + _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_end = 8229 + _MODIFYWORKFLOWPROPERTIES._serialized_start = 8231 + _MODIFYWORKFLOWPROPERTIES._serialized_end = 8310 + _UPDATERESPONSE._serialized_start = 8313 + _UPDATERESPONSE._serialized_end = 8523 + _SCHEDULENEXUSOPERATION._serialized_start = 8526 + _SCHEDULENEXUSOPERATION._serialized_end = 9064 + _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_start = 9014 + _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_end = 9064 + _REQUESTCANCELNEXUSOPERATION._serialized_start = 9066 + _REQUESTCANCELNEXUSOPERATION._serialized_end = 9108 + _APPENDTOSTREAM._serialized_start = 9111 + _APPENDTOSTREAM._serialized_end = 9240 + _CLOSESTREAM._serialized_start = 9242 + _CLOSESTREAM._serialized_end = 9319 + _READSTREAM._serialized_start = 9322 + _READSTREAM._serialized_end = 9528 + _REQUESTCANCELSTREAMREAD._serialized_start = 9530 + _REQUESTCANCELSTREAMREAD._serialized_end = 9568 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi index 81c47c0b03..d0dfce295f 100644 --- a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi +++ b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi @@ -25,6 +25,7 @@ import temporalio.api.enums.v1.workflow_pb2 import temporalio.api.failure.v1.message_pb2 import temporalio.api.sdk.v1.event_group_marker_pb2 import temporalio.api.sdk.v1.user_metadata_pb2 +import temporalio.api.stream.v1.message_pb2 import temporalio.api.workflow.v1.message_pb2 import temporalio.bridge.proto.child_workflow.child_workflow_pb2 import temporalio.bridge.proto.common.common_pb2 @@ -105,6 +106,10 @@ class WorkflowCommand(google.protobuf.message.Message): UPDATE_RESPONSE_FIELD_NUMBER: builtins.int SCHEDULE_NEXUS_OPERATION_FIELD_NUMBER: builtins.int REQUEST_CANCEL_NEXUS_OPERATION_FIELD_NUMBER: builtins.int + READ_STREAM_FIELD_NUMBER: builtins.int + REQUEST_CANCEL_STREAM_READ_FIELD_NUMBER: builtins.int + APPEND_TO_STREAM_FIELD_NUMBER: builtins.int + CLOSE_STREAM_FIELD_NUMBER: builtins.int @property def user_metadata(self) -> temporalio.api.sdk.v1.user_metadata_pb2.UserMetadata: """User metadata that may or may not be persisted into history depending on the command type. @@ -181,6 +186,14 @@ class WorkflowCommand(google.protobuf.message.Message): def request_cancel_nexus_operation( self, ) -> global___RequestCancelNexusOperation: ... + @property + def read_stream(self) -> global___ReadStream: ... + @property + def request_cancel_stream_read(self) -> global___RequestCancelStreamRead: ... + @property + def append_to_stream(self) -> global___AppendToStream: ... + @property + def close_stream(self) -> global___CloseStream: ... def __init__( self, *, @@ -219,10 +232,16 @@ class WorkflowCommand(google.protobuf.message.Message): schedule_nexus_operation: global___ScheduleNexusOperation | None = ..., request_cancel_nexus_operation: global___RequestCancelNexusOperation | None = ..., + read_stream: global___ReadStream | None = ..., + request_cancel_stream_read: global___RequestCancelStreamRead | None = ..., + append_to_stream: global___AppendToStream | None = ..., + close_stream: global___CloseStream | None = ..., ) -> None: ... def HasField( self, field_name: typing.Literal[ + "append_to_stream", + b"append_to_stream", "cancel_child_workflow_execution", b"cancel_child_workflow_execution", "cancel_signal_workflow", @@ -231,6 +250,8 @@ class WorkflowCommand(google.protobuf.message.Message): b"cancel_timer", "cancel_workflow_execution", b"cancel_workflow_execution", + "close_stream", + b"close_stream", "complete_workflow_execution", b"complete_workflow_execution", "continue_as_new_workflow_execution", @@ -239,6 +260,8 @@ class WorkflowCommand(google.protobuf.message.Message): b"fail_workflow_execution", "modify_workflow_properties", b"modify_workflow_properties", + "read_stream", + b"read_stream", "request_cancel_activity", b"request_cancel_activity", "request_cancel_external_workflow_execution", @@ -247,6 +270,8 @@ class WorkflowCommand(google.protobuf.message.Message): b"request_cancel_local_activity", "request_cancel_nexus_operation", b"request_cancel_nexus_operation", + "request_cancel_stream_read", + b"request_cancel_stream_read", "respond_to_query", b"respond_to_query", "schedule_activity", @@ -276,6 +301,8 @@ class WorkflowCommand(google.protobuf.message.Message): def ClearField( self, field_name: typing.Literal[ + "append_to_stream", + b"append_to_stream", "cancel_child_workflow_execution", b"cancel_child_workflow_execution", "cancel_signal_workflow", @@ -284,6 +311,8 @@ class WorkflowCommand(google.protobuf.message.Message): b"cancel_timer", "cancel_workflow_execution", b"cancel_workflow_execution", + "close_stream", + b"close_stream", "complete_workflow_execution", b"complete_workflow_execution", "continue_as_new_workflow_execution", @@ -294,6 +323,8 @@ class WorkflowCommand(google.protobuf.message.Message): b"fail_workflow_execution", "modify_workflow_properties", b"modify_workflow_properties", + "read_stream", + b"read_stream", "request_cancel_activity", b"request_cancel_activity", "request_cancel_external_workflow_execution", @@ -302,6 +333,8 @@ class WorkflowCommand(google.protobuf.message.Message): b"request_cancel_local_activity", "request_cancel_nexus_operation", b"request_cancel_nexus_operation", + "request_cancel_stream_read", + b"request_cancel_stream_read", "respond_to_query", b"respond_to_query", "schedule_activity", @@ -354,6 +387,10 @@ class WorkflowCommand(google.protobuf.message.Message): "update_response", "schedule_nexus_operation", "request_cancel_nexus_operation", + "read_stream", + "request_cancel_stream_read", + "append_to_stream", + "close_stream", ] | None ): ... @@ -1931,3 +1968,273 @@ class RequestCancelNexusOperation(google.protobuf.message.Message): def ClearField(self, field_name: typing.Literal["seq", b"seq"]) -> None: ... global___RequestCancelNexusOperation = RequestCancelNexusOperation + +@typing.final +class AppendToStream(google.protobuf.message.Message): + """Appends Records to a Stream as the Workflow's Producer. The result comes in a + `ResolveStreamAppend` job. Core makes the request id of the append. + + An append is at-least-once. A later attempt of the Workflow Task writes it again, on this Worker + or another. A try that reaches the Store after more batches than the Store remembers is written + again too, after them. + + No command stops an append, so lang takes the job of an append whose awaiter is gone. Core drops + an append that has no result when the Workflow's last command comes, as it drops a Local + Activity. That append may have reached the Store or not, and lang gets no job for it. + + The appends and the closes of one Stream reach the Store one at a time, in the order of their + commands. A close takes its place only once History has its intent. So an append that comes + after a `CloseStream`, before History has the task of that close, is written before the close. + + Core fails the Workflow Task, and gives lang no failure of the append, in these cases: + * `seq` is 0, or isn't above the `seq` of the append before it. + * `stream` is unset, its id is empty or longer than 4096 bytes, or its Store name is longer than + 4096 bytes. + * The Worker has no Stream runtime for the Store of `stream`. + * The append waits to try again when the heartbeat of the Workflow Task comes, because the Store + answered `StoreUnavailable`, gave no answer or panicked. The message of that failure starts + with `StreamStoreUnavailable:`. + + An append with no `bodies`, or with a batch over the limits of its Store, doesn't fail the + Workflow Task. Lang gets a `failed` job for it. + + In a replay, Core compares the `seq` and the `stream` of the command with History, and not its + `bodies`. A `stream` with no Store name matches any Store of History. An append with no result + in History runs again once the replay is over, as a later attempt, so a reader of the Stream can + see its batch twice. + + A completion of the Workflow Task while an append has no result in a marker forces a new task, + unless it has the Workflow's last command. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + STREAM_FIELD_NUMBER: builtins.int + BODIES_FIELD_NUMBER: builtins.int + seq: builtins.int + """Lang's incremental sequence number for appends, starting at 1.""" + @property + def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... + @property + def bodies( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + temporalio.api.common.v1.message_pb2.Payload + ]: ... + def __init__( + self, + *, + seq: builtins.int = ..., + stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + bodies: collections.abc.Iterable[temporalio.api.common.v1.message_pb2.Payload] + | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream", b"stream"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "bodies", b"bodies", "seq", b"seq", "stream", b"stream" + ], + ) -> None: ... + +global___AppendToStream = AppendToStream + +@typing.final +class CloseStream(google.protobuf.message.Message): + """Closes a Stream. The Workflow Task that sends the command records only the intent to close, and + Core closes the Stream once History has that task. The result comes in a `ResolveStreamClose` + job of a later task, so a close needs at least one more Workflow Task. + + These rules of `AppendToStream` hold for a close too: + * No command stops it. + * Core drops it when the Workflow's last command comes and it has no result. + * The same cases fail the Workflow Task. + * A replay compares the command with History in the same way. + * A completion of the Workflow Task while it has no result in a marker forces a new task. + + Workflow code that needs its close awaits the result before its last command. A close whose + intent is in History with no result runs again once a replay is over. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + STREAM_FIELD_NUMBER: builtins.int + seq: builtins.int + """Lang's incremental sequence number for closes, starting at 1.""" + @property + def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... + def __init__( + self, + *, + seq: builtins.int = ..., + stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream", b"stream"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["seq", b"seq", "stream", b"stream"] + ) -> None: ... + +global___CloseStream = CloseStream + +@typing.final +class ReadStream(google.protobuf.message.Message): + """Reads the next page of a Stream. The result comes in one `ResolveStreamRead` job, which has a + page, a failure or a cancel. Core asks the Store when the command comes, unless the Workflow + replays. A replay gives the read the result that History has for it. + + The page has the Records after `from_offset`, in the order of the Stream: + * the Records that the Stream has, or the first ones that come within `wait` + * no Records and `done`, if the Stream is closed and has none after `from_offset` + * no Records, if none came within `wait` + + To read on, lang sends a new `ReadStream` whose `from_offset` is the offset of the last Record + that it got. A page with no Record gives no offset, so the next read starts at the `from_offset` + of this one. + + What a read costs: + * Each page takes a command, an activation and an entry in the marker of its Workflow Task. + * A read holds its Workflow Task open while it waits for the Store, as a Local Activity does. A + Signal, a timer or an Activity result reaches Workflow code in the next task. The task in hand + completes once Workflow code sends a command for the server while only reads hold the task, + and at the latest at its heartbeat. A read that still waits adds the three events of a forced + Workflow Task at each heartbeat. + * One Workflow Task gives at most 16 MiB of Records, and its marker holds at most 1 MiB of them + for reads with `records_in_history`. A page that doesn't fit comes in the next task, which + Core forces. + * Without `records_in_history`, History has the count and a digest of the Records of each page. + A replay reads each page from the Store again, within the timeout of its Workflow Task. A + query of a run that isn't cached replays too. Once the Store no longer has the same Records, + each replay fails, also the one for a query of a closed Workflow. + + A read gets no job at the Workflow's last command, at a failed Workflow Task, at an eviction and + at the shutdown of the Worker. After the last three the Workflow replays. The replay gives each + read the result that History has for it. A read with no result in History runs again once the + replay is over, unless Workflow code cancelled it. Such a read gets its `cancelled` job then. + + Core fails the Workflow Task, and gives lang no failure of the read, in the cases that + `AppendToStream` lists and in these: + * `from_offset` is longer than 1024 bytes. + * `wait` is negative, or has its nanoseconds out of range. + * `max_records` or `max_bytes` is negative. + + In a replay, Core compares the `seq`, the `stream` and the `from_offset` of the command with + History. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + STREAM_FIELD_NUMBER: builtins.int + FROM_OFFSET_FIELD_NUMBER: builtins.int + WAIT_FIELD_NUMBER: builtins.int + RECORDS_IN_HISTORY_FIELD_NUMBER: builtins.int + MAX_RECORDS_FIELD_NUMBER: builtins.int + MAX_BYTES_FIELD_NUMBER: builtins.int + seq: builtins.int + """Lang's incremental sequence number for reads, starting at 1.""" + from_offset: builtins.bytes + """The page has the Records after this offset. If it's empty, the page starts at the beginning + of the Stream. + """ + records_in_history: builtins.bool + """If set, the marker of the task holds the Records of the page, so a replay doesn't read the + Store. A marker can't hold a Record whose Producer and body have more than 1.5 MiB, so the + read fails with `stream_unsupported` for one. + """ + max_records: builtins.int + """The maximum number of Records in the page, which is 256 if this is zero.""" + max_bytes: builtins.int + """The maximum size of the Records in the page, which is 4 MiB if this is zero. Core asks the + Store for at most 16 MiB, and for at most 1 MiB with `records_in_history`. One larger Record + still comes as a page, unless the read fails for it with `records_in_history`. + """ + @property + def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... + @property + def wait(self) -> google.protobuf.duration_pb2.Duration: + """How long the read waits for a Record if the Stream has none after `from_offset`. If it's + unset, the read doesn't wait. + """ + + def __init__( + self, + *, + seq: builtins.int = ..., + stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + from_offset: builtins.bytes = ..., + wait: google.protobuf.duration_pb2.Duration | None = ..., + records_in_history: builtins.bool = ..., + max_records: builtins.int = ..., + max_bytes: builtins.int = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream", b"stream", "wait", b"wait"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "from_offset", + b"from_offset", + "max_bytes", + b"max_bytes", + "max_records", + b"max_records", + "records_in_history", + b"records_in_history", + "seq", + b"seq", + "stream", + b"stream", + "wait", + b"wait", + ], + ) -> None: ... + +global___ReadStream = ReadStream + +@typing.final +class RequestCancelStreamRead(google.protobuf.message.Message): + """Cancels a read, as `RequestCancelLocalActivity` cancels a Local Activity whose cancellation type + is `TRY_CANCEL`. The read still gets its one `ResolveStreamRead` job. Once Core has the cancel, + that job has `cancelled`, unless lang already got the job of the read. Core drops a page or a + failure of the read that lang didn't get, and the next read from the same `from_offset` gives + the Records of a dropped page. + + If the activation that lang answers with the cancel has a job of the read, that job stays as it + is. So an SDK that runs Workflow code between the jobs of one activation can give that code a + page of a read that it already cancelled, in the first run and in a replay. + + A cancel costs an activation and an entry in the marker of its Workflow Task, for the + `cancelled` job. If the task completes at its heartbeat before that job, the cancel also costs + the events of a forced Workflow Task. + + A `ReadStream` and its cancel in one completion, in that order, make no Store call. + + In a replay, the job is the one that History has. A replay of a History without the flag that + turns workflow task chunking off can give the `cancelled` job before lang sends the cancel, in + the activation of the job that made Workflow code cancel. A read with a cancel and no result in + History gets its `cancelled` job once the replay is over. + + Core ignores the cancel of a read that got its job, and the cancel of a `seq` that lang skipped. + The cancel of a `seq` above that of the last read is a nondeterminism error. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + seq: builtins.int + """The `seq` of the `ReadStream` to cancel.""" + def __init__( + self, + *, + seq: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing.Literal["seq", b"seq"]) -> None: ... + +global___RequestCancelStreamRead = RequestCancelStreamRead From 7f855d605fe667f88b6ed28fe54fc86ae67adbd3 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Mon, 23 Nov 2026 13:00:34 -0700 Subject: [PATCH 10/24] Regenerate the Streams API with no `producer` in Workflow code The SDK sets the Producer of Workflow code from the run and its Workflow Task attempt, so the Workflow `append` and `close` have no `producer`. The code comes from the WIT and the nexgen commit that the API pins. --- .../system/stream_service/workflow/_resources/stream.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 2ec7074865..ee9411ab1c 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -22,7 +22,6 @@ CloseStreamResponse, DescribeStreamRequest, DescribeStreamResponse, - Producer, ReadRecordsRequest, ReadRecordsResponse, StreamRecord, @@ -67,13 +66,12 @@ async def __aexit__( async def append( self, *records: BodyT, - producer: Producer | None = None, ) -> AppendRecordsResponse: """Append values, and return the offsets of the batch.""" request = AppendRecordsRequest( ref=self.ref, - producer=((_support.workflow_producer()) if producer is None else producer), records=[AppendRecord(body=value) for value in records], + producer=_support.workflow_producer(), request_id=_support.append_request_id(), ) handle = await _append_records(request) @@ -81,12 +79,11 @@ async def append( async def close( self, - producer: Producer | None = None, ) -> None: """Close the Stream. Readers get the Records that are left, then end.""" request = CloseStreamRequest( ref=self.ref, - producer=((_support.workflow_producer()) if producer is None else producer), + producer=_support.workflow_producer(), ) handle = await _close_stream(request) await handle From 24078681171315b83160aaee3a27ddcabc490bfe Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Mon, 23 Nov 2026 23:11:02 -0700 Subject: [PATCH 11/24] Regenerate the API protos with refs in the Stream requests A Stream request takes a ref in place of a Stream id and has no request id, a Workflow's Activity Producer has its scheduled event id, and the task metadata has the Stream calls of Core. They come from the API that Core `e4934879` vendors, which the hand-written part pins. --- .../api/sdk/v1/task_complete_metadata_pb2.py | 6 +- .../api/sdk/v1/task_complete_metadata_pb2.pyi | 8 + temporalio/api/stream/v1/message_pb2.py | 28 ++-- temporalio/api/stream/v1/message_pb2.pyi | 26 ++- .../streamservice/v1/request_response_pb2.py | 40 ++--- .../streamservice/v1/request_response_pb2.pyi | 150 +++++++++--------- 6 files changed, 138 insertions(+), 120 deletions(-) diff --git a/temporalio/api/sdk/v1/task_complete_metadata_pb2.py b/temporalio/api/sdk/v1/task_complete_metadata_pb2.py index 411a4216bf..de70aaeddb 100644 --- a/temporalio/api/sdk/v1/task_complete_metadata_pb2.py +++ b/temporalio/api/sdk/v1/task_complete_metadata_pb2.py @@ -14,7 +14,7 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1"x\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\tB\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' + b'\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1"\x93\x01\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\t\x12\x19\n\x11\x63ore_stream_calls\x18\x05 \x01(\x0c\x42\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -22,6 +22,6 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\026io.temporal.api.sdk.v1B\031TaskCompleteMetadataProtoP\001Z\035go.temporal.io/api/sdk/v1;sdk\252\002\025Temporalio.Api.Sdk.V1\352\002\030Temporalio::Api::Sdk::V1" - _WORKFLOWTASKCOMPLETEDMETADATA._serialized_start = 73 - _WORKFLOWTASKCOMPLETEDMETADATA._serialized_end = 193 + _WORKFLOWTASKCOMPLETEDMETADATA._serialized_start = 74 + _WORKFLOWTASKCOMPLETEDMETADATA._serialized_end = 221 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi b/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi index c4efd608b6..1e552eb069 100644 --- a/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi +++ b/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi @@ -21,6 +21,7 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): LANG_USED_FLAGS_FIELD_NUMBER: builtins.int SDK_NAME_FIELD_NUMBER: builtins.int SDK_VERSION_FIELD_NUMBER: builtins.int + CORE_STREAM_CALLS_FIELD_NUMBER: builtins.int sdk_name: builtins.str """Name of the SDK that processed the task. This is usually something like "temporal-go" and is usually the same as client-name gRPC header. This should only be set if its value changed @@ -34,6 +35,10 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): usually the same as client-version gRPC header. This should only be set if its value changed since the last time recorded on the workflow (or be set on the first task). """ + core_stream_calls: builtins.bytes + """The Stream calls of this Workflow Task, in a format that SDK Core owns. A replay gives + Workflow code the same results from it. + """ @property def core_used_flags( self, @@ -78,10 +83,13 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): lang_used_flags: collections.abc.Iterable[builtins.int] | None = ..., sdk_name: builtins.str = ..., sdk_version: builtins.str = ..., + core_stream_calls: builtins.bytes = ..., ) -> None: ... def ClearField( self, field_name: typing.Literal[ + "core_stream_calls", + b"core_stream_calls", "core_used_flags", b"core_used_flags", "lang_used_flags", diff --git a/temporalio/api/stream/v1/message_pb2.py b/temporalio/api/stream/v1/message_pb2.py index a1d0900cdc..2983fc4967 100644 --- a/temporalio/api/stream/v1/message_pb2.py +++ b/temporalio/api/stream/v1/message_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\x88\x01\n\x10WorkflowProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12<\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"\xa3\x01\n\x15LocalActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12=\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\xa1\x01\n\x18WorkflowActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x8e\x01\n\x1aStandaloneActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"/\n\x0e\x43lientProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t"\xf5\x02\n\x08Producer\x12<\n\x08workflow\x18\x01 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x02 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12M\n\x11workflow_activity\x18\x03 \x01(\x0b\x32\x30.temporal.api.stream.v1.WorkflowActivityProducerH\x00\x12Q\n\x13standalone_activity\x18\x04 \x01(\x0b\x32\x32.temporal.api.stream.v1.StandaloneActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x05 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' + b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\x88\x01\n\x10WorkflowProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12<\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"\xa3\x01\n\x15LocalActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12=\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\xbd\x01\n\x18WorkflowActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x1a\n\x12scheduled_event_id\x18\x05 \x01(\x03\x12\x38\n\x07\x61ttempt\x18\x06 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x8e\x01\n\x1aStandaloneActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"/\n\x0e\x43lientProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t"\xf5\x02\n\x08Producer\x12<\n\x08workflow\x18\x01 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x02 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12M\n\x11workflow_activity\x18\x03 \x01(\x0b\x32\x30.temporal.api.stream.v1.WorkflowActivityProducerH\x00\x12Q\n\x13standalone_activity\x18\x04 \x01(\x0b\x32\x32.temporal.api.stream.v1.StandaloneActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x05 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -44,17 +44,17 @@ _LOCALACTIVITYPRODUCER._serialized_start = 663 _LOCALACTIVITYPRODUCER._serialized_end = 826 _WORKFLOWACTIVITYPRODUCER._serialized_start = 829 - _WORKFLOWACTIVITYPRODUCER._serialized_end = 990 - _STANDALONEACTIVITYPRODUCER._serialized_start = 993 - _STANDALONEACTIVITYPRODUCER._serialized_end = 1135 - _CLIENTPRODUCER._serialized_start = 1137 - _CLIENTPRODUCER._serialized_end = 1184 - _PRODUCER._serialized_start = 1187 - _PRODUCER._serialized_end = 1560 - _APPENDRECORD._serialized_start = 1562 - _APPENDRECORD._serialized_end = 1623 - _STREAMRECORD._serialized_start = 1626 - _STREAMRECORD._serialized_end = 1755 - _STREAMERRORDETAILS._serialized_start = 1757 - _STREAMERRORDETAILS._serialized_end = 1835 + _WORKFLOWACTIVITYPRODUCER._serialized_end = 1018 + _STANDALONEACTIVITYPRODUCER._serialized_start = 1021 + _STANDALONEACTIVITYPRODUCER._serialized_end = 1163 + _CLIENTPRODUCER._serialized_start = 1165 + _CLIENTPRODUCER._serialized_end = 1212 + _PRODUCER._serialized_start = 1215 + _PRODUCER._serialized_end = 1588 + _APPENDRECORD._serialized_start = 1590 + _APPENDRECORD._serialized_end = 1651 + _STREAMRECORD._serialized_start = 1654 + _STREAMRECORD._serialized_end = 1783 + _STREAMERRORDETAILS._serialized_start = 1785 + _STREAMERRORDETAILS._serialized_end = 1863 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 30026a9947..1c73eb0e62 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -18,8 +18,11 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class StreamRef(google.protobuf.message.Message): """Experimental. Might change in the future. - A reference to one Stream, which code passes to other code as data. Only an SDK uses this - message. A request to a Store or to the server has the `id` alone. + A reference to one Stream, which code passes to other code as data. Callers treat the `id` as + opaque. An id is never used for a second Stream while the Store remembers the first one, so a + create for a closed or expired Stream fails. A Store can forget an expired Stream after a time + of its choice, and a create for its id succeeds after that. Every SDK encodes a ref in a + Payload with this message, so a ref that one SDK writes decodes in another. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -30,7 +33,8 @@ class StreamRef(google.protobuf.message.Message): store: builtins.str """The name under which the client and Worker config registered the Store of this Stream. An SDK uses it to send a call on this ref to the right Store. When it's empty, the SDK picks - the Store from its config. + the Store from its config. Only an SDK sets and reads this field. The server and a Store + ignore it. """ def __init__( self, @@ -240,7 +244,10 @@ class LocalActivityProducer(google.protobuf.message.Message): run_id: builtins.str """Required.""" activity_id: builtins.str - """Required.""" + """Required. The id that the SDK gives the call, because a Local Activity has no scheduled + event. Two Local Activities of one run must not share it, or the Store takes them as one + Producer. Each SDK makes it from a counter of its own, unless the user sets it. + """ @property def attempt(self) -> global___LocalActivityAttempt: """Required.""" @@ -287,6 +294,7 @@ class WorkflowActivityProducer(google.protobuf.message.Message): WORKFLOW_ID_FIELD_NUMBER: builtins.int RUN_ID_FIELD_NUMBER: builtins.int ACTIVITY_ID_FIELD_NUMBER: builtins.int + SCHEDULED_EVENT_ID_FIELD_NUMBER: builtins.int ATTEMPT_FIELD_NUMBER: builtins.int namespace: builtins.str """Required. The namespace of the Workflow that scheduled the Activity.""" @@ -295,8 +303,11 @@ class WorkflowActivityProducer(google.protobuf.message.Message): run_id: builtins.str """Required.""" activity_id: builtins.str - """Required. A run can use an Activity id again after the first Activity ended. The second - Activity is then a later attempt of the same Producer. + """Required.""" + scheduled_event_id: builtins.int + """The id of the `ActivityTaskScheduled` event of the Activity in the History of its run. A run + can use an Activity id again after the first Activity ended, and this id separates the two + Activities, so they are separate Producers. It's zero when the SDK doesn't have it. """ @property def attempt(self) -> global___ActivityAttempt: @@ -309,6 +320,7 @@ class WorkflowActivityProducer(google.protobuf.message.Message): workflow_id: builtins.str = ..., run_id: builtins.str = ..., activity_id: builtins.str = ..., + scheduled_event_id: builtins.int = ..., attempt: global___ActivityAttempt | None = ..., ) -> None: ... def HasField( @@ -325,6 +337,8 @@ class WorkflowActivityProducer(google.protobuf.message.Message): b"namespace", "run_id", b"run_id", + "scheduled_event_id", + b"scheduled_event_id", "workflow_id", b"workflow_id", ], diff --git a/temporalio/api/streamservice/v1/request_response_pb2.py b/temporalio/api/streamservice/v1/request_response_pb2.py index 1d77998a79..fe9390519d 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.py +++ b/temporalio/api/streamservice/v1/request_response_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\x87\x01\n\x13\x43reateStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy\x12\x12\n\nrequest_id\x18\x03 \x01(\t"\'\n\x14\x43reateStreamResponse\x12\x0f\n\x07\x63reated\x18\x01 \x01(\x08"\xa8\x01\n\x14\x41ppendRecordsRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x12\n\nrequest_id\x18\x03 \x01(\t\x12\x35\n\x07records\x18\x04 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"[\n\x12\x43loseStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\x8d\x01\n\x12ReadRecordsRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"*\n\x15\x44\x65scribeStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' + b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\x97\x01\n\x13\x43reateStreamRequest\x12\x35\n\nstream_ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy"W\n\x14\x43reateStreamResponse\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xb1\x01\n\x14\x41ppendRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x35\n\x07records\x18\x03 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"x\n\x12\x43loseStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\xaa\x01\n\x12ReadRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"G\n\x15\x44\x65scribeStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -32,23 +32,23 @@ DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n io.temporal.api.streamservice.v1B\024RequestResponseProtoP\001Z1go.temporal.io/api/streamservice/v1;streamservice\252\002\037Temporalio.Api.StreamService.V1\352\002"Temporalio::Api::StreamService::V1' _CREATESTREAMREQUEST._serialized_start = 194 - _CREATESTREAMREQUEST._serialized_end = 329 - _CREATESTREAMRESPONSE._serialized_start = 331 - _CREATESTREAMRESPONSE._serialized_end = 370 - _APPENDRECORDSREQUEST._serialized_start = 373 - _APPENDRECORDSREQUEST._serialized_end = 541 - _APPENDRECORDSRESPONSE._serialized_start = 543 - _APPENDRECORDSRESPONSE._serialized_end = 609 - _CLOSESTREAMREQUEST._serialized_start = 611 - _CLOSESTREAMREQUEST._serialized_end = 702 - _CLOSESTREAMRESPONSE._serialized_start = 704 - _CLOSESTREAMRESPONSE._serialized_end = 725 - _READRECORDSREQUEST._serialized_start = 728 - _READRECORDSREQUEST._serialized_end = 869 - _READRECORDSRESPONSE._serialized_start = 871 - _READRECORDSRESPONSE._serialized_end = 982 - _DESCRIBESTREAMREQUEST._serialized_start = 984 - _DESCRIBESTREAMREQUEST._serialized_end = 1026 - _DESCRIBESTREAMRESPONSE._serialized_start = 1028 - _DESCRIBESTREAMRESPONSE._serialized_end = 1126 + _CREATESTREAMREQUEST._serialized_end = 345 + _CREATESTREAMRESPONSE._serialized_start = 347 + _CREATESTREAMRESPONSE._serialized_end = 434 + _APPENDRECORDSREQUEST._serialized_start = 437 + _APPENDRECORDSREQUEST._serialized_end = 614 + _APPENDRECORDSRESPONSE._serialized_start = 616 + _APPENDRECORDSRESPONSE._serialized_end = 682 + _CLOSESTREAMREQUEST._serialized_start = 684 + _CLOSESTREAMREQUEST._serialized_end = 804 + _CLOSESTREAMRESPONSE._serialized_start = 806 + _CLOSESTREAMRESPONSE._serialized_end = 827 + _READRECORDSREQUEST._serialized_start = 830 + _READRECORDSREQUEST._serialized_end = 1000 + _READRECORDSRESPONSE._serialized_start = 1002 + _READRECORDSRESPONSE._serialized_end = 1113 + _DESCRIBESTREAMREQUEST._serialized_start = 1115 + _DESCRIBESTREAMREQUEST._serialized_end = 1186 + _DESCRIBESTREAMRESPONSE._serialized_start = 1188 + _DESCRIBESTREAMRESPONSE._serialized_end = 1286 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index cf9e568cbd..e28902ed6c 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -21,52 +21,43 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class CreateStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Creates a Stream. If the Stream already exists, the result depends on `id_conflict_policy`. - `FAIL` fails with `ALREADY_EXISTS`, and `USE_EXISTING` returns the Stream with `created` - false. A retry of the create that made the Stream, with the same `request_id`, returns - `created` true. Either policy fails with `CLOSED` for a closed Stream and with `EXPIRED` for - an expired one. + `FAIL` fails with `ALREADY_EXISTS`, and `USE_EXISTING` returns the Stream with `created` false. A + retry of the create that made the Stream, with the same request id, returns `created` true. The + Store remembers the request id of that create, so a retry after a lost response doesn't fail with + `ALREADY_EXISTS`. Either policy fails with `CLOSED` for a closed Stream and with `EXPIRED` for an + expired one. A create has no Retention. Retention is a setting of the Store, as it's a setting of the namespace for Workflows. (-- api-linter: core::0133=disabled - aip.dev/not-precedent: The request identifies a Stream by its id. --) + aip.dev/not-precedent: The request identifies a Stream by its ref. --) """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_ID_FIELD_NUMBER: builtins.int + STREAM_REF_FIELD_NUMBER: builtins.int ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int - REQUEST_ID_FIELD_NUMBER: builtins.int - stream_id: builtins.str - """Required. The id of the Stream to create. Callers treat it as opaque. A create for a closed - or expired Stream fails. A Store can forget an expired Stream after a time of its choice, - and a create for its id succeeds after that. - """ id_conflict_policy: ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType ) """What the create does if the Stream already exists. Unspecified means `FAIL`.""" - request_id: builtins.str - """A value that's unique to this create call and the same on its retries. The Store remembers - the `request_id` of the create that made the Stream, so a retry after a lost response - doesn't fail with `ALREADY_EXISTS`. - """ + @property + def stream_ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required. The Stream to create. Its `id` must not be empty.""" + def __init__( self, *, - stream_id: builtins.str = ..., + stream_ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., id_conflict_policy: temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType = ..., - request_id: builtins.str = ..., ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream_ref", b"stream_ref"] + ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ - "id_conflict_policy", - b"id_conflict_policy", - "request_id", - b"request_id", - "stream_id", - b"stream_id", + "id_conflict_policy", b"id_conflict_policy", "stream_ref", b"stream_ref" ], ) -> None: ... @@ -80,15 +71,27 @@ class CreateStreamResponse(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor + REF_FIELD_NUMBER: builtins.int CREATED_FIELD_NUMBER: builtins.int created: builtins.bool """False when `USE_EXISTING` returned a Stream that already existed.""" + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """The ref of the Stream. The caller can pass it to other code as data. A Store and the server + return the ref as the request had it, because they don't know the Store names of an SDK. + The SDK then sets `store` to the Store that it picked, before the caller gets the ref. + """ + def __init__( self, *, + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., created: builtins.bool = ..., ) -> None: ... - def ClearField(self, field_name: typing.Literal["created", b"created"]) -> None: ... + def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["created", b"created", "ref", b"ref"] + ) -> None: ... global___CreateStreamResponse = CreateStreamResponse @@ -96,25 +99,23 @@ global___CreateStreamResponse = CreateStreamResponse class AppendRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Appends one batch of Records as one Producer. If the same batch arrives again, with the same - Producer, attempt and `request_id`, the Store writes it only once while it remembers the id. + Producer, attempt and request id, the Store writes it only once while it remembers the id, and it + returns the offsets of the first write. A caller that got no response sends the batch again with + the same request id. A Store remembers the request ids of the most recent batches of each + Producer of the Stream. How many it remembers is a setting of the Store, so a try that arrives + after more batches than that is written again. When the request id is empty, a retry is written + again. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_ID_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int - REQUEST_ID_FIELD_NUMBER: builtins.int RECORDS_FIELD_NUMBER: builtins.int - stream_id: builtins.str - """Required.""" - request_id: builtins.str - """A value that's unique to this append call and the same on its retries. A caller that got no - response sends the batch again with the same value, and the Store returns the offsets of - the first write. A Store remembers the `request_id` of the most recent batches of each - Producer of the Stream. How many it remembers is a setting of the Store, so a try that - arrives after more batches than that is written again. When it's empty, a retry is written - again. - """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: """Required. The Producer that writes the batch. A Producer sends the same value in its @@ -132,28 +133,20 @@ class AppendRecordsRequest(google.protobuf.message.Message): def __init__( self, *, - stream_id: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., - request_id: builtins.str = ..., records: collections.abc.Iterable[ temporalio.api.stream.v1.message_pb2.AppendRecord ] | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["producer", b"producer"] + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ - "producer", - b"producer", - "records", - b"records", - "request_id", - b"request_id", - "stream_id", - b"stream_id", + "producer", b"producer", "records", b"records", "ref", b"ref" ], ) -> None: ... @@ -196,10 +189,12 @@ class CloseStreamRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_ID_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int - stream_id: builtins.str - """Required.""" + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: """Required. The Producer that closes the Stream.""" @@ -207,15 +202,14 @@ class CloseStreamRequest(google.protobuf.message.Message): def __init__( self, *, - stream_id: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["producer", b"producer"] + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] ) -> builtins.bool: ... def ClearField( - self, - field_name: typing.Literal["producer", b"producer", "stream_id", b"stream_id"], + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] ) -> None: ... global___CloseStreamRequest = CloseStreamRequest @@ -243,13 +237,11 @@ class ReadRecordsRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_ID_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int FROM_OFFSET_FIELD_NUMBER: builtins.int MAX_RECORDS_FIELD_NUMBER: builtins.int MAX_BYTES_FIELD_NUMBER: builtins.int WAIT_FIELD_NUMBER: builtins.int - stream_id: builtins.str - """Required.""" from_offset: builtins.bytes """The read returns the Records after this offset. Empty means from the beginning. An offset past the newest one fails with `OFFSET_TOO_HIGH`. To read only new Records, a caller gets @@ -265,24 +257,27 @@ class ReadRecordsRequest(google.protobuf.message.Message): this is still returned, alone in its page, so a read always makes progress. Zero means no limit. """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + @property def wait(self) -> google.protobuf.duration_pb2.Duration: """How long the read waits for a new Record, or for the close of the Stream, before it returns - an empty page. When it's unset, the read returns immediately. The deadline of the request - must be longer than this wait. + an empty page. When it's unset, the read returns immediately. """ def __init__( self, *, - stream_id: builtins.str = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., from_offset: builtins.bytes = ..., max_records: builtins.int = ..., max_bytes: builtins.int = ..., wait: google.protobuf.duration_pb2.Duration | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["wait", b"wait"] + self, field_name: typing.Literal["ref", b"ref", "wait", b"wait"] ) -> builtins.bool: ... def ClearField( self, @@ -293,8 +288,8 @@ class ReadRecordsRequest(google.protobuf.message.Message): b"max_bytes", "max_records", b"max_records", - "stream_id", - b"stream_id", + "ref", + b"ref", "wait", b"wait", ], @@ -314,10 +309,10 @@ class ReadRecordsResponse(google.protobuf.message.Message): LAST_OFFSET_FIELD_NUMBER: builtins.int DONE_FIELD_NUMBER: builtins.int last_offset: builtins.bytes - """Where the next read goes on. The next read passes it as `from_offset`. It's never before - the last Record in this page, and it never skips a Record, but it can be after entries of - the Store that aren't Records. For an empty page it can be the `from_offset` of the - request, which is empty when the request had none. + """The last position that the read covered. The next read passes it as `from_offset`. Every + Store can give it, as the offset of the last Record in this page, or as the `from_offset` + of the request for an empty page. A Store can also give a later offset that skips only + entries of its own that aren't Records, so the next read doesn't scan them again. """ done: builtins.bool """True when the Stream is closed and this page has its last Record. A read has no other sign @@ -357,17 +352,18 @@ class DescribeStreamRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_ID_FIELD_NUMBER: builtins.int - stream_id: builtins.str - """Required.""" + REF_FIELD_NUMBER: builtins.int + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: + """Required.""" + def __init__( self, *, - stream_id: builtins.str = ..., - ) -> None: ... - def ClearField( - self, field_name: typing.Literal["stream_id", b"stream_id"] + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., ) -> None: ... + def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["ref", b"ref"]) -> None: ... global___DescribeStreamRequest = DescribeStreamRequest From bfaca8fbe1327f3b327438dad454ea5ac54844e5 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Mon, 23 Nov 2026 23:11:59 -0700 Subject: [PATCH 12/24] Regenerate the Streams API with refs in the requests Each request takes a ref, a create answers with the ref, and no request has a request id, since the Nexus envelope has it. A Workflow's Activity Producer has its scheduled event id. The code comes from the WIT that Core `e4934879` vendors and from nexgen `74f8ce76`. --- .../stream_service/client/_extensions.py | 15 +-- .../client/_resources/stream.py | 1 - .../nexus/system/stream_service/models.py | 100 ++++++++++++------ .../nexus/system/stream_service/services.py | 2 +- .../stream_service/workflow/__init__.py | 7 ++ .../workflow/_resources/stream.py | 1 - .../workflow/_system_nexus_interceptor.py | 33 ++++-- .../workflow/operations/create_stream.py | 12 +-- 8 files changed, 113 insertions(+), 58 deletions(-) diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index 0733e2882f..4cf7bc5d4b 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -13,11 +13,10 @@ if typing.TYPE_CHECKING: import temporalio.client -import temporalio.nexus.system._support as _support - from .._resource_context_manager import resource_context_manager from ..models import ( CreateStreamRequest, + CreateStreamResult, StreamIdConflictPolicy, StreamRef, ) @@ -101,16 +100,19 @@ async def _stream_service_create_stream( endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, ) handle = await nexus_client.start_operation( - operation=StreamService.create_stream, + operation="CreateStream", arg=request, id=f"{_uuid.uuid4()}", + result_type=CreateStreamResult[body_type], rpc_metadata=rpc_metadata or {}, rpc_timeout=rpc_timeout, ) result = await handle.result() + if result.ref is None: + raise RuntimeError("CreateStream answered without `ref`") resource = Stream[body_type]( nexus_client, - ref=request.ref, + ref=result.ref, created=result.created or None, ) return resource @@ -161,14 +163,13 @@ async def create_stream( """ if body_type is None: body_type = typing.Any - ref = StreamRef[body_type]( + stream_ref = StreamRef( id=id, store=store, ) request = CreateStreamRequest( - ref=ref, + stream_ref=stream_ref, id_conflict_policy=id_conflict_policy, - request_id=_support.request_id(), ) return await self._stream_service_create_stream( request, body_type, rpc_metadata=rpc_metadata, rpc_timeout=rpc_timeout diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index 6a6f46c451..f0545a5da0 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -86,7 +86,6 @@ async def append( else producer ), records=[AppendRecord(body=value) for value in records], - request_id=_support.append_request_id(), ) handle = await self._nexus_client.start_operation( operation=StreamService.append_records, diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index 0d455d0ef5..65561d2511 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -45,9 +45,8 @@ def _stream_status_from_proto(value: int) -> StreamStatus: class CreateStreamRequest(typing.Generic[BodyT]): """Create a Stream. If it already exists, fail, or return it with use-existing.""" - ref: StreamRef[BodyT] + stream_ref: StreamRef[BodyT] id_conflict_policy: StreamIdConflictPolicy | None = None - request_id: str | None = None class _CreateStreamRequestTransferTypeConverter( @@ -68,18 +67,19 @@ def from_transfer_type( type_hint: type[CreateStreamRequest[BodyT]], ) -> CreateStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.stream_id: - raise ValueError("missing required field CreateStreamRequest.ref") - ref = typing.cast( + if not value.HasField("stream_ref"): + raise ValueError("missing required field CreateStreamRequest.stream_ref") + stream_ref = typing.cast( StreamRef[BodyT], - _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), + _StreamRefTransferTypeConverter().from_transfer_type( + value.stream_ref, StreamRef[body_type] + ), ) return CreateStreamRequest( - ref=ref, + stream_ref=stream_ref, id_conflict_policy=StreamIdConflictPolicy(value.id_conflict_policy) if value.id_conflict_policy != 0 else None, - request_id=value.request_id if bool(value.request_id) else None, ) @typing_extensions.override @@ -90,15 +90,15 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest() ) - message.stream_id = _support.stream_ref_to_id(value.ref) + message.stream_ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.stream_ref) + ) if value.id_conflict_policy is not None: message.id_conflict_policy = ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType( value.id_conflict_policy ) ) - if value.request_id is not None: - message.request_id = value.request_id return message @@ -157,13 +157,14 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) -class CreateStreamResult: +class CreateStreamResult(typing.Generic[BodyT]): + ref: StreamRef[BodyT] | None = None created: bool | None = None class _CreateStreamResultTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - CreateStreamResult, + CreateStreamResult[BodyT], temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, ] ): @@ -176,27 +177,40 @@ class _CreateStreamResultTransferTypeConverter( def from_transfer_type( self, value: temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, - type_hint: type[CreateStreamResult], - ) -> CreateStreamResult: + type_hint: type[CreateStreamResult[BodyT]], + ) -> CreateStreamResult[BodyT]: + (body_type,) = typing.get_args(type_hint) or (typing.Any,) return CreateStreamResult( + ref=typing.cast( + StreamRef[BodyT], + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), + ) + if value.HasField("ref") + else None, created=value.created if bool(value.created) else None, ) @typing_extensions.override def to_transfer_type( self, - value: CreateStreamResult, + value: CreateStreamResult[BodyT], ) -> temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse: message = ( temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse() ) + if value.ref is not None: + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) if value.created is not None: message.created = value.created return message temporalio.converter.transfer_type_convertible( - _CreateStreamResultTransferTypeConverter + _CreateStreamResultTransferTypeConverter[typing.Any] )(CreateStreamResult) # pyright: ignore[reportUnusedCallResult] @@ -207,7 +221,6 @@ class AppendRecordsRequest(typing.Generic[BodyT]): ref: StreamRef[BodyT] records: list[AppendRecord[BodyT]] producer: Producer - request_id: str | None = None class _AppendRecordsRequestTransferTypeConverter( @@ -228,11 +241,13 @@ def from_transfer_type( type_hint: type[AppendRecordsRequest[BodyT]], ) -> AppendRecordsRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.stream_id: + if not value.HasField("ref"): raise ValueError("missing required field AppendRecordsRequest.ref") ref = typing.cast( StreamRef[BodyT], - _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), ) records = [ typing.cast( @@ -252,7 +267,6 @@ def from_transfer_type( ref=ref, records=records, producer=producer, - request_id=value.request_id if bool(value.request_id) else None, ) @typing_extensions.override @@ -263,7 +277,9 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest() ) - message.stream_id = _support.stream_ref_to_id(value.ref) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) for element in value.records: item = message.records.add() item.CopyFrom( @@ -272,8 +288,6 @@ def to_transfer_type( message.producer.CopyFrom( _ProducerTransferTypeConverter().to_transfer_type(value.producer) ) - if value.request_id is not None: - message.request_id = value.request_id return message @@ -731,7 +745,7 @@ def to_transfer_type( )(LocalActivityAttempt) # pyright: ignore[reportUnusedCallResult] -@dataclasses.dataclass(slots=True) +@dataclasses.dataclass(slots=True, kw_only=True) class WorkflowActivityProducer: """The Producer of one Activity that a Workflow scheduled.""" @@ -739,6 +753,7 @@ class WorkflowActivityProducer: workflow_id: str run_id: str activity_id: str + scheduled_event_id: int | None = None attempt: ActivityAttempt @@ -786,6 +801,9 @@ def from_transfer_type( workflow_id=workflow_id, run_id=run_id, activity_id=activity_id, + scheduled_event_id=value.scheduled_event_id + if value.scheduled_event_id != 0 + else None, attempt=attempt, ) @@ -799,6 +817,8 @@ def to_transfer_type( message.workflow_id = value.workflow_id message.run_id = value.run_id message.activity_id = value.activity_id + if value.scheduled_event_id is not None: + message.scheduled_event_id = value.scheduled_event_id message.attempt.CopyFrom( _ActivityAttemptTransferTypeConverter().to_transfer_type(value.attempt) ) @@ -1063,11 +1083,13 @@ def from_transfer_type( type_hint: type[CloseStreamRequest[BodyT]], ) -> CloseStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.stream_id: + if not value.HasField("ref"): raise ValueError("missing required field CloseStreamRequest.ref") ref = typing.cast( StreamRef[BodyT], - _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), ) if not value.HasField("producer"): raise ValueError("missing required field CloseStreamRequest.producer") @@ -1087,7 +1109,9 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest() ) - message.stream_id = _support.stream_ref_to_id(value.ref) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) message.producer.CopyFrom( _ProducerTransferTypeConverter().to_transfer_type(value.producer) ) @@ -1168,11 +1192,13 @@ def from_transfer_type( type_hint: type[ReadRecordsRequest[BodyT]], ) -> ReadRecordsRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.stream_id: + if not value.HasField("ref"): raise ValueError("missing required field ReadRecordsRequest.ref") ref = typing.cast( StreamRef[BodyT], - _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), ) return ReadRecordsRequest( ref=ref, @@ -1192,7 +1218,9 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest() ) - message.stream_id = _support.stream_ref_to_id(value.ref) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) if value.from_offset is not None: message.from_offset = value.from_offset if value.max_records is not None: @@ -1358,11 +1386,13 @@ def from_transfer_type( type_hint: type[DescribeStreamRequest[BodyT]], ) -> DescribeStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.stream_id: + if not value.HasField("ref"): raise ValueError("missing required field DescribeStreamRequest.ref") ref = typing.cast( StreamRef[BodyT], - _support.stream_ref_from_id(value.stream_id, StreamRef[body_type]), + _StreamRefTransferTypeConverter().from_transfer_type( + value.ref, StreamRef[body_type] + ), ) return DescribeStreamRequest( ref=ref, @@ -1376,7 +1406,9 @@ def to_transfer_type( message = ( temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest() ) - message.stream_id = _support.stream_ref_to_id(value.ref) + message.ref.CopyFrom( + _StreamRefTransferTypeConverter().to_transfer_type(value.ref) + ) return message diff --git a/temporalio/nexus/system/stream_service/services.py b/temporalio/nexus/system/stream_service/services.py index 5ed3f95bdc..fba6e9c0b2 100644 --- a/temporalio/nexus/system/stream_service/services.py +++ b/temporalio/nexus/system/stream_service/services.py @@ -29,7 +29,7 @@ class StreamService: create_stream: Operation[ CreateStreamRequest[typing.Any], - CreateStreamResult, + CreateStreamResult[typing.Any], ] = Operation(name="CreateStream") append_records: Operation[ diff --git a/temporalio/nexus/system/stream_service/workflow/__init__.py b/temporalio/nexus/system/stream_service/workflow/__init__.py index 3116066cfc..a933f9fddb 100644 --- a/temporalio/nexus/system/stream_service/workflow/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/__init__.py @@ -28,17 +28,24 @@ ] +_StorageTargetFactory = collections.abc.Callable[ + [_InputT], temporalio.converter.StorageDriverWorkflowInfo +] + + class _NexusOperationInfo(typing.Generic[_InputT, _OutputT]): def __init__( self, *, operation: nexusrpc.Operation[_InputT, _OutputT], serialization_context: _SerializationContextFactory[_InputT] | None = None, + storage_target: _StorageTargetFactory[_InputT] | None = None, ) -> None: self.operation: nexusrpc.Operation[_InputT, _OutputT] = operation self.serialization_context: _SerializationContextFactory[_InputT] | None = ( serialization_context ) + self.storage_target: _StorageTargetFactory[_InputT] | None = storage_target __nexus_operation_registry__: dict[ diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index ee9411ab1c..0c2c4fd2ae 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -72,7 +72,6 @@ async def append( ref=self.ref, records=[AppendRecord(body=value) for value in records], producer=_support.workflow_producer(), - request_id=_support.append_request_id(), ) handle = await _append_records(request) return await handle diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py index 78d36ba88e..d87e5f8748 100644 --- a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -32,13 +32,15 @@ async def _start_system_nexus_operation( and input.operation_name == "CreateStream" ): typed_input = typing.cast( - "StartNexusOperationInput[models.CreateStreamRequest[typing.Any], models.CreateStreamResult]", + "StartNexusOperationInput[models.CreateStreamRequest[typing.Any], models.CreateStreamResult[typing.Any]]", input, ) # The dispatch check above establishes that this operation's response type is _OutputT. return typing.cast( "temporalio.workflow.NexusOperationHandle[_OutputT]", - await interceptor.start_create_stream(typed_input.input), + await interceptor.start_create_stream( + typed_input.input, typed_input.output_type + ), ) if ( input.service == "temporal.api.streamservice.v1.StreamService" @@ -106,10 +108,16 @@ def _next_system_nexus_interceptor( ) -> _SystemNexusWorkflowOutboundInterceptorBase: ... async def start_create_stream( - self, request: models.CreateStreamRequest[typing.Any] - ) -> temporalio.workflow.NexusOperationHandle[models.CreateStreamResult]: + self, + request: models.CreateStreamRequest[typing.Any], + output_type: type[models.CreateStreamResult[typing.Any]] | None = None, + ) -> temporalio.workflow.NexusOperationHandle[ + models.CreateStreamResult[typing.Any] + ]: """Intercept the CreateStream operation.""" - return await self._next_system_nexus_interceptor().start_create_stream(request) + return await self._next_system_nexus_interceptor().start_create_stream( + request, output_type + ) async def start_append_records( self, request: models.AppendRecordsRequest[typing.Any] @@ -152,8 +160,12 @@ async def _schedule_system_nexus_operation( ) -> temporalio.workflow.NexusOperationHandle[_OutputT]: ... async def start_create_stream( - self, request: models.CreateStreamRequest[typing.Any] - ) -> temporalio.workflow.NexusOperationHandle[models.CreateStreamResult]: + self, + request: models.CreateStreamRequest[typing.Any], + output_type: type[models.CreateStreamResult[typing.Any]] | None = None, + ) -> temporalio.workflow.NexusOperationHandle[ + models.CreateStreamResult[typing.Any] + ]: from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT from temporalio.worker._interceptor import StartNexusOperationInput from temporalio.workflow import NexusOperationCancellationType @@ -164,7 +176,12 @@ async def start_create_stream( service="temporal.api.streamservice.v1.StreamService", operation="CreateStream", input=request, - output_type=models.CreateStreamResult, + output_type=typing.cast( + "type[models.CreateStreamResult[typing.Any]]", + models.CreateStreamResult, + ) + if output_type is None + else output_type, schedule_to_close_timeout=None, schedule_to_start_timeout=None, start_to_close_timeout=None, diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 24a8eafb9a..3d244a3a6c 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -5,7 +5,6 @@ import typing import temporalio.nexus.system -import temporalio.nexus.system._support as _support import temporalio.workflow from ..._resource_context_manager import resource_context_manager @@ -31,11 +30,13 @@ async def _create_stream( handle = await nexus_client.start_operation( operation="CreateStream", input=request, - output_type=CreateStreamResult, + output_type=CreateStreamResult[body_type], ) result = await handle + if result.ref is None: + raise RuntimeError("CreateStream answered without `ref`") return Stream[body_type]( - ref=request.ref, + ref=result.ref, created=result.created or None, ) @@ -79,13 +80,12 @@ async def create_stream( """ if body_type is None: body_type = typing.Any - ref = StreamRef[body_type]( + stream_ref = StreamRef( id=id, store=store, ) request = CreateStreamRequest( - ref=ref, + stream_ref=stream_ref, id_conflict_policy=id_conflict_policy, - request_id=_support.request_id(), ) return await _create_stream(request, body_type) From 41b14e74ad5c7e739bea50cb0cf4d7611bb93399 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Mon, 23 Nov 2026 23:12:30 -0700 Subject: [PATCH 13/24] Regenerate the bridge protos from Core's Stream ledger Core gives an Activity task the id of its scheduled event, keeps the Stream calls of a Workflow Task in a ledger in place of a marker, and gives each page of a Workflow read its last offset. The payload visitor stays the same, since no Payload moved. --- .../proto/activity_task/activity_task_pb2.py | 24 ++--- .../proto/activity_task/activity_task_pb2.pyi | 8 ++ .../bridge/proto/external_data/__init__.py | 4 +- .../proto/external_data/external_data_pb2.py | 34 +++---- .../proto/external_data/external_data_pb2.pyi | 44 ++++----- .../workflow_activation_pb2.py | 16 ++-- .../workflow_activation_pb2.pyi | 64 +++++++------ .../workflow_commands_pb2.py | 12 +-- .../workflow_commands_pb2.pyi | 93 ++++++++----------- 9 files changed, 152 insertions(+), 147 deletions(-) diff --git a/temporalio/bridge/proto/activity_task/activity_task_pb2.py b/temporalio/bridge/proto/activity_task/activity_task_pb2.py index 25233f5241..fd2ce8c211 100644 --- a/temporalio/bridge/proto/activity_task/activity_task_pb2.py +++ b/temporalio/bridge/proto/activity_task/activity_task_pb2.py @@ -27,7 +27,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n3temporal/sdk/core/activity_task/activity_task.proto\x12\x15\x63oresdk.activity_task\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a%temporal/sdk/core/common/common.proto"\x8d\x01\n\x0c\x41\x63tivityTask\x12\x12\n\ntask_token\x18\x01 \x01(\x0c\x12-\n\x05start\x18\x03 \x01(\x0b\x32\x1c.coresdk.activity_task.StartH\x00\x12/\n\x06\x63\x61ncel\x18\x04 \x01(\x0b\x32\x1d.coresdk.activity_task.CancelH\x00\x42\t\n\x07variant"\xdb\x08\n\x05Start\x12\x1a\n\x12workflow_namespace\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12\x45\n\x12workflow_execution\x18\x03 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x15\n\ractivity_type\x18\x05 \x01(\t\x12\x45\n\rheader_fields\x18\x06 \x03(\x0b\x32..coresdk.activity_task.Start.HeaderFieldsEntry\x12.\n\x05input\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12:\n\x11heartbeat_details\x18\x08 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x32\n\x0escheduled_time\x18\t \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x42\n\x1e\x63urrent_attempt_scheduled_time\x18\n \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x0cstarted_time\x18\x0b \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x0c \x01(\r\x12<\n\x19schedule_to_close_timeout\x18\r \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\x0e \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0f \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x32\n\x08priority\x18\x12 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12\x10\n\x08is_local\x18\x11 \x01(\x08\x12\x0e\n\x06run_id\x18\x13 \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x14 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x12\x41\n\rworkflow_task\x18\x15 \x01(\x0b\x32*.coresdk.activity_task.WorkflowTaskAttempt\x1aT\n\x11HeaderFieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x80\x02\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12!\n\x19previous_started_event_id\x18\x04 \x01(\x03\x12\x14\n\x0c\x66\x61iled_tasks\x18\x05 \x03(\x03\x12\x18\n\x10previous_attempt\x18\x06 \x01(\r\x12\x39\n\x15previous_started_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8a\x01\n\x06\x43\x61ncel\x12;\n\x06reason\x18\x01 \x01(\x0e\x32+.coresdk.activity_task.ActivityCancelReason\x12\x43\n\x07\x64\x65tails\x18\x02 \x01(\x0b\x32\x32.coresdk.activity_task.ActivityCancellationDetails"\xa0\x01\n\x1b\x41\x63tivityCancellationDetails\x12\x14\n\x0cis_not_found\x18\x01 \x01(\x08\x12\x14\n\x0cis_cancelled\x18\x02 \x01(\x08\x12\x11\n\tis_paused\x18\x03 \x01(\x08\x12\x14\n\x0cis_timed_out\x18\x04 \x01(\x08\x12\x1a\n\x12is_worker_shutdown\x18\x05 \x01(\x08\x12\x10\n\x08is_reset\x18\x06 \x01(\x08*o\n\x14\x41\x63tivityCancelReason\x12\r\n\tNOT_FOUND\x10\x00\x12\r\n\tCANCELLED\x10\x01\x12\r\n\tTIMED_OUT\x10\x02\x12\x13\n\x0fWORKER_SHUTDOWN\x10\x03\x12\n\n\x06PAUSED\x10\x04\x12\t\n\x05RESET\x10\x05\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ActivityTaskb\x06proto3' + b'\n3temporal/sdk/core/activity_task/activity_task.proto\x12\x15\x63oresdk.activity_task\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a%temporal/sdk/core/common/common.proto"\x8d\x01\n\x0c\x41\x63tivityTask\x12\x12\n\ntask_token\x18\x01 \x01(\x0c\x12-\n\x05start\x18\x03 \x01(\x0b\x32\x1c.coresdk.activity_task.StartH\x00\x12/\n\x06\x63\x61ncel\x18\x04 \x01(\x0b\x32\x1d.coresdk.activity_task.CancelH\x00\x42\t\n\x07variant"\xf7\x08\n\x05Start\x12\x1a\n\x12workflow_namespace\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12\x45\n\x12workflow_execution\x18\x03 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x15\n\ractivity_type\x18\x05 \x01(\t\x12\x45\n\rheader_fields\x18\x06 \x03(\x0b\x32..coresdk.activity_task.Start.HeaderFieldsEntry\x12.\n\x05input\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12:\n\x11heartbeat_details\x18\x08 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x32\n\x0escheduled_time\x18\t \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x42\n\x1e\x63urrent_attempt_scheduled_time\x18\n \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x0cstarted_time\x18\x0b \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x0c \x01(\r\x12<\n\x19schedule_to_close_timeout\x18\r \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\x0e \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0f \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x32\n\x08priority\x18\x12 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12\x10\n\x08is_local\x18\x11 \x01(\x08\x12\x0e\n\x06run_id\x18\x13 \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x14 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x12\x41\n\rworkflow_task\x18\x15 \x01(\x0b\x32*.coresdk.activity_task.WorkflowTaskAttempt\x12\x1a\n\x12scheduled_event_id\x18\x16 \x01(\x03\x1aT\n\x11HeaderFieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x80\x02\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12!\n\x19previous_started_event_id\x18\x04 \x01(\x03\x12\x14\n\x0c\x66\x61iled_tasks\x18\x05 \x03(\x03\x12\x18\n\x10previous_attempt\x18\x06 \x01(\r\x12\x39\n\x15previous_started_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8a\x01\n\x06\x43\x61ncel\x12;\n\x06reason\x18\x01 \x01(\x0e\x32+.coresdk.activity_task.ActivityCancelReason\x12\x43\n\x07\x64\x65tails\x18\x02 \x01(\x0b\x32\x32.coresdk.activity_task.ActivityCancellationDetails"\xa0\x01\n\x1b\x41\x63tivityCancellationDetails\x12\x14\n\x0cis_not_found\x18\x01 \x01(\x08\x12\x14\n\x0cis_cancelled\x18\x02 \x01(\x08\x12\x11\n\tis_paused\x18\x03 \x01(\x08\x12\x14\n\x0cis_timed_out\x18\x04 \x01(\x08\x12\x1a\n\x12is_worker_shutdown\x18\x05 \x01(\x08\x12\x10\n\x08is_reset\x18\x06 \x01(\x08*o\n\x14\x41\x63tivityCancelReason\x12\r\n\tNOT_FOUND\x10\x00\x12\r\n\tCANCELLED\x10\x01\x12\r\n\tTIMED_OUT\x10\x02\x12\x13\n\x0fWORKER_SHUTDOWN\x10\x03\x12\n\n\x06PAUSED\x10\x04\x12\t\n\x05RESET\x10\x05\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ActivityTaskb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -39,18 +39,18 @@ ) _START_HEADERFIELDSENTRY._options = None _START_HEADERFIELDSENTRY._serialized_options = b"8\001" - _ACTIVITYCANCELREASON._serialized_start = 2082 - _ACTIVITYCANCELREASON._serialized_end = 2193 + _ACTIVITYCANCELREASON._serialized_start = 2110 + _ACTIVITYCANCELREASON._serialized_end = 2221 _ACTIVITYTASK._serialized_start = 258 _ACTIVITYTASK._serialized_end = 399 _START._serialized_start = 402 - _START._serialized_end = 1517 - _START_HEADERFIELDSENTRY._serialized_start = 1433 - _START_HEADERFIELDSENTRY._serialized_end = 1517 - _WORKFLOWTASKATTEMPT._serialized_start = 1520 - _WORKFLOWTASKATTEMPT._serialized_end = 1776 - _CANCEL._serialized_start = 1779 - _CANCEL._serialized_end = 1917 - _ACTIVITYCANCELLATIONDETAILS._serialized_start = 1920 - _ACTIVITYCANCELLATIONDETAILS._serialized_end = 2080 + _START._serialized_end = 1545 + _START_HEADERFIELDSENTRY._serialized_start = 1461 + _START_HEADERFIELDSENTRY._serialized_end = 1545 + _WORKFLOWTASKATTEMPT._serialized_start = 1548 + _WORKFLOWTASKATTEMPT._serialized_end = 1804 + _CANCEL._serialized_start = 1807 + _CANCEL._serialized_end = 1945 + _ACTIVITYCANCELLATIONDETAILS._serialized_start = 1948 + _ACTIVITYCANCELLATIONDETAILS._serialized_end = 2108 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi b/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi index 345b0a6b1e..63b1711bf8 100644 --- a/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi +++ b/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi @@ -167,6 +167,7 @@ class Start(google.protobuf.message.Message): RUN_ID_FIELD_NUMBER: builtins.int PROPAGATED_NEXUS_SERIALIZATION_CONTEXT_FIELD_NUMBER: builtins.int WORKFLOW_TASK_FIELD_NUMBER: builtins.int + SCHEDULED_EVENT_ID_FIELD_NUMBER: builtins.int workflow_namespace: builtins.str """The namespace the workflow lives in""" workflow_type: builtins.str @@ -182,6 +183,10 @@ class Start(google.protobuf.message.Message): """ run_id: builtins.str """Run ID of this activity execution. Only set for standalone activities.""" + scheduled_event_id: builtins.int + """For an activity that a workflow scheduled, the event id of its ActivityTaskScheduled event. + 0 for a local activity, for a standalone activity, and when Core can't read it. + """ @property def workflow_execution( self, @@ -294,6 +299,7 @@ class Start(google.protobuf.message.Message): propagated_nexus_serialization_context: temporalio.api.nexus.v1.message_pb2.PropagatedSerializationContext | None = ..., workflow_task: global___WorkflowTaskAttempt | None = ..., + scheduled_event_id: builtins.int = ..., ) -> None: ... def HasField( self, @@ -353,6 +359,8 @@ class Start(google.protobuf.message.Message): b"run_id", "schedule_to_close_timeout", b"schedule_to_close_timeout", + "scheduled_event_id", + b"scheduled_event_id", "scheduled_time", b"scheduled_time", "start_to_close_timeout", diff --git a/temporalio/bridge/proto/external_data/__init__.py b/temporalio/bridge/proto/external_data/__init__.py index c33e1cbe28..0be236ec48 100644 --- a/temporalio/bridge/proto/external_data/__init__.py +++ b/temporalio/bridge/proto/external_data/__init__.py @@ -6,7 +6,7 @@ StreamCloseIntent, StreamCloseResult, StreamFailure, - StreamMarkerData, + StreamLedger, StreamReadPage, StreamReadResult, ) @@ -19,7 +19,7 @@ "StreamCloseIntent", "StreamCloseResult", "StreamFailure", - "StreamMarkerData", + "StreamLedger", "StreamReadPage", "StreamReadResult", ] diff --git a/temporalio/bridge/proto/external_data/external_data_pb2.py b/temporalio/bridge/proto/external_data/external_data_pb2.py index 803c79c8e0..e57fdd6ab4 100644 --- a/temporalio/bridge/proto/external_data/external_data_pb2.py +++ b/temporalio/bridge/proto/external_data/external_data_pb2.py @@ -18,7 +18,7 @@ from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xb2\x02\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x10\x61\x63tivation_index\x18\x08 \x01(\x04H\x00\x88\x01\x01\x42\x13\n\x11_activation_index"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\x81\x02\n\x10StreamMarkerData\x12?\n\rclose_intents\x18\x01 \x03(\x0b\x32(.coresdk.external_data.StreamCloseIntent\x12:\n\x07\x61ppends\x18\x02 \x03(\x0b\x32).coresdk.external_data.StreamAppendResult\x12\x38\n\x06\x63loses\x18\x03 \x03(\x0b\x32(.coresdk.external_data.StreamCloseResult\x12\x36\n\x05reads\x18\x04 \x03(\x0b\x32\'.coresdk.external_data.StreamReadResult"B\n\x11StreamCloseIntent\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"\xe0\x01\n\x12StreamAppendResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12>\n\x08\x61ppended\x18\x05 \x01(\x0b\x32*.coresdk.external_data.StreamAppendOffsetsH\x00\x12\x37\n\x07\x66\x61ilure\x18\x06 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x42\x08\n\x06result"@\n\x13StreamAppendOffsets\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"0\n\rStreamFailure\x12\x0e\n\x06reason\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t"q\n\x11StreamCloseResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x18\n\x10\x61\x63tivation_index\x18\x02 \x01(\x04\x12\x35\n\x07\x66\x61ilure\x18\x03 \x01(\x0b\x32$.coresdk.external_data.StreamFailure"\x97\x02\n\x10StreamReadResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12\x13\n\x0b\x66rom_offset\x18\x05 \x01(\x0c\x12\x35\n\x04page\x18\x06 \x01(\x0b\x32%.coresdk.external_data.StreamReadPageH\x00\x12\x37\n\x07\x66\x61ilure\x18\x07 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x12+\n\tcancelled\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06result"Z\n\x0eStreamReadPage\x12\x14\n\x0crecord_count\x18\x01 \x01(\r\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x0e\n\x06\x64igest\x18\x03 \x01(\x0c\x12\x14\n\x0crecord_bytes\x18\x04 \x01(\x04\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3' + b'\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xb2\x02\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x10\x61\x63tivation_index\x18\x08 \x01(\x04H\x00\x88\x01\x01\x42\x13\n\x11_activation_index"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xfd\x01\n\x0cStreamLedger\x12?\n\rclose_intents\x18\x01 \x03(\x0b\x32(.coresdk.external_data.StreamCloseIntent\x12:\n\x07\x61ppends\x18\x02 \x03(\x0b\x32).coresdk.external_data.StreamAppendResult\x12\x38\n\x06\x63loses\x18\x03 \x03(\x0b\x32(.coresdk.external_data.StreamCloseResult\x12\x36\n\x05reads\x18\x04 \x03(\x0b\x32\'.coresdk.external_data.StreamReadResult"B\n\x11StreamCloseIntent\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"\xe0\x01\n\x12StreamAppendResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12>\n\x08\x61ppended\x18\x05 \x01(\x0b\x32*.coresdk.external_data.StreamAppendOffsetsH\x00\x12\x37\n\x07\x66\x61ilure\x18\x06 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x42\x08\n\x06result"@\n\x13StreamAppendOffsets\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"0\n\rStreamFailure\x12\x0e\n\x06reason\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t"q\n\x11StreamCloseResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x18\n\x10\x61\x63tivation_index\x18\x02 \x01(\x04\x12\x35\n\x07\x66\x61ilure\x18\x03 \x01(\x0b\x32$.coresdk.external_data.StreamFailure"\x97\x02\n\x10StreamReadResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12\x13\n\x0b\x66rom_offset\x18\x05 \x01(\x0c\x12\x35\n\x04page\x18\x06 \x01(\x0b\x32%.coresdk.external_data.StreamReadPageH\x00\x12\x37\n\x07\x66\x61ilure\x18\x07 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x12+\n\tcancelled\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06result"o\n\x0eStreamReadPage\x12\x14\n\x0crecord_count\x18\x01 \x01(\r\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x0e\n\x06\x64igest\x18\x03 \x01(\x0c\x12\x14\n\x0crecord_bytes\x18\x04 \x01(\x04\x12\x13\n\x0blast_offset\x18\x05 \x01(\x0c\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -32,20 +32,20 @@ _LOCALACTIVITYMARKERDATA._serialized_end = 479 _PATCHEDMARKERDATA._serialized_start = 481 _PATCHEDMARKERDATA._serialized_end = 532 - _STREAMMARKERDATA._serialized_start = 535 - _STREAMMARKERDATA._serialized_end = 792 - _STREAMCLOSEINTENT._serialized_start = 794 - _STREAMCLOSEINTENT._serialized_end = 860 - _STREAMAPPENDRESULT._serialized_start = 863 - _STREAMAPPENDRESULT._serialized_end = 1087 - _STREAMAPPENDOFFSETS._serialized_start = 1089 - _STREAMAPPENDOFFSETS._serialized_end = 1153 - _STREAMFAILURE._serialized_start = 1155 - _STREAMFAILURE._serialized_end = 1203 - _STREAMCLOSERESULT._serialized_start = 1205 - _STREAMCLOSERESULT._serialized_end = 1318 - _STREAMREADRESULT._serialized_start = 1321 - _STREAMREADRESULT._serialized_end = 1600 - _STREAMREADPAGE._serialized_start = 1602 - _STREAMREADPAGE._serialized_end = 1692 + _STREAMLEDGER._serialized_start = 535 + _STREAMLEDGER._serialized_end = 788 + _STREAMCLOSEINTENT._serialized_start = 790 + _STREAMCLOSEINTENT._serialized_end = 856 + _STREAMAPPENDRESULT._serialized_start = 859 + _STREAMAPPENDRESULT._serialized_end = 1083 + _STREAMAPPENDOFFSETS._serialized_start = 1085 + _STREAMAPPENDOFFSETS._serialized_end = 1149 + _STREAMFAILURE._serialized_start = 1151 + _STREAMFAILURE._serialized_end = 1199 + _STREAMCLOSERESULT._serialized_start = 1201 + _STREAMCLOSERESULT._serialized_end = 1314 + _STREAMREADRESULT._serialized_start = 1317 + _STREAMREADRESULT._serialized_end = 1596 + _STREAMREADPAGE._serialized_start = 1598 + _STREAMREADPAGE._serialized_end = 1709 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/external_data/external_data_pb2.pyi b/temporalio/bridge/proto/external_data/external_data_pb2.pyi index a8dbcbd5a8..8911644cd7 100644 --- a/temporalio/bridge/proto/external_data/external_data_pb2.pyi +++ b/temporalio/bridge/proto/external_data/external_data_pb2.pyi @@ -144,22 +144,17 @@ class PatchedMarkerData(google.protobuf.message.Message): global___PatchedMarkerData = PatchedMarkerData @typing.final -class StreamMarkerData(google.protobuf.message.Message): - """The data of a `core_stream` marker. Core records one in each Workflow Task in which Workflow - code got a Stream result or asked for a close. The marker has these details: - * `data` has this message as JSON, with each `bytes` field as lower-case hex. - * `records` has the body of each Record of the reads with `records_in_history`, one payload for - each. They're in the order of `reads`, and those of one read in the order of its Stream. It's - absent if the marker has no such Record. - * `record_info` has one `binary/plain` payload with the rest of each of those Records, in the - same order. Each is its `temporalio.api.stream.v1.StreamRecord` with no body, with its length - before it as a varint. It's absent if `records` is. - - History keeps each marker, and every later version of Core reads it. So these rules hold for - each message of the marker: - * A field keeps its name, which is its key in the JSON. - * A new field is `optional`, since the markers of an earlier version don't have it. - * A new `repeated` field has `#[serde(default)]` in `build.rs`, for the same reason. +class StreamLedger(google.protobuf.message.Message): + """The ledger of a Workflow Task, which has the results and the close intents of its Stream calls. + Core puts it on the completion of each task in which Workflow code got a Stream result or asked + for a close, as the protobuf encoding of this message in the `core_stream_calls` of the + `sdk_metadata`. + + Every later version of Core must read the ledgers in History, so these rules apply to each + message of the ledger. + * A field keeps its number and its type. + * The default value of a new field means what an older ledger meant, since an older ledger + decodes to that value. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -215,7 +210,7 @@ class StreamMarkerData(google.protobuf.message.Message): ], ) -> None: ... -global___StreamMarkerData = StreamMarkerData +global___StreamLedger = StreamLedger @typing.final class StreamCloseIntent(google.protobuf.message.Message): @@ -338,7 +333,7 @@ class StreamFailure(google.protobuf.message.Message): MESSAGE_FIELD_NUMBER: builtins.int reason: builtins.str """The name of the `temporalio.api.enums.v1.StreamErrorReason`, such as - `STREAM_ERROR_REASON_CLOSED`. History has the name for good, so a reason keeps its name. + `STREAM_ERROR_REASON_CLOSED`. History stores the name, so a reason must never change its name. """ message: builtins.str """The message of the failure, of at most 4096 bytes.""" @@ -484,20 +479,22 @@ class StreamReadPage(google.protobuf.message.Message): DONE_FIELD_NUMBER: builtins.int DIGEST_FIELD_NUMBER: builtins.int RECORD_BYTES_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int record_count: builtins.int """The number of Records in the page.""" done: builtins.bool """True if the Stream was closed and had no Record after this page.""" digest: builtins.bytes - """The first 16 bytes of the SHA-256 of the Records. It's empty for a read with - `records_in_history`, whose Records are in the details of the marker, or if the page has no - Record. - """ + """The first 16 bytes of the SHA-256 of the Records. It's empty if the page has no Record.""" record_bytes: builtins.int """The bytes of the Records, each as a page of a read encodes it, with the tag and the length of its field. That is the measure of the `max_bytes` of a read. It's set when `digest` is, so a replay knows how much it reads. """ + last_offset: builtins.bytes + """The `last_offset` that Workflow code got with the page. A replay gives the same value, since + another read of the Store can end at another offset. + """ def __init__( self, *, @@ -505,6 +502,7 @@ class StreamReadPage(google.protobuf.message.Message): done: builtins.bool = ..., digest: builtins.bytes = ..., record_bytes: builtins.int = ..., + last_offset: builtins.bytes = ..., ) -> None: ... def ClearField( self, @@ -513,6 +511,8 @@ class StreamReadPage(google.protobuf.message.Message): b"digest", "done", b"done", + "last_offset", + b"last_offset", "record_bytes", b"record_bytes", "record_count", diff --git a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py index 68fe115f44..86fc4d33c1 100644 --- a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py +++ b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py @@ -52,7 +52,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n?temporal/sdk/core/workflow_activation/workflow_activation.proto\x12\x1b\x63oresdk.workflow_activation\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a%temporal/api/failure/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a$temporal/api/update/v1/message.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/stream/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a\x37temporal/sdk/core/activity_result/activity_result.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a#temporal/sdk/core/nexus/nexus.proto"\xa2\x04\n\x12WorkflowActivation\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0cis_replaying\x18\x03 \x01(\x08\x12\x16\n\x0ehistory_length\x18\x04 \x01(\r\x12@\n\x04jobs\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.WorkflowActivationJob\x12 \n\x18\x61vailable_internal_flags\x18\x06 \x03(\r\x12\x1a\n\x12history_size_bytes\x18\x07 \x01(\x04\x12!\n\x19\x63ontinue_as_new_suggested\x18\x08 \x01(\x08\x12T\n#deployment_version_for_current_task\x18\t \x01(\x0b\x32\'.coresdk.common.WorkerDeploymentVersion\x12\x18\n\x10last_sdk_version\x18\n \x01(\t\x12Z\n\x1fsuggest_continue_as_new_reasons\x18\x0b \x03(\x0e\x32\x31.temporal.api.enums.v1.SuggestContinueAsNewReason\x12\x30\n(target_worker_deployment_version_changed\x18\x0c \x01(\x08"\xd3\x0c\n\x15WorkflowActivationJob\x12N\n\x13initialize_workflow\x18\x01 \x01(\x0b\x32/.coresdk.workflow_activation.InitializeWorkflowH\x00\x12<\n\nfire_timer\x18\x02 \x01(\x0b\x32&.coresdk.workflow_activation.FireTimerH\x00\x12K\n\x12update_random_seed\x18\x04 \x01(\x0b\x32-.coresdk.workflow_activation.UpdateRandomSeedH\x00\x12\x44\n\x0equery_workflow\x18\x05 \x01(\x0b\x32*.coresdk.workflow_activation.QueryWorkflowH\x00\x12\x46\n\x0f\x63\x61ncel_workflow\x18\x06 \x01(\x0b\x32+.coresdk.workflow_activation.CancelWorkflowH\x00\x12\x46\n\x0fsignal_workflow\x18\x07 \x01(\x0b\x32+.coresdk.workflow_activation.SignalWorkflowH\x00\x12H\n\x10resolve_activity\x18\x08 \x01(\x0b\x32,.coresdk.workflow_activation.ResolveActivityH\x00\x12G\n\x10notify_has_patch\x18\t \x01(\x0b\x32+.coresdk.workflow_activation.NotifyHasPatchH\x00\x12q\n&resolve_child_workflow_execution_start\x18\n \x01(\x0b\x32?.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartH\x00\x12\x66\n resolve_child_workflow_execution\x18\x0b \x01(\x0b\x32:.coresdk.workflow_activation.ResolveChildWorkflowExecutionH\x00\x12\x66\n resolve_signal_external_workflow\x18\x0c \x01(\x0b\x32:.coresdk.workflow_activation.ResolveSignalExternalWorkflowH\x00\x12u\n(resolve_request_cancel_external_workflow\x18\r \x01(\x0b\x32\x41.coresdk.workflow_activation.ResolveRequestCancelExternalWorkflowH\x00\x12:\n\tdo_update\x18\x0e \x01(\x0b\x32%.coresdk.workflow_activation.DoUpdateH\x00\x12`\n\x1dresolve_nexus_operation_start\x18\x0f \x01(\x0b\x32\x37.coresdk.workflow_activation.ResolveNexusOperationStartH\x00\x12U\n\x17resolve_nexus_operation\x18\x10 \x01(\x0b\x32\x32.coresdk.workflow_activation.ResolveNexusOperationH\x00\x12M\n\x13resolve_stream_read\x18\x11 \x01(\x0b\x32..coresdk.workflow_activation.ResolveStreamReadH\x00\x12Q\n\x15resolve_stream_append\x18\x12 \x01(\x0b\x32\x30.coresdk.workflow_activation.ResolveStreamAppendH\x00\x12O\n\x14resolve_stream_close\x18\x13 \x01(\x0b\x32/.coresdk.workflow_activation.ResolveStreamCloseH\x00\x12I\n\x11remove_from_cache\x18\x32 \x01(\x0b\x32,.coresdk.workflow_activation.RemoveFromCacheH\x00\x42\t\n\x07variant"\xe3\x0b\n\x12InitializeWorkflow\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x17\n\x0frandomness_seed\x18\x04 \x01(\x04\x12M\n\x07headers\x18\x05 \x03(\x0b\x32<.coresdk.workflow_activation.InitializeWorkflow.HeadersEntry\x12\x10\n\x08identity\x18\x06 \x01(\t\x12I\n\x14parent_workflow_info\x18\x07 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12=\n\x1aworkflow_execution_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\'\n\x1f\x63ontinued_from_execution_run_id\x18\x0b \x01(\t\x12J\n\x13\x63ontinued_initiator\x18\x0c \x01(\x0e\x32-.temporal.api.enums.v1.ContinueAsNewInitiator\x12;\n\x11\x63ontinued_failure\x18\r \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12@\n\x16last_completion_result\x18\x0e \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x1e\n\x16\x66irst_execution_run_id\x18\x0f \x01(\t\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x0f\n\x07\x61ttempt\x18\x11 \x01(\x05\x12\x15\n\rcron_schedule\x18\x12 \x01(\t\x12\x46\n"workflow_execution_expiration_time\x18\x13 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x45\n"cron_schedule_to_schedule_interval\x18\x14 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x04memo\x18\x15 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\x12\x43\n\x11search_attributes\x18\x16 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12.\n\nstart_time\x18\x17 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\rroot_workflow\x18\x18 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x32\n\x08priority\x18\x19 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12!\n\x19original_execution_run_id\x18\x1a \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x1b \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x18\n\tFireTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"m\n\x0fResolveActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.activity_result.ActivityResolution\x12\x10\n\x08is_local\x18\x03 \x01(\x08"\xd1\x02\n"ResolveChildWorkflowExecutionStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12[\n\tsucceeded\x18\x02 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartSuccessH\x00\x12X\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartFailureH\x00\x12]\n\tcancelled\x18\x04 \x01(\x0b\x32H.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartCancelledH\x00\x42\x08\n\x06status";\n)ResolveChildWorkflowExecutionStartSuccess\x12\x0e\n\x06run_id\x18\x01 \x01(\t"\xa6\x01\n)ResolveChildWorkflowExecutionStartFailure\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12M\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32>.coresdk.child_workflow.StartChildWorkflowExecutionFailedCause"`\n+ResolveChildWorkflowExecutionStartCancelled\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"i\n\x1dResolveChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.child_workflow.ChildWorkflowResult"+\n\x10UpdateRandomSeed\x12\x17\n\x0frandomness_seed\x18\x01 \x01(\x04"\x84\x02\n\rQueryWorkflow\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12\x12\n\nquery_type\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12H\n\x07headers\x18\x05 \x03(\x0b\x32\x37.coresdk.workflow_activation.QueryWorkflow.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01" \n\x0e\x43\x61ncelWorkflow\x12\x0e\n\x06reason\x18\x01 \x01(\t"\xa1\x02\n\x0eSignalWorkflow\x12\x13\n\x0bsignal_name\x18\x01 \x01(\t\x12.\n\x05input\x18\x02 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x10\n\x08identity\x18\x03 \x01(\t\x12I\n\x07headers\x18\x05 \x03(\x0b\x32\x38.coresdk.workflow_activation.SignalWorkflow.HeadersEntry\x12\x1c\n\x14originating_event_id\x18\x06 \x01(\x03\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01""\n\x0eNotifyHasPatch\x12\x10\n\x08patch_id\x18\x01 \x01(\t"\xb1\x01\n\x1dResolveSignalExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.SignalExternalWorkflowExecutionFailedCause"\xb8\x01\n$ResolveRequestCancelExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.CancelExternalWorkflowExecutionFailedCause"\xb2\x03\n\x08\x44oUpdate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\x05input\x18\x04 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x43\n\x07headers\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.DoUpdate.HeadersEntry\x12*\n\x04meta\x18\x06 \x01(\x0b\x32\x1c.temporal.api.update.v1.Meta\x12\x15\n\rrun_validator\x18\x07 \x01(\x08\x12\x65\n&propagated_nexus_serialization_context\x18\x08 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x9a\x01\n\x1aResolveNexusOperationStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x19\n\x0foperation_token\x18\x02 \x01(\tH\x00\x12\x16\n\x0cstarted_sync\x18\x03 \x01(\x08H\x00\x12\x32\n\x06\x66\x61iled\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status"Y\n\x15ResolveNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x33\n\x06result\x18\x02 \x01(\x0b\x32#.coresdk.nexus.NexusOperationResult"\xe0\x02\n\x0fRemoveFromCache\x12\x0f\n\x07message\x18\x01 \x01(\t\x12K\n\x06reason\x18\x02 \x01(\x0e\x32;.coresdk.workflow_activation.RemoveFromCache.EvictionReason"\xee\x01\n\x0e\x45victionReason\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCACHE_FULL\x10\x01\x12\x0e\n\nCACHE_MISS\x10\x02\x12\x12\n\x0eNONDETERMINISM\x10\x03\x12\r\n\tLANG_FAIL\x10\x04\x12\x12\n\x0eLANG_REQUESTED\x10\x05\x12\x12\n\x0eTASK_NOT_FOUND\x10\x06\x12\x15\n\x11UNHANDLED_COMMAND\x10\x07\x12\t\n\x05\x46\x41TAL\x10\x08\x12\x1f\n\x1bPAGINATION_OR_HISTORY_FETCH\x10\t\x12\x1d\n\x19WORKFLOW_EXECUTION_ENDING\x10\n"\xc4\x01\n\x11ResolveStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x37\n\x04page\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_activation.StreamPageH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12+\n\tcancelled\x18\x04 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06status"Q\n\nStreamPage\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08"\xa1\x01\n\x13ResolveStreamAppend\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12?\n\x08\x61ppended\x18\x02 \x01(\x0b\x32+.coresdk.workflow_activation.StreamAppendedH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status";\n\x0eStreamAppended\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"S\n\x12ResolveStreamClose\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x30\n\x06\x66\x61iled\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.FailureB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowActivationb\x06proto3' + b'\n?temporal/sdk/core/workflow_activation/workflow_activation.proto\x12\x1b\x63oresdk.workflow_activation\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a%temporal/api/failure/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a$temporal/api/update/v1/message.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/stream/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a\x37temporal/sdk/core/activity_result/activity_result.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a#temporal/sdk/core/nexus/nexus.proto"\xa2\x04\n\x12WorkflowActivation\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0cis_replaying\x18\x03 \x01(\x08\x12\x16\n\x0ehistory_length\x18\x04 \x01(\r\x12@\n\x04jobs\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.WorkflowActivationJob\x12 \n\x18\x61vailable_internal_flags\x18\x06 \x03(\r\x12\x1a\n\x12history_size_bytes\x18\x07 \x01(\x04\x12!\n\x19\x63ontinue_as_new_suggested\x18\x08 \x01(\x08\x12T\n#deployment_version_for_current_task\x18\t \x01(\x0b\x32\'.coresdk.common.WorkerDeploymentVersion\x12\x18\n\x10last_sdk_version\x18\n \x01(\t\x12Z\n\x1fsuggest_continue_as_new_reasons\x18\x0b \x03(\x0e\x32\x31.temporal.api.enums.v1.SuggestContinueAsNewReason\x12\x30\n(target_worker_deployment_version_changed\x18\x0c \x01(\x08"\xd3\x0c\n\x15WorkflowActivationJob\x12N\n\x13initialize_workflow\x18\x01 \x01(\x0b\x32/.coresdk.workflow_activation.InitializeWorkflowH\x00\x12<\n\nfire_timer\x18\x02 \x01(\x0b\x32&.coresdk.workflow_activation.FireTimerH\x00\x12K\n\x12update_random_seed\x18\x04 \x01(\x0b\x32-.coresdk.workflow_activation.UpdateRandomSeedH\x00\x12\x44\n\x0equery_workflow\x18\x05 \x01(\x0b\x32*.coresdk.workflow_activation.QueryWorkflowH\x00\x12\x46\n\x0f\x63\x61ncel_workflow\x18\x06 \x01(\x0b\x32+.coresdk.workflow_activation.CancelWorkflowH\x00\x12\x46\n\x0fsignal_workflow\x18\x07 \x01(\x0b\x32+.coresdk.workflow_activation.SignalWorkflowH\x00\x12H\n\x10resolve_activity\x18\x08 \x01(\x0b\x32,.coresdk.workflow_activation.ResolveActivityH\x00\x12G\n\x10notify_has_patch\x18\t \x01(\x0b\x32+.coresdk.workflow_activation.NotifyHasPatchH\x00\x12q\n&resolve_child_workflow_execution_start\x18\n \x01(\x0b\x32?.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartH\x00\x12\x66\n resolve_child_workflow_execution\x18\x0b \x01(\x0b\x32:.coresdk.workflow_activation.ResolveChildWorkflowExecutionH\x00\x12\x66\n resolve_signal_external_workflow\x18\x0c \x01(\x0b\x32:.coresdk.workflow_activation.ResolveSignalExternalWorkflowH\x00\x12u\n(resolve_request_cancel_external_workflow\x18\r \x01(\x0b\x32\x41.coresdk.workflow_activation.ResolveRequestCancelExternalWorkflowH\x00\x12:\n\tdo_update\x18\x0e \x01(\x0b\x32%.coresdk.workflow_activation.DoUpdateH\x00\x12`\n\x1dresolve_nexus_operation_start\x18\x0f \x01(\x0b\x32\x37.coresdk.workflow_activation.ResolveNexusOperationStartH\x00\x12U\n\x17resolve_nexus_operation\x18\x10 \x01(\x0b\x32\x32.coresdk.workflow_activation.ResolveNexusOperationH\x00\x12M\n\x13resolve_stream_read\x18\x11 \x01(\x0b\x32..coresdk.workflow_activation.ResolveStreamReadH\x00\x12Q\n\x15resolve_stream_append\x18\x12 \x01(\x0b\x32\x30.coresdk.workflow_activation.ResolveStreamAppendH\x00\x12O\n\x14resolve_stream_close\x18\x13 \x01(\x0b\x32/.coresdk.workflow_activation.ResolveStreamCloseH\x00\x12I\n\x11remove_from_cache\x18\x32 \x01(\x0b\x32,.coresdk.workflow_activation.RemoveFromCacheH\x00\x42\t\n\x07variant"\xe3\x0b\n\x12InitializeWorkflow\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x17\n\x0frandomness_seed\x18\x04 \x01(\x04\x12M\n\x07headers\x18\x05 \x03(\x0b\x32<.coresdk.workflow_activation.InitializeWorkflow.HeadersEntry\x12\x10\n\x08identity\x18\x06 \x01(\t\x12I\n\x14parent_workflow_info\x18\x07 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12=\n\x1aworkflow_execution_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\'\n\x1f\x63ontinued_from_execution_run_id\x18\x0b \x01(\t\x12J\n\x13\x63ontinued_initiator\x18\x0c \x01(\x0e\x32-.temporal.api.enums.v1.ContinueAsNewInitiator\x12;\n\x11\x63ontinued_failure\x18\r \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12@\n\x16last_completion_result\x18\x0e \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x1e\n\x16\x66irst_execution_run_id\x18\x0f \x01(\t\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x0f\n\x07\x61ttempt\x18\x11 \x01(\x05\x12\x15\n\rcron_schedule\x18\x12 \x01(\t\x12\x46\n"workflow_execution_expiration_time\x18\x13 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x45\n"cron_schedule_to_schedule_interval\x18\x14 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x04memo\x18\x15 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\x12\x43\n\x11search_attributes\x18\x16 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12.\n\nstart_time\x18\x17 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\rroot_workflow\x18\x18 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x32\n\x08priority\x18\x19 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12!\n\x19original_execution_run_id\x18\x1a \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x1b \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x18\n\tFireTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"m\n\x0fResolveActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.activity_result.ActivityResolution\x12\x10\n\x08is_local\x18\x03 \x01(\x08"\xd1\x02\n"ResolveChildWorkflowExecutionStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12[\n\tsucceeded\x18\x02 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartSuccessH\x00\x12X\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartFailureH\x00\x12]\n\tcancelled\x18\x04 \x01(\x0b\x32H.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartCancelledH\x00\x42\x08\n\x06status";\n)ResolveChildWorkflowExecutionStartSuccess\x12\x0e\n\x06run_id\x18\x01 \x01(\t"\xa6\x01\n)ResolveChildWorkflowExecutionStartFailure\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12M\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32>.coresdk.child_workflow.StartChildWorkflowExecutionFailedCause"`\n+ResolveChildWorkflowExecutionStartCancelled\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"i\n\x1dResolveChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.child_workflow.ChildWorkflowResult"+\n\x10UpdateRandomSeed\x12\x17\n\x0frandomness_seed\x18\x01 \x01(\x04"\x84\x02\n\rQueryWorkflow\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12\x12\n\nquery_type\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12H\n\x07headers\x18\x05 \x03(\x0b\x32\x37.coresdk.workflow_activation.QueryWorkflow.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01" \n\x0e\x43\x61ncelWorkflow\x12\x0e\n\x06reason\x18\x01 \x01(\t"\xa1\x02\n\x0eSignalWorkflow\x12\x13\n\x0bsignal_name\x18\x01 \x01(\t\x12.\n\x05input\x18\x02 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x10\n\x08identity\x18\x03 \x01(\t\x12I\n\x07headers\x18\x05 \x03(\x0b\x32\x38.coresdk.workflow_activation.SignalWorkflow.HeadersEntry\x12\x1c\n\x14originating_event_id\x18\x06 \x01(\x03\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01""\n\x0eNotifyHasPatch\x12\x10\n\x08patch_id\x18\x01 \x01(\t"\xb1\x01\n\x1dResolveSignalExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.SignalExternalWorkflowExecutionFailedCause"\xb8\x01\n$ResolveRequestCancelExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.CancelExternalWorkflowExecutionFailedCause"\xb2\x03\n\x08\x44oUpdate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\x05input\x18\x04 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x43\n\x07headers\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.DoUpdate.HeadersEntry\x12*\n\x04meta\x18\x06 \x01(\x0b\x32\x1c.temporal.api.update.v1.Meta\x12\x15\n\rrun_validator\x18\x07 \x01(\x08\x12\x65\n&propagated_nexus_serialization_context\x18\x08 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x9a\x01\n\x1aResolveNexusOperationStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x19\n\x0foperation_token\x18\x02 \x01(\tH\x00\x12\x16\n\x0cstarted_sync\x18\x03 \x01(\x08H\x00\x12\x32\n\x06\x66\x61iled\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status"Y\n\x15ResolveNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x33\n\x06result\x18\x02 \x01(\x0b\x32#.coresdk.nexus.NexusOperationResult"\xe0\x02\n\x0fRemoveFromCache\x12\x0f\n\x07message\x18\x01 \x01(\t\x12K\n\x06reason\x18\x02 \x01(\x0e\x32;.coresdk.workflow_activation.RemoveFromCache.EvictionReason"\xee\x01\n\x0e\x45victionReason\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCACHE_FULL\x10\x01\x12\x0e\n\nCACHE_MISS\x10\x02\x12\x12\n\x0eNONDETERMINISM\x10\x03\x12\r\n\tLANG_FAIL\x10\x04\x12\x12\n\x0eLANG_REQUESTED\x10\x05\x12\x12\n\x0eTASK_NOT_FOUND\x10\x06\x12\x15\n\x11UNHANDLED_COMMAND\x10\x07\x12\t\n\x05\x46\x41TAL\x10\x08\x12\x1f\n\x1bPAGINATION_OR_HISTORY_FETCH\x10\t\x12\x1d\n\x19WORKFLOW_EXECUTION_ENDING\x10\n"\xc4\x01\n\x11ResolveStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x37\n\x04page\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_activation.StreamPageH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12+\n\tcancelled\x18\x04 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06status"f\n\nStreamPage\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x13\n\x0blast_offset\x18\x03 \x01(\x0c"\xa1\x01\n\x13ResolveStreamAppend\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12?\n\x08\x61ppended\x18\x02 \x01(\x0b\x32+.coresdk.workflow_activation.StreamAppendedH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status";\n\x0eStreamAppended\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"S\n\x12ResolveStreamClose\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x30\n\x06\x66\x61iled\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.FailureB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowActivationb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -125,11 +125,11 @@ _RESOLVESTREAMREAD._serialized_start = 7319 _RESOLVESTREAMREAD._serialized_end = 7515 _STREAMPAGE._serialized_start = 7517 - _STREAMPAGE._serialized_end = 7598 - _RESOLVESTREAMAPPEND._serialized_start = 7601 - _RESOLVESTREAMAPPEND._serialized_end = 7762 - _STREAMAPPENDED._serialized_start = 7764 - _STREAMAPPENDED._serialized_end = 7823 - _RESOLVESTREAMCLOSE._serialized_start = 7825 - _RESOLVESTREAMCLOSE._serialized_end = 7908 + _STREAMPAGE._serialized_end = 7619 + _RESOLVESTREAMAPPEND._serialized_start = 7622 + _RESOLVESTREAMAPPEND._serialized_end = 7783 + _STREAMAPPENDED._serialized_start = 7785 + _STREAMAPPENDED._serialized_end = 7844 + _RESOLVESTREAMCLOSE._serialized_start = 7846 + _RESOLVESTREAMCLOSE._serialized_end = 7929 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi index 1883c75fac..7b55db0be7 100644 --- a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi +++ b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi @@ -67,11 +67,10 @@ class WorkflowActivation(google.protobuf.message.Message): in that same activation (prime example: cancelling not-wait-for-cancel activities). So, we do this to ensure the LA resolution happens after that cancel (or whatever else it may be) as it normally would have when executing. - * The results of Stream calls go after the local activity resolutions, since a replay scans - ahead for their marker too. The appends come first, then the closes, and then the reads, each - kind by `seq`. A replay that gives the results of several activations in one keeps the order - of those activations among the results of Stream calls, and gives them after each local - activity resolution. + * The results of Stream calls go after the local activity resolutions, because a replay also + scans ahead for their ledger. Appends go first, then closes, then reads, and each kind is in + `seq` order. When a replay gives the results of several activations in one, the Stream results + keep the order of those activations, after all local activity resolutions. * Queries always go last (and, in fact, always come in their own activation) * Evictions also always come in their own activation @@ -1689,8 +1688,8 @@ global___RemoveFromCache = RemoveFromCache @typing.final class ResolveStreamRead(google.protobuf.message.Message): """The result of a `ReadStream`. A read gets at most one, and a read that lang cancelled gets one - too. It gets none only in the four cases that `ReadStream` lists. What `ResolveStreamAppend` - says of its activation holds for it. + too. It gets none only in the four cases that `ReadStream` lists. The activation rules of + `ResolveStreamAppend` apply to it too. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1762,10 +1761,15 @@ class StreamPage(google.protobuf.message.Message): RECORDS_FIELD_NUMBER: builtins.int DONE_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int done: builtins.bool """True if the Stream is closed and has no Record after this page. It's false if the page has no Record because none came within the `wait` of the read. """ + last_offset: builtins.bytes + """The offset where the page ends, as the Store gave it. The next read can pass it as its + `from_offset`. It's set also for a page with no Record. + """ @property def records( self, @@ -1785,30 +1789,34 @@ class StreamPage(google.protobuf.message.Message): ] | None = ..., done: builtins.bool = ..., + last_offset: builtins.bytes = ..., ) -> None: ... def ClearField( - self, field_name: typing.Literal["done", b"done", "records", b"records"] + self, + field_name: typing.Literal[ + "done", b"done", "last_offset", b"last_offset", "records", b"records" + ], ) -> None: ... global___StreamPage = StreamPage @typing.final class ResolveStreamAppend(google.protobuf.message.Message): - """The result of an `AppendToStream`. Core gives each result in the next activation after it comes, - so each result can cost an activation. + """The result of an `AppendToStream`. Core gives each result in the next activation after the + Store answers, so each result can cost an activation. - A replay gives a result in the activation in which the first run gave it only if History has - the flag that turns workflow task chunking off. Without that flag a replay gives the results of - a task in the order of the first run, and it gives a result in another activation in two cases: + A replay gives each result in the same activation as the first run only if History has the flag + that turns workflow task chunking off. Without the flag, a replay keeps the order of the results + of a task, but it can give a result in another activation in two cases. * A Workflow Task completes with no command, and the first activation of the next task has a result. A replay takes the two tasks as one, and can give the results of the first two activations of the second task in one. - * A Workflow Task starts with an Update that Workflow code rejects, which leaves no event. A - replay with no job to give then gives the results of History in the order of the first run, - up to the first one whose call Workflow code hasn't made, in one activation. - A task with only Stream calls replays in the activations of the same task with Local - Activities. In a task with both, a result waits for each result of the other kind that the - first run gave before it, so its activations can differ from those of Local Activities alone. + * A Workflow Task starts with an Update that Workflow code rejects, which leaves no event. When + such a replay has no other job to give, it gives the results of History in one activation, in + the order of the first run, up to the first one whose call Workflow code hasn't made yet. + A task with only Stream calls replays in the same activations as a task with only Local + Activities. In a task with both, a result waits for each result of the other kind that the first + run gave before it, so its activations can differ from those of Local Activities alone. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1822,12 +1830,12 @@ class ResolveStreamAppend(google.protobuf.message.Message): def appended(self) -> global___StreamAppended: ... @property def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: - """The failure of the append, with these parts: - * an `ApplicationFailureInfo` whose type is `stream_` and the reason of the Stream error - in snake case, such as `stream_closed`, and whose `non_retryable` is set - * in its details, one `binary/protobuf` payload of a - `temporalio.api.stream.v1.StreamErrorDetails` - * a message of at most 4096 bytes + """The failure of the append. It has these parts. + * An `ApplicationFailureInfo` whose type is `stream_` plus the reason of the Stream error + in snake case, such as `stream_closed`. Its `non_retryable` is set. + * In its details, one `binary/protobuf` payload of a + `temporalio.api.stream.v1.StreamErrorDetails`. + * A message of at most 4096 bytes. """ def __init__( @@ -1887,7 +1895,7 @@ global___StreamAppended = StreamAppended @typing.final class ResolveStreamClose(google.protobuf.message.Message): - """The result of a `CloseStream`. What `ResolveStreamAppend` says of its activation holds for it.""" + """The result of a `CloseStream`. The activation rules of `ResolveStreamAppend` apply to it too.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -1897,8 +1905,8 @@ class ResolveStreamClose(google.protobuf.message.Message): """The `seq` of the `CloseStream`.""" @property def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: - """Unset if the Stream is closed, even if it was already closed before. If set, it has the parts - of the `failed` of a `ResolveStreamAppend`. + """Unset if the Stream is closed, also when it was already closed. When set, it has the same + parts as the `failed` of a `ResolveStreamAppend`. """ def __init__( diff --git a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py index 7c8d6682de..4c37f88f41 100644 --- a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py +++ b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py @@ -49,7 +49,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a,temporal/api/sdk/v1/event_group_marker.proto\x1a$temporal/api/stream/v1/message.proto\x1a&temporal/api/workflow/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a#temporal/sdk/core/nexus/nexus.proto\x1a%temporal/sdk/core/common/common.proto"\xc8\x12\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12\x42\n\x13\x65vent_group_markers\x18\x65 \x03(\x0b\x32%.temporal.api.sdk.v1.EventGroupMarker\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x12<\n\x0bread_stream\x18\x17 \x01(\x0b\x32%.coresdk.workflow_commands.ReadStreamH\x00\x12X\n\x1arequest_cancel_stream_read\x18\x18 \x01(\x0b\x32\x32.coresdk.workflow_commands.RequestCancelStreamReadH\x00\x12\x45\n\x10\x61ppend_to_stream\x18\x19 \x01(\x0b\x32).coresdk.workflow_commands.AppendToStreamH\x00\x12>\n\x0c\x63lose_stream\x18\x1a \x01(\x0b\x32&.coresdk.workflow_commands.CloseStreamH\x00\x42\t\n\x07variant"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"\xb8\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x10 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x93\x06\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12#\n\x1binclude_arguments_in_marker\x18\x0e \x01(\x08\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"\x92\x07\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12\x43\n\x11search_attributes\x18\x08 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12[\n\x1binitial_versioning_behavior\x18\x0b \x01(\x0e\x32\x36.temporal.api.enums.v1.ContinueAsNewVersioningBehavior\x12\x39\n\x16\x62\x61\x63koff_start_interval\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"L\n\x17\x43\x61ncelWorkflowExecution\x12\x31\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32 .temporal.api.common.v1.Payloads"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xe1\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12\x43\n\x11search_attributes\x18\x11 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x14 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12I\n\x13versioning_override\x18\x15 \x01(\x0b\x32,.temporal.api.workflow.v1.VersioningOverride\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"J\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\x12\x0e\n\x06reason\x18\x02 \x01(\t"\x8e\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12\x0e\n\x06reason\x18\x03 \x01(\t"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r"e\n\x1eUpsertWorkflowSearchAttributes\x12\x43\n\x11search_attributes\x18\x01 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response"\x9a\x04\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x12H\n\x11\x63\x61ncellation_type\x18\x08 \x01(\x0e\x32-.coresdk.nexus.NexusOperationCancellationType\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x81\x01\n\x0e\x41ppendToStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12/\n\x06\x62odies\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload"M\n\x0b\x43loseStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"\xce\x01\n\nReadStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\'\n\x04wait\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x1a\n\x12records_in_history\x18\x05 \x01(\x08\x12\x13\n\x0bmax_records\x18\x06 \x01(\x05\x12\x11\n\tmax_bytes\x18\x07 \x01(\x03"&\n\x17RequestCancelStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3' + b'\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a,temporal/api/sdk/v1/event_group_marker.proto\x1a$temporal/api/stream/v1/message.proto\x1a&temporal/api/workflow/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a#temporal/sdk/core/nexus/nexus.proto\x1a%temporal/sdk/core/common/common.proto"\xc8\x12\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12\x42\n\x13\x65vent_group_markers\x18\x65 \x03(\x0b\x32%.temporal.api.sdk.v1.EventGroupMarker\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x12<\n\x0bread_stream\x18\x17 \x01(\x0b\x32%.coresdk.workflow_commands.ReadStreamH\x00\x12X\n\x1arequest_cancel_stream_read\x18\x18 \x01(\x0b\x32\x32.coresdk.workflow_commands.RequestCancelStreamReadH\x00\x12\x45\n\x10\x61ppend_to_stream\x18\x19 \x01(\x0b\x32).coresdk.workflow_commands.AppendToStreamH\x00\x12>\n\x0c\x63lose_stream\x18\x1a \x01(\x0b\x32&.coresdk.workflow_commands.CloseStreamH\x00\x42\t\n\x07variant"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"\xb8\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x10 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x93\x06\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12#\n\x1binclude_arguments_in_marker\x18\x0e \x01(\x08\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"\x92\x07\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12\x43\n\x11search_attributes\x18\x08 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12[\n\x1binitial_versioning_behavior\x18\x0b \x01(\x0e\x32\x36.temporal.api.enums.v1.ContinueAsNewVersioningBehavior\x12\x39\n\x16\x62\x61\x63koff_start_interval\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"L\n\x17\x43\x61ncelWorkflowExecution\x12\x31\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32 .temporal.api.common.v1.Payloads"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xe1\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12\x43\n\x11search_attributes\x18\x11 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x14 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12I\n\x13versioning_override\x18\x15 \x01(\x0b\x32,.temporal.api.workflow.v1.VersioningOverride\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"J\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\x12\x0e\n\x06reason\x18\x02 \x01(\t"\x8e\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12\x0e\n\x06reason\x18\x03 \x01(\t"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r"e\n\x1eUpsertWorkflowSearchAttributes\x12\x43\n\x11search_attributes\x18\x01 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response"\x9a\x04\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x12H\n\x11\x63\x61ncellation_type\x18\x08 \x01(\x0e\x32-.coresdk.nexus.NexusOperationCancellationType\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x81\x01\n\x0e\x41ppendToStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12/\n\x06\x62odies\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload"M\n\x0b\x43loseStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"\xb2\x01\n\nReadStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\'\n\x04wait\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x13\n\x0bmax_records\x18\x05 \x01(\x05\x12\x11\n\tmax_bytes\x18\x06 \x01(\x03"&\n\x17RequestCancelStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -75,8 +75,8 @@ _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_options = b"8\001" _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._options = None _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_options = b"8\001" - _ACTIVITYCANCELLATIONTYPE._serialized_start = 9570 - _ACTIVITYCANCELLATIONTYPE._serialized_end = 9658 + _ACTIVITYCANCELLATIONTYPE._serialized_start = 9542 + _ACTIVITYCANCELLATIONTYPE._serialized_end = 9630 _WORKFLOWCOMMAND._serialized_start = 596 _WORKFLOWCOMMAND._serialized_end = 2972 _STARTTIMER._serialized_start = 2974 @@ -146,7 +146,7 @@ _CLOSESTREAM._serialized_start = 9242 _CLOSESTREAM._serialized_end = 9319 _READSTREAM._serialized_start = 9322 - _READSTREAM._serialized_end = 9528 - _REQUESTCANCELSTREAMREAD._serialized_start = 9530 - _REQUESTCANCELSTREAMREAD._serialized_end = 9568 + _READSTREAM._serialized_end = 9500 + _REQUESTCANCELSTREAMREAD._serialized_start = 9502 + _REQUESTCANCELSTREAMREAD._serialized_end = 9540 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi index d0dfce295f..01498fb016 100644 --- a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi +++ b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi @@ -1971,40 +1971,42 @@ global___RequestCancelNexusOperation = RequestCancelNexusOperation @typing.final class AppendToStream(google.protobuf.message.Message): - """Appends Records to a Stream as the Workflow's Producer. The result comes in a - `ResolveStreamAppend` job. Core makes the request id of the append. + """Appends Records to a Stream as the Workflow's Producer. Core makes the request id of the append + and sends the result in a `ResolveStreamAppend` job. History keeps the result in the ledger of + the Workflow Task in which lang got it, on the completion of that task. An append is at-least-once. A later attempt of the Workflow Task writes it again, on this Worker - or another. A try that reaches the Store after more batches than the Store remembers is written - again too, after them. + or on another one. - No command stops an append, so lang takes the job of an append whose awaiter is gone. Core drops - an append that has no result when the Workflow's last command comes, as it drops a Local - Activity. That append may have reached the Store or not, and lang gets no job for it. + No command cancels an append, so lang must accept the job of an append that nothing awaits. + When lang sends the Workflow's last command, Core drops each append that has no result, as it + does for a Local Activity. Such an append may or may not have reached the Store, and lang gets + no job for it. - The appends and the closes of one Stream reach the Store one at a time, in the order of their - commands. A close takes its place only once History has its intent. So an append that comes - after a `CloseStream`, before History has the task of that close, is written before the close. + Core sends the appends and the closes of one Stream to the Store one at a time, in the order of + their commands. A close gets its place in that order only when History has its intent. So an + append that lang sends after a `CloseStream`, but before History has the task of that close, is + written before the close. - Core fails the Workflow Task, and gives lang no failure of the append, in these cases: + Core fails the Workflow Task in each of these cases, and gives lang no failure of the append. * `seq` is 0, or isn't above the `seq` of the append before it. * `stream` is unset, its id is empty or longer than 4096 bytes, or its Store name is longer than 4096 bytes. * The Worker has no Stream runtime for the Store of `stream`. - * The append waits to try again when the heartbeat of the Workflow Task comes, because the Store - answered `StoreUnavailable`, gave no answer or panicked. The message of that failure starts - with `StreamStoreUnavailable:`. + * The server doesn't take the `sdk_metadata` of a completion, so History can't keep the result. + * The append must wait for the task's heartbeat to try again, because the Store answered + `StoreUnavailable` or gave no answer. The failure message then starts with + `StreamStoreUnavailable:`. An append with no `bodies`, or with a batch over the limits of its Store, doesn't fail the Workflow Task. Lang gets a `failed` job for it. - In a replay, Core compares the `seq` and the `stream` of the command with History, and not its - `bodies`. A `stream` with no Store name matches any Store of History. An append with no result - in History runs again once the replay is over, as a later attempt, so a reader of the Stream can - see its batch twice. + In a replay, Core compares the `seq` and the `stream` of the command with History, but not the + `bodies`. A `stream` with no Store name matches any Store in History. An append with no result + in History runs again after the replay, as a later attempt, so a reader can see its batch twice. - A completion of the Workflow Task while an append has no result in a marker forces a new task, - unless it has the Workflow's last command. + If lang completes the Workflow Task while an append has no result in a ledger, Core forces a new + task, unless the completion has the Workflow's last command. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -2044,19 +2046,19 @@ global___AppendToStream = AppendToStream @typing.final class CloseStream(google.protobuf.message.Message): - """Closes a Stream. The Workflow Task that sends the command records only the intent to close, and - Core closes the Stream once History has that task. The result comes in a `ResolveStreamClose` - job of a later task, so a close needs at least one more Workflow Task. + """Closes a Stream. The Workflow Task that sends the command records only the intent to close. + Core closes the Stream when History has that task, and sends the result in a + `ResolveStreamClose` job of a later task. So a close needs at least one more Workflow Task. - These rules of `AppendToStream` hold for a close too: - * No command stops it. - * Core drops it when the Workflow's last command comes and it has no result. + These rules of `AppendToStream` apply to a close too. + * No command cancels it. + * Core drops it if it has no result when lang sends the Workflow's last command. * The same cases fail the Workflow Task. * A replay compares the command with History in the same way. - * A completion of the Workflow Task while it has no result in a marker forces a new task. + * If lang completes the task while the close has no result in a ledger, Core forces a new task. - Workflow code that needs its close awaits the result before its last command. A close whose - intent is in History with no result runs again once a replay is over. + Workflow code that needs its close must await the result before its last command. A close whose + intent is in History with no result runs again after a replay. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -2093,24 +2095,21 @@ class ReadStream(google.protobuf.message.Message): * no Records and `done`, if the Stream is closed and has none after `from_offset` * no Records, if none came within `wait` - To read on, lang sends a new `ReadStream` whose `from_offset` is the offset of the last Record - that it got. A page with no Record gives no offset, so the next read starts at the `from_offset` - of this one. + To read on, lang sends a new `ReadStream` whose `from_offset` is the `last_offset` of the page. What a read costs: - * Each page takes a command, an activation and an entry in the marker of its Workflow Task. + * Each page takes a command, an activation and an entry in the ledger of its Workflow Task. * A read holds its Workflow Task open while it waits for the Store, as a Local Activity does. A Signal, a timer or an Activity result reaches Workflow code in the next task. The task in hand completes once Workflow code sends a command for the server while only reads hold the task, and at the latest at its heartbeat. A read that still waits adds the three events of a forced Workflow Task at each heartbeat. - * One Workflow Task gives at most 16 MiB of Records, and its marker holds at most 1 MiB of them - for reads with `records_in_history`. A page that doesn't fit comes in the next task, which - Core forces. - * Without `records_in_history`, History has the count and a digest of the Records of each page. - A replay reads each page from the Store again, within the timeout of its Workflow Task. A - query of a run that isn't cached replays too. Once the Store no longer has the same Records, - each replay fails, also the one for a query of a closed Workflow. + * One Workflow Task gives at most 16 MiB of Records. A page that doesn't fit comes in the next + task, which Core forces. + * History has the count and a digest of the Records of each page. A replay reads each page from + the Store again, within the timeout of its Workflow Task. A query of a run that isn't cached + replays too. Once the Store no longer has the same Records, each replay fails, also the one for + a query of a closed Workflow. A read gets no job at the Workflow's last command, at a failed Workflow Task, at an eviction and at the shutdown of the Worker. After the last three the Workflow replays. The replay gives each @@ -2133,7 +2132,6 @@ class ReadStream(google.protobuf.message.Message): STREAM_FIELD_NUMBER: builtins.int FROM_OFFSET_FIELD_NUMBER: builtins.int WAIT_FIELD_NUMBER: builtins.int - RECORDS_IN_HISTORY_FIELD_NUMBER: builtins.int MAX_RECORDS_FIELD_NUMBER: builtins.int MAX_BYTES_FIELD_NUMBER: builtins.int seq: builtins.int @@ -2142,17 +2140,11 @@ class ReadStream(google.protobuf.message.Message): """The page has the Records after this offset. If it's empty, the page starts at the beginning of the Stream. """ - records_in_history: builtins.bool - """If set, the marker of the task holds the Records of the page, so a replay doesn't read the - Store. A marker can't hold a Record whose Producer and body have more than 1.5 MiB, so the - read fails with `stream_unsupported` for one. - """ max_records: builtins.int """The maximum number of Records in the page, which is 256 if this is zero.""" max_bytes: builtins.int """The maximum size of the Records in the page, which is 4 MiB if this is zero. Core asks the - Store for at most 16 MiB, and for at most 1 MiB with `records_in_history`. One larger Record - still comes as a page, unless the read fails for it with `records_in_history`. + Store for at most 16 MiB. One larger Record still comes as a page. """ @property def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... @@ -2169,7 +2161,6 @@ class ReadStream(google.protobuf.message.Message): stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., from_offset: builtins.bytes = ..., wait: google.protobuf.duration_pb2.Duration | None = ..., - records_in_history: builtins.bool = ..., max_records: builtins.int = ..., max_bytes: builtins.int = ..., ) -> None: ... @@ -2185,8 +2176,6 @@ class ReadStream(google.protobuf.message.Message): b"max_bytes", "max_records", b"max_records", - "records_in_history", - b"records_in_history", "seq", b"seq", "stream", @@ -2210,7 +2199,7 @@ class RequestCancelStreamRead(google.protobuf.message.Message): is. So an SDK that runs Workflow code between the jobs of one activation can give that code a page of a read that it already cancelled, in the first run and in a replay. - A cancel costs an activation and an entry in the marker of its Workflow Task, for the + A cancel costs an activation and an entry in the ledger of its Workflow Task, for the `cancelled` job. If the task completes at its heartbeat before that job, the cancel also costs the events of a forced Workflow Task. From 16be05f55b487697768c49121250806ddae7c2c8 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Tue, 24 Nov 2026 15:28:30 -0700 Subject: [PATCH 14/24] Pin Core with the Stream protos and the Stream WIT `gen_nexus_system_api.py` also generates the Stream service from `stream-service.wit`, for Workflow and client code. It adds the Workflow calls of that service to the exports of `temporalio.workflow`. --- scripts/gen_nexus_system_api.py | 51 +++++++++++++++++++++++---------- temporalio/bridge/sdk-core | 2 +- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index a5a6381f4b..90ba2af353 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -24,6 +24,7 @@ wit_deps_dir = wit_input_dir / "deps" workflow_output_dir = base_dir / "temporalio" / "nexus" / "system" / "workflow_service" notification_output_dir = base_dir / "temporalio" / "nexus" / "notifications" +stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service" workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py" NEX_GEN_VERSION = "0.2.13" proto_files = [ @@ -39,6 +40,12 @@ / "notificationservice" / "v1" / "request_response.proto", + gen_protos.api_proto_dir + / "temporal" + / "api" + / "streamservice" + / "v1" + / "request_response.proto", ] @@ -85,11 +92,11 @@ def generate_package( output_dir: Path, descriptor_path: Path, *, - native_api: bool, + targets: str | None, ) -> None: args = [*command, "python", str(wit_input_dir / wit_name), str(wit_deps_dir)] - if native_api: - args.extend(["--targets", "workflow"]) + if targets: + args.extend(["--targets", targets]) subprocess.check_call( [ *args, @@ -132,17 +139,28 @@ def replace_marker_block( def generate_workflow_exports() -> None: - exports = generated_exports(workflow_output_dir / "__init__.py") - import_block = [ - "# BEGIN GENERATED NEXUS SYSTEM EXPORTS\n", - "from temporalio.nexus.system.workflow_service import (\n", - *[f" {export},\n" for export in exports], - ")\n", - "# END GENERATED NEXUS SYSTEM EXPORTS\n", + packages = [ + ( + "temporalio.nexus.system.stream_service.workflow", + stream_output_dir / "workflow" / "__init__.py", + ), + ( + "temporalio.nexus.system.workflow_service", + workflow_output_dir / "__init__.py", + ), ] + exports = [(module, generated_exports(path)) for module, path in packages] + import_block = ["# BEGIN GENERATED NEXUS SYSTEM EXPORTS\n"] + for module, names in exports: + import_block += [ + f"from {module} import (\n", + *[f" {name},\n" for name in names], + ")\n", + ] + import_block.append("# END GENERATED NEXUS SYSTEM EXPORTS\n") all_block = [ " # BEGIN GENERATED NEXUS SYSTEM __ALL__\n", - *[f' "{export}",\n' for export in exports], + *[f' "{name}",\n' for _, names in exports for name in names], " # END GENERATED NEXUS SYSTEM __ALL__\n", ] content = workflow_init_path.read_text() @@ -163,6 +181,7 @@ def generate_nexus_system_api() -> None: required_paths = [ wit_input_dir / "workflow-service.wit", wit_input_dir / "notification-service.wit", + wit_input_dir / "stream-service.wit", wit_deps_dir, *proto_files, ] @@ -173,9 +192,10 @@ def generate_nexus_system_api() -> None: descriptor_path = Path(temp_dir) / "temporal_api.bin" build_descriptor_set(descriptor_path) command = nex_gen_command() - for wit_name, output_dir, native_api in ( - ("workflow-service.wit", workflow_output_dir, True), - ("notification-service.wit", notification_output_dir, False), + for wit_name, output_dir, targets in ( + ("workflow-service.wit", workflow_output_dir, "workflow"), + ("notification-service.wit", notification_output_dir, None), + ("stream-service.wit", stream_output_dir, "workflow,client"), ): shutil.rmtree(output_dir, ignore_errors=True) output_dir.parent.mkdir(parents=True, exist_ok=True) @@ -184,13 +204,14 @@ def generate_nexus_system_api() -> None: wit_name, output_dir, descriptor_path, - native_api=native_api, + targets=targets, ) workflow_output_dir.parent.joinpath("__init__.py").touch() generate_workflow_exports() format_paths = [ str(workflow_output_dir), str(notification_output_dir), + str(stream_output_dir), str(workflow_init_path), ] subprocess.check_call( diff --git a/temporalio/bridge/sdk-core b/temporalio/bridge/sdk-core index 0bf830696a..68afbba474 160000 --- a/temporalio/bridge/sdk-core +++ b/temporalio/bridge/sdk-core @@ -1 +1 @@ -Subproject commit 0bf830696a9952bd56629983b8dda373503d4bc3 +Subproject commit 68afbba4741cc48abdba0062557e1e2a1f9d16af From eb3b47467987c87e25bee7f4c65e2accf2ca858c Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Tue, 24 Nov 2026 15:28:30 -0700 Subject: [PATCH 15/24] Regenerate the protos and the Streams API at the pinned Core This is the output of `poe gen-protos` at the Core pin. The bridge protos and the payload visitor have no Stream commands or jobs, because this Core doesn't have them. --- temporalio/api/sdk/v1/__init__.py | 2 + temporalio/api/sdk/v1/stream_calls_pb2.py | 48 +++ temporalio/api/sdk/v1/stream_calls_pb2.pyi | 374 +++++++++++++++++ .../api/sdk/v1/task_complete_metadata_pb2.py | 10 +- .../api/sdk/v1/task_complete_metadata_pb2.pyi | 28 +- .../streamservice/v1/request_response_pb2.pyi | 9 +- temporalio/bridge/_visitor.py | 111 ----- .../proto/activity_task/activity_task_pb2.py | 24 +- .../proto/activity_task/activity_task_pb2.pyi | 8 - .../bridge/proto/external_data/__init__.py | 21 +- .../proto/external_data/external_data_pb2.py | 27 +- .../proto/external_data/external_data_pb2.pyi | 382 ------------------ .../proto/workflow_activation/__init__.py | 10 - .../workflow_activation_pb2.py | 119 +++--- .../workflow_activation_pb2.pyi | 280 +------------ .../proto/workflow_commands/__init__.py | 8 - .../workflow_commands_pb2.py | 145 +++---- .../workflow_commands_pb2.pyi | 296 -------------- .../nexus/system/workflow_service/__init__.py | 7 + 19 files changed, 602 insertions(+), 1307 deletions(-) create mode 100644 temporalio/api/sdk/v1/stream_calls_pb2.py create mode 100644 temporalio/api/sdk/v1/stream_calls_pb2.pyi diff --git a/temporalio/api/sdk/v1/__init__.py b/temporalio/api/sdk/v1/__init__.py index 4f23aac6a6..f37804007e 100644 --- a/temporalio/api/sdk/v1/__init__.py +++ b/temporalio/api/sdk/v1/__init__.py @@ -7,6 +7,7 @@ ) from .event_group_marker_pb2 import EventGroupMarker from .external_storage_pb2 import ExternalStorageReference +from .stream_calls_pb2 import WorkflowTaskStreamCalls from .task_complete_metadata_pb2 import WorkflowTaskCompletedMetadata from .user_metadata_pb2 import UserMetadata from .worker_config_pb2 import WorkerConfig @@ -30,4 +31,5 @@ "WorkflowInteractionDefinition", "WorkflowMetadata", "WorkflowTaskCompletedMetadata", + "WorkflowTaskStreamCalls", ] diff --git a/temporalio/api/sdk/v1/stream_calls_pb2.py b/temporalio/api/sdk/v1/stream_calls_pb2.py new file mode 100644 index 0000000000..7157cfad5f --- /dev/null +++ b/temporalio/api/sdk/v1/stream_calls_pb2.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: temporal/api/sdk/v1/stream_calls.proto +"""Generated protocol buffer code.""" + +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from temporalio.api.enums.v1 import ( + stream_pb2 as temporal_dot_api_dot_enums_dot_v1_dot_stream__pb2, +) +from temporalio.api.stream.v1 import ( + message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, +) + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n&temporal/api/sdk/v1/stream_calls.proto\x12\x13temporal.api.sdk.v1\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\x85\n\n\x17WorkflowTaskStreamCalls\x12O\n\rclose_intents\x18\x01 \x03(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CloseIntent\x12Q\n\x0e\x61ppend_results\x18\x02 \x03(\x0b\x32\x39.temporal.api.sdk.v1.WorkflowTaskStreamCalls.AppendResult\x12O\n\rclose_results\x18\x03 \x03(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CloseResult\x12M\n\x0cread_results\x18\x04 \x03(\x0b\x32\x37.temporal.api.sdk.v1.WorkflowTaskStreamCalls.ReadResult\x1aJ\n\x0b\x43loseIntent\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x1a\xf2\x01\n\x0c\x41ppendResult\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12N\n\x08\x61ppended\x18\x03 \x01(\x0b\x32:.temporal.api.sdk.v1.WorkflowTaskStreamCalls.AppendOffsetsH\x00\x12K\n\x07\x66\x61ilure\x18\x04 \x01(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CallFailureH\x00\x42\x08\n\x06result\x1a:\n\rAppendOffsets\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x1a\x65\n\x0b\x43loseResult\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12I\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CallFailure\x1a\xfc\x01\n\nReadResult\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\x45\n\x04page\x18\x04 \x01(\x0b\x32\x35.temporal.api.sdk.v1.WorkflowTaskStreamCalls.ReadPageH\x00\x12K\n\x07\x66\x61ilure\x18\x05 \x01(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CallFailureH\x00\x42\x08\n\x06result\x1ai\n\x08ReadPage\x12\x14\n\x0crecord_count\x18\x01 \x01(\x05\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x0e\n\x06\x64igest\x18\x03 \x01(\x0c\x12\x14\n\x0crecord_bytes\x18\x04 \x01(\x03\x12\x13\n\x0blast_offset\x18\x05 \x01(\x0c\x1aX\n\x0b\x43\x61llFailure\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReason\x12\x0f\n\x07message\x18\x02 \x01(\tB~\n\x16io.temporal.api.sdk.v1B\x10StreamCallsProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' +) + +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, __name__, globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b"\n\026io.temporal.api.sdk.v1B\020StreamCallsProtoP\001Z\035go.temporal.io/api/sdk/v1;sdk\252\002\025Temporalio.Api.Sdk.V1\352\002\030Temporalio::Api::Sdk::V1" + _WORKFLOWTASKSTREAMCALLS._serialized_start = 138 + _WORKFLOWTASKSTREAMCALLS._serialized_end = 1423 + _WORKFLOWTASKSTREAMCALLS_CLOSEINTENT._serialized_start = 489 + _WORKFLOWTASKSTREAMCALLS_CLOSEINTENT._serialized_end = 563 + _WORKFLOWTASKSTREAMCALLS_APPENDRESULT._serialized_start = 566 + _WORKFLOWTASKSTREAMCALLS_APPENDRESULT._serialized_end = 808 + _WORKFLOWTASKSTREAMCALLS_APPENDOFFSETS._serialized_start = 810 + _WORKFLOWTASKSTREAMCALLS_APPENDOFFSETS._serialized_end = 868 + _WORKFLOWTASKSTREAMCALLS_CLOSERESULT._serialized_start = 870 + _WORKFLOWTASKSTREAMCALLS_CLOSERESULT._serialized_end = 971 + _WORKFLOWTASKSTREAMCALLS_READRESULT._serialized_start = 974 + _WORKFLOWTASKSTREAMCALLS_READRESULT._serialized_end = 1226 + _WORKFLOWTASKSTREAMCALLS_READPAGE._serialized_start = 1228 + _WORKFLOWTASKSTREAMCALLS_READPAGE._serialized_end = 1333 + _WORKFLOWTASKSTREAMCALLS_CALLFAILURE._serialized_start = 1335 + _WORKFLOWTASKSTREAMCALLS_CALLFAILURE._serialized_end = 1423 +# @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/sdk/v1/stream_calls_pb2.pyi b/temporalio/api/sdk/v1/stream_calls_pb2.pyi new file mode 100644 index 0000000000..99c5890550 --- /dev/null +++ b/temporalio/api/sdk/v1/stream_calls_pb2.pyi @@ -0,0 +1,374 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import builtins +import collections.abc +import typing + +import google.protobuf.descriptor +import google.protobuf.internal.containers +import google.protobuf.message + +import temporalio.api.enums.v1.stream_pb2 +import temporalio.api.stream.v1.message_pb2 + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +@typing.final +class WorkflowTaskStreamCalls(google.protobuf.message.Message): + """Experimental. Might change in the future. + The Stream calls of one Workflow Task. An SDK records them on the completion of the task, so + that a replay gives Workflow code the same result for each call. A replay doesn't append or + close again for a result that is here. For a page, it reads the Records from the Store again. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + @typing.final + class CloseIntent(google.protobuf.message.Message): + """The intent of Workflow code to close a Stream.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + seq: builtins.int + """The sequence number that the SDK gave the close.""" + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... + def __init__( + self, + *, + seq: builtins.int = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["ref", b"ref"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["ref", b"ref", "seq", b"seq"] + ) -> None: ... + + @typing.final + class AppendResult(google.protobuf.message.Message): + """The result of an append.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + APPENDED_FIELD_NUMBER: builtins.int + FAILURE_FIELD_NUMBER: builtins.int + seq: builtins.int + """The sequence number that the SDK gave the append.""" + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... + @property + def appended(self) -> global___WorkflowTaskStreamCalls.AppendOffsets: ... + @property + def failure(self) -> global___WorkflowTaskStreamCalls.CallFailure: ... + def __init__( + self, + *, + seq: builtins.int = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + appended: global___WorkflowTaskStreamCalls.AppendOffsets | None = ..., + failure: global___WorkflowTaskStreamCalls.CallFailure | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "appended", + b"appended", + "failure", + b"failure", + "ref", + b"ref", + "result", + b"result", + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "appended", + b"appended", + "failure", + b"failure", + "ref", + b"ref", + "result", + b"result", + "seq", + b"seq", + ], + ) -> None: ... + def WhichOneof( + self, oneof_group: typing.Literal["result", b"result"] + ) -> typing.Literal["appended", "failure"] | None: ... + + @typing.final + class AppendOffsets(google.protobuf.message.Message): + """The offsets of the first and the last Record of a batch, as the Store returned them.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + FIRST_OFFSET_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + first_offset: builtins.bytes + last_offset: builtins.bytes + def __init__( + self, + *, + first_offset: builtins.bytes = ..., + last_offset: builtins.bytes = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "first_offset", b"first_offset", "last_offset", b"last_offset" + ], + ) -> None: ... + + @typing.final + class CloseResult(google.protobuf.message.Message): + """The result of a close. The intent with the same `seq` has the ref of the Stream.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + FAILURE_FIELD_NUMBER: builtins.int + seq: builtins.int + @property + def failure(self) -> global___WorkflowTaskStreamCalls.CallFailure: + """Unset if the Stream is closed.""" + + def __init__( + self, + *, + seq: builtins.int = ..., + failure: global___WorkflowTaskStreamCalls.CallFailure | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["failure", b"failure"] + ) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["failure", b"failure", "seq", b"seq"] + ) -> None: ... + + @typing.final + class ReadResult(google.protobuf.message.Message): + """The result of a read.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + SEQ_FIELD_NUMBER: builtins.int + REF_FIELD_NUMBER: builtins.int + FROM_OFFSET_FIELD_NUMBER: builtins.int + PAGE_FIELD_NUMBER: builtins.int + FAILURE_FIELD_NUMBER: builtins.int + seq: builtins.int + """The sequence number that the SDK gave the read.""" + from_offset: builtins.bytes + """The `from_offset` of the read. A replay reads the Records of the page after it. + (-- api-linter: core::0140::prepositions=disabled + aip.dev/not-precedent: "from" marks the start of a range of offsets. --) + """ + @property + def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... + @property + def page(self) -> global___WorkflowTaskStreamCalls.ReadPage: ... + @property + def failure(self) -> global___WorkflowTaskStreamCalls.CallFailure: ... + def __init__( + self, + *, + seq: builtins.int = ..., + ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + from_offset: builtins.bytes = ..., + page: global___WorkflowTaskStreamCalls.ReadPage | None = ..., + failure: global___WorkflowTaskStreamCalls.CallFailure | None = ..., + ) -> None: ... + def HasField( + self, + field_name: typing.Literal[ + "failure", + b"failure", + "page", + b"page", + "ref", + b"ref", + "result", + b"result", + ], + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "failure", + b"failure", + "from_offset", + b"from_offset", + "page", + b"page", + "ref", + b"ref", + "result", + b"result", + "seq", + b"seq", + ], + ) -> None: ... + def WhichOneof( + self, oneof_group: typing.Literal["result", b"result"] + ) -> typing.Literal["page", "failure"] | None: ... + + @typing.final + class ReadPage(google.protobuf.message.Message): + """A page that a read gave Workflow code. It doesn't have the Records. A replay reads them from + the Store again and checks them against `digest`. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RECORD_COUNT_FIELD_NUMBER: builtins.int + DONE_FIELD_NUMBER: builtins.int + DIGEST_FIELD_NUMBER: builtins.int + RECORD_BYTES_FIELD_NUMBER: builtins.int + LAST_OFFSET_FIELD_NUMBER: builtins.int + record_count: builtins.int + """The number of Records in the page.""" + done: builtins.bool + """True if the Stream was closed and had no Record after this page.""" + digest: builtins.bytes + """The first 16 bytes of a SHA-256 over the Records, in an encoding that the SDK owns. It's + empty if the page has no Record. + """ + record_bytes: builtins.int + """The size of the Records in bytes, as the `max_bytes` of a read measures it. It's set when + `digest` is, so a replay knows how much to read. + """ + last_offset: builtins.bytes + """The `last_offset` that Workflow code got with the page. A replay gives the same value, + since another read of the Store can end at another offset. + """ + def __init__( + self, + *, + record_count: builtins.int = ..., + done: builtins.bool = ..., + digest: builtins.bytes = ..., + record_bytes: builtins.int = ..., + last_offset: builtins.bytes = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "digest", + b"digest", + "done", + b"done", + "last_offset", + b"last_offset", + "record_bytes", + b"record_bytes", + "record_count", + b"record_count", + ], + ) -> None: ... + + @typing.final + class CallFailure(google.protobuf.message.Message): + """Why a call failed. The SDK builds the error that Workflow code gets from it.""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REASON_FIELD_NUMBER: builtins.int + MESSAGE_FIELD_NUMBER: builtins.int + reason: temporalio.api.enums.v1.stream_pb2.StreamErrorReason.ValueType + message: builtins.str + def __init__( + self, + *, + reason: temporalio.api.enums.v1.stream_pb2.StreamErrorReason.ValueType = ..., + message: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["message", b"message", "reason", b"reason"] + ) -> None: ... + + CLOSE_INTENTS_FIELD_NUMBER: builtins.int + APPEND_RESULTS_FIELD_NUMBER: builtins.int + CLOSE_RESULTS_FIELD_NUMBER: builtins.int + READ_RESULTS_FIELD_NUMBER: builtins.int + @property + def close_intents( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___WorkflowTaskStreamCalls.CloseIntent + ]: + """The closes that Workflow code asked for in this task. The SDK closes a Stream only when + History has the intent, so the result of a close is in a later task. + """ + + @property + def append_results( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___WorkflowTaskStreamCalls.AppendResult + ]: + """The results of the appends that Workflow code got in this task.""" + + @property + def close_results( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___WorkflowTaskStreamCalls.CloseResult + ]: + """The results of the closes that Workflow code got in this task.""" + + @property + def read_results( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + global___WorkflowTaskStreamCalls.ReadResult + ]: + """The results of the reads that Workflow code got in this task.""" + + def __init__( + self, + *, + close_intents: collections.abc.Iterable[ + global___WorkflowTaskStreamCalls.CloseIntent + ] + | None = ..., + append_results: collections.abc.Iterable[ + global___WorkflowTaskStreamCalls.AppendResult + ] + | None = ..., + close_results: collections.abc.Iterable[ + global___WorkflowTaskStreamCalls.CloseResult + ] + | None = ..., + read_results: collections.abc.Iterable[ + global___WorkflowTaskStreamCalls.ReadResult + ] + | None = ..., + ) -> None: ... + def ClearField( + self, + field_name: typing.Literal[ + "append_results", + b"append_results", + "close_intents", + b"close_intents", + "close_results", + b"close_results", + "read_results", + b"read_results", + ], + ) -> None: ... + +global___WorkflowTaskStreamCalls = WorkflowTaskStreamCalls diff --git a/temporalio/api/sdk/v1/task_complete_metadata_pb2.py b/temporalio/api/sdk/v1/task_complete_metadata_pb2.py index de70aaeddb..53b3e6df84 100644 --- a/temporalio/api/sdk/v1/task_complete_metadata_pb2.py +++ b/temporalio/api/sdk/v1/task_complete_metadata_pb2.py @@ -13,8 +13,12 @@ _sym_db = _symbol_database.Default() +from temporalio.api.sdk.v1 import ( + stream_calls_pb2 as temporal_dot_api_dot_sdk_dot_v1_dot_stream__calls__pb2, +) + DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1"\x93\x01\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\t\x12\x19\n\x11\x63ore_stream_calls\x18\x05 \x01(\x0c\x42\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' + b'\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1\x1a&temporal/api/sdk/v1/stream_calls.proto"\xbc\x01\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\t\x12\x42\n\x0cstream_calls\x18\x05 \x01(\x0b\x32,.temporal.api.sdk.v1.WorkflowTaskStreamCallsB\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -22,6 +26,6 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\026io.temporal.api.sdk.v1B\031TaskCompleteMetadataProtoP\001Z\035go.temporal.io/api/sdk/v1;sdk\252\002\025Temporalio.Api.Sdk.V1\352\002\030Temporalio::Api::Sdk::V1" - _WORKFLOWTASKCOMPLETEDMETADATA._serialized_start = 74 - _WORKFLOWTASKCOMPLETEDMETADATA._serialized_end = 221 + _WORKFLOWTASKCOMPLETEDMETADATA._serialized_start = 114 + _WORKFLOWTASKCOMPLETEDMETADATA._serialized_end = 302 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi b/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi index 1e552eb069..9aba16f238 100644 --- a/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi +++ b/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi @@ -11,6 +11,8 @@ import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message +import temporalio.api.sdk.v1.stream_calls_pb2 + DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final @@ -21,7 +23,7 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): LANG_USED_FLAGS_FIELD_NUMBER: builtins.int SDK_NAME_FIELD_NUMBER: builtins.int SDK_VERSION_FIELD_NUMBER: builtins.int - CORE_STREAM_CALLS_FIELD_NUMBER: builtins.int + STREAM_CALLS_FIELD_NUMBER: builtins.int sdk_name: builtins.str """Name of the SDK that processed the task. This is usually something like "temporal-go" and is usually the same as client-name gRPC header. This should only be set if its value changed @@ -35,10 +37,6 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): usually the same as client-version gRPC header. This should only be set if its value changed since the last time recorded on the workflow (or be set on the first task). """ - core_stream_calls: builtins.bytes - """The Stream calls of this Workflow Task, in a format that SDK Core owns. A replay gives - Workflow code the same results from it. - """ @property def core_used_flags( self, @@ -76,6 +74,16 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): aip.dev/not-precedent: These really shouldn't have negative values. --) """ + @property + def stream_calls( + self, + ) -> temporalio.api.sdk.v1.stream_calls_pb2.WorkflowTaskStreamCalls: + """Experimental. Might change in the future. + The Stream calls of this Workflow Task. An SDK sets it if Workflow code got the result of a + Stream call in the task, asked for a close, or has a call with no result yet. So it can have + no entry. + """ + def __init__( self, *, @@ -83,13 +91,15 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): lang_used_flags: collections.abc.Iterable[builtins.int] | None = ..., sdk_name: builtins.str = ..., sdk_version: builtins.str = ..., - core_stream_calls: builtins.bytes = ..., + stream_calls: temporalio.api.sdk.v1.stream_calls_pb2.WorkflowTaskStreamCalls + | None = ..., ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream_calls", b"stream_calls"] + ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ - "core_stream_calls", - b"core_stream_calls", "core_used_flags", b"core_used_flags", "lang_used_flags", @@ -98,6 +108,8 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): b"sdk_name", "sdk_version", b"sdk_version", + "stream_calls", + b"stream_calls", ], ) -> None: ... diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index e28902ed6c..f1c9eca954 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -309,10 +309,11 @@ class ReadRecordsResponse(google.protobuf.message.Message): LAST_OFFSET_FIELD_NUMBER: builtins.int DONE_FIELD_NUMBER: builtins.int last_offset: builtins.bytes - """The last position that the read covered. The next read passes it as `from_offset`. Every - Store can give it, as the offset of the last Record in this page, or as the `from_offset` - of the request for an empty page. A Store can also give a later offset that skips only - entries of its own that aren't Records, so the next read doesn't scan them again. + """The last position that the read covered. The next read passes it as `from_offset`. A Store + doesn't have to set it. If it's empty, that position is the offset of the last Record in + this page, or the `from_offset` of the request for an empty page. A Store can set a later + offset that skips only entries of its own that aren't Records, so the next read doesn't + scan them again. """ done: builtins.bool """True when the Stream is closed and this page has its last Record. A read has no other sign diff --git a/temporalio/bridge/_visitor.py b/temporalio/bridge/_visitor.py index 4b02edbc65..ead09a986f 100644 --- a/temporalio/bridge/_visitor.py +++ b/temporalio/bridge/_visitor.py @@ -308,38 +308,6 @@ async def _visit_coresdk_workflow_activation_ResolveNexusOperation( if o.HasField("result"): await self._visit_coresdk_nexus_NexusOperationResult(fs, o.result) - 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_ResolveStreamAppend( - self, fs: VisitorFunctions, o: Any - ): - if o.HasField("failed"): - await self._visit_temporal_api_failure_v1_Failure(fs, o.failed) - - async def _visit_coresdk_workflow_activation_ResolveStreamClose( - self, fs: VisitorFunctions, o: Any - ): - if 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 ): @@ -385,18 +353,6 @@ async def _visit_coresdk_workflow_activation_WorkflowActivationJob( await self._visit_coresdk_workflow_activation_ResolveNexusOperation( fs, o.resolve_nexus_operation ) - elif o.HasField("resolve_stream_read"): - await self._visit_coresdk_workflow_activation_ResolveStreamRead( - fs, o.resolve_stream_read - ) - elif o.HasField("resolve_stream_append"): - await self._visit_coresdk_workflow_activation_ResolveStreamAppend( - fs, o.resolve_stream_append - ) - elif o.HasField("resolve_stream_close"): - await self._visit_coresdk_workflow_activation_ResolveStreamClose( - fs, o.resolve_stream_close - ) async def _visit_coresdk_workflow_activation_WorkflowActivation( self, fs: VisitorFunctions, o: Any @@ -536,11 +492,6 @@ async def _visit_coresdk_workflow_commands_ScheduleNexusOperation( if o.HasField("input"): await self._visit_nexus_operation_input_payload(fs, o.input) - async def _visit_coresdk_workflow_commands_AppendToStream( - self, fs: VisitorFunctions, o: Any - ): - await self._visit_payload_container(fs, o.bodies) - async def _visit_coresdk_workflow_commands_WorkflowCommand( self, fs: VisitorFunctions, o: Any ): @@ -600,10 +551,6 @@ async def _visit_coresdk_workflow_commands_WorkflowCommand( await self._visit_coresdk_workflow_commands_ScheduleNexusOperation( fs, o.schedule_nexus_operation ) - elif o.HasField("append_to_stream"): - await self._visit_coresdk_workflow_commands_AppendToStream( - fs, o.append_to_stream - ) async def _visit_coresdk_workflow_completion_Success( self, fs: VisitorFunctions, o: Any @@ -692,64 +639,6 @@ async def _visit_temporal_api_notificationservice_v1_OnCompleteResponse( ) -> None: pass - async def _visit_temporal_api_streamservice_v1_CreateStreamRequest( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_streamservice_v1_CreateStreamResponse( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_stream_v1_AppendRecord( - 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_AppendRecordsRequest( - self, fs: VisitorFunctions, o: Any - ): - for v in o.records: - await self._visit_temporal_api_stream_v1_AppendRecord(fs, v) - - async def _visit_temporal_api_streamservice_v1_AppendRecordsResponse( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_streamservice_v1_CloseStreamRequest( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_streamservice_v1_CloseStreamResponse( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_streamservice_v1_ReadRecordsRequest( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_streamservice_v1_ReadRecordsResponse( - self, fs: VisitorFunctions, o: Any - ): - for v in o.records: - await self._visit_temporal_api_stream_v1_StreamRecord(fs, v) - - async def _visit_temporal_api_streamservice_v1_DescribeStreamRequest( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - - async def _visit_temporal_api_streamservice_v1_DescribeStreamResponse( - self, fs: VisitorFunctions, o: Any - ) -> None: - pass - async def _visit_temporal_api_common_v1_Header(self, fs: VisitorFunctions, o: Any): for v in o.fields.values(): await self._visit_temporal_api_common_v1_Payload(fs, v) diff --git a/temporalio/bridge/proto/activity_task/activity_task_pb2.py b/temporalio/bridge/proto/activity_task/activity_task_pb2.py index fd2ce8c211..25233f5241 100644 --- a/temporalio/bridge/proto/activity_task/activity_task_pb2.py +++ b/temporalio/bridge/proto/activity_task/activity_task_pb2.py @@ -27,7 +27,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n3temporal/sdk/core/activity_task/activity_task.proto\x12\x15\x63oresdk.activity_task\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a%temporal/sdk/core/common/common.proto"\x8d\x01\n\x0c\x41\x63tivityTask\x12\x12\n\ntask_token\x18\x01 \x01(\x0c\x12-\n\x05start\x18\x03 \x01(\x0b\x32\x1c.coresdk.activity_task.StartH\x00\x12/\n\x06\x63\x61ncel\x18\x04 \x01(\x0b\x32\x1d.coresdk.activity_task.CancelH\x00\x42\t\n\x07variant"\xf7\x08\n\x05Start\x12\x1a\n\x12workflow_namespace\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12\x45\n\x12workflow_execution\x18\x03 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x15\n\ractivity_type\x18\x05 \x01(\t\x12\x45\n\rheader_fields\x18\x06 \x03(\x0b\x32..coresdk.activity_task.Start.HeaderFieldsEntry\x12.\n\x05input\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12:\n\x11heartbeat_details\x18\x08 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x32\n\x0escheduled_time\x18\t \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x42\n\x1e\x63urrent_attempt_scheduled_time\x18\n \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x0cstarted_time\x18\x0b \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x0c \x01(\r\x12<\n\x19schedule_to_close_timeout\x18\r \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\x0e \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0f \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x32\n\x08priority\x18\x12 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12\x10\n\x08is_local\x18\x11 \x01(\x08\x12\x0e\n\x06run_id\x18\x13 \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x14 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x12\x41\n\rworkflow_task\x18\x15 \x01(\x0b\x32*.coresdk.activity_task.WorkflowTaskAttempt\x12\x1a\n\x12scheduled_event_id\x18\x16 \x01(\x03\x1aT\n\x11HeaderFieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x80\x02\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12!\n\x19previous_started_event_id\x18\x04 \x01(\x03\x12\x14\n\x0c\x66\x61iled_tasks\x18\x05 \x03(\x03\x12\x18\n\x10previous_attempt\x18\x06 \x01(\r\x12\x39\n\x15previous_started_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8a\x01\n\x06\x43\x61ncel\x12;\n\x06reason\x18\x01 \x01(\x0e\x32+.coresdk.activity_task.ActivityCancelReason\x12\x43\n\x07\x64\x65tails\x18\x02 \x01(\x0b\x32\x32.coresdk.activity_task.ActivityCancellationDetails"\xa0\x01\n\x1b\x41\x63tivityCancellationDetails\x12\x14\n\x0cis_not_found\x18\x01 \x01(\x08\x12\x14\n\x0cis_cancelled\x18\x02 \x01(\x08\x12\x11\n\tis_paused\x18\x03 \x01(\x08\x12\x14\n\x0cis_timed_out\x18\x04 \x01(\x08\x12\x1a\n\x12is_worker_shutdown\x18\x05 \x01(\x08\x12\x10\n\x08is_reset\x18\x06 \x01(\x08*o\n\x14\x41\x63tivityCancelReason\x12\r\n\tNOT_FOUND\x10\x00\x12\r\n\tCANCELLED\x10\x01\x12\r\n\tTIMED_OUT\x10\x02\x12\x13\n\x0fWORKER_SHUTDOWN\x10\x03\x12\n\n\x06PAUSED\x10\x04\x12\t\n\x05RESET\x10\x05\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ActivityTaskb\x06proto3' + b'\n3temporal/sdk/core/activity_task/activity_task.proto\x12\x15\x63oresdk.activity_task\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a%temporal/sdk/core/common/common.proto"\x8d\x01\n\x0c\x41\x63tivityTask\x12\x12\n\ntask_token\x18\x01 \x01(\x0c\x12-\n\x05start\x18\x03 \x01(\x0b\x32\x1c.coresdk.activity_task.StartH\x00\x12/\n\x06\x63\x61ncel\x18\x04 \x01(\x0b\x32\x1d.coresdk.activity_task.CancelH\x00\x42\t\n\x07variant"\xdb\x08\n\x05Start\x12\x1a\n\x12workflow_namespace\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12\x45\n\x12workflow_execution\x18\x03 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x15\n\ractivity_type\x18\x05 \x01(\t\x12\x45\n\rheader_fields\x18\x06 \x03(\x0b\x32..coresdk.activity_task.Start.HeaderFieldsEntry\x12.\n\x05input\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12:\n\x11heartbeat_details\x18\x08 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x32\n\x0escheduled_time\x18\t \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x42\n\x1e\x63urrent_attempt_scheduled_time\x18\n \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x30\n\x0cstarted_time\x18\x0b \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x0c \x01(\r\x12<\n\x19schedule_to_close_timeout\x18\r \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\x0e \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0f \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x32\n\x08priority\x18\x12 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12\x10\n\x08is_local\x18\x11 \x01(\x08\x12\x0e\n\x06run_id\x18\x13 \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x14 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x12\x41\n\rworkflow_task\x18\x15 \x01(\x0b\x32*.coresdk.activity_task.WorkflowTaskAttempt\x1aT\n\x11HeaderFieldsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x80\x02\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12!\n\x19previous_started_event_id\x18\x04 \x01(\x03\x12\x14\n\x0c\x66\x61iled_tasks\x18\x05 \x03(\x03\x12\x18\n\x10previous_attempt\x18\x06 \x01(\r\x12\x39\n\x15previous_started_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8a\x01\n\x06\x43\x61ncel\x12;\n\x06reason\x18\x01 \x01(\x0e\x32+.coresdk.activity_task.ActivityCancelReason\x12\x43\n\x07\x64\x65tails\x18\x02 \x01(\x0b\x32\x32.coresdk.activity_task.ActivityCancellationDetails"\xa0\x01\n\x1b\x41\x63tivityCancellationDetails\x12\x14\n\x0cis_not_found\x18\x01 \x01(\x08\x12\x14\n\x0cis_cancelled\x18\x02 \x01(\x08\x12\x11\n\tis_paused\x18\x03 \x01(\x08\x12\x14\n\x0cis_timed_out\x18\x04 \x01(\x08\x12\x1a\n\x12is_worker_shutdown\x18\x05 \x01(\x08\x12\x10\n\x08is_reset\x18\x06 \x01(\x08*o\n\x14\x41\x63tivityCancelReason\x12\r\n\tNOT_FOUND\x10\x00\x12\r\n\tCANCELLED\x10\x01\x12\r\n\tTIMED_OUT\x10\x02\x12\x13\n\x0fWORKER_SHUTDOWN\x10\x03\x12\n\n\x06PAUSED\x10\x04\x12\t\n\x05RESET\x10\x05\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ActivityTaskb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -39,18 +39,18 @@ ) _START_HEADERFIELDSENTRY._options = None _START_HEADERFIELDSENTRY._serialized_options = b"8\001" - _ACTIVITYCANCELREASON._serialized_start = 2110 - _ACTIVITYCANCELREASON._serialized_end = 2221 + _ACTIVITYCANCELREASON._serialized_start = 2082 + _ACTIVITYCANCELREASON._serialized_end = 2193 _ACTIVITYTASK._serialized_start = 258 _ACTIVITYTASK._serialized_end = 399 _START._serialized_start = 402 - _START._serialized_end = 1545 - _START_HEADERFIELDSENTRY._serialized_start = 1461 - _START_HEADERFIELDSENTRY._serialized_end = 1545 - _WORKFLOWTASKATTEMPT._serialized_start = 1548 - _WORKFLOWTASKATTEMPT._serialized_end = 1804 - _CANCEL._serialized_start = 1807 - _CANCEL._serialized_end = 1945 - _ACTIVITYCANCELLATIONDETAILS._serialized_start = 1948 - _ACTIVITYCANCELLATIONDETAILS._serialized_end = 2108 + _START._serialized_end = 1517 + _START_HEADERFIELDSENTRY._serialized_start = 1433 + _START_HEADERFIELDSENTRY._serialized_end = 1517 + _WORKFLOWTASKATTEMPT._serialized_start = 1520 + _WORKFLOWTASKATTEMPT._serialized_end = 1776 + _CANCEL._serialized_start = 1779 + _CANCEL._serialized_end = 1917 + _ACTIVITYCANCELLATIONDETAILS._serialized_start = 1920 + _ACTIVITYCANCELLATIONDETAILS._serialized_end = 2080 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi b/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi index 63b1711bf8..345b0a6b1e 100644 --- a/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi +++ b/temporalio/bridge/proto/activity_task/activity_task_pb2.pyi @@ -167,7 +167,6 @@ class Start(google.protobuf.message.Message): RUN_ID_FIELD_NUMBER: builtins.int PROPAGATED_NEXUS_SERIALIZATION_CONTEXT_FIELD_NUMBER: builtins.int WORKFLOW_TASK_FIELD_NUMBER: builtins.int - SCHEDULED_EVENT_ID_FIELD_NUMBER: builtins.int workflow_namespace: builtins.str """The namespace the workflow lives in""" workflow_type: builtins.str @@ -183,10 +182,6 @@ class Start(google.protobuf.message.Message): """ run_id: builtins.str """Run ID of this activity execution. Only set for standalone activities.""" - scheduled_event_id: builtins.int - """For an activity that a workflow scheduled, the event id of its ActivityTaskScheduled event. - 0 for a local activity, for a standalone activity, and when Core can't read it. - """ @property def workflow_execution( self, @@ -299,7 +294,6 @@ class Start(google.protobuf.message.Message): propagated_nexus_serialization_context: temporalio.api.nexus.v1.message_pb2.PropagatedSerializationContext | None = ..., workflow_task: global___WorkflowTaskAttempt | None = ..., - scheduled_event_id: builtins.int = ..., ) -> None: ... def HasField( self, @@ -359,8 +353,6 @@ class Start(google.protobuf.message.Message): b"run_id", "schedule_to_close_timeout", b"schedule_to_close_timeout", - "scheduled_event_id", - b"scheduled_event_id", "scheduled_time", b"scheduled_time", "start_to_close_timeout", diff --git a/temporalio/bridge/proto/external_data/__init__.py b/temporalio/bridge/proto/external_data/__init__.py index 0be236ec48..836e97ef43 100644 --- a/temporalio/bridge/proto/external_data/__init__.py +++ b/temporalio/bridge/proto/external_data/__init__.py @@ -1,25 +1,6 @@ -from .external_data_pb2 import ( - LocalActivityMarkerData, - PatchedMarkerData, - StreamAppendOffsets, - StreamAppendResult, - StreamCloseIntent, - StreamCloseResult, - StreamFailure, - StreamLedger, - StreamReadPage, - StreamReadResult, -) +from .external_data_pb2 import LocalActivityMarkerData, PatchedMarkerData __all__ = [ "LocalActivityMarkerData", "PatchedMarkerData", - "StreamAppendOffsets", - "StreamAppendResult", - "StreamCloseIntent", - "StreamCloseResult", - "StreamFailure", - "StreamLedger", - "StreamReadPage", - "StreamReadResult", ] diff --git a/temporalio/bridge/proto/external_data/external_data_pb2.py b/temporalio/bridge/proto/external_data/external_data_pb2.py index e57fdd6ab4..4bda6f5144 100644 --- a/temporalio/bridge/proto/external_data/external_data_pb2.py +++ b/temporalio/bridge/proto/external_data/external_data_pb2.py @@ -14,11 +14,10 @@ from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 -from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xb2\x02\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x10\x61\x63tivation_index\x18\x08 \x01(\x04H\x00\x88\x01\x01\x42\x13\n\x11_activation_index"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xfd\x01\n\x0cStreamLedger\x12?\n\rclose_intents\x18\x01 \x03(\x0b\x32(.coresdk.external_data.StreamCloseIntent\x12:\n\x07\x61ppends\x18\x02 \x03(\x0b\x32).coresdk.external_data.StreamAppendResult\x12\x38\n\x06\x63loses\x18\x03 \x03(\x0b\x32(.coresdk.external_data.StreamCloseResult\x12\x36\n\x05reads\x18\x04 \x03(\x0b\x32\'.coresdk.external_data.StreamReadResult"B\n\x11StreamCloseIntent\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t"\xe0\x01\n\x12StreamAppendResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12>\n\x08\x61ppended\x18\x05 \x01(\x0b\x32*.coresdk.external_data.StreamAppendOffsetsH\x00\x12\x37\n\x07\x66\x61ilure\x18\x06 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x42\x08\n\x06result"@\n\x13StreamAppendOffsets\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"0\n\rStreamFailure\x12\x0e\n\x06reason\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t"q\n\x11StreamCloseResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x18\n\x10\x61\x63tivation_index\x18\x02 \x01(\x04\x12\x35\n\x07\x66\x61ilure\x18\x03 \x01(\x0b\x32$.coresdk.external_data.StreamFailure"\x97\x02\n\x10StreamReadResult\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tstream_id\x18\x02 \x01(\t\x12\r\n\x05store\x18\x03 \x01(\t\x12\x18\n\x10\x61\x63tivation_index\x18\x04 \x01(\x04\x12\x13\n\x0b\x66rom_offset\x18\x05 \x01(\x0c\x12\x35\n\x04page\x18\x06 \x01(\x0b\x32%.coresdk.external_data.StreamReadPageH\x00\x12\x37\n\x07\x66\x61ilure\x18\x07 \x01(\x0b\x32$.coresdk.external_data.StreamFailureH\x00\x12+\n\tcancelled\x18\x08 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06result"o\n\x0eStreamReadPage\x12\x14\n\x0crecord_count\x18\x01 \x01(\r\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x0e\n\x06\x64igest\x18\x03 \x01(\x0c\x12\x14\n\x0crecord_bytes\x18\x04 \x01(\x04\x12\x13\n\x0blast_offset\x18\x05 \x01(\x0c\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3' + b'\n3temporal/sdk/core/external_data/external_data.proto\x12\x15\x63oresdk.external_data\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xb2\x02\n\x17LocalActivityMarkerData\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x03 \x01(\t\x12\x15\n\ractivity_type\x18\x04 \x01(\t\x12\x31\n\rcomplete_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12*\n\x07\x62\x61\x63koff\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12:\n\x16original_schedule_time\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x1d\n\x10\x61\x63tivation_index\x18\x08 \x01(\x04H\x00\x88\x01\x01\x42\x13\n\x11_activation_index"3\n\x11PatchedMarkerData\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08\x42\x32\xea\x02/Temporalio::Internal::Bridge::Api::ExternalDatab\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -28,24 +27,8 @@ DESCRIPTOR._serialized_options = ( b"\352\002/Temporalio::Internal::Bridge::Api::ExternalData" ) - _LOCALACTIVITYMARKERDATA._serialized_start = 173 - _LOCALACTIVITYMARKERDATA._serialized_end = 479 - _PATCHEDMARKERDATA._serialized_start = 481 - _PATCHEDMARKERDATA._serialized_end = 532 - _STREAMLEDGER._serialized_start = 535 - _STREAMLEDGER._serialized_end = 788 - _STREAMCLOSEINTENT._serialized_start = 790 - _STREAMCLOSEINTENT._serialized_end = 856 - _STREAMAPPENDRESULT._serialized_start = 859 - _STREAMAPPENDRESULT._serialized_end = 1083 - _STREAMAPPENDOFFSETS._serialized_start = 1085 - _STREAMAPPENDOFFSETS._serialized_end = 1149 - _STREAMFAILURE._serialized_start = 1151 - _STREAMFAILURE._serialized_end = 1199 - _STREAMCLOSERESULT._serialized_start = 1201 - _STREAMCLOSERESULT._serialized_end = 1314 - _STREAMREADRESULT._serialized_start = 1317 - _STREAMREADRESULT._serialized_end = 1596 - _STREAMREADPAGE._serialized_start = 1598 - _STREAMREADPAGE._serialized_end = 1709 + _LOCALACTIVITYMARKERDATA._serialized_start = 144 + _LOCALACTIVITYMARKERDATA._serialized_end = 450 + _PATCHEDMARKERDATA._serialized_start = 452 + _PATCHEDMARKERDATA._serialized_end = 503 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/external_data/external_data_pb2.pyi b/temporalio/bridge/proto/external_data/external_data_pb2.pyi index 8911644cd7..edcd4581a1 100644 --- a/temporalio/bridge/proto/external_data/external_data_pb2.pyi +++ b/temporalio/bridge/proto/external_data/external_data_pb2.pyi @@ -4,13 +4,10 @@ isort:skip_file """ import builtins -import collections.abc import typing import google.protobuf.descriptor import google.protobuf.duration_pb2 -import google.protobuf.empty_pb2 -import google.protobuf.internal.containers import google.protobuf.message import google.protobuf.timestamp_pb2 @@ -142,382 +139,3 @@ class PatchedMarkerData(google.protobuf.message.Message): ) -> None: ... global___PatchedMarkerData = PatchedMarkerData - -@typing.final -class StreamLedger(google.protobuf.message.Message): - """The ledger of a Workflow Task, which has the results and the close intents of its Stream calls. - Core puts it on the completion of each task in which Workflow code got a Stream result or asked - for a close, as the protobuf encoding of this message in the `core_stream_calls` of the - `sdk_metadata`. - - Every later version of Core must read the ledgers in History, so these rules apply to each - message of the ledger. - * A field keeps its number and its type. - * The default value of a new field means what an older ledger meant, since an older ledger - decodes to that value. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - CLOSE_INTENTS_FIELD_NUMBER: builtins.int - APPENDS_FIELD_NUMBER: builtins.int - CLOSES_FIELD_NUMBER: builtins.int - READS_FIELD_NUMBER: builtins.int - @property - def close_intents( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___StreamCloseIntent - ]: ... - @property - def appends( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___StreamAppendResult - ]: ... - @property - def closes( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___StreamCloseResult - ]: ... - @property - def reads( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___StreamReadResult - ]: ... - def __init__( - self, - *, - close_intents: collections.abc.Iterable[global___StreamCloseIntent] - | None = ..., - appends: collections.abc.Iterable[global___StreamAppendResult] | None = ..., - closes: collections.abc.Iterable[global___StreamCloseResult] | None = ..., - reads: collections.abc.Iterable[global___StreamReadResult] | None = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "appends", - b"appends", - "close_intents", - b"close_intents", - "closes", - b"closes", - "reads", - b"reads", - ], - ) -> None: ... - -global___StreamLedger = StreamLedger - -@typing.final -class StreamCloseIntent(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 - seq: builtins.int - stream_id: builtins.str - store: builtins.str - """The Store name of the Stream's ref.""" - def __init__( - self, - *, - seq: builtins.int = ..., - stream_id: builtins.str = ..., - store: builtins.str = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "seq", b"seq", "store", b"store", "stream_id", b"stream_id" - ], - ) -> None: ... - -global___StreamCloseIntent = StreamCloseIntent - -@typing.final -class StreamAppendResult(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 - APPENDED_FIELD_NUMBER: builtins.int - FAILURE_FIELD_NUMBER: builtins.int - seq: builtins.int - stream_id: builtins.str - store: builtins.str - """The Store name of the Stream's ref.""" - activation_index: builtins.int - """The index of the activation, within its Workflow Task, in which Workflow code got the result.""" - @property - def appended(self) -> global___StreamAppendOffsets: ... - @property - def failure(self) -> global___StreamFailure: ... - def __init__( - self, - *, - seq: builtins.int = ..., - stream_id: builtins.str = ..., - store: builtins.str = ..., - activation_index: builtins.int = ..., - appended: global___StreamAppendOffsets | None = ..., - failure: global___StreamFailure | None = ..., - ) -> None: ... - def HasField( - self, - field_name: typing.Literal[ - "appended", b"appended", "failure", b"failure", "result", b"result" - ], - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "activation_index", - b"activation_index", - "appended", - b"appended", - "failure", - b"failure", - "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["appended", "failure"] | None: ... - -global___StreamAppendResult = StreamAppendResult - -@typing.final -class StreamAppendOffsets(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - FIRST_OFFSET_FIELD_NUMBER: builtins.int - LAST_OFFSET_FIELD_NUMBER: builtins.int - first_offset: builtins.bytes - last_offset: builtins.bytes - def __init__( - self, - *, - first_offset: builtins.bytes = ..., - last_offset: builtins.bytes = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "first_offset", b"first_offset", "last_offset", b"last_offset" - ], - ) -> None: ... - -global___StreamAppendOffsets = StreamAppendOffsets - -@typing.final -class StreamFailure(google.protobuf.message.Message): - """Why a Stream call failed. Core builds the failure that Workflow code gets from these two.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - REASON_FIELD_NUMBER: builtins.int - MESSAGE_FIELD_NUMBER: builtins.int - reason: builtins.str - """The name of the `temporalio.api.enums.v1.StreamErrorReason`, such as - `STREAM_ERROR_REASON_CLOSED`. History stores the name, so a reason must never change its name. - """ - message: builtins.str - """The message of the failure, of at most 4096 bytes.""" - def __init__( - self, - *, - reason: builtins.str = ..., - message: builtins.str = ..., - ) -> None: ... - def ClearField( - self, field_name: typing.Literal["message", b"message", "reason", b"reason"] - ) -> None: ... - -global___StreamFailure = StreamFailure - -@typing.final -class StreamCloseResult(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - ACTIVATION_INDEX_FIELD_NUMBER: builtins.int - FAILURE_FIELD_NUMBER: builtins.int - seq: builtins.int - activation_index: builtins.int - """The index of the activation, within its Workflow Task, in which Workflow code got the result.""" - @property - def failure(self) -> global___StreamFailure: - """Unset if the Stream is closed.""" - - def __init__( - self, - *, - seq: builtins.int = ..., - activation_index: builtins.int = ..., - failure: global___StreamFailure | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["failure", b"failure"] - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "activation_index", - b"activation_index", - "failure", - b"failure", - "seq", - b"seq", - ], - ) -> None: ... - -global___StreamCloseResult = StreamCloseResult - -@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 - FROM_OFFSET_FIELD_NUMBER: builtins.int - PAGE_FIELD_NUMBER: builtins.int - FAILURE_FIELD_NUMBER: builtins.int - CANCELLED_FIELD_NUMBER: builtins.int - seq: builtins.int - stream_id: builtins.str - store: builtins.str - """The Store name of the Stream's ref.""" - activation_index: builtins.int - """The index of the activation, within its Workflow Task, in which Workflow code got the result.""" - from_offset: builtins.bytes - """The `from_offset` of the read. A replay reads the Records of a page after it.""" - @property - def page(self) -> global___StreamReadPage: ... - @property - def failure(self) -> global___StreamFailure: ... - @property - def cancelled(self) -> google.protobuf.empty_pb2.Empty: - """Workflow code cancelled the read before it got the job of the read.""" - - def __init__( - self, - *, - seq: builtins.int = ..., - stream_id: builtins.str = ..., - store: builtins.str = ..., - activation_index: builtins.int = ..., - from_offset: builtins.bytes = ..., - page: global___StreamReadPage | None = ..., - failure: global___StreamFailure | None = ..., - cancelled: google.protobuf.empty_pb2.Empty | None = ..., - ) -> None: ... - def HasField( - self, - field_name: typing.Literal[ - "cancelled", - b"cancelled", - "failure", - b"failure", - "page", - b"page", - "result", - b"result", - ], - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "activation_index", - b"activation_index", - "cancelled", - b"cancelled", - "failure", - b"failure", - "from_offset", - b"from_offset", - "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", "cancelled"] | None: ... - -global___StreamReadResult = StreamReadResult - -@typing.final -class StreamReadPage(google.protobuf.message.Message): - """A page that a read gave Workflow code.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - RECORD_COUNT_FIELD_NUMBER: builtins.int - DONE_FIELD_NUMBER: builtins.int - DIGEST_FIELD_NUMBER: builtins.int - RECORD_BYTES_FIELD_NUMBER: builtins.int - LAST_OFFSET_FIELD_NUMBER: builtins.int - record_count: builtins.int - """The number of Records in the page.""" - done: builtins.bool - """True if the Stream was closed and had no Record after this page.""" - digest: builtins.bytes - """The first 16 bytes of the SHA-256 of the Records. It's empty if the page has no Record.""" - record_bytes: builtins.int - """The bytes of the Records, each as a page of a read encodes it, with the tag and the length of - its field. That is the measure of the `max_bytes` of a read. It's set when `digest` is, so a - replay knows how much it reads. - """ - last_offset: builtins.bytes - """The `last_offset` that Workflow code got with the page. A replay gives the same value, since - another read of the Store can end at another offset. - """ - def __init__( - self, - *, - record_count: builtins.int = ..., - done: builtins.bool = ..., - digest: builtins.bytes = ..., - record_bytes: builtins.int = ..., - last_offset: builtins.bytes = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "digest", - b"digest", - "done", - b"done", - "last_offset", - b"last_offset", - "record_bytes", - b"record_bytes", - "record_count", - b"record_count", - ], - ) -> None: ... - -global___StreamReadPage = StreamReadPage diff --git a/temporalio/bridge/proto/workflow_activation/__init__.py b/temporalio/bridge/proto/workflow_activation/__init__.py index 6db42d326e..5c178e2185 100644 --- a/temporalio/bridge/proto/workflow_activation/__init__.py +++ b/temporalio/bridge/proto/workflow_activation/__init__.py @@ -16,12 +16,7 @@ ResolveNexusOperationStart, ResolveRequestCancelExternalWorkflow, ResolveSignalExternalWorkflow, - ResolveStreamAppend, - ResolveStreamClose, - ResolveStreamRead, SignalWorkflow, - StreamAppended, - StreamPage, UpdateRandomSeed, WorkflowActivation, WorkflowActivationJob, @@ -45,12 +40,7 @@ "ResolveNexusOperationStart", "ResolveRequestCancelExternalWorkflow", "ResolveSignalExternalWorkflow", - "ResolveStreamAppend", - "ResolveStreamClose", - "ResolveStreamRead", "SignalWorkflow", - "StreamAppended", - "StreamPage", "UpdateRandomSeed", "WorkflowActivation", "WorkflowActivationJob", diff --git a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py index 86fc4d33c1..589119c72b 100644 --- a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py +++ b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.py @@ -32,9 +32,6 @@ from temporalio.api.nexus.v1 import ( message_pb2 as temporal_dot_api_dot_nexus_dot_v1_dot_message__pb2, ) -from temporalio.api.stream.v1 import ( - message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, -) from temporalio.api.update.v1 import ( message_pb2 as temporal_dot_api_dot_update_dot_v1_dot_message__pb2, ) @@ -52,7 +49,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n?temporal/sdk/core/workflow_activation/workflow_activation.proto\x12\x1b\x63oresdk.workflow_activation\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a%temporal/api/failure/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a$temporal/api/update/v1/message.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/stream/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a\x37temporal/sdk/core/activity_result/activity_result.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a#temporal/sdk/core/nexus/nexus.proto"\xa2\x04\n\x12WorkflowActivation\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0cis_replaying\x18\x03 \x01(\x08\x12\x16\n\x0ehistory_length\x18\x04 \x01(\r\x12@\n\x04jobs\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.WorkflowActivationJob\x12 \n\x18\x61vailable_internal_flags\x18\x06 \x03(\r\x12\x1a\n\x12history_size_bytes\x18\x07 \x01(\x04\x12!\n\x19\x63ontinue_as_new_suggested\x18\x08 \x01(\x08\x12T\n#deployment_version_for_current_task\x18\t \x01(\x0b\x32\'.coresdk.common.WorkerDeploymentVersion\x12\x18\n\x10last_sdk_version\x18\n \x01(\t\x12Z\n\x1fsuggest_continue_as_new_reasons\x18\x0b \x03(\x0e\x32\x31.temporal.api.enums.v1.SuggestContinueAsNewReason\x12\x30\n(target_worker_deployment_version_changed\x18\x0c \x01(\x08"\xd3\x0c\n\x15WorkflowActivationJob\x12N\n\x13initialize_workflow\x18\x01 \x01(\x0b\x32/.coresdk.workflow_activation.InitializeWorkflowH\x00\x12<\n\nfire_timer\x18\x02 \x01(\x0b\x32&.coresdk.workflow_activation.FireTimerH\x00\x12K\n\x12update_random_seed\x18\x04 \x01(\x0b\x32-.coresdk.workflow_activation.UpdateRandomSeedH\x00\x12\x44\n\x0equery_workflow\x18\x05 \x01(\x0b\x32*.coresdk.workflow_activation.QueryWorkflowH\x00\x12\x46\n\x0f\x63\x61ncel_workflow\x18\x06 \x01(\x0b\x32+.coresdk.workflow_activation.CancelWorkflowH\x00\x12\x46\n\x0fsignal_workflow\x18\x07 \x01(\x0b\x32+.coresdk.workflow_activation.SignalWorkflowH\x00\x12H\n\x10resolve_activity\x18\x08 \x01(\x0b\x32,.coresdk.workflow_activation.ResolveActivityH\x00\x12G\n\x10notify_has_patch\x18\t \x01(\x0b\x32+.coresdk.workflow_activation.NotifyHasPatchH\x00\x12q\n&resolve_child_workflow_execution_start\x18\n \x01(\x0b\x32?.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartH\x00\x12\x66\n resolve_child_workflow_execution\x18\x0b \x01(\x0b\x32:.coresdk.workflow_activation.ResolveChildWorkflowExecutionH\x00\x12\x66\n resolve_signal_external_workflow\x18\x0c \x01(\x0b\x32:.coresdk.workflow_activation.ResolveSignalExternalWorkflowH\x00\x12u\n(resolve_request_cancel_external_workflow\x18\r \x01(\x0b\x32\x41.coresdk.workflow_activation.ResolveRequestCancelExternalWorkflowH\x00\x12:\n\tdo_update\x18\x0e \x01(\x0b\x32%.coresdk.workflow_activation.DoUpdateH\x00\x12`\n\x1dresolve_nexus_operation_start\x18\x0f \x01(\x0b\x32\x37.coresdk.workflow_activation.ResolveNexusOperationStartH\x00\x12U\n\x17resolve_nexus_operation\x18\x10 \x01(\x0b\x32\x32.coresdk.workflow_activation.ResolveNexusOperationH\x00\x12M\n\x13resolve_stream_read\x18\x11 \x01(\x0b\x32..coresdk.workflow_activation.ResolveStreamReadH\x00\x12Q\n\x15resolve_stream_append\x18\x12 \x01(\x0b\x32\x30.coresdk.workflow_activation.ResolveStreamAppendH\x00\x12O\n\x14resolve_stream_close\x18\x13 \x01(\x0b\x32/.coresdk.workflow_activation.ResolveStreamCloseH\x00\x12I\n\x11remove_from_cache\x18\x32 \x01(\x0b\x32,.coresdk.workflow_activation.RemoveFromCacheH\x00\x42\t\n\x07variant"\xe3\x0b\n\x12InitializeWorkflow\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x17\n\x0frandomness_seed\x18\x04 \x01(\x04\x12M\n\x07headers\x18\x05 \x03(\x0b\x32<.coresdk.workflow_activation.InitializeWorkflow.HeadersEntry\x12\x10\n\x08identity\x18\x06 \x01(\t\x12I\n\x14parent_workflow_info\x18\x07 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12=\n\x1aworkflow_execution_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\'\n\x1f\x63ontinued_from_execution_run_id\x18\x0b \x01(\t\x12J\n\x13\x63ontinued_initiator\x18\x0c \x01(\x0e\x32-.temporal.api.enums.v1.ContinueAsNewInitiator\x12;\n\x11\x63ontinued_failure\x18\r \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12@\n\x16last_completion_result\x18\x0e \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x1e\n\x16\x66irst_execution_run_id\x18\x0f \x01(\t\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x0f\n\x07\x61ttempt\x18\x11 \x01(\x05\x12\x15\n\rcron_schedule\x18\x12 \x01(\t\x12\x46\n"workflow_execution_expiration_time\x18\x13 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x45\n"cron_schedule_to_schedule_interval\x18\x14 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x04memo\x18\x15 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\x12\x43\n\x11search_attributes\x18\x16 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12.\n\nstart_time\x18\x17 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\rroot_workflow\x18\x18 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x32\n\x08priority\x18\x19 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12!\n\x19original_execution_run_id\x18\x1a \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x1b \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x18\n\tFireTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"m\n\x0fResolveActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.activity_result.ActivityResolution\x12\x10\n\x08is_local\x18\x03 \x01(\x08"\xd1\x02\n"ResolveChildWorkflowExecutionStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12[\n\tsucceeded\x18\x02 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartSuccessH\x00\x12X\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartFailureH\x00\x12]\n\tcancelled\x18\x04 \x01(\x0b\x32H.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartCancelledH\x00\x42\x08\n\x06status";\n)ResolveChildWorkflowExecutionStartSuccess\x12\x0e\n\x06run_id\x18\x01 \x01(\t"\xa6\x01\n)ResolveChildWorkflowExecutionStartFailure\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12M\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32>.coresdk.child_workflow.StartChildWorkflowExecutionFailedCause"`\n+ResolveChildWorkflowExecutionStartCancelled\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"i\n\x1dResolveChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.child_workflow.ChildWorkflowResult"+\n\x10UpdateRandomSeed\x12\x17\n\x0frandomness_seed\x18\x01 \x01(\x04"\x84\x02\n\rQueryWorkflow\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12\x12\n\nquery_type\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12H\n\x07headers\x18\x05 \x03(\x0b\x32\x37.coresdk.workflow_activation.QueryWorkflow.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01" \n\x0e\x43\x61ncelWorkflow\x12\x0e\n\x06reason\x18\x01 \x01(\t"\xa1\x02\n\x0eSignalWorkflow\x12\x13\n\x0bsignal_name\x18\x01 \x01(\t\x12.\n\x05input\x18\x02 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x10\n\x08identity\x18\x03 \x01(\t\x12I\n\x07headers\x18\x05 \x03(\x0b\x32\x38.coresdk.workflow_activation.SignalWorkflow.HeadersEntry\x12\x1c\n\x14originating_event_id\x18\x06 \x01(\x03\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01""\n\x0eNotifyHasPatch\x12\x10\n\x08patch_id\x18\x01 \x01(\t"\xb1\x01\n\x1dResolveSignalExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.SignalExternalWorkflowExecutionFailedCause"\xb8\x01\n$ResolveRequestCancelExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.CancelExternalWorkflowExecutionFailedCause"\xb2\x03\n\x08\x44oUpdate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\x05input\x18\x04 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x43\n\x07headers\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.DoUpdate.HeadersEntry\x12*\n\x04meta\x18\x06 \x01(\x0b\x32\x1c.temporal.api.update.v1.Meta\x12\x15\n\rrun_validator\x18\x07 \x01(\x08\x12\x65\n&propagated_nexus_serialization_context\x18\x08 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x9a\x01\n\x1aResolveNexusOperationStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x19\n\x0foperation_token\x18\x02 \x01(\tH\x00\x12\x16\n\x0cstarted_sync\x18\x03 \x01(\x08H\x00\x12\x32\n\x06\x66\x61iled\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status"Y\n\x15ResolveNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x33\n\x06result\x18\x02 \x01(\x0b\x32#.coresdk.nexus.NexusOperationResult"\xe0\x02\n\x0fRemoveFromCache\x12\x0f\n\x07message\x18\x01 \x01(\t\x12K\n\x06reason\x18\x02 \x01(\x0e\x32;.coresdk.workflow_activation.RemoveFromCache.EvictionReason"\xee\x01\n\x0e\x45victionReason\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCACHE_FULL\x10\x01\x12\x0e\n\nCACHE_MISS\x10\x02\x12\x12\n\x0eNONDETERMINISM\x10\x03\x12\r\n\tLANG_FAIL\x10\x04\x12\x12\n\x0eLANG_REQUESTED\x10\x05\x12\x12\n\x0eTASK_NOT_FOUND\x10\x06\x12\x15\n\x11UNHANDLED_COMMAND\x10\x07\x12\t\n\x05\x46\x41TAL\x10\x08\x12\x1f\n\x1bPAGINATION_OR_HISTORY_FETCH\x10\t\x12\x1d\n\x19WORKFLOW_EXECUTION_ENDING\x10\n"\xc4\x01\n\x11ResolveStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x37\n\x04page\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_activation.StreamPageH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12+\n\tcancelled\x18\x04 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x42\x08\n\x06status"f\n\nStreamPage\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x13\n\x0blast_offset\x18\x03 \x01(\x0c"\xa1\x01\n\x13ResolveStreamAppend\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12?\n\x08\x61ppended\x18\x02 \x01(\x0b\x32+.coresdk.workflow_activation.StreamAppendedH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status";\n\x0eStreamAppended\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"S\n\x12ResolveStreamClose\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x30\n\x06\x66\x61iled\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.FailureB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowActivationb\x06proto3' + b'\n?temporal/sdk/core/workflow_activation/workflow_activation.proto\x12\x1b\x63oresdk.workflow_activation\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a%temporal/api/failure/v1/message.proto\x1a#temporal/api/nexus/v1/message.proto\x1a$temporal/api/update/v1/message.proto\x1a$temporal/api/common/v1/message.proto\x1a(temporal/api/enums/v1/failed_cause.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a\x37temporal/sdk/core/activity_result/activity_result.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a%temporal/sdk/core/common/common.proto\x1a#temporal/sdk/core/nexus/nexus.proto"\xa2\x04\n\x12WorkflowActivation\x12\x0e\n\x06run_id\x18\x01 \x01(\t\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0cis_replaying\x18\x03 \x01(\x08\x12\x16\n\x0ehistory_length\x18\x04 \x01(\r\x12@\n\x04jobs\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.WorkflowActivationJob\x12 \n\x18\x61vailable_internal_flags\x18\x06 \x03(\r\x12\x1a\n\x12history_size_bytes\x18\x07 \x01(\x04\x12!\n\x19\x63ontinue_as_new_suggested\x18\x08 \x01(\x08\x12T\n#deployment_version_for_current_task\x18\t \x01(\x0b\x32\'.coresdk.common.WorkerDeploymentVersion\x12\x18\n\x10last_sdk_version\x18\n \x01(\t\x12Z\n\x1fsuggest_continue_as_new_reasons\x18\x0b \x03(\x0e\x32\x31.temporal.api.enums.v1.SuggestContinueAsNewReason\x12\x30\n(target_worker_deployment_version_changed\x18\x0c \x01(\x08"\xe0\n\n\x15WorkflowActivationJob\x12N\n\x13initialize_workflow\x18\x01 \x01(\x0b\x32/.coresdk.workflow_activation.InitializeWorkflowH\x00\x12<\n\nfire_timer\x18\x02 \x01(\x0b\x32&.coresdk.workflow_activation.FireTimerH\x00\x12K\n\x12update_random_seed\x18\x04 \x01(\x0b\x32-.coresdk.workflow_activation.UpdateRandomSeedH\x00\x12\x44\n\x0equery_workflow\x18\x05 \x01(\x0b\x32*.coresdk.workflow_activation.QueryWorkflowH\x00\x12\x46\n\x0f\x63\x61ncel_workflow\x18\x06 \x01(\x0b\x32+.coresdk.workflow_activation.CancelWorkflowH\x00\x12\x46\n\x0fsignal_workflow\x18\x07 \x01(\x0b\x32+.coresdk.workflow_activation.SignalWorkflowH\x00\x12H\n\x10resolve_activity\x18\x08 \x01(\x0b\x32,.coresdk.workflow_activation.ResolveActivityH\x00\x12G\n\x10notify_has_patch\x18\t \x01(\x0b\x32+.coresdk.workflow_activation.NotifyHasPatchH\x00\x12q\n&resolve_child_workflow_execution_start\x18\n \x01(\x0b\x32?.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartH\x00\x12\x66\n resolve_child_workflow_execution\x18\x0b \x01(\x0b\x32:.coresdk.workflow_activation.ResolveChildWorkflowExecutionH\x00\x12\x66\n resolve_signal_external_workflow\x18\x0c \x01(\x0b\x32:.coresdk.workflow_activation.ResolveSignalExternalWorkflowH\x00\x12u\n(resolve_request_cancel_external_workflow\x18\r \x01(\x0b\x32\x41.coresdk.workflow_activation.ResolveRequestCancelExternalWorkflowH\x00\x12:\n\tdo_update\x18\x0e \x01(\x0b\x32%.coresdk.workflow_activation.DoUpdateH\x00\x12`\n\x1dresolve_nexus_operation_start\x18\x0f \x01(\x0b\x32\x37.coresdk.workflow_activation.ResolveNexusOperationStartH\x00\x12U\n\x17resolve_nexus_operation\x18\x10 \x01(\x0b\x32\x32.coresdk.workflow_activation.ResolveNexusOperationH\x00\x12I\n\x11remove_from_cache\x18\x32 \x01(\x0b\x32,.coresdk.workflow_activation.RemoveFromCacheH\x00\x42\t\n\x07variant"\xe3\x0b\n\x12InitializeWorkflow\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x17\n\x0frandomness_seed\x18\x04 \x01(\x04\x12M\n\x07headers\x18\x05 \x03(\x0b\x32<.coresdk.workflow_activation.InitializeWorkflow.HeadersEntry\x12\x10\n\x08identity\x18\x06 \x01(\t\x12I\n\x14parent_workflow_info\x18\x07 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12=\n\x1aworkflow_execution_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\'\n\x1f\x63ontinued_from_execution_run_id\x18\x0b \x01(\t\x12J\n\x13\x63ontinued_initiator\x18\x0c \x01(\x0e\x32-.temporal.api.enums.v1.ContinueAsNewInitiator\x12;\n\x11\x63ontinued_failure\x18\r \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12@\n\x16last_completion_result\x18\x0e \x01(\x0b\x32 .temporal.api.common.v1.Payloads\x12\x1e\n\x16\x66irst_execution_run_id\x18\x0f \x01(\t\x12\x39\n\x0cretry_policy\x18\x10 \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x0f\n\x07\x61ttempt\x18\x11 \x01(\x05\x12\x15\n\rcron_schedule\x18\x12 \x01(\t\x12\x46\n"workflow_execution_expiration_time\x18\x13 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x45\n"cron_schedule_to_schedule_interval\x18\x14 \x01(\x0b\x32\x19.google.protobuf.Duration\x12*\n\x04memo\x18\x15 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo\x12\x43\n\x11search_attributes\x18\x16 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12.\n\nstart_time\x18\x17 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12@\n\rroot_workflow\x18\x18 \x01(\x0b\x32).temporal.api.common.v1.WorkflowExecution\x12\x32\n\x08priority\x18\x19 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12!\n\x19original_execution_run_id\x18\x1a \x01(\t\x12\x65\n&propagated_nexus_serialization_context\x18\x1b \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x18\n\tFireTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"m\n\x0fResolveActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.activity_result.ActivityResolution\x12\x10\n\x08is_local\x18\x03 \x01(\x08"\xd1\x02\n"ResolveChildWorkflowExecutionStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12[\n\tsucceeded\x18\x02 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartSuccessH\x00\x12X\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32\x46.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartFailureH\x00\x12]\n\tcancelled\x18\x04 \x01(\x0b\x32H.coresdk.workflow_activation.ResolveChildWorkflowExecutionStartCancelledH\x00\x42\x08\n\x06status";\n)ResolveChildWorkflowExecutionStartSuccess\x12\x0e\n\x06run_id\x18\x01 \x01(\t"\xa6\x01\n)ResolveChildWorkflowExecutionStartFailure\x12\x13\n\x0bworkflow_id\x18\x01 \x01(\t\x12\x15\n\rworkflow_type\x18\x02 \x01(\t\x12M\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32>.coresdk.child_workflow.StartChildWorkflowExecutionFailedCause"`\n+ResolveChildWorkflowExecutionStartCancelled\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"i\n\x1dResolveChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12;\n\x06result\x18\x02 \x01(\x0b\x32+.coresdk.child_workflow.ChildWorkflowResult"+\n\x10UpdateRandomSeed\x12\x17\n\x0frandomness_seed\x18\x01 \x01(\x04"\x84\x02\n\rQueryWorkflow\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12\x12\n\nquery_type\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12H\n\x07headers\x18\x05 \x03(\x0b\x32\x37.coresdk.workflow_activation.QueryWorkflow.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01" \n\x0e\x43\x61ncelWorkflow\x12\x0e\n\x06reason\x18\x01 \x01(\t"\xa1\x02\n\x0eSignalWorkflow\x12\x13\n\x0bsignal_name\x18\x01 \x01(\t\x12.\n\x05input\x18\x02 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x10\n\x08identity\x18\x03 \x01(\t\x12I\n\x07headers\x18\x05 \x03(\x0b\x32\x38.coresdk.workflow_activation.SignalWorkflow.HeadersEntry\x12\x1c\n\x14originating_event_id\x18\x06 \x01(\x03\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01""\n\x0eNotifyHasPatch\x12\x10\n\x08patch_id\x18\x01 \x01(\t"\xb1\x01\n\x1dResolveSignalExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.SignalExternalWorkflowExecutionFailedCause"\xb8\x01\n$ResolveRequestCancelExternalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32 .temporal.api.failure.v1.Failure\x12P\n\x05\x63\x61use\x18\x03 \x01(\x0e\x32\x41.temporal.api.enums.v1.CancelExternalWorkflowExecutionFailedCause"\xb2\x03\n\x08\x44oUpdate\x12\n\n\x02id\x18\x01 \x01(\t\x12\x1c\n\x14protocol_instance_id\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12.\n\x05input\x18\x04 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x43\n\x07headers\x18\x05 \x03(\x0b\x32\x32.coresdk.workflow_activation.DoUpdate.HeadersEntry\x12*\n\x04meta\x18\x06 \x01(\x0b\x32\x1c.temporal.api.update.v1.Meta\x12\x15\n\rrun_validator\x18\x07 \x01(\x08\x12\x65\n&propagated_nexus_serialization_context\x18\x08 \x01(\x0b\x32\x35.temporal.api.nexus.v1.PropagatedSerializationContext\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x9a\x01\n\x1aResolveNexusOperationStart\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x19\n\x0foperation_token\x18\x02 \x01(\tH\x00\x12\x16\n\x0cstarted_sync\x18\x03 \x01(\x08H\x00\x12\x32\n\x06\x66\x61iled\x18\x04 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\x08\n\x06status"Y\n\x15ResolveNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x33\n\x06result\x18\x02 \x01(\x0b\x32#.coresdk.nexus.NexusOperationResult"\xe0\x02\n\x0fRemoveFromCache\x12\x0f\n\x07message\x18\x01 \x01(\t\x12K\n\x06reason\x18\x02 \x01(\x0e\x32;.coresdk.workflow_activation.RemoveFromCache.EvictionReason"\xee\x01\n\x0e\x45victionReason\x12\x0f\n\x0bUNSPECIFIED\x10\x00\x12\x0e\n\nCACHE_FULL\x10\x01\x12\x0e\n\nCACHE_MISS\x10\x02\x12\x12\n\x0eNONDETERMINISM\x10\x03\x12\r\n\tLANG_FAIL\x10\x04\x12\x12\n\x0eLANG_REQUESTED\x10\x05\x12\x12\n\x0eTASK_NOT_FOUND\x10\x06\x12\x15\n\x11UNHANDLED_COMMAND\x10\x07\x12\t\n\x05\x46\x41TAL\x10\x08\x12\x1f\n\x1bPAGINATION_OR_HISTORY_FETCH\x10\t\x12\x1d\n\x19WORKFLOW_EXECUTION_ENDING\x10\nB8\xea\x02\x35Temporalio::Internal::Bridge::Api::WorkflowActivationb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -70,66 +67,56 @@ _SIGNALWORKFLOW_HEADERSENTRY._serialized_options = b"8\001" _DOUPDATE_HEADERSENTRY._options = None _DOUPDATE_HEADERSENTRY._serialized_options = b"8\001" - _WORKFLOWACTIVATION._serialized_start = 649 - _WORKFLOWACTIVATION._serialized_end = 1195 - _WORKFLOWACTIVATIONJOB._serialized_start = 1198 - _WORKFLOWACTIVATIONJOB._serialized_end = 2817 - _INITIALIZEWORKFLOW._serialized_start = 2820 - _INITIALIZEWORKFLOW._serialized_end = 4327 - _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_start = 4248 - _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_end = 4327 - _FIRETIMER._serialized_start = 4329 - _FIRETIMER._serialized_end = 4353 - _RESOLVEACTIVITY._serialized_start = 4355 - _RESOLVEACTIVITY._serialized_end = 4464 - _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_start = 4467 - _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_end = 4804 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_start = 4806 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_end = 4865 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_start = 4868 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_end = 5034 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_start = 5036 - _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_end = 5132 - _RESOLVECHILDWORKFLOWEXECUTION._serialized_start = 5134 - _RESOLVECHILDWORKFLOWEXECUTION._serialized_end = 5239 - _UPDATERANDOMSEED._serialized_start = 5241 - _UPDATERANDOMSEED._serialized_end = 5284 - _QUERYWORKFLOW._serialized_start = 5287 - _QUERYWORKFLOW._serialized_end = 5547 - _QUERYWORKFLOW_HEADERSENTRY._serialized_start = 4248 - _QUERYWORKFLOW_HEADERSENTRY._serialized_end = 4327 - _CANCELWORKFLOW._serialized_start = 5549 - _CANCELWORKFLOW._serialized_end = 5581 - _SIGNALWORKFLOW._serialized_start = 5584 - _SIGNALWORKFLOW._serialized_end = 5873 - _SIGNALWORKFLOW_HEADERSENTRY._serialized_start = 4248 - _SIGNALWORKFLOW_HEADERSENTRY._serialized_end = 4327 - _NOTIFYHASPATCH._serialized_start = 5875 - _NOTIFYHASPATCH._serialized_end = 5909 - _RESOLVESIGNALEXTERNALWORKFLOW._serialized_start = 5912 - _RESOLVESIGNALEXTERNALWORKFLOW._serialized_end = 6089 - _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_start = 6092 - _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_end = 6276 - _DOUPDATE._serialized_start = 6279 - _DOUPDATE._serialized_end = 6713 - _DOUPDATE_HEADERSENTRY._serialized_start = 4248 - _DOUPDATE_HEADERSENTRY._serialized_end = 4327 - _RESOLVENEXUSOPERATIONSTART._serialized_start = 6716 - _RESOLVENEXUSOPERATIONSTART._serialized_end = 6870 - _RESOLVENEXUSOPERATION._serialized_start = 6872 - _RESOLVENEXUSOPERATION._serialized_end = 6961 - _REMOVEFROMCACHE._serialized_start = 6964 - _REMOVEFROMCACHE._serialized_end = 7316 - _REMOVEFROMCACHE_EVICTIONREASON._serialized_start = 7078 - _REMOVEFROMCACHE_EVICTIONREASON._serialized_end = 7316 - _RESOLVESTREAMREAD._serialized_start = 7319 - _RESOLVESTREAMREAD._serialized_end = 7515 - _STREAMPAGE._serialized_start = 7517 - _STREAMPAGE._serialized_end = 7619 - _RESOLVESTREAMAPPEND._serialized_start = 7622 - _RESOLVESTREAMAPPEND._serialized_end = 7783 - _STREAMAPPENDED._serialized_start = 7785 - _STREAMAPPENDED._serialized_end = 7844 - _RESOLVESTREAMCLOSE._serialized_start = 7846 - _RESOLVESTREAMCLOSE._serialized_end = 7929 + _WORKFLOWACTIVATION._serialized_start = 611 + _WORKFLOWACTIVATION._serialized_end = 1157 + _WORKFLOWACTIVATIONJOB._serialized_start = 1160 + _WORKFLOWACTIVATIONJOB._serialized_end = 2536 + _INITIALIZEWORKFLOW._serialized_start = 2539 + _INITIALIZEWORKFLOW._serialized_end = 4046 + _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_start = 3967 + _INITIALIZEWORKFLOW_HEADERSENTRY._serialized_end = 4046 + _FIRETIMER._serialized_start = 4048 + _FIRETIMER._serialized_end = 4072 + _RESOLVEACTIVITY._serialized_start = 4074 + _RESOLVEACTIVITY._serialized_end = 4183 + _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_start = 4186 + _RESOLVECHILDWORKFLOWEXECUTIONSTART._serialized_end = 4523 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_start = 4525 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTSUCCESS._serialized_end = 4584 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_start = 4587 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTFAILURE._serialized_end = 4753 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_start = 4755 + _RESOLVECHILDWORKFLOWEXECUTIONSTARTCANCELLED._serialized_end = 4851 + _RESOLVECHILDWORKFLOWEXECUTION._serialized_start = 4853 + _RESOLVECHILDWORKFLOWEXECUTION._serialized_end = 4958 + _UPDATERANDOMSEED._serialized_start = 4960 + _UPDATERANDOMSEED._serialized_end = 5003 + _QUERYWORKFLOW._serialized_start = 5006 + _QUERYWORKFLOW._serialized_end = 5266 + _QUERYWORKFLOW_HEADERSENTRY._serialized_start = 3967 + _QUERYWORKFLOW_HEADERSENTRY._serialized_end = 4046 + _CANCELWORKFLOW._serialized_start = 5268 + _CANCELWORKFLOW._serialized_end = 5300 + _SIGNALWORKFLOW._serialized_start = 5303 + _SIGNALWORKFLOW._serialized_end = 5592 + _SIGNALWORKFLOW_HEADERSENTRY._serialized_start = 3967 + _SIGNALWORKFLOW_HEADERSENTRY._serialized_end = 4046 + _NOTIFYHASPATCH._serialized_start = 5594 + _NOTIFYHASPATCH._serialized_end = 5628 + _RESOLVESIGNALEXTERNALWORKFLOW._serialized_start = 5631 + _RESOLVESIGNALEXTERNALWORKFLOW._serialized_end = 5808 + _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_start = 5811 + _RESOLVEREQUESTCANCELEXTERNALWORKFLOW._serialized_end = 5995 + _DOUPDATE._serialized_start = 5998 + _DOUPDATE._serialized_end = 6432 + _DOUPDATE_HEADERSENTRY._serialized_start = 3967 + _DOUPDATE_HEADERSENTRY._serialized_end = 4046 + _RESOLVENEXUSOPERATIONSTART._serialized_start = 6435 + _RESOLVENEXUSOPERATIONSTART._serialized_end = 6589 + _RESOLVENEXUSOPERATION._serialized_start = 6591 + _RESOLVENEXUSOPERATION._serialized_end = 6680 + _REMOVEFROMCACHE._serialized_start = 6683 + _REMOVEFROMCACHE._serialized_end = 7035 + _REMOVEFROMCACHE_EVICTIONREASON._serialized_start = 6797 + _REMOVEFROMCACHE_EVICTIONREASON._serialized_end = 7035 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi index 7b55db0be7..e55917d810 100644 --- a/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi +++ b/temporalio/bridge/proto/workflow_activation/workflow_activation_pb2.pyi @@ -13,7 +13,6 @@ import typing import google.protobuf.descriptor import google.protobuf.duration_pb2 -import google.protobuf.empty_pb2 import google.protobuf.internal.containers import google.protobuf.internal.enum_type_wrapper import google.protobuf.message @@ -24,7 +23,6 @@ import temporalio.api.enums.v1.failed_cause_pb2 import temporalio.api.enums.v1.workflow_pb2 import temporalio.api.failure.v1.message_pb2 import temporalio.api.nexus.v1.message_pb2 -import temporalio.api.stream.v1.message_pb2 import temporalio.api.update.v1.message_pb2 import temporalio.bridge.proto.activity_result.activity_result_pb2 import temporalio.bridge.proto.child_workflow.child_workflow_pb2 @@ -51,7 +49,7 @@ class WorkflowActivation(google.protobuf.message.Message): 3. random-seed-updates 4. signals/updates 5. all others - 6. local activity resolutions, then Stream results + 6. local activity resolutions 7. queries 8. evictions @@ -67,10 +65,6 @@ class WorkflowActivation(google.protobuf.message.Message): in that same activation (prime example: cancelling not-wait-for-cancel activities). So, we do this to ensure the LA resolution happens after that cancel (or whatever else it may be) as it normally would have when executing. - * The results of Stream calls go after the local activity resolutions, because a replay also - scans ahead for their ledger. Appends go first, then closes, then reads, and each kind is in - `seq` order. When a replay gives the results of several activations in one, the Stream results - keep the order of those activations, after all local activity resolutions. * Queries always go last (and, in fact, always come in their own activation) * Evictions also always come in their own activation @@ -256,9 +250,6 @@ class WorkflowActivationJob(google.protobuf.message.Message): DO_UPDATE_FIELD_NUMBER: builtins.int RESOLVE_NEXUS_OPERATION_START_FIELD_NUMBER: builtins.int RESOLVE_NEXUS_OPERATION_FIELD_NUMBER: builtins.int - RESOLVE_STREAM_READ_FIELD_NUMBER: builtins.int - RESOLVE_STREAM_APPEND_FIELD_NUMBER: builtins.int - RESOLVE_STREAM_CLOSE_FIELD_NUMBER: builtins.int REMOVE_FROM_CACHE_FIELD_NUMBER: builtins.int @property def initialize_workflow(self) -> global___InitializeWorkflow: @@ -333,18 +324,6 @@ class WorkflowActivationJob(google.protobuf.message.Message): def resolve_nexus_operation(self) -> global___ResolveNexusOperation: """A nexus operation resolved.""" - @property - def resolve_stream_read(self) -> global___ResolveStreamRead: - """A read of a Stream finished.""" - - @property - def resolve_stream_append(self) -> global___ResolveStreamAppend: - """An append to a Stream finished.""" - - @property - def resolve_stream_close(self) -> global___ResolveStreamClose: - """A close of a Stream finished.""" - @property def remove_from_cache(self) -> global___RemoveFromCache: """Remove the workflow identified by the [WorkflowActivation] containing this job from the @@ -374,9 +353,6 @@ class WorkflowActivationJob(google.protobuf.message.Message): do_update: global___DoUpdate | None = ..., resolve_nexus_operation_start: global___ResolveNexusOperationStart | None = ..., resolve_nexus_operation: global___ResolveNexusOperation | None = ..., - resolve_stream_read: global___ResolveStreamRead | None = ..., - resolve_stream_append: global___ResolveStreamAppend | None = ..., - resolve_stream_close: global___ResolveStreamClose | None = ..., remove_from_cache: global___RemoveFromCache | None = ..., ) -> None: ... def HasField( @@ -410,12 +386,6 @@ class WorkflowActivationJob(google.protobuf.message.Message): b"resolve_request_cancel_external_workflow", "resolve_signal_external_workflow", b"resolve_signal_external_workflow", - "resolve_stream_append", - b"resolve_stream_append", - "resolve_stream_close", - b"resolve_stream_close", - "resolve_stream_read", - b"resolve_stream_read", "signal_workflow", b"signal_workflow", "update_random_seed", @@ -455,12 +425,6 @@ class WorkflowActivationJob(google.protobuf.message.Message): b"resolve_request_cancel_external_workflow", "resolve_signal_external_workflow", b"resolve_signal_external_workflow", - "resolve_stream_append", - b"resolve_stream_append", - "resolve_stream_close", - b"resolve_stream_close", - "resolve_stream_read", - b"resolve_stream_read", "signal_workflow", b"signal_workflow", "update_random_seed", @@ -488,9 +452,6 @@ class WorkflowActivationJob(google.protobuf.message.Message): "do_update", "resolve_nexus_operation_start", "resolve_nexus_operation", - "resolve_stream_read", - "resolve_stream_append", - "resolve_stream_close", "remove_from_cache", ] | None @@ -1684,242 +1645,3 @@ class RemoveFromCache(google.protobuf.message.Message): ) -> None: ... global___RemoveFromCache = RemoveFromCache - -@typing.final -class ResolveStreamRead(google.protobuf.message.Message): - """The result of a `ReadStream`. A read gets at most one, and a read that lang cancelled gets one - too. It gets none only in the four cases that `ReadStream` lists. The activation rules of - `ResolveStreamAppend` apply to it too. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - PAGE_FIELD_NUMBER: builtins.int - FAILED_FIELD_NUMBER: builtins.int - CANCELLED_FIELD_NUMBER: builtins.int - seq: builtins.int - """The `seq` of the `ReadStream`.""" - @property - def page(self) -> global___StreamPage: ... - @property - def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: - """The failure of the read. It has the parts of the `failed` of a `ResolveStreamAppend`.""" - - @property - def cancelled(self) -> google.protobuf.empty_pb2.Empty: - """Core got a `RequestCancelStreamRead` for the read before lang got a job for it. The job - comes in the next activation after the cancel, or in the next Workflow Task if the task - in hand completes first. `RequestCancelStreamRead` says when a replay gives it. - """ - - def __init__( - self, - *, - seq: builtins.int = ..., - page: global___StreamPage | None = ..., - failed: temporalio.api.failure.v1.message_pb2.Failure | None = ..., - cancelled: google.protobuf.empty_pb2.Empty | None = ..., - ) -> None: ... - def HasField( - self, - field_name: typing.Literal[ - "cancelled", - b"cancelled", - "failed", - b"failed", - "page", - b"page", - "status", - b"status", - ], - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "cancelled", - b"cancelled", - "failed", - b"failed", - "page", - b"page", - "seq", - b"seq", - "status", - b"status", - ], - ) -> None: ... - def WhichOneof( - self, oneof_group: typing.Literal["status", b"status"] - ) -> typing.Literal["page", "failed", "cancelled"] | None: ... - -global___ResolveStreamRead = ResolveStreamRead - -@typing.final -class StreamPage(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - RECORDS_FIELD_NUMBER: builtins.int - DONE_FIELD_NUMBER: builtins.int - LAST_OFFSET_FIELD_NUMBER: builtins.int - done: builtins.bool - """True if the Stream is closed and has no Record after this page. It's false if the page has - no Record because none came within the `wait` of the read. - """ - last_offset: builtins.bytes - """The offset where the page ends, as the Store gave it. The next read can pass it as its - `from_offset`. It's set also for a page with no Record. - """ - @property - def records( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - temporalio.api.stream.v1.message_pb2.StreamRecord - ]: - """The Records of the page, in the order of the Stream. It's empty if no Record came within the - `wait` of the read, or if the Stream is closed and has no Record after the `from_offset` of - the read. - """ - - def __init__( - self, - *, - records: collections.abc.Iterable[ - temporalio.api.stream.v1.message_pb2.StreamRecord - ] - | None = ..., - done: builtins.bool = ..., - last_offset: builtins.bytes = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "done", b"done", "last_offset", b"last_offset", "records", b"records" - ], - ) -> None: ... - -global___StreamPage = StreamPage - -@typing.final -class ResolveStreamAppend(google.protobuf.message.Message): - """The result of an `AppendToStream`. Core gives each result in the next activation after the - Store answers, so each result can cost an activation. - - A replay gives each result in the same activation as the first run only if History has the flag - that turns workflow task chunking off. Without the flag, a replay keeps the order of the results - of a task, but it can give a result in another activation in two cases. - * A Workflow Task completes with no command, and the first activation of the next task has a - result. A replay takes the two tasks as one, and can give the results of the first two - activations of the second task in one. - * A Workflow Task starts with an Update that Workflow code rejects, which leaves no event. When - such a replay has no other job to give, it gives the results of History in one activation, in - the order of the first run, up to the first one whose call Workflow code hasn't made yet. - A task with only Stream calls replays in the same activations as a task with only Local - Activities. In a task with both, a result waits for each result of the other kind that the first - run gave before it, so its activations can differ from those of Local Activities alone. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - APPENDED_FIELD_NUMBER: builtins.int - FAILED_FIELD_NUMBER: builtins.int - seq: builtins.int - """The `seq` of the `AppendToStream`.""" - @property - def appended(self) -> global___StreamAppended: ... - @property - def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: - """The failure of the append. It has these parts. - * An `ApplicationFailureInfo` whose type is `stream_` plus the reason of the Stream error - in snake case, such as `stream_closed`. Its `non_retryable` is set. - * In its details, one `binary/protobuf` payload of a - `temporalio.api.stream.v1.StreamErrorDetails`. - * A message of at most 4096 bytes. - """ - - def __init__( - self, - *, - seq: builtins.int = ..., - appended: global___StreamAppended | None = ..., - failed: temporalio.api.failure.v1.message_pb2.Failure | None = ..., - ) -> None: ... - def HasField( - self, - field_name: typing.Literal[ - "appended", b"appended", "failed", b"failed", "status", b"status" - ], - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "appended", - b"appended", - "failed", - b"failed", - "seq", - b"seq", - "status", - b"status", - ], - ) -> None: ... - def WhichOneof( - self, oneof_group: typing.Literal["status", b"status"] - ) -> typing.Literal["appended", "failed"] | None: ... - -global___ResolveStreamAppend = ResolveStreamAppend - -@typing.final -class StreamAppended(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - FIRST_OFFSET_FIELD_NUMBER: builtins.int - LAST_OFFSET_FIELD_NUMBER: builtins.int - first_offset: builtins.bytes - last_offset: builtins.bytes - def __init__( - self, - *, - first_offset: builtins.bytes = ..., - last_offset: builtins.bytes = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "first_offset", b"first_offset", "last_offset", b"last_offset" - ], - ) -> None: ... - -global___StreamAppended = StreamAppended - -@typing.final -class ResolveStreamClose(google.protobuf.message.Message): - """The result of a `CloseStream`. The activation rules of `ResolveStreamAppend` apply to it too.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - FAILED_FIELD_NUMBER: builtins.int - seq: builtins.int - """The `seq` of the `CloseStream`.""" - @property - def failed(self) -> temporalio.api.failure.v1.message_pb2.Failure: - """Unset if the Stream is closed, also when it was already closed. When set, it has the same - parts as the `failed` of a `ResolveStreamAppend`. - """ - - def __init__( - self, - *, - seq: builtins.int = ..., - failed: temporalio.api.failure.v1.message_pb2.Failure | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["failed", b"failed"] - ) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["failed", b"failed", "seq", b"seq"] - ) -> None: ... - -global___ResolveStreamClose = ResolveStreamClose diff --git a/temporalio/bridge/proto/workflow_commands/__init__.py b/temporalio/bridge/proto/workflow_commands/__init__.py index e2cc730d8d..f599917afa 100644 --- a/temporalio/bridge/proto/workflow_commands/__init__.py +++ b/temporalio/bridge/proto/workflow_commands/__init__.py @@ -1,23 +1,19 @@ from .workflow_commands_pb2 import ( ActivityCancellationType, - AppendToStream, CancelChildWorkflowExecution, CancelSignalWorkflow, CancelTimer, CancelWorkflowExecution, - CloseStream, CompleteWorkflowExecution, ContinueAsNewWorkflowExecution, FailWorkflowExecution, ModifyWorkflowProperties, QueryResult, QuerySuccess, - ReadStream, RequestCancelActivity, RequestCancelExternalWorkflowExecution, RequestCancelLocalActivity, RequestCancelNexusOperation, - RequestCancelStreamRead, ScheduleActivity, ScheduleLocalActivity, ScheduleNexusOperation, @@ -32,24 +28,20 @@ __all__ = [ "ActivityCancellationType", - "AppendToStream", "CancelChildWorkflowExecution", "CancelSignalWorkflow", "CancelTimer", "CancelWorkflowExecution", - "CloseStream", "CompleteWorkflowExecution", "ContinueAsNewWorkflowExecution", "FailWorkflowExecution", "ModifyWorkflowProperties", "QueryResult", "QuerySuccess", - "ReadStream", "RequestCancelActivity", "RequestCancelExternalWorkflowExecution", "RequestCancelLocalActivity", "RequestCancelNexusOperation", - "RequestCancelStreamRead", "ScheduleActivity", "ScheduleLocalActivity", "ScheduleNexusOperation", diff --git a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py index 4c37f88f41..3573f36b11 100644 --- a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py +++ b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.py @@ -32,9 +32,6 @@ from temporalio.api.sdk.v1 import ( user_metadata_pb2 as temporal_dot_api_dot_sdk_dot_v1_dot_user__metadata__pb2, ) -from temporalio.api.stream.v1 import ( - message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, -) from temporalio.api.workflow.v1 import ( message_pb2 as temporal_dot_api_dot_workflow_dot_v1_dot_message__pb2, ) @@ -49,7 +46,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a,temporal/api/sdk/v1/event_group_marker.proto\x1a$temporal/api/stream/v1/message.proto\x1a&temporal/api/workflow/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a#temporal/sdk/core/nexus/nexus.proto\x1a%temporal/sdk/core/common/common.proto"\xc8\x12\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12\x42\n\x13\x65vent_group_markers\x18\x65 \x03(\x0b\x32%.temporal.api.sdk.v1.EventGroupMarker\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x12<\n\x0bread_stream\x18\x17 \x01(\x0b\x32%.coresdk.workflow_commands.ReadStreamH\x00\x12X\n\x1arequest_cancel_stream_read\x18\x18 \x01(\x0b\x32\x32.coresdk.workflow_commands.RequestCancelStreamReadH\x00\x12\x45\n\x10\x61ppend_to_stream\x18\x19 \x01(\x0b\x32).coresdk.workflow_commands.AppendToStreamH\x00\x12>\n\x0c\x63lose_stream\x18\x1a \x01(\x0b\x32&.coresdk.workflow_commands.CloseStreamH\x00\x42\t\n\x07variant"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"\xb8\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x10 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x93\x06\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12#\n\x1binclude_arguments_in_marker\x18\x0e \x01(\x08\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"\x92\x07\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12\x43\n\x11search_attributes\x18\x08 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12[\n\x1binitial_versioning_behavior\x18\x0b \x01(\x0e\x32\x36.temporal.api.enums.v1.ContinueAsNewVersioningBehavior\x12\x39\n\x16\x62\x61\x63koff_start_interval\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"L\n\x17\x43\x61ncelWorkflowExecution\x12\x31\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32 .temporal.api.common.v1.Payloads"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xe1\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12\x43\n\x11search_attributes\x18\x11 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x14 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12I\n\x13versioning_override\x18\x15 \x01(\x0b\x32,.temporal.api.workflow.v1.VersioningOverride\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"J\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\x12\x0e\n\x06reason\x18\x02 \x01(\t"\x8e\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12\x0e\n\x06reason\x18\x03 \x01(\t"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r"e\n\x1eUpsertWorkflowSearchAttributes\x12\x43\n\x11search_attributes\x18\x01 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response"\x9a\x04\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x12H\n\x11\x63\x61ncellation_type\x18\x08 \x01(\x0e\x32-.coresdk.nexus.NexusOperationCancellationType\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x81\x01\n\x0e\x41ppendToStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12/\n\x06\x62odies\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload"M\n\x0b\x43loseStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"\xb2\x01\n\nReadStream\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x31\n\x06stream\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\'\n\x04wait\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x13\n\x0bmax_records\x18\x05 \x01(\x05\x12\x11\n\tmax_bytes\x18\x06 \x01(\x03"&\n\x17RequestCancelStreamRead\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3' + b'\n;temporal/sdk/core/workflow_commands/workflow_commands.proto\x12\x19\x63oresdk.workflow_commands\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a$temporal/api/common/v1/message.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a%temporal/api/failure/v1/message.proto\x1a\'temporal/api/sdk/v1/user_metadata.proto\x1a,temporal/api/sdk/v1/event_group_marker.proto\x1a&temporal/api/workflow/v1/message.proto\x1a\x35temporal/sdk/core/child_workflow/child_workflow.proto\x1a#temporal/sdk/core/nexus/nexus.proto\x1a%temporal/sdk/core/common/common.proto"\xa9\x10\n\x0fWorkflowCommand\x12\x38\n\ruser_metadata\x18\x64 \x01(\x0b\x32!.temporal.api.sdk.v1.UserMetadata\x12\x42\n\x13\x65vent_group_markers\x18\x65 \x03(\x0b\x32%.temporal.api.sdk.v1.EventGroupMarker\x12<\n\x0bstart_timer\x18\x01 \x01(\x0b\x32%.coresdk.workflow_commands.StartTimerH\x00\x12H\n\x11schedule_activity\x18\x02 \x01(\x0b\x32+.coresdk.workflow_commands.ScheduleActivityH\x00\x12\x42\n\x10respond_to_query\x18\x03 \x01(\x0b\x32&.coresdk.workflow_commands.QueryResultH\x00\x12S\n\x17request_cancel_activity\x18\x04 \x01(\x0b\x32\x30.coresdk.workflow_commands.RequestCancelActivityH\x00\x12>\n\x0c\x63\x61ncel_timer\x18\x05 \x01(\x0b\x32&.coresdk.workflow_commands.CancelTimerH\x00\x12[\n\x1b\x63omplete_workflow_execution\x18\x06 \x01(\x0b\x32\x34.coresdk.workflow_commands.CompleteWorkflowExecutionH\x00\x12S\n\x17\x66\x61il_workflow_execution\x18\x07 \x01(\x0b\x32\x30.coresdk.workflow_commands.FailWorkflowExecutionH\x00\x12g\n"continue_as_new_workflow_execution\x18\x08 \x01(\x0b\x32\x39.coresdk.workflow_commands.ContinueAsNewWorkflowExecutionH\x00\x12W\n\x19\x63\x61ncel_workflow_execution\x18\t \x01(\x0b\x32\x32.coresdk.workflow_commands.CancelWorkflowExecutionH\x00\x12\x45\n\x10set_patch_marker\x18\n \x01(\x0b\x32).coresdk.workflow_commands.SetPatchMarkerH\x00\x12`\n\x1estart_child_workflow_execution\x18\x0b \x01(\x0b\x32\x36.coresdk.workflow_commands.StartChildWorkflowExecutionH\x00\x12\x62\n\x1f\x63\x61ncel_child_workflow_execution\x18\x0c \x01(\x0b\x32\x37.coresdk.workflow_commands.CancelChildWorkflowExecutionH\x00\x12w\n*request_cancel_external_workflow_execution\x18\r \x01(\x0b\x32\x41.coresdk.workflow_commands.RequestCancelExternalWorkflowExecutionH\x00\x12h\n"signal_external_workflow_execution\x18\x0e \x01(\x0b\x32:.coresdk.workflow_commands.SignalExternalWorkflowExecutionH\x00\x12Q\n\x16\x63\x61ncel_signal_workflow\x18\x0f \x01(\x0b\x32/.coresdk.workflow_commands.CancelSignalWorkflowH\x00\x12S\n\x17schedule_local_activity\x18\x10 \x01(\x0b\x32\x30.coresdk.workflow_commands.ScheduleLocalActivityH\x00\x12^\n\x1drequest_cancel_local_activity\x18\x11 \x01(\x0b\x32\x35.coresdk.workflow_commands.RequestCancelLocalActivityH\x00\x12\x66\n!upsert_workflow_search_attributes\x18\x12 \x01(\x0b\x32\x39.coresdk.workflow_commands.UpsertWorkflowSearchAttributesH\x00\x12Y\n\x1amodify_workflow_properties\x18\x13 \x01(\x0b\x32\x33.coresdk.workflow_commands.ModifyWorkflowPropertiesH\x00\x12\x44\n\x0fupdate_response\x18\x14 \x01(\x0b\x32).coresdk.workflow_commands.UpdateResponseH\x00\x12U\n\x18schedule_nexus_operation\x18\x15 \x01(\x0b\x32\x31.coresdk.workflow_commands.ScheduleNexusOperationH\x00\x12`\n\x1erequest_cancel_nexus_operation\x18\x16 \x01(\x0b\x32\x36.coresdk.workflow_commands.RequestCancelNexusOperationH\x00\x42\t\n\x07variant"S\n\nStartTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x38\n\x15start_to_fire_timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration"\x1a\n\x0b\x43\x61ncelTimer\x12\x0b\n\x03seq\x18\x01 \x01(\r"\xb8\x06\n\x10ScheduleActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12I\n\x07headers\x18\x06 \x03(\x0b\x32\x38.coresdk.workflow_commands.ScheduleActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x34\n\x11heartbeat_timeout\x18\x0b \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0c \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12\x1e\n\x16\x64o_not_eagerly_execute\x18\x0e \x01(\x08\x12;\n\x11versioning_intent\x18\x0f \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x10 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"\x93\x06\n\x15ScheduleLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x15\n\ractivity_type\x18\x03 \x01(\t\x12\x0f\n\x07\x61ttempt\x18\x04 \x01(\r\x12:\n\x16original_schedule_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12N\n\x07headers\x18\x06 \x03(\x0b\x32=.coresdk.workflow_commands.ScheduleLocalActivity.HeadersEntry\x12\x32\n\targuments\x18\x07 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x0cretry_policy\x18\x0b \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x38\n\x15local_retry_threshold\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x12N\n\x11\x63\x61ncellation_type\x18\r \x01(\x0e\x32\x33.coresdk.workflow_commands.ActivityCancellationType\x12#\n\x1binclude_arguments_in_marker\x18\x0e \x01(\x08\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"$\n\x15RequestCancelActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r")\n\x1aRequestCancelLocalActivity\x12\x0b\n\x03seq\x18\x01 \x01(\r"\x9c\x01\n\x0bQueryResult\x12\x10\n\x08query_id\x18\x01 \x01(\t\x12<\n\tsucceeded\x18\x02 \x01(\x0b\x32\'.coresdk.workflow_commands.QuerySuccessH\x00\x12\x32\n\x06\x66\x61iled\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x42\t\n\x07variant"A\n\x0cQuerySuccess\x12\x31\n\x08response\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"L\n\x19\x43ompleteWorkflowExecution\x12/\n\x06result\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"J\n\x15\x46\x61ilWorkflowExecution\x12\x31\n\x07\x66\x61ilure\x18\x01 \x01(\x0b\x32 .temporal.api.failure.v1.Failure"\x92\x07\n\x1e\x43ontinueAsNewWorkflowExecution\x12\x15\n\rworkflow_type\x18\x01 \x01(\t\x12\x12\n\ntask_queue\x18\x02 \x01(\t\x12\x32\n\targuments\x18\x03 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x37\n\x14workflow_run_timeout\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration\x12Q\n\x04memo\x18\x06 \x03(\x0b\x32\x43.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.MemoEntry\x12W\n\x07headers\x18\x07 \x03(\x0b\x32\x46.coresdk.workflow_commands.ContinueAsNewWorkflowExecution.HeadersEntry\x12\x43\n\x11search_attributes\x18\x08 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12\x39\n\x0cretry_policy\x18\t \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12;\n\x11versioning_intent\x18\n \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12[\n\x1binitial_versioning_behavior\x18\x0b \x01(\x0e\x32\x36.temporal.api.enums.v1.ContinueAsNewVersioningBehavior\x12\x39\n\x16\x62\x61\x63koff_start_interval\x18\x0c \x01(\x0b\x32\x19.google.protobuf.Duration\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"L\n\x17\x43\x61ncelWorkflowExecution\x12\x31\n\x07\x64\x65tails\x18\x01 \x01(\x0b\x32 .temporal.api.common.v1.Payloads"6\n\x0eSetPatchMarker\x12\x10\n\x08patch_id\x18\x01 \x01(\t\x12\x12\n\ndeprecated\x18\x02 \x01(\x08"\xe1\t\n\x1bStartChildWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x03 \x01(\t\x12\x15\n\rworkflow_type\x18\x04 \x01(\t\x12\x12\n\ntask_queue\x18\x05 \x01(\t\x12.\n\x05input\x18\x06 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12=\n\x1aworkflow_execution_timeout\x18\x07 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x37\n\x14workflow_run_timeout\x18\x08 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x38\n\x15workflow_task_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x46\n\x13parent_close_policy\x18\n \x01(\x0e\x32).coresdk.child_workflow.ParentClosePolicy\x12N\n\x18workflow_id_reuse_policy\x18\x0c \x01(\x0e\x32,.temporal.api.enums.v1.WorkflowIdReusePolicy\x12\x39\n\x0cretry_policy\x18\r \x01(\x0b\x32#.temporal.api.common.v1.RetryPolicy\x12\x15\n\rcron_schedule\x18\x0e \x01(\t\x12T\n\x07headers\x18\x0f \x03(\x0b\x32\x43.coresdk.workflow_commands.StartChildWorkflowExecution.HeadersEntry\x12N\n\x04memo\x18\x10 \x03(\x0b\x32@.coresdk.workflow_commands.StartChildWorkflowExecution.MemoEntry\x12\x43\n\x11search_attributes\x18\x11 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes\x12P\n\x11\x63\x61ncellation_type\x18\x12 \x01(\x0e\x32\x35.coresdk.child_workflow.ChildWorkflowCancellationType\x12;\n\x11versioning_intent\x18\x13 \x01(\x0e\x32 .coresdk.common.VersioningIntent\x12\x32\n\x08priority\x18\x14 \x01(\x0b\x32 .temporal.api.common.v1.Priority\x12I\n\x13versioning_override\x18\x15 \x01(\x0b\x32,.temporal.api.workflow.v1.VersioningOverride\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x1aL\n\tMemoEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01"J\n\x1c\x43\x61ncelChildWorkflowExecution\x12\x1a\n\x12\x63hild_workflow_seq\x18\x01 \x01(\r\x12\x0e\n\x06reason\x18\x02 \x01(\t"\x8e\x01\n&RequestCancelExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12G\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecution\x12\x0e\n\x06reason\x18\x03 \x01(\t"\x8f\x03\n\x1fSignalExternalWorkflowExecution\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12I\n\x12workflow_execution\x18\x02 \x01(\x0b\x32+.coresdk.common.NamespacedWorkflowExecutionH\x00\x12\x1b\n\x11\x63hild_workflow_id\x18\x03 \x01(\tH\x00\x12\x13\n\x0bsignal_name\x18\x04 \x01(\t\x12-\n\x04\x61rgs\x18\x05 \x03(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12X\n\x07headers\x18\x06 \x03(\x0b\x32G.coresdk.workflow_commands.SignalExternalWorkflowExecution.HeadersEntry\x1aO\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12.\n\x05value\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload:\x02\x38\x01\x42\x08\n\x06target"#\n\x14\x43\x61ncelSignalWorkflow\x12\x0b\n\x03seq\x18\x01 \x01(\r"e\n\x1eUpsertWorkflowSearchAttributes\x12\x43\n\x11search_attributes\x18\x01 \x01(\x0b\x32(.temporal.api.common.v1.SearchAttributes"O\n\x18ModifyWorkflowProperties\x12\x33\n\rupserted_memo\x18\x01 \x01(\x0b\x32\x1c.temporal.api.common.v1.Memo"\xd2\x01\n\x0eUpdateResponse\x12\x1c\n\x14protocol_instance_id\x18\x01 \x01(\t\x12*\n\x08\x61\x63\x63\x65pted\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x34\n\x08rejected\x18\x03 \x01(\x0b\x32 .temporal.api.failure.v1.FailureH\x00\x12\x34\n\tcompleted\x18\x04 \x01(\x0b\x32\x1f.temporal.api.common.v1.PayloadH\x00\x42\n\n\x08response"\x9a\x04\n\x16ScheduleNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r\x12\x10\n\x08\x65ndpoint\x18\x02 \x01(\t\x12\x0f\n\x07service\x18\x03 \x01(\t\x12\x11\n\toperation\x18\x04 \x01(\t\x12.\n\x05input\x18\x05 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12<\n\x19schedule_to_close_timeout\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12X\n\x0cnexus_header\x18\x07 \x03(\x0b\x32\x42.coresdk.workflow_commands.ScheduleNexusOperation.NexusHeaderEntry\x12H\n\x11\x63\x61ncellation_type\x18\x08 \x01(\x0e\x32-.coresdk.nexus.NexusOperationCancellationType\x12<\n\x19schedule_to_start_timeout\x18\t \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x39\n\x16start_to_close_timeout\x18\n \x01(\x0b\x32\x19.google.protobuf.Duration\x1a\x32\n\x10NexusHeaderEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"*\n\x1bRequestCancelNexusOperation\x12\x0b\n\x03seq\x18\x01 \x01(\r*X\n\x18\x41\x63tivityCancellationType\x12\x0e\n\nTRY_CANCEL\x10\x00\x12\x1f\n\x1bWAIT_CANCELLATION_COMPLETED\x10\x01\x12\x0b\n\x07\x41\x42\x41NDON\x10\x02\x42\x36\xea\x02\x33Temporalio::Internal::Bridge::Api::WorkflowCommandsb\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -75,78 +72,70 @@ _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_options = b"8\001" _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._options = None _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_options = b"8\001" - _ACTIVITYCANCELLATIONTYPE._serialized_start = 9542 - _ACTIVITYCANCELLATIONTYPE._serialized_end = 9630 - _WORKFLOWCOMMAND._serialized_start = 596 - _WORKFLOWCOMMAND._serialized_end = 2972 - _STARTTIMER._serialized_start = 2974 - _STARTTIMER._serialized_end = 3057 - _CANCELTIMER._serialized_start = 3059 - _CANCELTIMER._serialized_end = 3085 - _SCHEDULEACTIVITY._serialized_start = 3088 - _SCHEDULEACTIVITY._serialized_end = 3912 - _SCHEDULEACTIVITY_HEADERSENTRY._serialized_start = 3833 - _SCHEDULEACTIVITY_HEADERSENTRY._serialized_end = 3912 - _SCHEDULELOCALACTIVITY._serialized_start = 3915 - _SCHEDULELOCALACTIVITY._serialized_end = 4702 - _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_start = 3833 - _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_end = 3912 - _REQUESTCANCELACTIVITY._serialized_start = 4704 - _REQUESTCANCELACTIVITY._serialized_end = 4740 - _REQUESTCANCELLOCALACTIVITY._serialized_start = 4742 - _REQUESTCANCELLOCALACTIVITY._serialized_end = 4783 - _QUERYRESULT._serialized_start = 4786 - _QUERYRESULT._serialized_end = 4942 - _QUERYSUCCESS._serialized_start = 4944 - _QUERYSUCCESS._serialized_end = 5009 - _COMPLETEWORKFLOWEXECUTION._serialized_start = 5011 - _COMPLETEWORKFLOWEXECUTION._serialized_end = 5087 - _FAILWORKFLOWEXECUTION._serialized_start = 5089 - _FAILWORKFLOWEXECUTION._serialized_end = 5163 - _CONTINUEASNEWWORKFLOWEXECUTION._serialized_start = 5166 - _CONTINUEASNEWWORKFLOWEXECUTION._serialized_end = 6080 - _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5923 - _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5999 - _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3833 - _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3912 - _CANCELWORKFLOWEXECUTION._serialized_start = 6082 - _CANCELWORKFLOWEXECUTION._serialized_end = 6158 - _SETPATCHMARKER._serialized_start = 6160 - _SETPATCHMARKER._serialized_end = 6214 - _STARTCHILDWORKFLOWEXECUTION._serialized_start = 6217 - _STARTCHILDWORKFLOWEXECUTION._serialized_end = 7466 - _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3833 - _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3912 - _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5923 - _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5999 - _CANCELCHILDWORKFLOWEXECUTION._serialized_start = 7468 - _CANCELCHILDWORKFLOWEXECUTION._serialized_end = 7542 - _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_start = 7545 - _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_end = 7687 - _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_start = 7690 - _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_end = 8089 - _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3833 - _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3912 - _CANCELSIGNALWORKFLOW._serialized_start = 8091 - _CANCELSIGNALWORKFLOW._serialized_end = 8126 - _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_start = 8128 - _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_end = 8229 - _MODIFYWORKFLOWPROPERTIES._serialized_start = 8231 - _MODIFYWORKFLOWPROPERTIES._serialized_end = 8310 - _UPDATERESPONSE._serialized_start = 8313 - _UPDATERESPONSE._serialized_end = 8523 - _SCHEDULENEXUSOPERATION._serialized_start = 8526 - _SCHEDULENEXUSOPERATION._serialized_end = 9064 - _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_start = 9014 - _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_end = 9064 - _REQUESTCANCELNEXUSOPERATION._serialized_start = 9066 - _REQUESTCANCELNEXUSOPERATION._serialized_end = 9108 - _APPENDTOSTREAM._serialized_start = 9111 - _APPENDTOSTREAM._serialized_end = 9240 - _CLOSESTREAM._serialized_start = 9242 - _CLOSESTREAM._serialized_end = 9319 - _READSTREAM._serialized_start = 9322 - _READSTREAM._serialized_end = 9500 - _REQUESTCANCELSTREAMREAD._serialized_start = 9502 - _REQUESTCANCELSTREAMREAD._serialized_end = 9540 + _ACTIVITYCANCELLATIONTYPE._serialized_start = 8785 + _ACTIVITYCANCELLATIONTYPE._serialized_end = 8873 + _WORKFLOWCOMMAND._serialized_start = 558 + _WORKFLOWCOMMAND._serialized_end = 2647 + _STARTTIMER._serialized_start = 2649 + _STARTTIMER._serialized_end = 2732 + _CANCELTIMER._serialized_start = 2734 + _CANCELTIMER._serialized_end = 2760 + _SCHEDULEACTIVITY._serialized_start = 2763 + _SCHEDULEACTIVITY._serialized_end = 3587 + _SCHEDULEACTIVITY_HEADERSENTRY._serialized_start = 3508 + _SCHEDULEACTIVITY_HEADERSENTRY._serialized_end = 3587 + _SCHEDULELOCALACTIVITY._serialized_start = 3590 + _SCHEDULELOCALACTIVITY._serialized_end = 4377 + _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_start = 3508 + _SCHEDULELOCALACTIVITY_HEADERSENTRY._serialized_end = 3587 + _REQUESTCANCELACTIVITY._serialized_start = 4379 + _REQUESTCANCELACTIVITY._serialized_end = 4415 + _REQUESTCANCELLOCALACTIVITY._serialized_start = 4417 + _REQUESTCANCELLOCALACTIVITY._serialized_end = 4458 + _QUERYRESULT._serialized_start = 4461 + _QUERYRESULT._serialized_end = 4617 + _QUERYSUCCESS._serialized_start = 4619 + _QUERYSUCCESS._serialized_end = 4684 + _COMPLETEWORKFLOWEXECUTION._serialized_start = 4686 + _COMPLETEWORKFLOWEXECUTION._serialized_end = 4762 + _FAILWORKFLOWEXECUTION._serialized_start = 4764 + _FAILWORKFLOWEXECUTION._serialized_end = 4838 + _CONTINUEASNEWWORKFLOWEXECUTION._serialized_start = 4841 + _CONTINUEASNEWWORKFLOWEXECUTION._serialized_end = 5755 + _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5598 + _CONTINUEASNEWWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5674 + _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3508 + _CONTINUEASNEWWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3587 + _CANCELWORKFLOWEXECUTION._serialized_start = 5757 + _CANCELWORKFLOWEXECUTION._serialized_end = 5833 + _SETPATCHMARKER._serialized_start = 5835 + _SETPATCHMARKER._serialized_end = 5889 + _STARTCHILDWORKFLOWEXECUTION._serialized_start = 5892 + _STARTCHILDWORKFLOWEXECUTION._serialized_end = 7141 + _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3508 + _STARTCHILDWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3587 + _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_start = 5598 + _STARTCHILDWORKFLOWEXECUTION_MEMOENTRY._serialized_end = 5674 + _CANCELCHILDWORKFLOWEXECUTION._serialized_start = 7143 + _CANCELCHILDWORKFLOWEXECUTION._serialized_end = 7217 + _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_start = 7220 + _REQUESTCANCELEXTERNALWORKFLOWEXECUTION._serialized_end = 7362 + _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_start = 7365 + _SIGNALEXTERNALWORKFLOWEXECUTION._serialized_end = 7764 + _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_start = 3508 + _SIGNALEXTERNALWORKFLOWEXECUTION_HEADERSENTRY._serialized_end = 3587 + _CANCELSIGNALWORKFLOW._serialized_start = 7766 + _CANCELSIGNALWORKFLOW._serialized_end = 7801 + _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_start = 7803 + _UPSERTWORKFLOWSEARCHATTRIBUTES._serialized_end = 7904 + _MODIFYWORKFLOWPROPERTIES._serialized_start = 7906 + _MODIFYWORKFLOWPROPERTIES._serialized_end = 7985 + _UPDATERESPONSE._serialized_start = 7988 + _UPDATERESPONSE._serialized_end = 8198 + _SCHEDULENEXUSOPERATION._serialized_start = 8201 + _SCHEDULENEXUSOPERATION._serialized_end = 8739 + _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_start = 8689 + _SCHEDULENEXUSOPERATION_NEXUSHEADERENTRY._serialized_end = 8739 + _REQUESTCANCELNEXUSOPERATION._serialized_start = 8741 + _REQUESTCANCELNEXUSOPERATION._serialized_end = 8783 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi index 01498fb016..81c47c0b03 100644 --- a/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi +++ b/temporalio/bridge/proto/workflow_commands/workflow_commands_pb2.pyi @@ -25,7 +25,6 @@ import temporalio.api.enums.v1.workflow_pb2 import temporalio.api.failure.v1.message_pb2 import temporalio.api.sdk.v1.event_group_marker_pb2 import temporalio.api.sdk.v1.user_metadata_pb2 -import temporalio.api.stream.v1.message_pb2 import temporalio.api.workflow.v1.message_pb2 import temporalio.bridge.proto.child_workflow.child_workflow_pb2 import temporalio.bridge.proto.common.common_pb2 @@ -106,10 +105,6 @@ class WorkflowCommand(google.protobuf.message.Message): UPDATE_RESPONSE_FIELD_NUMBER: builtins.int SCHEDULE_NEXUS_OPERATION_FIELD_NUMBER: builtins.int REQUEST_CANCEL_NEXUS_OPERATION_FIELD_NUMBER: builtins.int - READ_STREAM_FIELD_NUMBER: builtins.int - REQUEST_CANCEL_STREAM_READ_FIELD_NUMBER: builtins.int - APPEND_TO_STREAM_FIELD_NUMBER: builtins.int - CLOSE_STREAM_FIELD_NUMBER: builtins.int @property def user_metadata(self) -> temporalio.api.sdk.v1.user_metadata_pb2.UserMetadata: """User metadata that may or may not be persisted into history depending on the command type. @@ -186,14 +181,6 @@ class WorkflowCommand(google.protobuf.message.Message): def request_cancel_nexus_operation( self, ) -> global___RequestCancelNexusOperation: ... - @property - def read_stream(self) -> global___ReadStream: ... - @property - def request_cancel_stream_read(self) -> global___RequestCancelStreamRead: ... - @property - def append_to_stream(self) -> global___AppendToStream: ... - @property - def close_stream(self) -> global___CloseStream: ... def __init__( self, *, @@ -232,16 +219,10 @@ class WorkflowCommand(google.protobuf.message.Message): schedule_nexus_operation: global___ScheduleNexusOperation | None = ..., request_cancel_nexus_operation: global___RequestCancelNexusOperation | None = ..., - read_stream: global___ReadStream | None = ..., - request_cancel_stream_read: global___RequestCancelStreamRead | None = ..., - append_to_stream: global___AppendToStream | None = ..., - close_stream: global___CloseStream | None = ..., ) -> None: ... def HasField( self, field_name: typing.Literal[ - "append_to_stream", - b"append_to_stream", "cancel_child_workflow_execution", b"cancel_child_workflow_execution", "cancel_signal_workflow", @@ -250,8 +231,6 @@ class WorkflowCommand(google.protobuf.message.Message): b"cancel_timer", "cancel_workflow_execution", b"cancel_workflow_execution", - "close_stream", - b"close_stream", "complete_workflow_execution", b"complete_workflow_execution", "continue_as_new_workflow_execution", @@ -260,8 +239,6 @@ class WorkflowCommand(google.protobuf.message.Message): b"fail_workflow_execution", "modify_workflow_properties", b"modify_workflow_properties", - "read_stream", - b"read_stream", "request_cancel_activity", b"request_cancel_activity", "request_cancel_external_workflow_execution", @@ -270,8 +247,6 @@ class WorkflowCommand(google.protobuf.message.Message): b"request_cancel_local_activity", "request_cancel_nexus_operation", b"request_cancel_nexus_operation", - "request_cancel_stream_read", - b"request_cancel_stream_read", "respond_to_query", b"respond_to_query", "schedule_activity", @@ -301,8 +276,6 @@ class WorkflowCommand(google.protobuf.message.Message): def ClearField( self, field_name: typing.Literal[ - "append_to_stream", - b"append_to_stream", "cancel_child_workflow_execution", b"cancel_child_workflow_execution", "cancel_signal_workflow", @@ -311,8 +284,6 @@ class WorkflowCommand(google.protobuf.message.Message): b"cancel_timer", "cancel_workflow_execution", b"cancel_workflow_execution", - "close_stream", - b"close_stream", "complete_workflow_execution", b"complete_workflow_execution", "continue_as_new_workflow_execution", @@ -323,8 +294,6 @@ class WorkflowCommand(google.protobuf.message.Message): b"fail_workflow_execution", "modify_workflow_properties", b"modify_workflow_properties", - "read_stream", - b"read_stream", "request_cancel_activity", b"request_cancel_activity", "request_cancel_external_workflow_execution", @@ -333,8 +302,6 @@ class WorkflowCommand(google.protobuf.message.Message): b"request_cancel_local_activity", "request_cancel_nexus_operation", b"request_cancel_nexus_operation", - "request_cancel_stream_read", - b"request_cancel_stream_read", "respond_to_query", b"respond_to_query", "schedule_activity", @@ -387,10 +354,6 @@ class WorkflowCommand(google.protobuf.message.Message): "update_response", "schedule_nexus_operation", "request_cancel_nexus_operation", - "read_stream", - "request_cancel_stream_read", - "append_to_stream", - "close_stream", ] | None ): ... @@ -1968,262 +1931,3 @@ class RequestCancelNexusOperation(google.protobuf.message.Message): def ClearField(self, field_name: typing.Literal["seq", b"seq"]) -> None: ... global___RequestCancelNexusOperation = RequestCancelNexusOperation - -@typing.final -class AppendToStream(google.protobuf.message.Message): - """Appends Records to a Stream as the Workflow's Producer. Core makes the request id of the append - and sends the result in a `ResolveStreamAppend` job. History keeps the result in the ledger of - the Workflow Task in which lang got it, on the completion of that task. - - An append is at-least-once. A later attempt of the Workflow Task writes it again, on this Worker - or on another one. - - No command cancels an append, so lang must accept the job of an append that nothing awaits. - When lang sends the Workflow's last command, Core drops each append that has no result, as it - does for a Local Activity. Such an append may or may not have reached the Store, and lang gets - no job for it. - - Core sends the appends and the closes of one Stream to the Store one at a time, in the order of - their commands. A close gets its place in that order only when History has its intent. So an - append that lang sends after a `CloseStream`, but before History has the task of that close, is - written before the close. - - Core fails the Workflow Task in each of these cases, and gives lang no failure of the append. - * `seq` is 0, or isn't above the `seq` of the append before it. - * `stream` is unset, its id is empty or longer than 4096 bytes, or its Store name is longer than - 4096 bytes. - * The Worker has no Stream runtime for the Store of `stream`. - * The server doesn't take the `sdk_metadata` of a completion, so History can't keep the result. - * The append must wait for the task's heartbeat to try again, because the Store answered - `StoreUnavailable` or gave no answer. The failure message then starts with - `StreamStoreUnavailable:`. - - An append with no `bodies`, or with a batch over the limits of its Store, doesn't fail the - Workflow Task. Lang gets a `failed` job for it. - - In a replay, Core compares the `seq` and the `stream` of the command with History, but not the - `bodies`. A `stream` with no Store name matches any Store in History. An append with no result - in History runs again after the replay, as a later attempt, so a reader can see its batch twice. - - If lang completes the Workflow Task while an append has no result in a ledger, Core forces a new - task, unless the completion has the Workflow's last command. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - STREAM_FIELD_NUMBER: builtins.int - BODIES_FIELD_NUMBER: builtins.int - seq: builtins.int - """Lang's incremental sequence number for appends, starting at 1.""" - @property - def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... - @property - def bodies( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - temporalio.api.common.v1.message_pb2.Payload - ]: ... - def __init__( - self, - *, - seq: builtins.int = ..., - stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - bodies: collections.abc.Iterable[temporalio.api.common.v1.message_pb2.Payload] - | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["stream", b"stream"] - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "bodies", b"bodies", "seq", b"seq", "stream", b"stream" - ], - ) -> None: ... - -global___AppendToStream = AppendToStream - -@typing.final -class CloseStream(google.protobuf.message.Message): - """Closes a Stream. The Workflow Task that sends the command records only the intent to close. - Core closes the Stream when History has that task, and sends the result in a - `ResolveStreamClose` job of a later task. So a close needs at least one more Workflow Task. - - These rules of `AppendToStream` apply to a close too. - * No command cancels it. - * Core drops it if it has no result when lang sends the Workflow's last command. - * The same cases fail the Workflow Task. - * A replay compares the command with History in the same way. - * If lang completes the task while the close has no result in a ledger, Core forces a new task. - - Workflow code that needs its close must await the result before its last command. A close whose - intent is in History with no result runs again after a replay. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - STREAM_FIELD_NUMBER: builtins.int - seq: builtins.int - """Lang's incremental sequence number for closes, starting at 1.""" - @property - def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... - def __init__( - self, - *, - seq: builtins.int = ..., - stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["stream", b"stream"] - ) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["seq", b"seq", "stream", b"stream"] - ) -> None: ... - -global___CloseStream = CloseStream - -@typing.final -class ReadStream(google.protobuf.message.Message): - """Reads the next page of a Stream. The result comes in one `ResolveStreamRead` job, which has a - page, a failure or a cancel. Core asks the Store when the command comes, unless the Workflow - replays. A replay gives the read the result that History has for it. - - The page has the Records after `from_offset`, in the order of the Stream: - * the Records that the Stream has, or the first ones that come within `wait` - * no Records and `done`, if the Stream is closed and has none after `from_offset` - * no Records, if none came within `wait` - - To read on, lang sends a new `ReadStream` whose `from_offset` is the `last_offset` of the page. - - What a read costs: - * Each page takes a command, an activation and an entry in the ledger of its Workflow Task. - * A read holds its Workflow Task open while it waits for the Store, as a Local Activity does. A - Signal, a timer or an Activity result reaches Workflow code in the next task. The task in hand - completes once Workflow code sends a command for the server while only reads hold the task, - and at the latest at its heartbeat. A read that still waits adds the three events of a forced - Workflow Task at each heartbeat. - * One Workflow Task gives at most 16 MiB of Records. A page that doesn't fit comes in the next - task, which Core forces. - * History has the count and a digest of the Records of each page. A replay reads each page from - the Store again, within the timeout of its Workflow Task. A query of a run that isn't cached - replays too. Once the Store no longer has the same Records, each replay fails, also the one for - a query of a closed Workflow. - - A read gets no job at the Workflow's last command, at a failed Workflow Task, at an eviction and - at the shutdown of the Worker. After the last three the Workflow replays. The replay gives each - read the result that History has for it. A read with no result in History runs again once the - replay is over, unless Workflow code cancelled it. Such a read gets its `cancelled` job then. - - Core fails the Workflow Task, and gives lang no failure of the read, in the cases that - `AppendToStream` lists and in these: - * `from_offset` is longer than 1024 bytes. - * `wait` is negative, or has its nanoseconds out of range. - * `max_records` or `max_bytes` is negative. - - In a replay, Core compares the `seq`, the `stream` and the `from_offset` of the command with - History. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - STREAM_FIELD_NUMBER: builtins.int - FROM_OFFSET_FIELD_NUMBER: builtins.int - WAIT_FIELD_NUMBER: builtins.int - MAX_RECORDS_FIELD_NUMBER: builtins.int - MAX_BYTES_FIELD_NUMBER: builtins.int - seq: builtins.int - """Lang's incremental sequence number for reads, starting at 1.""" - from_offset: builtins.bytes - """The page has the Records after this offset. If it's empty, the page starts at the beginning - of the Stream. - """ - max_records: builtins.int - """The maximum number of Records in the page, which is 256 if this is zero.""" - max_bytes: builtins.int - """The maximum size of the Records in the page, which is 4 MiB if this is zero. Core asks the - Store for at most 16 MiB. One larger Record still comes as a page. - """ - @property - def stream(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... - @property - def wait(self) -> google.protobuf.duration_pb2.Duration: - """How long the read waits for a Record if the Stream has none after `from_offset`. If it's - unset, the read doesn't wait. - """ - - def __init__( - self, - *, - seq: builtins.int = ..., - stream: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - from_offset: builtins.bytes = ..., - wait: google.protobuf.duration_pb2.Duration | None = ..., - max_records: builtins.int = ..., - max_bytes: builtins.int = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["stream", b"stream", "wait", b"wait"] - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "from_offset", - b"from_offset", - "max_bytes", - b"max_bytes", - "max_records", - b"max_records", - "seq", - b"seq", - "stream", - b"stream", - "wait", - b"wait", - ], - ) -> None: ... - -global___ReadStream = ReadStream - -@typing.final -class RequestCancelStreamRead(google.protobuf.message.Message): - """Cancels a read, as `RequestCancelLocalActivity` cancels a Local Activity whose cancellation type - is `TRY_CANCEL`. The read still gets its one `ResolveStreamRead` job. Once Core has the cancel, - that job has `cancelled`, unless lang already got the job of the read. Core drops a page or a - failure of the read that lang didn't get, and the next read from the same `from_offset` gives - the Records of a dropped page. - - If the activation that lang answers with the cancel has a job of the read, that job stays as it - is. So an SDK that runs Workflow code between the jobs of one activation can give that code a - page of a read that it already cancelled, in the first run and in a replay. - - A cancel costs an activation and an entry in the ledger of its Workflow Task, for the - `cancelled` job. If the task completes at its heartbeat before that job, the cancel also costs - the events of a forced Workflow Task. - - A `ReadStream` and its cancel in one completion, in that order, make no Store call. - - In a replay, the job is the one that History has. A replay of a History without the flag that - turns workflow task chunking off can give the `cancelled` job before lang sends the cancel, in - the activation of the job that made Workflow code cancel. A read with a cancel and no result in - History gets its `cancelled` job once the replay is over. - - Core ignores the cancel of a read that got its job, and the cancel of a `seq` that lang skipped. - The cancel of a `seq` above that of the last read is a nondeterminism error. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - seq: builtins.int - """The `seq` of the `ReadStream` to cancel.""" - def __init__( - self, - *, - seq: builtins.int = ..., - ) -> None: ... - def ClearField(self, field_name: typing.Literal["seq", b"seq"]) -> None: ... - -global___RequestCancelStreamRead = RequestCancelStreamRead diff --git a/temporalio/nexus/system/workflow_service/__init__.py b/temporalio/nexus/system/workflow_service/__init__.py index c249d52d1e..153d00a3c2 100644 --- a/temporalio/nexus/system/workflow_service/__init__.py +++ b/temporalio/nexus/system/workflow_service/__init__.py @@ -27,17 +27,24 @@ ] +_StorageTargetFactory = collections.abc.Callable[ + [_InputT], temporalio.converter.StorageDriverWorkflowInfo +] + + class _NexusOperationInfo(typing.Generic[_InputT, _OutputT]): def __init__( self, *, operation: nexusrpc.Operation[_InputT, _OutputT], serialization_context: _SerializationContextFactory[_InputT] | None = None, + storage_target: _StorageTargetFactory[_InputT] | None = None, ) -> None: self.operation: nexusrpc.Operation[_InputT, _OutputT] = operation self.serialization_context: _SerializationContextFactory[_InputT] | None = ( serialization_context ) + self.storage_target: _StorageTargetFactory[_InputT] | None = storage_target __nexus_operation_registry__: dict[ From cf851239a31c6b7b2d709e3f53bf546c1cea755e Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Wed, 25 Nov 2026 07:54:54 -0700 Subject: [PATCH 16/24] Pin Core at the SDK and Store sets of the Stream protos The Stream WIT refers to the SDK messages in `temporal/api/sdk/v1/stream.proto`, so the descriptor set that nexgen reads has that file too. --- scripts/gen_nexus_system_api.py | 1 + temporalio/bridge/sdk-core | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index 90ba2af353..61bad6341b 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -46,6 +46,7 @@ / "streamservice" / "v1" / "request_response.proto", + gen_protos.api_proto_dir / "temporal" / "api" / "sdk" / "v1" / "stream.proto", ] diff --git a/temporalio/bridge/sdk-core b/temporalio/bridge/sdk-core index 68afbba474..45434777fc 160000 --- a/temporalio/bridge/sdk-core +++ b/temporalio/bridge/sdk-core @@ -1 +1 @@ -Subproject commit 68afbba4741cc48abdba0062557e1e2a1f9d16af +Subproject commit 45434777fc4b496c8a9f78c263c030e828d5c5cf From 10dcd0e60a0816960114b3155dd27d7ec9c51ff6 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Wed, 25 Nov 2026 07:54:54 -0700 Subject: [PATCH 17/24] Regenerate the protos and the Streams API with no close This is the output of `poe gen-protos` with nexgen at `74f8ce76`. The Streams API has no close, no `done` and no `StreamStatus`, and its requests have the ref of a Stream. --- temporalio/api/enums/v1/__init__.py | 3 +- temporalio/api/enums/v1/stream_pb2.py | 12 +- temporalio/api/enums/v1/stream_pb2.pyi | 76 +--- temporalio/api/sdk/v1/__init__.py | 16 +- temporalio/api/sdk/v1/stream_calls_pb2.py | 48 --- temporalio/api/sdk/v1/stream_calls_pb2.pyi | 374 ------------------ temporalio/api/sdk/v1/stream_pb2.py | 46 +++ temporalio/api/sdk/v1/stream_pb2.pyi | 246 ++++++++++++ .../api/sdk/v1/task_complete_metadata_pb2.py | 10 +- .../api/sdk/v1/task_complete_metadata_pb2.pyi | 20 - temporalio/api/stream/v1/__init__.py | 2 - temporalio/api/stream/v1/message_pb2.py | 52 ++- temporalio/api/stream/v1/message_pb2.pyi | 41 +- temporalio/api/streamservice/v1/__init__.py | 4 - .../streamservice/v1/request_response_pb2.py | 38 +- .../streamservice/v1/request_response_pb2.pyi | 168 ++------ .../nexus/system/stream_service/__init__.py | 6 - .../_resource_context_manager.py | 93 ----- .../stream_service/client/_extensions.py | 4 - .../client/_resources/stream.py | 48 +-- .../nexus/system/stream_service/models.py | 229 ++--------- .../nexus/system/stream_service/services.py | 7 - .../stream_service/workflow/__init__.py | 6 - .../workflow/_resources/stream.py | 49 +-- .../workflow/_system_nexus_interceptor.py | 42 -- .../workflow/operations/create_stream.py | 4 - 26 files changed, 468 insertions(+), 1176 deletions(-) delete mode 100644 temporalio/api/sdk/v1/stream_calls_pb2.py delete mode 100644 temporalio/api/sdk/v1/stream_calls_pb2.pyi create mode 100644 temporalio/api/sdk/v1/stream_pb2.py create mode 100644 temporalio/api/sdk/v1/stream_pb2.pyi delete mode 100644 temporalio/nexus/system/stream_service/_resource_context_manager.py diff --git a/temporalio/api/enums/v1/__init__.py b/temporalio/api/enums/v1/__init__.py index 0efbca2cfc..58abe69b3e 100644 --- a/temporalio/api/enums/v1/__init__.py +++ b/temporalio/api/enums/v1/__init__.py @@ -49,7 +49,7 @@ from .query_pb2 import QueryRejectCondition, QueryResultType from .reset_pb2 import ResetReapplyExcludeType, ResetReapplyType, ResetType from .schedule_pb2 import ScheduleOverlapPolicy -from .stream_pb2 import StreamErrorReason, StreamIdConflictPolicy, StreamStatus +from .stream_pb2 import StreamErrorReason, StreamIdConflictPolicy from .task_queue_pb2 import ( BuildIdTaskReachability, DescribeTaskQueueMode, @@ -129,7 +129,6 @@ "StartChildWorkflowExecutionFailedCause", "StreamErrorReason", "StreamIdConflictPolicy", - "StreamStatus", "SuggestContinueAsNewReason", "TaskQueueKind", "TaskQueueType", diff --git a/temporalio/api/enums/v1/stream_pb2.py b/temporalio/api/enums/v1/stream_pb2.py index a272a2da88..1fd015c418 100644 --- a/temporalio/api/enums/v1/stream_pb2.py +++ b/temporalio/api/enums/v1/stream_pb2.py @@ -14,7 +14,7 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*_\n\x0cStreamStatus\x12\x1d\n\x19STREAM_STATUS_UNSPECIFIED\x10\x00\x12\x16\n\x12STREAM_STATUS_OPEN\x10\x01\x12\x18\n\x14STREAM_STATUS_CLOSED\x10\x02*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xf9\x03\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_CLOSED\x10\x03\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x04\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x05\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\x06\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\x07\x12(\n$STREAM_ERROR_REASON_INVALID_ARGUMENT\x10\x08\x12)\n%STREAM_ERROR_REASON_STORE_UNAVAILABLE\x10\t\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\n\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\x0b\x12%\n!STREAM_ERROR_REASON_STORE_CORRUPT\x10\x0c\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' + b'\n"temporal/api/enums/v1/stream.proto\x12\x15temporal.api.enums.v1*\x93\x01\n\x16StreamIdConflictPolicy\x12)\n%STREAM_ID_CONFLICT_POLICY_UNSPECIFIED\x10\x00\x12"\n\x1eSTREAM_ID_CONFLICT_POLICY_FAIL\x10\x01\x12*\n&STREAM_ID_CONFLICT_POLICY_USE_EXISTING\x10\x02*\xd9\x03\n\x11StreamErrorReason\x12#\n\x1fSTREAM_ERROR_REASON_UNSPECIFIED\x10\x00\x12!\n\x1dSTREAM_ERROR_REASON_NOT_FOUND\x10\x01\x12\x1f\n\x1bSTREAM_ERROR_REASON_EXPIRED\x10\x02\x12\x1e\n\x1aSTREAM_ERROR_REASON_FENCED\x10\x03\x12&\n"STREAM_ERROR_REASON_FORMAT_TOO_NEW\x10\x04\x12\'\n#STREAM_ERROR_REASON_OFFSET_TOO_HIGH\x10\x05\x12!\n\x1dSTREAM_ERROR_REASON_TOO_LARGE\x10\x06\x12(\n$STREAM_ERROR_REASON_INVALID_ARGUMENT\x10\x07\x12)\n%STREAM_ERROR_REASON_STORE_UNAVAILABLE\x10\x08\x12#\n\x1fSTREAM_ERROR_REASON_UNSUPPORTED\x10\t\x12&\n"STREAM_ERROR_REASON_ALREADY_EXISTS\x10\n\x12%\n!STREAM_ERROR_REASON_STORE_CORRUPT\x10\x0b\x42\x83\x01\n\x18io.temporal.api.enums.v1B\x0bStreamProtoP\x01Z!go.temporal.io/api/enums/v1;enums\xaa\x02\x17Temporalio.Api.Enums.V1\xea\x02\x1aTemporalio::Api::Enums::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -22,10 +22,8 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\030io.temporal.api.enums.v1B\013StreamProtoP\001Z!go.temporal.io/api/enums/v1;enums\252\002\027Temporalio.Api.Enums.V1\352\002\032Temporalio::Api::Enums::V1" - _STREAMSTATUS._serialized_start = 61 - _STREAMSTATUS._serialized_end = 156 - _STREAMIDCONFLICTPOLICY._serialized_start = 159 - _STREAMIDCONFLICTPOLICY._serialized_end = 306 - _STREAMERRORREASON._serialized_start = 309 - _STREAMERRORREASON._serialized_end = 814 + _STREAMIDCONFLICTPOLICY._serialized_start = 62 + _STREAMIDCONFLICTPOLICY._serialized_end = 209 + _STREAMERRORREASON._serialized_start = 212 + _STREAMERRORREASON._serialized_end = 685 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/enums/v1/stream_pb2.pyi b/temporalio/api/enums/v1/stream_pb2.pyi index bf1d90918a..638ab6eb0e 100644 --- a/temporalio/api/enums/v1/stream_pb2.pyi +++ b/temporalio/api/enums/v1/stream_pb2.pyi @@ -17,38 +17,6 @@ else: DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -class _StreamStatus: - ValueType = typing.NewType("ValueType", builtins.int) - V: typing_extensions.TypeAlias = ValueType - -class _StreamStatusEnumTypeWrapper( - google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[ - _StreamStatus.ValueType - ], - builtins.type, -): - DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor - STREAM_STATUS_UNSPECIFIED: _StreamStatus.ValueType # 0 - STREAM_STATUS_OPEN: _StreamStatus.ValueType # 1 - """The Stream accepts appends.""" - STREAM_STATUS_CLOSED: _StreamStatus.ValueType # 2 - """The Stream is closed. It accepts no append, and a read ends after its last Record.""" - -class StreamStatus(_StreamStatus, metaclass=_StreamStatusEnumTypeWrapper): - """Experimental. Might change in the future. - The status of a Stream, as a describe returns it. A describe of an expired Stream fails with - the reason `EXPIRED`, so it has no status. - (-- api-linter: core::0216::synonyms=disabled - aip.dev/not-precedent: It has the same form as WorkflowExecutionStatus. --) - """ - -STREAM_STATUS_UNSPECIFIED: StreamStatus.ValueType # 0 -STREAM_STATUS_OPEN: StreamStatus.ValueType # 1 -"""The Stream accepts appends.""" -STREAM_STATUS_CLOSED: StreamStatus.ValueType # 2 -"""The Stream is closed. It accepts no append, and a read ends after its last Record.""" -global___StreamStatus = StreamStatus - class _StreamIdConflictPolicy: ValueType = typing.NewType("ValueType", builtins.int) V: typing_extensions.TypeAlias = ValueType @@ -96,30 +64,28 @@ class _StreamErrorReasonEnumTypeWrapper( STREAM_ERROR_REASON_NOT_FOUND: _StreamErrorReason.ValueType # 1 """The Stream was never created (`NOT_FOUND`).""" STREAM_ERROR_REASON_EXPIRED: _StreamErrorReason.ValueType # 2 - """The Retention of the Stream or its Producer idle TTL has passed (`NOT_FOUND`).""" - STREAM_ERROR_REASON_CLOSED: _StreamErrorReason.ValueType # 3 - """The Stream is closed (`FAILED_PRECONDITION`).""" - STREAM_ERROR_REASON_FENCED: _StreamErrorReason.ValueType # 4 + """The Retention of the Stream has passed since its create or its last append (`NOT_FOUND`).""" + STREAM_ERROR_REASON_FENCED: _StreamErrorReason.ValueType # 3 """A later attempt of the same Producer has already written, and the Store fences (`FAILED_PRECONDITION`). """ - STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 5 + STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 4 """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" - STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 6 + STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 5 """The offset is past the newest one, for example after a failover lost the newest Records. A read from it works again once the Stream has Records up to that offset (`OUT_OF_RANGE`). """ - STREAM_ERROR_REASON_TOO_LARGE: _StreamErrorReason.ValueType # 7 + STREAM_ERROR_REASON_TOO_LARGE: _StreamErrorReason.ValueType # 6 """A Record or a batch is larger than the Store allows (`INVALID_ARGUMENT`).""" - STREAM_ERROR_REASON_INVALID_ARGUMENT: _StreamErrorReason.ValueType # 8 + STREAM_ERROR_REASON_INVALID_ARGUMENT: _StreamErrorReason.ValueType # 7 """The request is malformed (`INVALID_ARGUMENT`).""" - STREAM_ERROR_REASON_STORE_UNAVAILABLE: _StreamErrorReason.ValueType # 9 + STREAM_ERROR_REASON_STORE_UNAVAILABLE: _StreamErrorReason.ValueType # 8 """The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" - STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 10 + STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 9 """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" - STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 11 + STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 10 """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" - STREAM_ERROR_REASON_STORE_CORRUPT: _StreamErrorReason.ValueType # 12 + STREAM_ERROR_REASON_STORE_CORRUPT: _StreamErrorReason.ValueType # 11 """The Store returned data that isn't valid, such as a stored value of the wrong length. A retry reads the same data (`DATA_LOSS`). """ @@ -137,30 +103,28 @@ STREAM_ERROR_REASON_UNSPECIFIED: StreamErrorReason.ValueType # 0 STREAM_ERROR_REASON_NOT_FOUND: StreamErrorReason.ValueType # 1 """The Stream was never created (`NOT_FOUND`).""" STREAM_ERROR_REASON_EXPIRED: StreamErrorReason.ValueType # 2 -"""The Retention of the Stream or its Producer idle TTL has passed (`NOT_FOUND`).""" -STREAM_ERROR_REASON_CLOSED: StreamErrorReason.ValueType # 3 -"""The Stream is closed (`FAILED_PRECONDITION`).""" -STREAM_ERROR_REASON_FENCED: StreamErrorReason.ValueType # 4 +"""The Retention of the Stream has passed since its create or its last append (`NOT_FOUND`).""" +STREAM_ERROR_REASON_FENCED: StreamErrorReason.ValueType # 3 """A later attempt of the same Producer has already written, and the Store fences (`FAILED_PRECONDITION`). """ -STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 5 +STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 4 """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" -STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 6 +STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 5 """The offset is past the newest one, for example after a failover lost the newest Records. A read from it works again once the Stream has Records up to that offset (`OUT_OF_RANGE`). """ -STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 7 +STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 6 """A Record or a batch is larger than the Store allows (`INVALID_ARGUMENT`).""" -STREAM_ERROR_REASON_INVALID_ARGUMENT: StreamErrorReason.ValueType # 8 +STREAM_ERROR_REASON_INVALID_ARGUMENT: StreamErrorReason.ValueType # 7 """The request is malformed (`INVALID_ARGUMENT`).""" -STREAM_ERROR_REASON_STORE_UNAVAILABLE: StreamErrorReason.ValueType # 9 +STREAM_ERROR_REASON_STORE_UNAVAILABLE: StreamErrorReason.ValueType # 8 """The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" -STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 10 +STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 9 """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" -STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 11 +STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 10 """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" -STREAM_ERROR_REASON_STORE_CORRUPT: StreamErrorReason.ValueType # 12 +STREAM_ERROR_REASON_STORE_CORRUPT: StreamErrorReason.ValueType # 11 """The Store returned data that isn't valid, such as a stored value of the wrong length. A retry reads the same data (`DATA_LOSS`). """ diff --git a/temporalio/api/sdk/v1/__init__.py b/temporalio/api/sdk/v1/__init__.py index f37804007e..c35c2154d9 100644 --- a/temporalio/api/sdk/v1/__init__.py +++ b/temporalio/api/sdk/v1/__init__.py @@ -7,7 +7,14 @@ ) from .event_group_marker_pb2 import EventGroupMarker from .external_storage_pb2 import ExternalStorageReference -from .stream_calls_pb2 import WorkflowTaskStreamCalls +from .stream_pb2 import ( + AppendRecordsRequest, + CreateStreamRequest, + CreateStreamResponse, + DescribeStreamRequest, + ReadRecordsRequest, + StreamRef, +) from .task_complete_metadata_pb2 import WorkflowTaskCompletedMetadata from .user_metadata_pb2 import UserMetadata from .worker_config_pb2 import WorkerConfig @@ -18,18 +25,23 @@ ) __all__ = [ + "AppendRecordsRequest", + "CreateStreamRequest", + "CreateStreamResponse", + "DescribeStreamRequest", "EnhancedStackTrace", "EventGroupMarker", "ExternalStorageReference", + "ReadRecordsRequest", "StackTrace", "StackTraceFileLocation", "StackTraceFileSlice", "StackTraceSDKInfo", + "StreamRef", "UserMetadata", "WorkerConfig", "WorkflowDefinition", "WorkflowInteractionDefinition", "WorkflowMetadata", "WorkflowTaskCompletedMetadata", - "WorkflowTaskStreamCalls", ] diff --git a/temporalio/api/sdk/v1/stream_calls_pb2.py b/temporalio/api/sdk/v1/stream_calls_pb2.py deleted file mode 100644 index 7157cfad5f..0000000000 --- a/temporalio/api/sdk/v1/stream_calls_pb2.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: temporal/api/sdk/v1/stream_calls.proto -"""Generated protocol buffer code.""" - -from google.protobuf import descriptor as _descriptor -from google.protobuf import descriptor_pool as _descriptor_pool -from google.protobuf import symbol_database as _symbol_database -from google.protobuf.internal import builder as _builder - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from temporalio.api.enums.v1 import ( - stream_pb2 as temporal_dot_api_dot_enums_dot_v1_dot_stream__pb2, -) -from temporalio.api.stream.v1 import ( - message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, -) - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n&temporal/api/sdk/v1/stream_calls.proto\x12\x13temporal.api.sdk.v1\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\x85\n\n\x17WorkflowTaskStreamCalls\x12O\n\rclose_intents\x18\x01 \x03(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CloseIntent\x12Q\n\x0e\x61ppend_results\x18\x02 \x03(\x0b\x32\x39.temporal.api.sdk.v1.WorkflowTaskStreamCalls.AppendResult\x12O\n\rclose_results\x18\x03 \x03(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CloseResult\x12M\n\x0cread_results\x18\x04 \x03(\x0b\x32\x37.temporal.api.sdk.v1.WorkflowTaskStreamCalls.ReadResult\x1aJ\n\x0b\x43loseIntent\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x1a\xf2\x01\n\x0c\x41ppendResult\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12N\n\x08\x61ppended\x18\x03 \x01(\x0b\x32:.temporal.api.sdk.v1.WorkflowTaskStreamCalls.AppendOffsetsH\x00\x12K\n\x07\x66\x61ilure\x18\x04 \x01(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CallFailureH\x00\x42\x08\n\x06result\x1a:\n\rAppendOffsets\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x1a\x65\n\x0b\x43loseResult\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12I\n\x07\x66\x61ilure\x18\x02 \x01(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CallFailure\x1a\xfc\x01\n\nReadResult\x12\x0b\n\x03seq\x18\x01 \x01(\x05\x12.\n\x03ref\x18\x02 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x03 \x01(\x0c\x12\x45\n\x04page\x18\x04 \x01(\x0b\x32\x35.temporal.api.sdk.v1.WorkflowTaskStreamCalls.ReadPageH\x00\x12K\n\x07\x66\x61ilure\x18\x05 \x01(\x0b\x32\x38.temporal.api.sdk.v1.WorkflowTaskStreamCalls.CallFailureH\x00\x42\x08\n\x06result\x1ai\n\x08ReadPage\x12\x14\n\x0crecord_count\x18\x01 \x01(\x05\x12\x0c\n\x04\x64one\x18\x02 \x01(\x08\x12\x0e\n\x06\x64igest\x18\x03 \x01(\x0c\x12\x14\n\x0crecord_bytes\x18\x04 \x01(\x03\x12\x13\n\x0blast_offset\x18\x05 \x01(\x0c\x1aX\n\x0b\x43\x61llFailure\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReason\x12\x0f\n\x07message\x18\x02 \x01(\tB~\n\x16io.temporal.api.sdk.v1B\x10StreamCallsProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' -) - -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, __name__, globals()) -if _descriptor._USE_C_DESCRIPTORS == False: - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b"\n\026io.temporal.api.sdk.v1B\020StreamCallsProtoP\001Z\035go.temporal.io/api/sdk/v1;sdk\252\002\025Temporalio.Api.Sdk.V1\352\002\030Temporalio::Api::Sdk::V1" - _WORKFLOWTASKSTREAMCALLS._serialized_start = 138 - _WORKFLOWTASKSTREAMCALLS._serialized_end = 1423 - _WORKFLOWTASKSTREAMCALLS_CLOSEINTENT._serialized_start = 489 - _WORKFLOWTASKSTREAMCALLS_CLOSEINTENT._serialized_end = 563 - _WORKFLOWTASKSTREAMCALLS_APPENDRESULT._serialized_start = 566 - _WORKFLOWTASKSTREAMCALLS_APPENDRESULT._serialized_end = 808 - _WORKFLOWTASKSTREAMCALLS_APPENDOFFSETS._serialized_start = 810 - _WORKFLOWTASKSTREAMCALLS_APPENDOFFSETS._serialized_end = 868 - _WORKFLOWTASKSTREAMCALLS_CLOSERESULT._serialized_start = 870 - _WORKFLOWTASKSTREAMCALLS_CLOSERESULT._serialized_end = 971 - _WORKFLOWTASKSTREAMCALLS_READRESULT._serialized_start = 974 - _WORKFLOWTASKSTREAMCALLS_READRESULT._serialized_end = 1226 - _WORKFLOWTASKSTREAMCALLS_READPAGE._serialized_start = 1228 - _WORKFLOWTASKSTREAMCALLS_READPAGE._serialized_end = 1333 - _WORKFLOWTASKSTREAMCALLS_CALLFAILURE._serialized_start = 1335 - _WORKFLOWTASKSTREAMCALLS_CALLFAILURE._serialized_end = 1423 -# @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/sdk/v1/stream_calls_pb2.pyi b/temporalio/api/sdk/v1/stream_calls_pb2.pyi deleted file mode 100644 index 99c5890550..0000000000 --- a/temporalio/api/sdk/v1/stream_calls_pb2.pyi +++ /dev/null @@ -1,374 +0,0 @@ -""" -@generated by mypy-protobuf. Do not edit manually! -isort:skip_file -""" - -import builtins -import collections.abc -import typing - -import google.protobuf.descriptor -import google.protobuf.internal.containers -import google.protobuf.message - -import temporalio.api.enums.v1.stream_pb2 -import temporalio.api.stream.v1.message_pb2 - -DESCRIPTOR: google.protobuf.descriptor.FileDescriptor - -@typing.final -class WorkflowTaskStreamCalls(google.protobuf.message.Message): - """Experimental. Might change in the future. - The Stream calls of one Workflow Task. An SDK records them on the completion of the task, so - that a replay gives Workflow code the same result for each call. A replay doesn't append or - close again for a result that is here. For a page, it reads the Records from the Store again. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - @typing.final - class CloseIntent(google.protobuf.message.Message): - """The intent of Workflow code to close a Stream.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - REF_FIELD_NUMBER: builtins.int - seq: builtins.int - """The sequence number that the SDK gave the close.""" - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... - def __init__( - self, - *, - seq: builtins.int = ..., - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["ref", b"ref"] - ) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["ref", b"ref", "seq", b"seq"] - ) -> None: ... - - @typing.final - class AppendResult(google.protobuf.message.Message): - """The result of an append.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - REF_FIELD_NUMBER: builtins.int - APPENDED_FIELD_NUMBER: builtins.int - FAILURE_FIELD_NUMBER: builtins.int - seq: builtins.int - """The sequence number that the SDK gave the append.""" - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... - @property - def appended(self) -> global___WorkflowTaskStreamCalls.AppendOffsets: ... - @property - def failure(self) -> global___WorkflowTaskStreamCalls.CallFailure: ... - def __init__( - self, - *, - seq: builtins.int = ..., - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - appended: global___WorkflowTaskStreamCalls.AppendOffsets | None = ..., - failure: global___WorkflowTaskStreamCalls.CallFailure | None = ..., - ) -> None: ... - def HasField( - self, - field_name: typing.Literal[ - "appended", - b"appended", - "failure", - b"failure", - "ref", - b"ref", - "result", - b"result", - ], - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "appended", - b"appended", - "failure", - b"failure", - "ref", - b"ref", - "result", - b"result", - "seq", - b"seq", - ], - ) -> None: ... - def WhichOneof( - self, oneof_group: typing.Literal["result", b"result"] - ) -> typing.Literal["appended", "failure"] | None: ... - - @typing.final - class AppendOffsets(google.protobuf.message.Message): - """The offsets of the first and the last Record of a batch, as the Store returned them.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - FIRST_OFFSET_FIELD_NUMBER: builtins.int - LAST_OFFSET_FIELD_NUMBER: builtins.int - first_offset: builtins.bytes - last_offset: builtins.bytes - def __init__( - self, - *, - first_offset: builtins.bytes = ..., - last_offset: builtins.bytes = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "first_offset", b"first_offset", "last_offset", b"last_offset" - ], - ) -> None: ... - - @typing.final - class CloseResult(google.protobuf.message.Message): - """The result of a close. The intent with the same `seq` has the ref of the Stream.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - FAILURE_FIELD_NUMBER: builtins.int - seq: builtins.int - @property - def failure(self) -> global___WorkflowTaskStreamCalls.CallFailure: - """Unset if the Stream is closed.""" - - def __init__( - self, - *, - seq: builtins.int = ..., - failure: global___WorkflowTaskStreamCalls.CallFailure | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["failure", b"failure"] - ) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["failure", b"failure", "seq", b"seq"] - ) -> None: ... - - @typing.final - class ReadResult(google.protobuf.message.Message): - """The result of a read.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - SEQ_FIELD_NUMBER: builtins.int - REF_FIELD_NUMBER: builtins.int - FROM_OFFSET_FIELD_NUMBER: builtins.int - PAGE_FIELD_NUMBER: builtins.int - FAILURE_FIELD_NUMBER: builtins.int - seq: builtins.int - """The sequence number that the SDK gave the read.""" - from_offset: builtins.bytes - """The `from_offset` of the read. A replay reads the Records of the page after it. - (-- api-linter: core::0140::prepositions=disabled - aip.dev/not-precedent: "from" marks the start of a range of offsets. --) - """ - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: ... - @property - def page(self) -> global___WorkflowTaskStreamCalls.ReadPage: ... - @property - def failure(self) -> global___WorkflowTaskStreamCalls.CallFailure: ... - def __init__( - self, - *, - seq: builtins.int = ..., - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - from_offset: builtins.bytes = ..., - page: global___WorkflowTaskStreamCalls.ReadPage | None = ..., - failure: global___WorkflowTaskStreamCalls.CallFailure | None = ..., - ) -> None: ... - def HasField( - self, - field_name: typing.Literal[ - "failure", - b"failure", - "page", - b"page", - "ref", - b"ref", - "result", - b"result", - ], - ) -> builtins.bool: ... - def ClearField( - self, - field_name: typing.Literal[ - "failure", - b"failure", - "from_offset", - b"from_offset", - "page", - b"page", - "ref", - b"ref", - "result", - b"result", - "seq", - b"seq", - ], - ) -> None: ... - def WhichOneof( - self, oneof_group: typing.Literal["result", b"result"] - ) -> typing.Literal["page", "failure"] | None: ... - - @typing.final - class ReadPage(google.protobuf.message.Message): - """A page that a read gave Workflow code. It doesn't have the Records. A replay reads them from - the Store again and checks them against `digest`. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - RECORD_COUNT_FIELD_NUMBER: builtins.int - DONE_FIELD_NUMBER: builtins.int - DIGEST_FIELD_NUMBER: builtins.int - RECORD_BYTES_FIELD_NUMBER: builtins.int - LAST_OFFSET_FIELD_NUMBER: builtins.int - record_count: builtins.int - """The number of Records in the page.""" - done: builtins.bool - """True if the Stream was closed and had no Record after this page.""" - digest: builtins.bytes - """The first 16 bytes of a SHA-256 over the Records, in an encoding that the SDK owns. It's - empty if the page has no Record. - """ - record_bytes: builtins.int - """The size of the Records in bytes, as the `max_bytes` of a read measures it. It's set when - `digest` is, so a replay knows how much to read. - """ - last_offset: builtins.bytes - """The `last_offset` that Workflow code got with the page. A replay gives the same value, - since another read of the Store can end at another offset. - """ - def __init__( - self, - *, - record_count: builtins.int = ..., - done: builtins.bool = ..., - digest: builtins.bytes = ..., - record_bytes: builtins.int = ..., - last_offset: builtins.bytes = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "digest", - b"digest", - "done", - b"done", - "last_offset", - b"last_offset", - "record_bytes", - b"record_bytes", - "record_count", - b"record_count", - ], - ) -> None: ... - - @typing.final - class CallFailure(google.protobuf.message.Message): - """Why a call failed. The SDK builds the error that Workflow code gets from it.""" - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - REASON_FIELD_NUMBER: builtins.int - MESSAGE_FIELD_NUMBER: builtins.int - reason: temporalio.api.enums.v1.stream_pb2.StreamErrorReason.ValueType - message: builtins.str - def __init__( - self, - *, - reason: temporalio.api.enums.v1.stream_pb2.StreamErrorReason.ValueType = ..., - message: builtins.str = ..., - ) -> None: ... - def ClearField( - self, field_name: typing.Literal["message", b"message", "reason", b"reason"] - ) -> None: ... - - CLOSE_INTENTS_FIELD_NUMBER: builtins.int - APPEND_RESULTS_FIELD_NUMBER: builtins.int - CLOSE_RESULTS_FIELD_NUMBER: builtins.int - READ_RESULTS_FIELD_NUMBER: builtins.int - @property - def close_intents( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___WorkflowTaskStreamCalls.CloseIntent - ]: - """The closes that Workflow code asked for in this task. The SDK closes a Stream only when - History has the intent, so the result of a close is in a later task. - """ - - @property - def append_results( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___WorkflowTaskStreamCalls.AppendResult - ]: - """The results of the appends that Workflow code got in this task.""" - - @property - def close_results( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___WorkflowTaskStreamCalls.CloseResult - ]: - """The results of the closes that Workflow code got in this task.""" - - @property - def read_results( - self, - ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ - global___WorkflowTaskStreamCalls.ReadResult - ]: - """The results of the reads that Workflow code got in this task.""" - - def __init__( - self, - *, - close_intents: collections.abc.Iterable[ - global___WorkflowTaskStreamCalls.CloseIntent - ] - | None = ..., - append_results: collections.abc.Iterable[ - global___WorkflowTaskStreamCalls.AppendResult - ] - | None = ..., - close_results: collections.abc.Iterable[ - global___WorkflowTaskStreamCalls.CloseResult - ] - | None = ..., - read_results: collections.abc.Iterable[ - global___WorkflowTaskStreamCalls.ReadResult - ] - | None = ..., - ) -> None: ... - def ClearField( - self, - field_name: typing.Literal[ - "append_results", - b"append_results", - "close_intents", - b"close_intents", - "close_results", - b"close_results", - "read_results", - b"read_results", - ], - ) -> None: ... - -global___WorkflowTaskStreamCalls = WorkflowTaskStreamCalls diff --git a/temporalio/api/sdk/v1/stream_pb2.py b/temporalio/api/sdk/v1/stream_pb2.py new file mode 100644 index 0000000000..efa1175735 --- /dev/null +++ b/temporalio/api/sdk/v1/stream_pb2.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: temporal/api/sdk/v1/stream.proto +"""Generated protocol buffer code.""" + +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 + +from temporalio.api.enums.v1 import ( + stream_pb2 as temporal_dot_api_dot_enums_dot_v1_dot_stream__pb2, +) +from temporalio.api.stream.v1 import ( + message_pb2 as temporal_dot_api_dot_stream_dot_v1_dot_message__pb2, +) + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n temporal/api/sdk/v1/stream.proto\x12\x13temporal.api.sdk.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"\x94\x01\n\x13\x43reateStreamRequest\x12\x32\n\nstream_ref\x18\x01 \x01(\x0b\x32\x1e.temporal.api.sdk.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy"T\n\x14\x43reateStreamResponse\x12+\n\x03ref\x18\x01 \x01(\x0b\x32\x1e.temporal.api.sdk.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xae\x01\n\x14\x41ppendRecordsRequest\x12+\n\x03ref\x18\x01 \x01(\x0b\x32\x1e.temporal.api.sdk.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x35\n\x07records\x18\x03 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"\xa7\x01\n\x12ReadRecordsRequest\x12+\n\x03ref\x18\x01 \x01(\x0b\x32\x1e.temporal.api.sdk.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"D\n\x15\x44\x65scribeStreamRequest\x12+\n\x03ref\x18\x01 \x01(\x0b\x32\x1e.temporal.api.sdk.v1.StreamRefBy\n\x16io.temporal.api.sdk.v1B\x0bStreamProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' +) + +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, __name__, globals()) +if _descriptor._USE_C_DESCRIPTORS == False: + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b"\n\026io.temporal.api.sdk.v1B\013StreamProtoP\001Z\035go.temporal.io/api/sdk/v1;sdk\252\002\025Temporalio.Api.Sdk.V1\352\002\030Temporalio::Api::Sdk::V1" + _STREAMREF._serialized_start = 163 + _STREAMREF._serialized_end = 201 + _CREATESTREAMREQUEST._serialized_start = 204 + _CREATESTREAMREQUEST._serialized_end = 352 + _CREATESTREAMRESPONSE._serialized_start = 354 + _CREATESTREAMRESPONSE._serialized_end = 438 + _APPENDRECORDSREQUEST._serialized_start = 441 + _APPENDRECORDSREQUEST._serialized_end = 615 + _READRECORDSREQUEST._serialized_start = 618 + _READRECORDSREQUEST._serialized_end = 785 + _DESCRIBESTREAMREQUEST._serialized_start = 787 + _DESCRIBESTREAMREQUEST._serialized_end = 855 +# @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/sdk/v1/stream_pb2.pyi b/temporalio/api/sdk/v1/stream_pb2.pyi new file mode 100644 index 0000000000..96a2d227dd --- /dev/null +++ b/temporalio/api/sdk/v1/stream_pb2.pyi @@ -0,0 +1,246 @@ +""" +@generated by mypy-protobuf. Do not edit manually! +isort:skip_file +""" + +import builtins +import collections.abc +import typing + +import google.protobuf.descriptor +import google.protobuf.duration_pb2 +import google.protobuf.internal.containers +import google.protobuf.message + +import temporalio.api.enums.v1.stream_pb2 +import temporalio.api.stream.v1.message_pb2 + +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor + +@typing.final +class StreamRef(google.protobuf.message.Message): + """Experimental. Might change in the future. + A reference to one Stream, which code passes to other code as data. Callers treat the `id` as + opaque. An id is never used for a second Stream while the Store remembers the first one, so a + create for an expired Stream fails. A Store can forget an expired Stream after a time of its + choice, and a create for its id succeeds after that. Every SDK encodes a ref in a Payload with + this message, so a ref that one SDK writes decodes in another. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ID_FIELD_NUMBER: builtins.int + STORE_FIELD_NUMBER: builtins.int + id: builtins.str + store: builtins.str + """The name under which the client and Worker config registered the Store of this Stream. An + SDK uses it to send a call on this ref to the right Store. When it's empty, the SDK picks + the Store from its config. Only an SDK sets and reads this field. A Store and the server + never get it, because their requests have only the Stream id. + """ + def __init__( + self, + *, + id: builtins.str = ..., + store: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["id", b"id", "store", b"store"] + ) -> None: ... + +global___StreamRef = StreamRef + +@typing.final +class CreateStreamRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + The SDK form of `temporalio.api.streamservice.v1.CreateStreamRequest`, with the ref of the Stream + in place of its id. The other fields mean the same. + (-- api-linter: core::0133=disabled + aip.dev/not-precedent: The request identifies a Stream by its ref. --) + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + STREAM_REF_FIELD_NUMBER: builtins.int + ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int + id_conflict_policy: ( + temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType + ) + @property + def stream_ref(self) -> global___StreamRef: + """Required. The Stream to create. Its `id` must not be empty.""" + + def __init__( + self, + *, + stream_ref: global___StreamRef | None = ..., + id_conflict_policy: temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["stream_ref", b"stream_ref"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "id_conflict_policy", b"id_conflict_policy", "stream_ref", b"stream_ref" + ], + ) -> None: ... + +global___CreateStreamRequest = CreateStreamRequest + +@typing.final +class CreateStreamResponse(google.protobuf.message.Message): + """Experimental. Might change in the future. + The Stream that the create made or found. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REF_FIELD_NUMBER: builtins.int + CREATED_FIELD_NUMBER: builtins.int + created: builtins.bool + """False when `USE_EXISTING` returned a Stream that already existed.""" + @property + def ref(self) -> global___StreamRef: + """The ref of the Stream. The caller can pass it to other code as data. The SDK builds it from + the request and the Store that it picked. + """ + + def __init__( + self, + *, + ref: global___StreamRef | None = ..., + created: builtins.bool = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... + def ClearField( + self, field_name: typing.Literal["created", b"created", "ref", b"ref"] + ) -> None: ... + +global___CreateStreamResponse = CreateStreamResponse + +@typing.final +class AppendRecordsRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + The SDK form of `temporalio.api.streamservice.v1.AppendRecordsRequest`, with the ref of the Stream + in place of its id. The other fields mean the same. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REF_FIELD_NUMBER: builtins.int + PRODUCER_FIELD_NUMBER: builtins.int + RECORDS_FIELD_NUMBER: builtins.int + @property + def ref(self) -> global___StreamRef: + """Required.""" + + @property + def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: ... + @property + def records( + self, + ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[ + temporalio.api.stream.v1.message_pb2.AppendRecord + ]: ... + def __init__( + self, + *, + ref: global___StreamRef | None = ..., + producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., + records: collections.abc.Iterable[ + temporalio.api.stream.v1.message_pb2.AppendRecord + ] + | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "producer", b"producer", "records", b"records", "ref", b"ref" + ], + ) -> None: ... + +global___AppendRecordsRequest = AppendRecordsRequest + +@typing.final +class ReadRecordsRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + The SDK form of `temporalio.api.streamservice.v1.ReadRecordsRequest`, with the ref of the Stream + in place of its id. The other fields mean the same. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REF_FIELD_NUMBER: builtins.int + FROM_OFFSET_FIELD_NUMBER: builtins.int + MAX_RECORDS_FIELD_NUMBER: builtins.int + MAX_BYTES_FIELD_NUMBER: builtins.int + WAIT_FIELD_NUMBER: builtins.int + from_offset: builtins.bytes + """(-- api-linter: core::0140::prepositions=disabled + aip.dev/not-precedent: "from" marks the start of a range of offsets. --) + """ + max_records: builtins.int + max_bytes: builtins.int + @property + def ref(self) -> global___StreamRef: + """Required.""" + + @property + def wait(self) -> google.protobuf.duration_pb2.Duration: ... + def __init__( + self, + *, + ref: global___StreamRef | None = ..., + from_offset: builtins.bytes = ..., + max_records: builtins.int = ..., + max_bytes: builtins.int = ..., + wait: google.protobuf.duration_pb2.Duration | None = ..., + ) -> None: ... + def HasField( + self, field_name: typing.Literal["ref", b"ref", "wait", b"wait"] + ) -> builtins.bool: ... + def ClearField( + self, + field_name: typing.Literal[ + "from_offset", + b"from_offset", + "max_bytes", + b"max_bytes", + "max_records", + b"max_records", + "ref", + b"ref", + "wait", + b"wait", + ], + ) -> None: ... + +global___ReadRecordsRequest = ReadRecordsRequest + +@typing.final +class DescribeStreamRequest(google.protobuf.message.Message): + """Experimental. Might change in the future. + The SDK form of `temporalio.api.streamservice.v1.DescribeStreamRequest`, with the ref of the + Stream in place of its id. + """ + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + REF_FIELD_NUMBER: builtins.int + @property + def ref(self) -> global___StreamRef: + """Required.""" + + def __init__( + self, + *, + ref: global___StreamRef | None = ..., + ) -> None: ... + def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... + def ClearField(self, field_name: typing.Literal["ref", b"ref"]) -> None: ... + +global___DescribeStreamRequest = DescribeStreamRequest diff --git a/temporalio/api/sdk/v1/task_complete_metadata_pb2.py b/temporalio/api/sdk/v1/task_complete_metadata_pb2.py index 53b3e6df84..411a4216bf 100644 --- a/temporalio/api/sdk/v1/task_complete_metadata_pb2.py +++ b/temporalio/api/sdk/v1/task_complete_metadata_pb2.py @@ -13,12 +13,8 @@ _sym_db = _symbol_database.Default() -from temporalio.api.sdk.v1 import ( - stream_calls_pb2 as temporal_dot_api_dot_sdk_dot_v1_dot_stream__calls__pb2, -) - DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1\x1a&temporal/api/sdk/v1/stream_calls.proto"\xbc\x01\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\t\x12\x42\n\x0cstream_calls\x18\x05 \x01(\x0b\x32,.temporal.api.sdk.v1.WorkflowTaskStreamCallsB\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' + b'\n0temporal/api/sdk/v1/task_complete_metadata.proto\x12\x13temporal.api.sdk.v1"x\n\x1dWorkflowTaskCompletedMetadata\x12\x17\n\x0f\x63ore_used_flags\x18\x01 \x03(\r\x12\x17\n\x0flang_used_flags\x18\x02 \x03(\r\x12\x10\n\x08sdk_name\x18\x03 \x01(\t\x12\x13\n\x0bsdk_version\x18\x04 \x01(\tB\x87\x01\n\x16io.temporal.api.sdk.v1B\x19TaskCompleteMetadataProtoP\x01Z\x1dgo.temporal.io/api/sdk/v1;sdk\xaa\x02\x15Temporalio.Api.Sdk.V1\xea\x02\x18Temporalio::Api::Sdk::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -26,6 +22,6 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\026io.temporal.api.sdk.v1B\031TaskCompleteMetadataProtoP\001Z\035go.temporal.io/api/sdk/v1;sdk\252\002\025Temporalio.Api.Sdk.V1\352\002\030Temporalio::Api::Sdk::V1" - _WORKFLOWTASKCOMPLETEDMETADATA._serialized_start = 114 - _WORKFLOWTASKCOMPLETEDMETADATA._serialized_end = 302 + _WORKFLOWTASKCOMPLETEDMETADATA._serialized_start = 73 + _WORKFLOWTASKCOMPLETEDMETADATA._serialized_end = 193 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi b/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi index 9aba16f238..c4efd608b6 100644 --- a/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi +++ b/temporalio/api/sdk/v1/task_complete_metadata_pb2.pyi @@ -11,8 +11,6 @@ import google.protobuf.descriptor import google.protobuf.internal.containers import google.protobuf.message -import temporalio.api.sdk.v1.stream_calls_pb2 - DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final @@ -23,7 +21,6 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): LANG_USED_FLAGS_FIELD_NUMBER: builtins.int SDK_NAME_FIELD_NUMBER: builtins.int SDK_VERSION_FIELD_NUMBER: builtins.int - STREAM_CALLS_FIELD_NUMBER: builtins.int sdk_name: builtins.str """Name of the SDK that processed the task. This is usually something like "temporal-go" and is usually the same as client-name gRPC header. This should only be set if its value changed @@ -74,16 +71,6 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): aip.dev/not-precedent: These really shouldn't have negative values. --) """ - @property - def stream_calls( - self, - ) -> temporalio.api.sdk.v1.stream_calls_pb2.WorkflowTaskStreamCalls: - """Experimental. Might change in the future. - The Stream calls of this Workflow Task. An SDK sets it if Workflow code got the result of a - Stream call in the task, asked for a close, or has a call with no result yet. So it can have - no entry. - """ - def __init__( self, *, @@ -91,12 +78,7 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): lang_used_flags: collections.abc.Iterable[builtins.int] | None = ..., sdk_name: builtins.str = ..., sdk_version: builtins.str = ..., - stream_calls: temporalio.api.sdk.v1.stream_calls_pb2.WorkflowTaskStreamCalls - | None = ..., ) -> None: ... - def HasField( - self, field_name: typing.Literal["stream_calls", b"stream_calls"] - ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ @@ -108,8 +90,6 @@ class WorkflowTaskCompletedMetadata(google.protobuf.message.Message): b"sdk_name", "sdk_version", b"sdk_version", - "stream_calls", - b"stream_calls", ], ) -> None: ... diff --git a/temporalio/api/stream/v1/__init__.py b/temporalio/api/stream/v1/__init__.py index 2757a8a4d8..6e13004121 100644 --- a/temporalio/api/stream/v1/__init__.py +++ b/temporalio/api/stream/v1/__init__.py @@ -8,7 +8,6 @@ StandaloneActivityProducer, StreamErrorDetails, StreamRecord, - StreamRef, WorkflowActivityProducer, WorkflowProducer, WorkflowTaskAttempt, @@ -24,7 +23,6 @@ "StandaloneActivityProducer", "StreamErrorDetails", "StreamRecord", - "StreamRef", "WorkflowActivityProducer", "WorkflowProducer", "WorkflowTaskAttempt", diff --git a/temporalio/api/stream/v1/message_pb2.py b/temporalio/api/stream/v1/message_pb2.py index 2983fc4967..424b3f3402 100644 --- a/temporalio/api/stream/v1/message_pb2.py +++ b/temporalio/api/stream/v1/message_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"&\n\tStreamRef\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05store\x18\x02 \x01(\t"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\x88\x01\n\x10WorkflowProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12<\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"\xa3\x01\n\x15LocalActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12=\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\xbd\x01\n\x18WorkflowActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x1a\n\x12scheduled_event_id\x18\x05 \x01(\x03\x12\x38\n\x07\x61ttempt\x18\x06 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x8e\x01\n\x1aStandaloneActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"/\n\x0e\x43lientProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t"\xf5\x02\n\x08Producer\x12<\n\x08workflow\x18\x01 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x02 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12M\n\x11workflow_activity\x18\x03 \x01(\x0b\x32\x30.temporal.api.stream.v1.WorkflowActivityProducerH\x00\x12Q\n\x13standalone_activity\x18\x04 \x01(\x0b\x32\x32.temporal.api.stream.v1.StandaloneActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x05 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' + b'\n$temporal/api/stream/v1/message.proto\x12\x16temporal.api.stream.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a$temporal/api/common/v1/message.proto\x1a"temporal/api/enums/v1/stream.proto"r\n\x13WorkflowTaskAttempt\x12\x18\n\x10started_event_id\x18\x01 \x01(\x03\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05\x12\x30\n\x0cstarted_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"b\n\x14LocalActivityAttempt\x12\x39\n\x04task\x18\x01 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"^\n\x0f\x41\x63tivityAttempt\x12:\n\x16\x61ttempt_scheduled_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x61ttempt\x18\x02 \x01(\x05"\x88\x01\n\x10WorkflowProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12<\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32+.temporal.api.stream.v1.WorkflowTaskAttempt"\xa3\x01\n\x15LocalActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12=\n\x07\x61ttempt\x18\x05 \x01(\x0b\x32,.temporal.api.stream.v1.LocalActivityAttempt"\xbd\x01\n\x18WorkflowActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0bworkflow_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x04 \x01(\t\x12\x1a\n\x12scheduled_event_id\x18\x05 \x01(\x03\x12\x38\n\x07\x61ttempt\x18\x06 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"\x8e\x01\n\x1aStandaloneActivityProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tivity_id\x18\x02 \x01(\t\x12\x0e\n\x06run_id\x18\x03 \x01(\t\x12\x38\n\x07\x61ttempt\x18\x04 \x01(\x0b\x32\'.temporal.api.stream.v1.ActivityAttempt"/\n\x0e\x43lientProducer\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t"\xf5\x02\n\x08Producer\x12<\n\x08workflow\x18\x01 \x01(\x0b\x32(.temporal.api.stream.v1.WorkflowProducerH\x00\x12G\n\x0elocal_activity\x18\x02 \x01(\x0b\x32-.temporal.api.stream.v1.LocalActivityProducerH\x00\x12M\n\x11workflow_activity\x18\x03 \x01(\x0b\x32\x30.temporal.api.stream.v1.WorkflowActivityProducerH\x00\x12Q\n\x13standalone_activity\x18\x04 \x01(\x0b\x32\x32.temporal.api.stream.v1.StandaloneActivityProducerH\x00\x12\x38\n\x06\x63lient\x18\x05 \x01(\x0b\x32&.temporal.api.stream.v1.ClientProducerH\x00\x42\x06\n\x04kind"=\n\x0c\x41ppendRecord\x12-\n\x04\x62ody\x18\x01 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload"\x81\x01\n\x0cStreamRecord\x12\x32\n\x08producer\x18\x01 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12-\n\x04\x62ody\x18\x02 \x01(\x0b\x32\x1f.temporal.api.common.v1.Payload\x12\x0e\n\x06offset\x18\x03 \x01(\x0c"N\n\x12StreamErrorDetails\x12\x38\n\x06reason\x18\x01 \x01(\x0e\x32(.temporal.api.enums.v1.StreamErrorReasonB\x89\x01\n\x19io.temporal.api.stream.v1B\x0cMessageProtoP\x01Z#go.temporal.io/api/stream/v1;stream\xaa\x02\x18Temporalio.Api.Stream.V1\xea\x02\x1bTemporalio::Api::Stream::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -31,30 +31,28 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b"\n\031io.temporal.api.stream.v1B\014MessageProtoP\001Z#go.temporal.io/api/stream/v1;stream\252\002\030Temporalio.Api.Stream.V1\352\002\033Temporalio::Api::Stream::V1" - _STREAMREF._serialized_start = 171 - _STREAMREF._serialized_end = 209 - _WORKFLOWTASKATTEMPT._serialized_start = 211 - _WORKFLOWTASKATTEMPT._serialized_end = 325 - _LOCALACTIVITYATTEMPT._serialized_start = 327 - _LOCALACTIVITYATTEMPT._serialized_end = 425 - _ACTIVITYATTEMPT._serialized_start = 427 - _ACTIVITYATTEMPT._serialized_end = 521 - _WORKFLOWPRODUCER._serialized_start = 524 - _WORKFLOWPRODUCER._serialized_end = 660 - _LOCALACTIVITYPRODUCER._serialized_start = 663 - _LOCALACTIVITYPRODUCER._serialized_end = 826 - _WORKFLOWACTIVITYPRODUCER._serialized_start = 829 - _WORKFLOWACTIVITYPRODUCER._serialized_end = 1018 - _STANDALONEACTIVITYPRODUCER._serialized_start = 1021 - _STANDALONEACTIVITYPRODUCER._serialized_end = 1163 - _CLIENTPRODUCER._serialized_start = 1165 - _CLIENTPRODUCER._serialized_end = 1212 - _PRODUCER._serialized_start = 1215 - _PRODUCER._serialized_end = 1588 - _APPENDRECORD._serialized_start = 1590 - _APPENDRECORD._serialized_end = 1651 - _STREAMRECORD._serialized_start = 1654 - _STREAMRECORD._serialized_end = 1783 - _STREAMERRORDETAILS._serialized_start = 1785 - _STREAMERRORDETAILS._serialized_end = 1863 + _WORKFLOWTASKATTEMPT._serialized_start = 171 + _WORKFLOWTASKATTEMPT._serialized_end = 285 + _LOCALACTIVITYATTEMPT._serialized_start = 287 + _LOCALACTIVITYATTEMPT._serialized_end = 385 + _ACTIVITYATTEMPT._serialized_start = 387 + _ACTIVITYATTEMPT._serialized_end = 481 + _WORKFLOWPRODUCER._serialized_start = 484 + _WORKFLOWPRODUCER._serialized_end = 620 + _LOCALACTIVITYPRODUCER._serialized_start = 623 + _LOCALACTIVITYPRODUCER._serialized_end = 786 + _WORKFLOWACTIVITYPRODUCER._serialized_start = 789 + _WORKFLOWACTIVITYPRODUCER._serialized_end = 978 + _STANDALONEACTIVITYPRODUCER._serialized_start = 981 + _STANDALONEACTIVITYPRODUCER._serialized_end = 1123 + _CLIENTPRODUCER._serialized_start = 1125 + _CLIENTPRODUCER._serialized_end = 1172 + _PRODUCER._serialized_start = 1175 + _PRODUCER._serialized_end = 1548 + _APPENDRECORD._serialized_start = 1550 + _APPENDRECORD._serialized_end = 1611 + _STREAMRECORD._serialized_start = 1614 + _STREAMRECORD._serialized_end = 1743 + _STREAMERRORDETAILS._serialized_start = 1745 + _STREAMERRORDETAILS._serialized_end = 1823 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 1c73eb0e62..1a3d472a20 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -15,39 +15,6 @@ import temporalio.api.enums.v1.stream_pb2 DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -@typing.final -class StreamRef(google.protobuf.message.Message): - """Experimental. Might change in the future. - A reference to one Stream, which code passes to other code as data. Callers treat the `id` as - opaque. An id is never used for a second Stream while the Store remembers the first one, so a - create for a closed or expired Stream fails. A Store can forget an expired Stream after a time - of its choice, and a create for its id succeeds after that. Every SDK encodes a ref in a - Payload with this message, so a ref that one SDK writes decodes in another. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - ID_FIELD_NUMBER: builtins.int - STORE_FIELD_NUMBER: builtins.int - id: builtins.str - store: builtins.str - """The name under which the client and Worker config registered the Store of this Stream. An - SDK uses it to send a call on this ref to the right Store. When it's empty, the SDK picks - the Store from its config. Only an SDK sets and reads this field. The server and a Store - ignore it. - """ - def __init__( - self, - *, - id: builtins.str = ..., - store: builtins.str = ..., - ) -> None: ... - def ClearField( - self, field_name: typing.Literal["id", b"id", "store", b"store"] - ) -> None: ... - -global___StreamRef = StreamRef - @typing.final class WorkflowTaskAttempt(google.protobuf.message.Message): """Experimental. Might change in the future. @@ -172,9 +139,8 @@ global___ActivityAttempt = ActivityAttempt @typing.final class WorkflowProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - The Producer of a Workflow run. Workflow code writes as this Producer when it appends or - closes in a Workflow Task. A write from one of its Local Activities uses a - `LocalActivityProducer`. + The Producer of a Workflow run. Workflow code writes as this Producer when it appends in a + Workflow Task. A write from one of its Local Activities uses a `LocalActivityProducer`. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -545,8 +511,7 @@ global___AppendRecord = AppendRecord @typing.final class StreamRecord(google.protobuf.message.Message): """Experimental. Might change in the future. - One Record of a Stream, as a read returns it. A read returns only Records. A close stores no - Record, so a read reports it with `done` in its response. + One Record of a Stream, as a read returns it. A read returns only Records. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/temporalio/api/streamservice/v1/__init__.py b/temporalio/api/streamservice/v1/__init__.py index 40801cf9a5..a232488de4 100644 --- a/temporalio/api/streamservice/v1/__init__.py +++ b/temporalio/api/streamservice/v1/__init__.py @@ -1,8 +1,6 @@ from .request_response_pb2 import ( AppendRecordsRequest, AppendRecordsResponse, - CloseStreamRequest, - CloseStreamResponse, CreateStreamRequest, CreateStreamResponse, DescribeStreamRequest, @@ -14,8 +12,6 @@ __all__ = [ "AppendRecordsRequest", "AppendRecordsResponse", - "CloseStreamRequest", - "CloseStreamResponse", "CreateStreamRequest", "CreateStreamResponse", "DescribeStreamRequest", diff --git a/temporalio/api/streamservice/v1/request_response_pb2.py b/temporalio/api/streamservice/v1/request_response_pb2.py index fe9390519d..0b54c5bb5d 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.py +++ b/temporalio/api/streamservice/v1/request_response_pb2.py @@ -23,7 +23,7 @@ ) DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( - b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"\x97\x01\n\x13\x43reateStreamRequest\x12\x35\n\nstream_ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy"W\n\x14\x43reateStreamResponse\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x0f\n\x07\x63reated\x18\x02 \x01(\x08"\xb1\x01\n\x14\x41ppendRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x35\n\x07records\x18\x03 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"x\n\x12\x43loseStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer"\x15\n\x13\x43loseStreamResponse"\xaa\x01\n\x12ReadRecordsRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"o\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x12\x0c\n\x04\x64one\x18\x03 \x01(\x08"G\n\x15\x44\x65scribeStreamRequest\x12.\n\x03ref\x18\x01 \x01(\x0b\x32!.temporal.api.stream.v1.StreamRef"b\n\x16\x44\x65scribeStreamResponse\x12\x33\n\x06status\x18\x01 \x01(\x0e\x32#.temporal.api.enums.v1.StreamStatus\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' + b'\n4temporal/api/streamservice/v1/request_response.proto\x12\x1dtemporal.api.streamservice.v1\x1a\x1egoogle/protobuf/duration.proto\x1a"temporal/api/enums/v1/stream.proto\x1a$temporal/api/stream/v1/message.proto"s\n\x13\x43reateStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12I\n\x12id_conflict_policy\x18\x02 \x01(\x0e\x32-.temporal.api.enums.v1.StreamIdConflictPolicy"\'\n\x14\x43reateStreamResponse\x12\x0f\n\x07\x63reated\x18\x01 \x01(\x08"\x94\x01\n\x14\x41ppendRecordsRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x32\n\x08producer\x18\x02 \x01(\x0b\x32 .temporal.api.stream.v1.Producer\x12\x35\n\x07records\x18\x03 \x03(\x0b\x32$.temporal.api.stream.v1.AppendRecord"B\n\x15\x41ppendRecordsResponse\x12\x14\n\x0c\x66irst_offset\x18\x01 \x01(\x0c\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"\x8d\x01\n\x12ReadRecordsRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t\x12\x13\n\x0b\x66rom_offset\x18\x02 \x01(\x0c\x12\x13\n\x0bmax_records\x18\x03 \x01(\x05\x12\x11\n\tmax_bytes\x18\x04 \x01(\x03\x12\'\n\x04wait\x18\x05 \x01(\x0b\x32\x19.google.protobuf.Duration"a\n\x13ReadRecordsResponse\x12\x35\n\x07records\x18\x01 \x03(\x0b\x32$.temporal.api.stream.v1.StreamRecord\x12\x13\n\x0blast_offset\x18\x02 \x01(\x0c"*\n\x15\x44\x65scribeStreamRequest\x12\x11\n\tstream_id\x18\x01 \x01(\t"-\n\x16\x44\x65scribeStreamResponse\x12\x13\n\x0blast_offset\x18\x01 \x01(\x0c\x42\xb4\x01\n io.temporal.api.streamservice.v1B\x14RequestResponseProtoP\x01Z1go.temporal.io/api/streamservice/v1;streamservice\xaa\x02\x1fTemporalio.Api.StreamService.V1\xea\x02"Temporalio::Api::StreamService::V1b\x06proto3' ) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) @@ -31,24 +31,20 @@ if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None DESCRIPTOR._serialized_options = b'\n io.temporal.api.streamservice.v1B\024RequestResponseProtoP\001Z1go.temporal.io/api/streamservice/v1;streamservice\252\002\037Temporalio.Api.StreamService.V1\352\002"Temporalio::Api::StreamService::V1' - _CREATESTREAMREQUEST._serialized_start = 194 - _CREATESTREAMREQUEST._serialized_end = 345 - _CREATESTREAMRESPONSE._serialized_start = 347 - _CREATESTREAMRESPONSE._serialized_end = 434 - _APPENDRECORDSREQUEST._serialized_start = 437 - _APPENDRECORDSREQUEST._serialized_end = 614 - _APPENDRECORDSRESPONSE._serialized_start = 616 - _APPENDRECORDSRESPONSE._serialized_end = 682 - _CLOSESTREAMREQUEST._serialized_start = 684 - _CLOSESTREAMREQUEST._serialized_end = 804 - _CLOSESTREAMRESPONSE._serialized_start = 806 - _CLOSESTREAMRESPONSE._serialized_end = 827 - _READRECORDSREQUEST._serialized_start = 830 - _READRECORDSREQUEST._serialized_end = 1000 - _READRECORDSRESPONSE._serialized_start = 1002 - _READRECORDSRESPONSE._serialized_end = 1113 - _DESCRIBESTREAMREQUEST._serialized_start = 1115 - _DESCRIBESTREAMREQUEST._serialized_end = 1186 - _DESCRIBESTREAMRESPONSE._serialized_start = 1188 - _DESCRIBESTREAMRESPONSE._serialized_end = 1286 + _CREATESTREAMREQUEST._serialized_start = 193 + _CREATESTREAMREQUEST._serialized_end = 308 + _CREATESTREAMRESPONSE._serialized_start = 310 + _CREATESTREAMRESPONSE._serialized_end = 349 + _APPENDRECORDSREQUEST._serialized_start = 352 + _APPENDRECORDSREQUEST._serialized_end = 500 + _APPENDRECORDSRESPONSE._serialized_start = 502 + _APPENDRECORDSRESPONSE._serialized_end = 568 + _READRECORDSREQUEST._serialized_start = 571 + _READRECORDSREQUEST._serialized_end = 712 + _READRECORDSRESPONSE._serialized_start = 714 + _READRECORDSRESPONSE._serialized_end = 811 + _DESCRIBESTREAMREQUEST._serialized_start = 813 + _DESCRIBESTREAMREQUEST._serialized_end = 855 + _DESCRIBESTREAMRESPONSE._serialized_start = 857 + _DESCRIBESTREAMRESPONSE._serialized_end = 902 # @@protoc_insertion_point(module_scope) diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index f1c9eca954..cb36694bc6 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -21,43 +21,38 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor class CreateStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Creates a Stream. If the Stream already exists, the result depends on `id_conflict_policy`. - `FAIL` fails with `ALREADY_EXISTS`, and `USE_EXISTING` returns the Stream with `created` false. A - retry of the create that made the Stream, with the same request id, returns `created` true. The - Store remembers the request id of that create, so a retry after a lost response doesn't fail with - `ALREADY_EXISTS`. Either policy fails with `CLOSED` for a closed Stream and with `EXPIRED` for an - expired one. + `FAIL` fails with `ALREADY_EXISTS`, and `USE_EXISTING` succeeds with `created` false. A retry of + the create that made the Stream, with the same request id, returns `created` true. The Store + remembers the request id of that create, so a retry after a lost response doesn't fail with + `ALREADY_EXISTS`. Either policy fails with `EXPIRED` for an expired Stream. A create has no Retention. Retention is a setting of the Store, as it's a setting of the - namespace for Workflows. + namespace for Workflows. It's the only lifetime setting of a Stream. It starts at the create, + and each append starts it again. When it passes, the Stream is expired. (-- api-linter: core::0133=disabled - aip.dev/not-precedent: The request identifies a Stream by its ref. --) + aip.dev/not-precedent: The request identifies a Stream by its id. --) """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - STREAM_REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int ID_CONFLICT_POLICY_FIELD_NUMBER: builtins.int + stream_id: builtins.str + """Required. The id of the Stream to create. It must not be empty.""" id_conflict_policy: ( temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType ) """What the create does if the Stream already exists. Unspecified means `FAIL`.""" - @property - def stream_ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required. The Stream to create. Its `id` must not be empty.""" - def __init__( self, *, - stream_ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., id_conflict_policy: temporalio.api.enums.v1.stream_pb2.StreamIdConflictPolicy.ValueType = ..., ) -> None: ... - def HasField( - self, field_name: typing.Literal["stream_ref", b"stream_ref"] - ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ - "id_conflict_policy", b"id_conflict_policy", "stream_ref", b"stream_ref" + "id_conflict_policy", b"id_conflict_policy", "stream_id", b"stream_id" ], ) -> None: ... @@ -66,32 +61,20 @@ global___CreateStreamRequest = CreateStreamRequest @typing.final class CreateStreamResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - The Stream that the create made or found. + The result of a create. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int CREATED_FIELD_NUMBER: builtins.int created: builtins.bool - """False when `USE_EXISTING` returned a Stream that already existed.""" - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """The ref of the Stream. The caller can pass it to other code as data. A Store and the server - return the ref as the request had it, because they don't know the Store names of an SDK. - The SDK then sets `store` to the Store that it picked, before the caller gets the ref. - """ - + """False when `USE_EXISTING` found a Stream that already existed.""" def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., created: builtins.bool = ..., ) -> None: ... - def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["created", b"created", "ref", b"ref"] - ) -> None: ... + def ClearField(self, field_name: typing.Literal["created", b"created"]) -> None: ... global___CreateStreamResponse = CreateStreamResponse @@ -109,18 +92,14 @@ class AppendRecordsRequest(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int PRODUCER_FIELD_NUMBER: builtins.int RECORDS_FIELD_NUMBER: builtins.int - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - + stream_id: builtins.str + """Required.""" @property def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: - """Required. The Producer that writes the batch. A Producer sends the same value in its - appends and in its close, so the Store orders all of its writes the same way. - """ + """Required. The Producer that writes the batch.""" @property def records( @@ -133,7 +112,7 @@ class AppendRecordsRequest(google.protobuf.message.Message): def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., records: collections.abc.Iterable[ temporalio.api.stream.v1.message_pb2.AppendRecord @@ -141,12 +120,12 @@ class AppendRecordsRequest(google.protobuf.message.Message): | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] + self, field_name: typing.Literal["producer", b"producer"] ) -> builtins.bool: ... def ClearField( self, field_name: typing.Literal[ - "producer", b"producer", "records", b"records", "ref", b"ref" + "producer", b"producer", "records", b"records", "stream_id", b"stream_id" ], ) -> None: ... @@ -179,69 +158,22 @@ class AppendRecordsResponse(google.protobuf.message.Message): global___AppendRecordsResponse = AppendRecordsResponse -@typing.final -class CloseStreamRequest(google.protobuf.message.Message): - """Experimental. Might change in the future. - Closes a Stream. Readers still get the Records that are left, and then their reads end. Later - appends fail with `CLOSED`. A close writes no Record and has no value, so code with a final - value appends it before the close. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - REF_FIELD_NUMBER: builtins.int - PRODUCER_FIELD_NUMBER: builtins.int - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - - @property - def producer(self) -> temporalio.api.stream.v1.message_pb2.Producer: - """Required. The Producer that closes the Stream.""" - - def __init__( - self, - *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., - producer: temporalio.api.stream.v1.message_pb2.Producer | None = ..., - ) -> None: ... - def HasField( - self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] - ) -> builtins.bool: ... - def ClearField( - self, field_name: typing.Literal["producer", b"producer", "ref", b"ref"] - ) -> None: ... - -global___CloseStreamRequest = CloseStreamRequest - -@typing.final -class CloseStreamResponse(google.protobuf.message.Message): - """Experimental. Might change in the future. - The response to a close. The Store sends it after it has recorded the close. - """ - - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - def __init__( - self, - ) -> None: ... - -global___CloseStreamResponse = CloseStreamResponse - @typing.final class ReadRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. Reads one page of Records after an offset. When no Record is left, the read waits for a new - one or for the close of the Stream, so a reader long-polls. + one, so a reader long-polls. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int + STREAM_ID_FIELD_NUMBER: builtins.int FROM_OFFSET_FIELD_NUMBER: builtins.int MAX_RECORDS_FIELD_NUMBER: builtins.int MAX_BYTES_FIELD_NUMBER: builtins.int WAIT_FIELD_NUMBER: builtins.int + stream_id: builtins.str + """Required.""" from_offset: builtins.bytes """The read returns the Records after this offset. Empty means from the beginning. An offset past the newest one fails with `OFFSET_TOO_HIGH`. To read only new Records, a caller gets @@ -257,27 +189,23 @@ class ReadRecordsRequest(google.protobuf.message.Message): this is still returned, alone in its page, so a read always makes progress. Zero means no limit. """ - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - @property def wait(self) -> google.protobuf.duration_pb2.Duration: - """How long the read waits for a new Record, or for the close of the Stream, before it returns - an empty page. When it's unset, the read returns immediately. + """How long the read waits for a new Record before it returns an empty page. When it's unset, + the read returns immediately. """ def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., from_offset: builtins.bytes = ..., max_records: builtins.int = ..., max_bytes: builtins.int = ..., wait: google.protobuf.duration_pb2.Duration | None = ..., ) -> None: ... def HasField( - self, field_name: typing.Literal["ref", b"ref", "wait", b"wait"] + self, field_name: typing.Literal["wait", b"wait"] ) -> builtins.bool: ... def ClearField( self, @@ -288,8 +216,8 @@ class ReadRecordsRequest(google.protobuf.message.Message): b"max_bytes", "max_records", b"max_records", - "ref", - b"ref", + "stream_id", + b"stream_id", "wait", b"wait", ], @@ -307,7 +235,6 @@ class ReadRecordsResponse(google.protobuf.message.Message): RECORDS_FIELD_NUMBER: builtins.int LAST_OFFSET_FIELD_NUMBER: builtins.int - DONE_FIELD_NUMBER: builtins.int last_offset: builtins.bytes """The last position that the read covered. The next read passes it as `from_offset`. A Store doesn't have to set it. If it's empty, that position is the offset of the last Record in @@ -315,11 +242,6 @@ class ReadRecordsResponse(google.protobuf.message.Message): offset that skips only entries of its own that aren't Records, so the next read doesn't scan them again. """ - done: builtins.bool - """True when the Stream is closed and this page has its last Record. A read has no other sign - of a close, because a close stores no Record. A read of a closed Stream with no Record left - returns immediately with `done`. - """ @property def records( self, @@ -334,12 +256,11 @@ class ReadRecordsResponse(google.protobuf.message.Message): ] | None = ..., last_offset: builtins.bytes = ..., - done: builtins.bool = ..., ) -> None: ... def ClearField( self, field_name: typing.Literal[ - "done", b"done", "last_offset", b"last_offset", "records", b"records" + "last_offset", b"last_offset", "records", b"records" ], ) -> None: ... @@ -348,23 +269,22 @@ global___ReadRecordsResponse = ReadRecordsResponse @typing.final class DescribeStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Gets the status and the newest offset of a Stream. + Gets the newest offset of a Stream. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor - REF_FIELD_NUMBER: builtins.int - @property - def ref(self) -> temporalio.api.stream.v1.message_pb2.StreamRef: - """Required.""" - + STREAM_ID_FIELD_NUMBER: builtins.int + stream_id: builtins.str + """Required.""" def __init__( self, *, - ref: temporalio.api.stream.v1.message_pb2.StreamRef | None = ..., + stream_id: builtins.str = ..., + ) -> None: ... + def ClearField( + self, field_name: typing.Literal["stream_id", b"stream_id"] ) -> None: ... - def HasField(self, field_name: typing.Literal["ref", b"ref"]) -> builtins.bool: ... - def ClearField(self, field_name: typing.Literal["ref", b"ref"]) -> None: ... global___DescribeStreamRequest = DescribeStreamRequest @@ -377,9 +297,7 @@ class DescribeStreamResponse(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - STATUS_FIELD_NUMBER: builtins.int LAST_OFFSET_FIELD_NUMBER: builtins.int - status: temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType last_offset: builtins.bytes """The offset of the newest Record, or an offset after it that skips no Record. A read from it returns only the Records that come later. It's empty when the Stream has no Record. @@ -387,12 +305,10 @@ class DescribeStreamResponse(google.protobuf.message.Message): def __init__( self, *, - status: temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType = ..., last_offset: builtins.bytes = ..., ) -> None: ... def ClearField( - self, - field_name: typing.Literal["last_offset", b"last_offset", "status", b"status"], + self, field_name: typing.Literal["last_offset", b"last_offset"] ) -> None: ... global___DescribeStreamResponse = DescribeStreamResponse diff --git a/temporalio/nexus/system/stream_service/__init__.py b/temporalio/nexus/system/stream_service/__init__.py index e3f70b11cd..5490e8461a 100644 --- a/temporalio/nexus/system/stream_service/__init__.py +++ b/temporalio/nexus/system/stream_service/__init__.py @@ -8,8 +8,6 @@ AppendRecordsRequest, AppendRecordsResponse, ClientProducer, - CloseStreamRequest, - CloseStreamResponse, CreateStreamRequest, CreateStreamResult, DescribeStreamRequest, @@ -29,7 +27,6 @@ StreamIdConflictPolicy, StreamRecord, StreamRef, - StreamStatus, Timestamp, WorkflowActivityProducer, WorkflowProducer, @@ -43,8 +40,6 @@ "AppendRecordsRequest", "AppendRecordsResponse", "ClientProducer", - "CloseStreamRequest", - "CloseStreamResponse", "CreateStreamRequest", "CreateStreamResult", "DescribeStreamRequest", @@ -64,7 +59,6 @@ "StreamIdConflictPolicy", "StreamRecord", "StreamRef", - "StreamStatus", "Timestamp", "WorkflowActivityProducer", "WorkflowProducer", diff --git a/temporalio/nexus/system/stream_service/_resource_context_manager.py b/temporalio/nexus/system/stream_service/_resource_context_manager.py deleted file mode 100644 index fa0c8b6fe9..0000000000 --- a/temporalio/nexus/system/stream_service/_resource_context_manager.py +++ /dev/null @@ -1,93 +0,0 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! - -from __future__ import annotations - -import collections.abc -import functools -import types -import typing - -import typing_extensions - - -class _Closable(typing.Protocol): - async def __aenter__(self) -> object: ... - - async def __aexit__( - self, - exc_type: type[BaseException] | None, - exc: BaseException | None, - tb: types.TracebackType | None, - ) -> None: ... - - -_ResourceT = typing.TypeVar("_ResourceT", bound=_Closable) -_P = typing_extensions.ParamSpec("_P") - - -@typing.final -class ResourceContextManager( - collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT], - typing.Generic[_ResourceT], -): - """The create call. You can use it two ways. Await it to get the resource and manage it - yourself. Or open it with ``async with`` to get the resource and close it at the end of the - block. The ``async with`` form does the create for you, so you do not add a separate await.""" - - def __init__( - self, call: collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT] - ) -> None: - self._call: collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT] = call - self._resource: _ResourceT | None = None - self.__name__: str = getattr(call, "__name__", type(self).__name__) - self.__qualname__: str = getattr(call, "__qualname__", self.__name__) - - @typing_extensions.override - def __await__(self) -> collections.abc.Generator[typing.Any, None, _ResourceT]: - return self._call.__await__() - - @typing_extensions.override - def send(self, value: typing.Any) -> typing.Any: - return self._call.send(value) - - @typing_extensions.override - def throw( - self, - typ: typing.Any, - val: typing.Any = None, - tb: types.TracebackType | None = None, - ) -> typing.Any: - return self._call.throw(typ, val, tb) - - @typing_extensions.override - def close(self) -> None: - self._call.close() - - async def __aenter__(self) -> _ResourceT: - resource = await self._call - _ = await resource.__aenter__() - self._resource = resource - return resource - - async def __aexit__( - self, - exc_type: type[BaseException] | None, - exc: BaseException | None, - tb: types.TracebackType | None, - ) -> None: - if self._resource is not None: - await self._resource.__aexit__(exc_type, exc, tb) - - -def resource_context_manager( - function: collections.abc.Callable[ - _P, collections.abc.Coroutine[typing.Any, typing.Any, _ResourceT] - ], -) -> collections.abc.Callable[_P, ResourceContextManager[_ResourceT]]: - """Wraps a call that returns a closable resource in a ``ResourceContextManager``.""" - - @functools.wraps(function) - def call(*args: _P.args, **kwargs: _P.kwargs) -> ResourceContextManager[_ResourceT]: - return ResourceContextManager(function(*args, **kwargs)) - - return call diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index 4cf7bc5d4b..3ff7aac9a2 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -13,7 +13,6 @@ if typing.TYPE_CHECKING: import temporalio.client -from .._resource_context_manager import resource_context_manager from ..models import ( CreateStreamRequest, CreateStreamResult, @@ -118,7 +117,6 @@ async def _stream_service_create_stream( return resource @typing.overload - @resource_context_manager async def create_stream( self, *, @@ -131,7 +129,6 @@ async def create_stream( ) -> Stream[BodyT]: ... @typing.overload - @resource_context_manager async def create_stream( self, *, @@ -143,7 +140,6 @@ async def create_stream( rpc_timeout: datetime.timedelta | None = None, ) -> Stream[object]: ... - @resource_context_manager async def create_stream( self, *, diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index f0545a5da0..07c2f528f9 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -4,12 +4,9 @@ import collections.abc import datetime -import types import typing import uuid as _uuid -import typing_extensions - if typing.TYPE_CHECKING: import temporalio.client @@ -20,7 +17,6 @@ AppendRecord, AppendRecordsRequest, AppendRecordsResponse, - CloseStreamRequest, DescribeStreamRequest, DescribeStreamResponse, Producer, @@ -59,17 +55,6 @@ def body_type(self) -> type[BodyT]: arguments = typing.get_args(getattr(self.ref, "__orig_class__", None)) return typing.cast("type[BodyT]", arguments[0] if arguments else object) - async def __aenter__(self) -> typing_extensions.Self: - return self - - async def __aexit__( - self, - exc_type: type[BaseException] | None, - exc: BaseException | None, - tb: types.TracebackType | None, - ) -> None: - await self.close() - async def append( self, *records: BodyT, @@ -96,31 +81,6 @@ async def append( ) return await handle.result() - async def close( - self, - producer: Producer | None = None, - *, - rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, - rpc_timeout: datetime.timedelta | None = None, - ) -> None: - """Close the Stream. Readers get the Records that are left, then end.""" - request = CloseStreamRequest( - ref=self.ref, - producer=( - (_support.default_producer(self._nexus_client)) - if producer is None - else producer - ), - ) - handle = await self._nexus_client.start_operation( - operation=StreamService.close_stream, - arg=request, - id=f"{_uuid.uuid4()}", - rpc_metadata=rpc_metadata or {}, - rpc_timeout=rpc_timeout, - ) - _ = await handle.result() - async def read_page( self, from_offset: bytes | None = None, @@ -166,8 +126,7 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record or a close before an empty - page. + wait: How long the read waits for a new Record before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ @@ -215,8 +174,7 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record or a close before an empty - page. + wait: How long the read waits for a new Record before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ @@ -248,7 +206,7 @@ async def describe( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> DescribeStreamResponse: - """Return the status and the newest offset of the Stream.""" + """Return the newest offset of the Stream.""" request = DescribeStreamRequest( ref=self.ref, ) diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index 65561d2511..870869ccd5 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -11,6 +11,7 @@ import typing_extensions import temporalio.api.enums.v1.stream_pb2 +import temporalio.api.sdk.v1.stream_pb2 import temporalio.api.stream.v1.message_pb2 import temporalio.api.streamservice.v1.request_response_pb2 import temporalio.converter @@ -23,20 +24,6 @@ class StreamIdConflictPolicy(enum.IntEnum): StreamIdConflictPolicyUseExisting = 2 -class StreamStatus(enum.IntEnum): - StreamStatusUnspecified = 0 - StreamStatusOpen = 1 - StreamStatusClosed = 2 - - -def _stream_status_from_proto(value: int) -> StreamStatus: - try: - return StreamStatus(value) - except ValueError: - # A newer peer can send a case that this enum doesn't know. - return StreamStatus.StreamStatusUnspecified - - BodyT = typing.TypeVar("BodyT") _BodyT = typing_extensions.TypeVar("_BodyT", default=object) @@ -51,19 +38,17 @@ class CreateStreamRequest(typing.Generic[BodyT]): class _CreateStreamRequestTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - CreateStreamRequest[BodyT], - temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest, + CreateStreamRequest[BodyT], temporalio.api.sdk.v1.stream_pb2.CreateStreamRequest ] ): - transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest + transfer_type: type[temporalio.api.sdk.v1.stream_pb2.CreateStreamRequest] | None = ( + temporalio.api.sdk.v1.stream_pb2.CreateStreamRequest + ) @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest, + value: temporalio.api.sdk.v1.stream_pb2.CreateStreamRequest, type_hint: type[CreateStreamRequest[BodyT]], ) -> CreateStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) @@ -86,10 +71,8 @@ def from_transfer_type( def to_transfer_type( self, value: CreateStreamRequest[BodyT], - ) -> temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.CreateStreamRequest() - ) + ) -> temporalio.api.sdk.v1.stream_pb2.CreateStreamRequest: + message = temporalio.api.sdk.v1.stream_pb2.CreateStreamRequest() message.stream_ref.CopyFrom( _StreamRefTransferTypeConverter().to_transfer_type(value.stream_ref) ) @@ -117,17 +100,17 @@ class StreamRef(typing.Generic[_BodyT]): class _StreamRefTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - StreamRef[BodyT], temporalio.api.stream.v1.message_pb2.StreamRef + StreamRef[BodyT], temporalio.api.sdk.v1.stream_pb2.StreamRef ] ): - transfer_type: type[temporalio.api.stream.v1.message_pb2.StreamRef] | None = ( - temporalio.api.stream.v1.message_pb2.StreamRef + transfer_type: type[temporalio.api.sdk.v1.stream_pb2.StreamRef] | None = ( + temporalio.api.sdk.v1.stream_pb2.StreamRef ) @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.stream.v1.message_pb2.StreamRef, + value: temporalio.api.sdk.v1.stream_pb2.StreamRef, type_hint: type[StreamRef[BodyT]], ) -> StreamRef[BodyT]: (_body_type,) = typing.get_args(type_hint) or (typing.Any,) @@ -143,8 +126,8 @@ def from_transfer_type( def to_transfer_type( self, value: StreamRef[BodyT], - ) -> temporalio.api.stream.v1.message_pb2.StreamRef: - message = temporalio.api.stream.v1.message_pb2.StreamRef() + ) -> temporalio.api.sdk.v1.stream_pb2.StreamRef: + message = temporalio.api.sdk.v1.stream_pb2.StreamRef() message.id = value.id if value.store is not None: message.store = value.store @@ -164,19 +147,17 @@ class CreateStreamResult(typing.Generic[BodyT]): class _CreateStreamResultTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - CreateStreamResult[BodyT], - temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, + CreateStreamResult[BodyT], temporalio.api.sdk.v1.stream_pb2.CreateStreamResponse ] ): transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse + type[temporalio.api.sdk.v1.stream_pb2.CreateStreamResponse] | None + ) = temporalio.api.sdk.v1.stream_pb2.CreateStreamResponse @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse, + value: temporalio.api.sdk.v1.stream_pb2.CreateStreamResponse, type_hint: type[CreateStreamResult[BodyT]], ) -> CreateStreamResult[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) @@ -196,10 +177,8 @@ def from_transfer_type( def to_transfer_type( self, value: CreateStreamResult[BodyT], - ) -> temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.CreateStreamResponse() - ) + ) -> temporalio.api.sdk.v1.stream_pb2.CreateStreamResponse: + message = temporalio.api.sdk.v1.stream_pb2.CreateStreamResponse() if value.ref is not None: message.ref.CopyFrom( _StreamRefTransferTypeConverter().to_transfer_type(value.ref) @@ -226,18 +205,17 @@ class AppendRecordsRequest(typing.Generic[BodyT]): class _AppendRecordsRequestTransferTypeConverter( temporalio.converter.TransferTypeConverter[ AppendRecordsRequest[BodyT], - temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest, + temporalio.api.sdk.v1.stream_pb2.AppendRecordsRequest, ] ): transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest + type[temporalio.api.sdk.v1.stream_pb2.AppendRecordsRequest] | None + ) = temporalio.api.sdk.v1.stream_pb2.AppendRecordsRequest @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest, + value: temporalio.api.sdk.v1.stream_pb2.AppendRecordsRequest, type_hint: type[AppendRecordsRequest[BodyT]], ) -> AppendRecordsRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) @@ -273,10 +251,8 @@ def from_transfer_type( def to_transfer_type( self, value: AppendRecordsRequest[BodyT], - ) -> temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.AppendRecordsRequest() - ) + ) -> temporalio.api.sdk.v1.stream_pb2.AppendRecordsRequest: + message = temporalio.api.sdk.v1.stream_pb2.AppendRecordsRequest() message.ref.CopyFrom( _StreamRefTransferTypeConverter().to_transfer_type(value.ref) ) @@ -1057,112 +1033,6 @@ def to_transfer_type( )(AppendRecordsResponse) # pyright: ignore[reportUnusedCallResult] -@dataclasses.dataclass(slots=True) -class CloseStreamRequest(typing.Generic[BodyT]): - """Close a Stream. Readers get the Records that are left. Later appends fail.""" - - ref: StreamRef[BodyT] - producer: Producer - - -class _CloseStreamRequestTransferTypeConverter( - temporalio.converter.TransferTypeConverter[ - CloseStreamRequest[BodyT], - temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest, - ] -): - transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest - - @typing_extensions.override - def from_transfer_type( - self, - value: temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest, - type_hint: type[CloseStreamRequest[BodyT]], - ) -> CloseStreamRequest[BodyT]: - (body_type,) = typing.get_args(type_hint) or (typing.Any,) - if not value.HasField("ref"): - raise ValueError("missing required field CloseStreamRequest.ref") - ref = typing.cast( - StreamRef[BodyT], - _StreamRefTransferTypeConverter().from_transfer_type( - value.ref, StreamRef[body_type] - ), - ) - if not value.HasField("producer"): - raise ValueError("missing required field CloseStreamRequest.producer") - producer = _ProducerTransferTypeConverter().from_transfer_type( - value.producer, Producer - ) - return CloseStreamRequest( - ref=ref, - producer=producer, - ) - - @typing_extensions.override - def to_transfer_type( - self, - value: CloseStreamRequest[BodyT], - ) -> temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.CloseStreamRequest() - ) - message.ref.CopyFrom( - _StreamRefTransferTypeConverter().to_transfer_type(value.ref) - ) - message.producer.CopyFrom( - _ProducerTransferTypeConverter().to_transfer_type(value.producer) - ) - return message - - -temporalio.converter.transfer_type_convertible( - _CloseStreamRequestTransferTypeConverter[typing.Any] -)(CloseStreamRequest) # pyright: ignore[reportUnusedCallResult] - - -@dataclasses.dataclass(slots=True) -class CloseStreamResponse: - pass - - -class _CloseStreamResponseTransferTypeConverter( - temporalio.converter.TransferTypeConverter[ - CloseStreamResponse, - temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse, - ] -): - transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse - - @typing_extensions.override - def from_transfer_type( - self, - value: temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse, - type_hint: type[CloseStreamResponse], - ) -> CloseStreamResponse: - return CloseStreamResponse() - - @typing_extensions.override - def to_transfer_type( - self, - value: CloseStreamResponse, - ) -> temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.CloseStreamResponse() - ) - return message - - -temporalio.converter.transfer_type_convertible( - _CloseStreamResponseTransferTypeConverter -)(CloseStreamResponse) # pyright: ignore[reportUnusedCallResult] - - @dataclasses.dataclass(slots=True) class ReadRecordsRequest(typing.Generic[BodyT]): """Read Records after an offset.""" @@ -1176,19 +1046,17 @@ class ReadRecordsRequest(typing.Generic[BodyT]): class _ReadRecordsRequestTransferTypeConverter( temporalio.converter.TransferTypeConverter[ - ReadRecordsRequest[BodyT], - temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest, + ReadRecordsRequest[BodyT], temporalio.api.sdk.v1.stream_pb2.ReadRecordsRequest ] ): - transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest + transfer_type: type[temporalio.api.sdk.v1.stream_pb2.ReadRecordsRequest] | None = ( + temporalio.api.sdk.v1.stream_pb2.ReadRecordsRequest + ) @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest, + value: temporalio.api.sdk.v1.stream_pb2.ReadRecordsRequest, type_hint: type[ReadRecordsRequest[BodyT]], ) -> ReadRecordsRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) @@ -1214,10 +1082,8 @@ def from_transfer_type( def to_transfer_type( self, value: ReadRecordsRequest[BodyT], - ) -> temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.ReadRecordsRequest() - ) + ) -> temporalio.api.sdk.v1.stream_pb2.ReadRecordsRequest: + message = temporalio.api.sdk.v1.stream_pb2.ReadRecordsRequest() message.ref.CopyFrom( _StreamRefTransferTypeConverter().to_transfer_type(value.ref) ) @@ -1237,11 +1103,10 @@ def to_transfer_type( )(ReadRecordsRequest) # pyright: ignore[reportUnusedCallResult] -@dataclasses.dataclass(slots=True, kw_only=True) +@dataclasses.dataclass(slots=True) class ReadRecordsResponse(typing.Generic[BodyT]): records: list[StreamRecord[BodyT]] last_offset: bytes | None = None - done: bool class _ReadRecordsResponseTransferTypeConverter( @@ -1271,11 +1136,9 @@ def from_transfer_type( ) for item in value.records ] - done = value.done return ReadRecordsResponse( records=records, last_offset=value.last_offset if bool(value.last_offset) else None, - done=done, ) @typing_extensions.override @@ -1293,7 +1156,6 @@ def to_transfer_type( ) if value.last_offset is not None: message.last_offset = value.last_offset - message.done = value.done return message @@ -1371,18 +1233,17 @@ class DescribeStreamRequest(typing.Generic[BodyT]): class _DescribeStreamRequestTransferTypeConverter( temporalio.converter.TransferTypeConverter[ DescribeStreamRequest[BodyT], - temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest, + temporalio.api.sdk.v1.stream_pb2.DescribeStreamRequest, ] ): transfer_type: ( - type[temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest] - | None - ) = temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest + type[temporalio.api.sdk.v1.stream_pb2.DescribeStreamRequest] | None + ) = temporalio.api.sdk.v1.stream_pb2.DescribeStreamRequest @typing_extensions.override def from_transfer_type( self, - value: temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest, + value: temporalio.api.sdk.v1.stream_pb2.DescribeStreamRequest, type_hint: type[DescribeStreamRequest[BodyT]], ) -> DescribeStreamRequest[BodyT]: (body_type,) = typing.get_args(type_hint) or (typing.Any,) @@ -1402,10 +1263,8 @@ def from_transfer_type( def to_transfer_type( self, value: DescribeStreamRequest[BodyT], - ) -> temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest: - message = ( - temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamRequest() - ) + ) -> temporalio.api.sdk.v1.stream_pb2.DescribeStreamRequest: + message = temporalio.api.sdk.v1.stream_pb2.DescribeStreamRequest() message.ref.CopyFrom( _StreamRefTransferTypeConverter().to_transfer_type(value.ref) ) @@ -1419,7 +1278,6 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class DescribeStreamResponse: - status: StreamStatus | None = None last_offset: bytes | None = None @@ -1443,9 +1301,6 @@ def from_transfer_type( type_hint: type[DescribeStreamResponse], ) -> DescribeStreamResponse: return DescribeStreamResponse( - status=_stream_status_from_proto(value.status) - if value.status != 0 - else None, last_offset=value.last_offset if bool(value.last_offset) else None, ) @@ -1455,10 +1310,6 @@ def to_transfer_type( value: DescribeStreamResponse, ) -> temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse: message = temporalio.api.streamservice.v1.request_response_pb2.DescribeStreamResponse() - if value.status is not None: - message.status = temporalio.api.enums.v1.stream_pb2.StreamStatus.ValueType( - value.status - ) if value.last_offset is not None: message.last_offset = value.last_offset return message diff --git a/temporalio/nexus/system/stream_service/services.py b/temporalio/nexus/system/stream_service/services.py index fba6e9c0b2..32c3137d1a 100644 --- a/temporalio/nexus/system/stream_service/services.py +++ b/temporalio/nexus/system/stream_service/services.py @@ -9,8 +9,6 @@ from .models import ( AppendRecordsRequest, AppendRecordsResponse, - CloseStreamRequest, - CloseStreamResponse, CreateStreamRequest, CreateStreamResult, DescribeStreamRequest, @@ -37,11 +35,6 @@ class StreamService: AppendRecordsResponse, ] = Operation(name="AppendRecords") - close_stream: Operation[ - CloseStreamRequest[typing.Any], - CloseStreamResponse, - ] = Operation(name="CloseStream") - read_records: Operation[ ReadRecordsRequest[typing.Any], ReadRecordsResponse[typing.Any], diff --git a/temporalio/nexus/system/stream_service/workflow/__init__.py b/temporalio/nexus/system/stream_service/workflow/__init__.py index a933f9fddb..f7b8423df4 100644 --- a/temporalio/nexus/system/stream_service/workflow/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/__init__.py @@ -63,12 +63,6 @@ def __init__( ): _NexusOperationInfo( operation=_services.StreamService.append_records, ), - ( - "temporal.api.streamservice.v1.StreamService", - "CloseStream", - ): _NexusOperationInfo( - operation=_services.StreamService.close_stream, - ), ( "temporal.api.streamservice.v1.StreamService", "ReadRecords", diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 0c2c4fd2ae..7beb83d443 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -4,11 +4,8 @@ import collections.abc import datetime -import types import typing -import typing_extensions - import temporalio.nexus.system import temporalio.nexus.system._support as _support import temporalio.workflow @@ -18,8 +15,6 @@ AppendRecord, AppendRecordsRequest, AppendRecordsResponse, - CloseStreamRequest, - CloseStreamResponse, DescribeStreamRequest, DescribeStreamResponse, ReadRecordsRequest, @@ -52,17 +47,6 @@ def body_type(self) -> type[BodyT]: arguments = typing.get_args(getattr(self.ref, "__orig_class__", None)) return typing.cast("type[BodyT]", arguments[0] if arguments else object) - async def __aenter__(self) -> typing_extensions.Self: - return self - - async def __aexit__( - self, - exc_type: type[BaseException] | None, - exc: BaseException | None, - tb: types.TracebackType | None, - ) -> None: - await self.close() - async def append( self, *records: BodyT, @@ -76,17 +60,6 @@ async def append( handle = await _append_records(request) return await handle - async def close( - self, - ) -> None: - """Close the Stream. Readers get the Records that are left, then end.""" - request = CloseStreamRequest( - ref=self.ref, - producer=_support.workflow_producer(), - ) - handle = await _close_stream(request) - await handle - async def read_page( self, from_offset: bytes | None = None, @@ -119,8 +92,7 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record or a close before an empty - page. + wait: How long the read waits for a new Record before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ @@ -157,8 +129,7 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record or a close before an empty - page. + wait: How long the read waits for a new Record before an empty page. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ @@ -185,7 +156,7 @@ def read( async def describe( self, ) -> DescribeStreamResponse: - """Return the status and the newest offset of the Stream.""" + """Return the newest offset of the Stream.""" request = DescribeStreamRequest( ref=self.ref, ) @@ -246,20 +217,6 @@ async def _append_records( ) -async def _close_stream( - request: CloseStreamRequest[BodyT], -) -> temporalio.workflow.NexusOperationHandle[CloseStreamResponse,]: - nexus_client = temporalio.workflow.create_nexus_client( - service="temporal.api.streamservice.v1.StreamService", - endpoint=temporalio.nexus.system.TEMPORAL_SYSTEM_ENDPOINT, - ) - return await nexus_client.start_operation( - operation="CloseStream", - input=request, - output_type=CloseStreamResponse, - ) - - async def _read_records( request: ReadRecordsRequest[BodyT], body_type: type[BodyT], diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py index d87e5f8748..11275b599c 100644 --- a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -55,19 +55,6 @@ async def _start_system_nexus_operation( "temporalio.workflow.NexusOperationHandle[_OutputT]", await interceptor.start_append_records(typed_input.input), ) - if ( - input.service == "temporal.api.streamservice.v1.StreamService" - and input.operation_name == "CloseStream" - ): - typed_input = typing.cast( - "StartNexusOperationInput[models.CloseStreamRequest[typing.Any], models.CloseStreamResponse]", - input, - ) - # The dispatch check above establishes that this operation's response type is _OutputT. - return typing.cast( - "temporalio.workflow.NexusOperationHandle[_OutputT]", - await interceptor.start_close_stream(typed_input.input), - ) if ( input.service == "temporal.api.streamservice.v1.StreamService" and input.operation_name == "ReadRecords" @@ -125,12 +112,6 @@ async def start_append_records( """Intercept the AppendRecords operation.""" return await self._next_system_nexus_interceptor().start_append_records(request) - async def start_close_stream( - self, request: models.CloseStreamRequest[typing.Any] - ) -> temporalio.workflow.NexusOperationHandle[models.CloseStreamResponse]: - """Intercept the CloseStream operation.""" - return await self._next_system_nexus_interceptor().start_close_stream(request) - async def start_read_records( self, request: models.ReadRecordsRequest[typing.Any], @@ -214,29 +195,6 @@ async def start_append_records( ) ) - async def start_close_stream( - self, request: models.CloseStreamRequest[typing.Any] - ) -> temporalio.workflow.NexusOperationHandle[models.CloseStreamResponse]: - from temporalio.nexus.system import TEMPORAL_SYSTEM_ENDPOINT - from temporalio.worker._interceptor import StartNexusOperationInput - from temporalio.workflow import NexusOperationCancellationType - - return await self._schedule_system_nexus_operation( - StartNexusOperationInput( - endpoint=TEMPORAL_SYSTEM_ENDPOINT, - service="temporal.api.streamservice.v1.StreamService", - operation="CloseStream", - input=request, - output_type=models.CloseStreamResponse, - schedule_to_close_timeout=None, - schedule_to_start_timeout=None, - start_to_close_timeout=None, - cancellation_type=NexusOperationCancellationType.WAIT_COMPLETED, - headers=None, - summary=None, - ) - ) - async def start_read_records( self, request: models.ReadRecordsRequest[typing.Any], diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 3d244a3a6c..1f32e906a2 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -7,7 +7,6 @@ import temporalio.nexus.system import temporalio.workflow -from ..._resource_context_manager import resource_context_manager from ...models import ( CreateStreamRequest, CreateStreamResult, @@ -42,7 +41,6 @@ async def _create_stream( @typing.overload -@resource_context_manager async def create_stream( *, id: str, @@ -53,7 +51,6 @@ async def create_stream( @typing.overload -@resource_context_manager async def create_stream( *, id: str, @@ -63,7 +60,6 @@ async def create_stream( ) -> Stream[object]: ... -@resource_context_manager async def create_stream( *, id: str, From 523848f164315f6a4cf50143eb433719fbee137b Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Wed, 25 Nov 2026 18:24:01 -0700 Subject: [PATCH 18/24] Generate the Nexus system API with nexgen 0.2.14 nexgen 0.2.14 is the first release that accepts the Stream WIT, so check-protos can generate it. The code is the same as before, only the version in each file header changes. --- scripts/gen_nexus_system_api.py | 2 +- temporalio/nexus/notifications/__init__.py | 2 +- temporalio/nexus/notifications/models.py | 2 +- temporalio/nexus/system/stream_service/__init__.py | 2 +- temporalio/nexus/system/stream_service/_poll.py | 2 +- temporalio/nexus/system/stream_service/client/__init__.py | 2 +- temporalio/nexus/system/stream_service/client/_extensions.py | 2 +- .../nexus/system/stream_service/client/_resources/__init__.py | 2 +- .../nexus/system/stream_service/client/_resources/stream.py | 2 +- temporalio/nexus/system/stream_service/models.py | 2 +- temporalio/nexus/system/stream_service/services.py | 2 +- temporalio/nexus/system/stream_service/workflow/__init__.py | 2 +- .../nexus/system/stream_service/workflow/_resources/__init__.py | 2 +- .../nexus/system/stream_service/workflow/_resources/stream.py | 2 +- .../system/stream_service/workflow/_system_nexus_interceptor.py | 2 +- .../nexus/system/stream_service/workflow/operations/__init__.py | 2 +- .../system/stream_service/workflow/operations/create_stream.py | 2 +- temporalio/nexus/system/workflow_service/__init__.py | 2 +- .../nexus/system/workflow_service/_system_nexus_interceptor.py | 2 +- temporalio/nexus/system/workflow_service/models.py | 2 +- temporalio/nexus/system/workflow_service/operations/__init__.py | 2 +- .../workflow_service/operations/signal_with_start_workflow.py | 2 +- temporalio/nexus/system/workflow_service/services.py | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index 61bad6341b..913af05616 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -26,7 +26,7 @@ notification_output_dir = base_dir / "temporalio" / "nexus" / "notifications" stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service" workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py" -NEX_GEN_VERSION = "0.2.13" +NEX_GEN_VERSION = "0.2.14" proto_files = [ gen_protos.api_proto_dir / "temporal" diff --git a/temporalio/nexus/notifications/__init__.py b/temporalio/nexus/notifications/__init__.py index 8904171e02..29fc72fbea 100644 --- a/temporalio/nexus/notifications/__init__.py +++ b/temporalio/nexus/notifications/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/notifications/models.py b/temporalio/nexus/notifications/models.py index 0eb97fae21..ffa44ba82a 100644 --- a/temporalio/nexus/notifications/models.py +++ b/temporalio/nexus/notifications/models.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/__init__.py b/temporalio/nexus/system/stream_service/__init__.py index 5490e8461a..f3df0b0fb4 100644 --- a/temporalio/nexus/system/stream_service/__init__.py +++ b/temporalio/nexus/system/stream_service/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/_poll.py b/temporalio/nexus/system/stream_service/_poll.py index 6910c0c5b9..a7628506cc 100644 --- a/temporalio/nexus/system/stream_service/_poll.py +++ b/temporalio/nexus/system/stream_service/_poll.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/__init__.py b/temporalio/nexus/system/stream_service/client/__init__.py index 2debc404b6..4d358ab45a 100644 --- a/temporalio/nexus/system/stream_service/client/__init__.py +++ b/temporalio/nexus/system/stream_service/client/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index 3ff7aac9a2..7c43097ee6 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/_resources/__init__.py b/temporalio/nexus/system/stream_service/client/_resources/__init__.py index c4e5635675..fd52fe93f3 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/__init__.py +++ b/temporalio/nexus/system/stream_service/client/_resources/__init__.py @@ -1,3 +1,3 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index 07c2f528f9..cddf3ab97e 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index 870869ccd5..d5b815af33 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/services.py b/temporalio/nexus/system/stream_service/services.py index 32c3137d1a..d2c21e3f23 100644 --- a/temporalio/nexus/system/stream_service/services.py +++ b/temporalio/nexus/system/stream_service/services.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/__init__.py b/temporalio/nexus/system/stream_service/workflow/__init__.py index f7b8423df4..c886841f74 100644 --- a/temporalio/nexus/system/stream_service/workflow/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py b/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py index 997e556b26..501c93db22 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 7beb83d443..84d5b1b418 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py index 11275b599c..11d737cede 100644 --- a/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/stream_service/workflow/_system_nexus_interceptor.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/operations/__init__.py b/temporalio/nexus/system/stream_service/workflow/operations/__init__.py index c4e5635675..fd52fe93f3 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/__init__.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/__init__.py @@ -1,3 +1,3 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 1f32e906a2..2655d6483f 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/workflow_service/__init__.py b/temporalio/nexus/system/workflow_service/__init__.py index 153d00a3c2..bb3cacad8b 100644 --- a/temporalio/nexus/system/workflow_service/__init__.py +++ b/temporalio/nexus/system/workflow_service/__init__.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/workflow_service/_system_nexus_interceptor.py b/temporalio/nexus/system/workflow_service/_system_nexus_interceptor.py index 82b81c63a0..6a86df28f4 100644 --- a/temporalio/nexus/system/workflow_service/_system_nexus_interceptor.py +++ b/temporalio/nexus/system/workflow_service/_system_nexus_interceptor.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/workflow_service/models.py b/temporalio/nexus/system/workflow_service/models.py index a17f83a296..b6472b0f65 100644 --- a/temporalio/nexus/system/workflow_service/models.py +++ b/temporalio/nexus/system/workflow_service/models.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/workflow_service/operations/__init__.py b/temporalio/nexus/system/workflow_service/operations/__init__.py index c4e5635675..fd52fe93f3 100644 --- a/temporalio/nexus/system/workflow_service/operations/__init__.py +++ b/temporalio/nexus/system/workflow_service/operations/__init__.py @@ -1,3 +1,3 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/workflow_service/operations/signal_with_start_workflow.py b/temporalio/nexus/system/workflow_service/operations/signal_with_start_workflow.py index 35f1e0934b..b697ace130 100644 --- a/temporalio/nexus/system/workflow_service/operations/signal_with_start_workflow.py +++ b/temporalio/nexus/system/workflow_service/operations/signal_with_start_workflow.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations diff --git a/temporalio/nexus/system/workflow_service/services.py b/temporalio/nexus/system/workflow_service/services.py index b9d6f3d943..46cdbf596a 100644 --- a/temporalio/nexus/system/workflow_service/services.py +++ b/temporalio/nexus/system/workflow_service/services.py @@ -1,4 +1,4 @@ -# Generated by nexgen v0.2.13. DO NOT EDIT! +# Generated by nexgen v0.2.14. DO NOT EDIT! from __future__ import annotations From 3574894011b508b5bfd2238076821580c5e7c111 Mon Sep 17 00:00:00 2001 From: Moe Dashti Date: Wed, 25 Nov 2026 21:19:38 -0700 Subject: [PATCH 19/24] Pin Core to the Streams protos with the read doc of api#895 The generated read docstrings say the poll iterator keeps reading after a page with no Record. The bridge lock adds the crates the new Core asks for. --- temporalio/bridge/Cargo.lock | 49 +++++++++++++++++++ temporalio/bridge/sdk-core | 2 +- .../client/_resources/stream.py | 10 ++-- .../workflow/_resources/stream.py | 10 ++-- 4 files changed, 64 insertions(+), 7 deletions(-) diff --git a/temporalio/bridge/Cargo.lock b/temporalio/bridge/Cargo.lock index 1aaae8a89d..5a39070232 100644 --- a/temporalio/bridge/Cargo.lock +++ b/temporalio/bridge/Cargo.lock @@ -1339,6 +1339,29 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" +[[package]] +name = "nexus-rpc" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6bd72bb0b8a558f1ad4e6502a47d6db0c07b93902a11d7f806f8791b6b14f7b" +dependencies = [ + "nexus-rpc-macros", + "serde", + "thiserror", +] + +[[package]] +name = "nexus-rpc-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be6dc5d7783ce0428a2baf74d82bd816f8e9fb30543ff07a9e0e0556e6839dd9" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "nix" version = "0.32.0" @@ -1683,6 +1706,15 @@ dependencies = [ "syn 3.0.10", ] +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -2686,6 +2718,7 @@ dependencies = [ "derive_more", "erased-serde", "futures", + "nexus-rpc", "parking_lot", "prost", "prost-wkt-types", @@ -2716,6 +2749,7 @@ dependencies = [ "http", "pbjson", "pbjson-build", + "percent-encoding", "prost", "prost-wkt-types", "serde", @@ -2913,6 +2947,18 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.25.19+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + [[package]] name = "toml_parser" version = "1.1.6+spec-1.1.0" @@ -3607,6 +3653,9 @@ name = "winnow" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef" +dependencies = [ + "memchr", +] [[package]] name = "wit-bindgen" diff --git a/temporalio/bridge/sdk-core b/temporalio/bridge/sdk-core index 45434777fc..8990e6c4ef 160000 --- a/temporalio/bridge/sdk-core +++ b/temporalio/bridge/sdk-core @@ -1 +1 @@ -Subproject commit 45434777fc4b496c8a9f78c263c030e828d5c5cf +Subproject commit 8990e6c4ef9fc848d3dda015974db240b2535c63 diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index cddf3ab97e..38eddafec7 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -91,7 +91,9 @@ async def read_page( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> ReadRecordsResponse[BodyT]: - """Read one page of Records. The poll iterator reads them all.""" + """Read one page of Records. The poll iterator keeps reading after a page with no + Record. + """ request = ReadRecordsRequest( ref=self.ref, from_offset=from_offset, @@ -121,7 +123,8 @@ async def read_pages( ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: """Yield each response of ``read_page`` until the poll helper stops. - Read one page of Records. The poll iterator reads them all. + Read one page of Records. The poll iterator keeps reading after a page with no + Record. Args: from_offset: Read after this offset. Empty means from the beginning. @@ -169,7 +172,8 @@ def read( ``next_request`` resumes after the last item that the iterator yielded. It is ``None`` after the last page. - Read one page of Records. The poll iterator reads them all. + Read one page of Records. The poll iterator keeps reading after a page with no + Record. Args: from_offset: Read after this offset. Empty means from the beginning. diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 84d5b1b418..9c34780667 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -67,7 +67,9 @@ async def read_page( wait: datetime.timedelta | None = None, max_bytes: int | None = None, ) -> ReadRecordsResponse[BodyT]: - """Read one page of Records. The poll iterator reads them all.""" + """Read one page of Records. The poll iterator keeps reading after a page with no + Record. + """ request = ReadRecordsRequest( ref=self.ref, from_offset=from_offset, @@ -87,7 +89,8 @@ async def read_pages( ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: """Yield each response of ``read_page`` until the poll helper stops. - Read one page of Records. The poll iterator reads them all. + Read one page of Records. The poll iterator keeps reading after a page with no + Record. Args: from_offset: Read after this offset. Empty means from the beginning. @@ -124,7 +127,8 @@ def read( ``next_request`` resumes after the last item that the iterator yielded. It is ``None`` after the last page. - Read one page of Records. The poll iterator reads them all. + Read one page of Records. The poll iterator keeps reading after a page with no + Record. Args: from_offset: Read after this offset. Empty means from the beginning. From f89671d9b08daa27553e8abd44df40aa403fdbca Mon Sep 17 00:00:00 2001 From: Mohammad Dashti Date: Fri, 27 Nov 2026 02:15:13 -0700 Subject: [PATCH 20/24] Pin reviewed Stream contracts and the client poll generator --- scripts/gen_nexus_system_api.py | 21 +++-- temporalio/api/enums/v1/stream_pb2.pyi | 35 +++----- temporalio/api/sdk/v1/stream_pb2.pyi | 31 +++---- temporalio/api/stream/v1/message_pb2.pyi | 87 ++++++------------- .../streamservice/v1/request_response_pb2.pyi | 49 ++++------- temporalio/bridge/sdk-core | 2 +- .../nexus/system/stream_service/_poll.py | 2 +- .../stream_service/client/_extensions.py | 2 +- .../client/_resources/stream.py | 17 ++-- .../nexus/system/stream_service/models.py | 4 +- .../workflow/_resources/stream.py | 14 +-- .../workflow/operations/create_stream.py | 2 +- 12 files changed, 103 insertions(+), 163 deletions(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index 913af05616..4212ea775d 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -26,7 +26,8 @@ notification_output_dir = base_dir / "temporalio" / "nexus" / "notifications" stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service" workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py" -NEX_GEN_VERSION = "0.2.14" +# Empty-page polls need the cancellation fix before its nexgen release. +NEX_GEN_REVISION = "cb6dccfa158bab4c0662b85a31d3da63d0b8179b" proto_files = [ gen_protos.api_proto_dir / "temporal" @@ -53,25 +54,27 @@ def nex_gen_command() -> list[str]: if bin_path := os.environ.get("NEX_GEN_BIN"): return [bin_path] - if ( - shutil.which("nexgen") is None - or subprocess.check_output(["nexgen", "--version"], text=True).strip() - != f"nexgen {NEX_GEN_VERSION}" - ): + install_dir = base_dir / "build" / "nexgen" / NEX_GEN_REVISION + binary = install_dir / "bin" / ("nexgen.exe" if os.name == "nt" else "nexgen") + if not binary.is_file(): subprocess.check_call( [ "cargo", "install", "--locked", "nexgen", - "--version", - NEX_GEN_VERSION, + "--git", + "https://github.com/temporalio/nexgen.git", + "--rev", + NEX_GEN_REVISION, + "--root", + str(install_dir), "--features", "advanced", "--force", ] ) - return ["nexgen"] + return [str(binary)] def build_descriptor_set(descriptor_path: Path) -> None: diff --git a/temporalio/api/enums/v1/stream_pb2.pyi b/temporalio/api/enums/v1/stream_pb2.pyi index 638ab6eb0e..4c0f9134b9 100644 --- a/temporalio/api/enums/v1/stream_pb2.pyi +++ b/temporalio/api/enums/v1/stream_pb2.pyi @@ -32,21 +32,20 @@ class _StreamIdConflictPolicyEnumTypeWrapper( STREAM_ID_CONFLICT_POLICY_FAIL: _StreamIdConflictPolicy.ValueType # 1 """The create fails with `ALREADY_EXISTS`.""" STREAM_ID_CONFLICT_POLICY_USE_EXISTING: _StreamIdConflictPolicy.ValueType # 2 - """The create returns the open Stream, and the Retention of that Stream doesn't change.""" + """The create returns the existing Stream without changing its expiry.""" class StreamIdConflictPolicy( _StreamIdConflictPolicy, metaclass=_StreamIdConflictPolicyEnumTypeWrapper ): """Experimental. Might change in the future. - What a create does if its Stream already exists. Unspecified means `FAIL`, as it does for a - Workflow start. + The conflict policy for an existing Stream. Unspecified means `FAIL`. """ STREAM_ID_CONFLICT_POLICY_UNSPECIFIED: StreamIdConflictPolicy.ValueType # 0 STREAM_ID_CONFLICT_POLICY_FAIL: StreamIdConflictPolicy.ValueType # 1 """The create fails with `ALREADY_EXISTS`.""" STREAM_ID_CONFLICT_POLICY_USE_EXISTING: StreamIdConflictPolicy.ValueType # 2 -"""The create returns the open Stream, and the Retention of that Stream doesn't change.""" +"""The create returns the existing Stream without changing its expiry.""" global___StreamIdConflictPolicy = StreamIdConflictPolicy class _StreamErrorReason: @@ -64,11 +63,9 @@ class _StreamErrorReasonEnumTypeWrapper( STREAM_ERROR_REASON_NOT_FOUND: _StreamErrorReason.ValueType # 1 """The Stream was never created (`NOT_FOUND`).""" STREAM_ERROR_REASON_EXPIRED: _StreamErrorReason.ValueType # 2 - """The Retention of the Stream has passed since its create or its last append (`NOT_FOUND`).""" + """Retention has passed since create or the last append of a new batch (`NOT_FOUND`).""" STREAM_ERROR_REASON_FENCED: _StreamErrorReason.ValueType # 3 - """A later attempt of the same Producer has already written, and the Store fences - (`FAILED_PRECONDITION`). - """ + """A later attempt of this Producer has written, and fencing is enabled (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_FORMAT_TOO_NEW: _StreamErrorReason.ValueType # 4 """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_OFFSET_TOO_HIGH: _StreamErrorReason.ValueType # 5 @@ -80,34 +77,28 @@ class _StreamErrorReasonEnumTypeWrapper( STREAM_ERROR_REASON_INVALID_ARGUMENT: _StreamErrorReason.ValueType # 7 """The request is malformed (`INVALID_ARGUMENT`).""" STREAM_ERROR_REASON_STORE_UNAVAILABLE: _StreamErrorReason.ValueType # 8 - """The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" + """The Store failed or did not respond. A retry can succeed (`UNAVAILABLE`).""" STREAM_ERROR_REASON_UNSUPPORTED: _StreamErrorReason.ValueType # 9 """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" STREAM_ERROR_REASON_ALREADY_EXISTS: _StreamErrorReason.ValueType # 10 """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" STREAM_ERROR_REASON_STORE_CORRUPT: _StreamErrorReason.ValueType # 11 - """The Store returned data that isn't valid, such as a stored value of the wrong length. A - retry reads the same data (`DATA_LOSS`). - """ + """Stored data is invalid. Retrying cannot repair it (`DATA_LOSS`).""" class StreamErrorReason( _StreamErrorReason, metaclass=_StreamErrorReasonEnumTypeWrapper ): """Experimental. Might change in the future. - Why a Stream call failed. Each reason maps to one gRPC status code, shown in parentheses, and - several reasons share a code. So callers check the reason and not the status code. An SDK - raises one error type with the reason in it. + Several reasons share a gRPC status code. Callers must check the reason to distinguish them. """ STREAM_ERROR_REASON_UNSPECIFIED: StreamErrorReason.ValueType # 0 STREAM_ERROR_REASON_NOT_FOUND: StreamErrorReason.ValueType # 1 """The Stream was never created (`NOT_FOUND`).""" STREAM_ERROR_REASON_EXPIRED: StreamErrorReason.ValueType # 2 -"""The Retention of the Stream has passed since its create or its last append (`NOT_FOUND`).""" +"""Retention has passed since create or the last append of a new batch (`NOT_FOUND`).""" STREAM_ERROR_REASON_FENCED: StreamErrorReason.ValueType # 3 -"""A later attempt of the same Producer has already written, and the Store fences -(`FAILED_PRECONDITION`). -""" +"""A later attempt of this Producer has written, and fencing is enabled (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_FORMAT_TOO_NEW: StreamErrorReason.ValueType # 4 """The Stream has a newer format than this caller knows (`FAILED_PRECONDITION`).""" STREAM_ERROR_REASON_OFFSET_TOO_HIGH: StreamErrorReason.ValueType # 5 @@ -119,13 +110,11 @@ STREAM_ERROR_REASON_TOO_LARGE: StreamErrorReason.ValueType # 6 STREAM_ERROR_REASON_INVALID_ARGUMENT: StreamErrorReason.ValueType # 7 """The request is malformed (`INVALID_ARGUMENT`).""" STREAM_ERROR_REASON_STORE_UNAVAILABLE: StreamErrorReason.ValueType # 8 -"""The Store failed or didn't answer, and a retry can succeed (`UNAVAILABLE`).""" +"""The Store failed or did not respond. A retry can succeed (`UNAVAILABLE`).""" STREAM_ERROR_REASON_UNSUPPORTED: StreamErrorReason.ValueType # 9 """The Store doesn't support something that the call needs (`UNIMPLEMENTED`).""" STREAM_ERROR_REASON_ALREADY_EXISTS: StreamErrorReason.ValueType # 10 """A create with the `FAIL` policy found that the Stream already exists (`ALREADY_EXISTS`).""" STREAM_ERROR_REASON_STORE_CORRUPT: StreamErrorReason.ValueType # 11 -"""The Store returned data that isn't valid, such as a stored value of the wrong length. A -retry reads the same data (`DATA_LOSS`). -""" +"""Stored data is invalid. Retrying cannot repair it (`DATA_LOSS`).""" global___StreamErrorReason = StreamErrorReason diff --git a/temporalio/api/sdk/v1/stream_pb2.pyi b/temporalio/api/sdk/v1/stream_pb2.pyi index 96a2d227dd..b9640b060b 100644 --- a/temporalio/api/sdk/v1/stream_pb2.pyi +++ b/temporalio/api/sdk/v1/stream_pb2.pyi @@ -20,11 +20,8 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class StreamRef(google.protobuf.message.Message): """Experimental. Might change in the future. - A reference to one Stream, which code passes to other code as data. Callers treat the `id` as - opaque. An id is never used for a second Stream while the Store remembers the first one, so a - create for an expired Stream fails. A Store can forget an expired Stream after a time of its - choice, and a create for its id succeeds after that. Every SDK encodes a ref in a Payload with - this message, so a ref that one SDK writes decodes in another. + Callers treat `id` as opaque. A Store can reuse an expired id only after it forgets the Stream. + SDKs encode references with this message so that other SDKs can decode them. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -33,10 +30,8 @@ class StreamRef(google.protobuf.message.Message): STORE_FIELD_NUMBER: builtins.int id: builtins.str store: builtins.str - """The name under which the client and Worker config registered the Store of this Stream. An - SDK uses it to send a call on this ref to the right Store. When it's empty, the SDK picks - the Store from its config. Only an SDK sets and reads this field. A Store and the server - never get it, because their requests have only the Stream id. + """The registered Store name. Empty selects the configured default. + This field is local to the SDK. Store and server requests omit it. """ def __init__( self, @@ -53,8 +48,7 @@ global___StreamRef = StreamRef @typing.final class CreateStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - The SDK form of `temporalio.api.streamservice.v1.CreateStreamRequest`, with the ref of the Stream - in place of its id. The other fields mean the same. + Uses the Store request contract, with a `StreamRef` for SDK routing. (-- api-linter: core::0133=disabled aip.dev/not-precedent: The request identifies a Stream by its ref. --) """ @@ -91,7 +85,7 @@ global___CreateStreamRequest = CreateStreamRequest @typing.final class CreateStreamResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - The Stream that the create made or found. + The reference includes the Store selected by the SDK. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -102,9 +96,7 @@ class CreateStreamResponse(google.protobuf.message.Message): """False when `USE_EXISTING` returned a Stream that already existed.""" @property def ref(self) -> global___StreamRef: - """The ref of the Stream. The caller can pass it to other code as data. The SDK builds it from - the request and the Store that it picked. - """ + """The SDK fills the Store name so that another caller can route the reference.""" def __init__( self, @@ -122,8 +114,7 @@ global___CreateStreamResponse = CreateStreamResponse @typing.final class AppendRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - The SDK form of `temporalio.api.streamservice.v1.AppendRecordsRequest`, with the ref of the Stream - in place of its id. The other fields mean the same. + Uses the Store request contract, with a `StreamRef` for SDK routing. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -168,8 +159,7 @@ global___AppendRecordsRequest = AppendRecordsRequest @typing.final class ReadRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - The SDK form of `temporalio.api.streamservice.v1.ReadRecordsRequest`, with the ref of the Stream - in place of its id. The other fields mean the same. + Uses the Store request contract, with a `StreamRef` for SDK routing. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -224,8 +214,7 @@ global___ReadRecordsRequest = ReadRecordsRequest @typing.final class DescribeStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - The SDK form of `temporalio.api.streamservice.v1.DescribeStreamRequest`, with the ref of the - Stream in place of its id. + Uses the Store request contract, with a `StreamRef` for SDK routing. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 1a3d472a20..5ed310d1ec 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -18,10 +18,8 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class WorkflowTaskAttempt(google.protobuf.message.Message): """Experimental. Might change in the future. - One attempt of a Workflow Task. Two attempts of the same Producer compare by - `started_event_id`, then `attempt`, then `started_time`. Attempts of different Producers have - no order. A Producer is for one run, so the attempts of a reset run or of the next run in a - chain have no order with the attempts of this run. + Attempts of one Producer compare by `started_event_id`, then `attempt`, then `started_time`. + Attempts from different runs have no order, including reset and Continue-As-New runs. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -32,14 +30,11 @@ class WorkflowTaskAttempt(google.protobuf.message.Message): started_event_id: builtins.int """Required.""" attempt: builtins.int - """Required. The attempt number of the task, starting at 1. Every task starts at 1 again, so - this number alone can't order the writes of a run. - """ + """Required. Starts at 1 for each task, so this number alone cannot order writes in a run.""" @property def started_time(self) -> google.protobuf.timestamp_pb2.Timestamp: - """When this attempt started. The server can use a started event id for a second task, for - example after it drops a speculative task, and this time distinguishes the two. It's empty - when the server sent no started time for the task. + """Distinguishes tasks when the server reuses a started event id after a speculative task. + Empty when the server did not send a started time. """ def __init__( @@ -69,9 +64,8 @@ global___WorkflowTaskAttempt = WorkflowTaskAttempt @typing.final class LocalActivityAttempt(google.protobuf.message.Message): """Experimental. Might change in the future. - One attempt of a Local Activity. Two attempts compare by `task`, then `attempt`, so the same - call in a later Workflow Task is a later attempt. Attempts of two runs have no order. Their - Records have only their order in the Stream. + Attempts of one Producer compare by `task`, then `attempt`. + A later Workflow Task therefore has a later attempt. Attempts from different runs have no order. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -113,9 +107,7 @@ class ActivityAttempt(google.protobuf.message.Message): """Required. The attempt number, starting at 1.""" @property def attempt_scheduled_time(self) -> google.protobuf.timestamp_pb2.Timestamp: - """Required. When the server scheduled this attempt. A reset of the Activity starts the - attempt number at 1 again, so this time is what orders the attempts across a reset. - """ + """Required. A reset restarts the attempt number, so this time orders attempts across a reset.""" def __init__( self, @@ -139,8 +131,7 @@ global___ActivityAttempt = ActivityAttempt @typing.final class WorkflowProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - The Producer of a Workflow run. Workflow code writes as this Producer when it appends in a - Workflow Task. A write from one of its Local Activities uses a `LocalActivityProducer`. + Workflow writes share one Producer per run. Local Activity writes use `LocalActivityProducer`. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -154,14 +145,10 @@ class WorkflowProducer(google.protobuf.message.Message): workflow_id: builtins.str """Required.""" run_id: builtins.str - """Required. The id of this run, not the first run id of its chain. Each run is a separate - Producer. - """ + """Required. This run id separates the Producer from other runs in the chain.""" @property def attempt(self) -> global___WorkflowTaskAttempt: - """The Workflow Task attempt that makes the write. Workflow code leaves it empty, and the SDK - sets it before it sends the write to the Store. - """ + """Workflow code leaves this empty so that the SDK can set the actual Workflow Task attempt.""" def __init__( self, @@ -210,9 +197,8 @@ class LocalActivityProducer(google.protobuf.message.Message): run_id: builtins.str """Required.""" activity_id: builtins.str - """Required. The id that the SDK gives the call, because a Local Activity has no scheduled - event. Two Local Activities of one run must not share it, or the Store takes them as one - Producer. Each SDK makes it from a counter of its own, unless the user sets it. + """Required. Local Activities have no scheduled event, so this id distinguishes calls in a run. + The SDK assigns an id from its counter unless the user sets one. Do not reuse it within a run. """ @property def attempt(self) -> global___LocalActivityAttempt: @@ -271,9 +257,8 @@ class WorkflowActivityProducer(google.protobuf.message.Message): activity_id: builtins.str """Required.""" scheduled_event_id: builtins.int - """The id of the `ActivityTaskScheduled` event of the Activity in the History of its run. A run - can use an Activity id again after the first Activity ended, and this id separates the two - Activities, so they are separate Producers. It's zero when the SDK doesn't have it. + """Distinguishes calls when a run reuses an Activity id after an Activity completes. + Zero when the SDK does not have the `ActivityTaskScheduled` event id. """ @property def attempt(self) -> global___ActivityAttempt: @@ -315,8 +300,7 @@ global___WorkflowActivityProducer = WorkflowActivityProducer @typing.final class StandaloneActivityProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - The Producer of a Standalone Activity. Its attempts compare as those of a Workflow's Activity - do. + Standalone Activity attempts use the same order as Workflow Activity attempts. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -365,8 +349,7 @@ global___StandaloneActivityProducer = StandaloneActivityProducer @typing.final class ClientProducer(google.protobuf.message.Message): """Experimental. Might change in the future. - The Producer of a client. A client has no run and no attempt, so a Store never fences its - writes and a reader never hides them. + Clients have no attempt, so their writes cannot be fenced or superseded by a later attempt. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -376,9 +359,7 @@ class ClientProducer(google.protobuf.message.Message): namespace: builtins.str """Required.""" id: builtins.str - """Required. The caller can set it, for example to the id of the Nexus operation that - writes. Without one, the SDK makes an id for each client object. - """ + """Required. The SDK generates an id per client object unless the caller supplies one.""" def __init__( self, *, @@ -394,17 +375,10 @@ global___ClientProducer = ClientProducer @typing.final class Producer(google.protobuf.message.Message): """Experimental. Might change in the future. - The writer of a batch of Records. A Producer is one unit of work, such as one Activity or one - Workflow run. Two Producers are the same when they have the same kind and the same ids. - Every kind except a client also has the attempt that made the write, and the attempt is not - part of what identifies the Producer. - - A Store that fences fails a write with `FENCED` when a later attempt of the same Producer has - already written. A Store that doesn't fence accepts the write. Each Record has its Producer - and attempt either way, so a reader can hide the Records of an earlier attempt. - - Attempts of different Producers have no order. A new run has new Producers, so no write fences - or supersedes the Records of an earlier run, such as the base run of a reset. + The kind and ids identify a Producer. The attempt does not. + With fencing enabled, a write fails with `FENCED` after a later attempt of that Producer writes. + Records retain their Producer and attempt so that readers can apply their own retry policy. + Attempts of different Producers have no order. A reset run cannot fence its base run. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -485,8 +459,7 @@ global___Producer = Producer @typing.final class AppendRecord(google.protobuf.message.Message): """Experimental. Might change in the future. - One Record of a batch to append. The Store stores it with the Producer of the batch and - assigns its offset. + The Store adds the batch Producer and assigns an offset. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -510,9 +483,7 @@ global___AppendRecord = AppendRecord @typing.final class StreamRecord(google.protobuf.message.Message): - """Experimental. Might change in the future. - One Record of a Stream, as a read returns it. A read returns only Records. - """ + """Experimental. Might change in the future.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -520,11 +491,8 @@ class StreamRecord(google.protobuf.message.Message): BODY_FIELD_NUMBER: builtins.int OFFSET_FIELD_NUMBER: builtins.int offset: builtins.bytes - """Required. The position of this Record in its Stream. It's never empty. Offsets are unique - and ordered within one Stream, but they have gaps, so they don't count Records. Two offsets - of one Stream compare as unsigned bytes, in the order of their Records, so a reader, a - Store and the server can order them without decoding them. An offset doesn't identify - its Stream, so a read checks it against the Stream of the request. + """Required and nonempty. Offsets are unique within a Stream. Unsigned byte order matches + Record order. Gaps cannot be used to count Records. Offsets do not identify their Stream. """ @property def producer(self) -> global___Producer: ... @@ -552,8 +520,7 @@ global___StreamRecord = StreamRecord @typing.final class StreamErrorDetails(google.protobuf.message.Message): """Experimental. Might change in the future. - The details of a failed Stream call. They're in the gRPC status details, and in the details - of the application failure when the call is a Nexus operation. + Returned in gRPC status details or Nexus application failure details. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index cb36694bc6..b7abc4d67d 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -20,15 +20,12 @@ DESCRIPTOR: google.protobuf.descriptor.FileDescriptor @typing.final class CreateStreamRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Creates a Stream. If the Stream already exists, the result depends on `id_conflict_policy`. - `FAIL` fails with `ALREADY_EXISTS`, and `USE_EXISTING` succeeds with `created` false. A retry of - the create that made the Stream, with the same request id, returns `created` true. The Store - remembers the request id of that create, so a retry after a lost response doesn't fail with - `ALREADY_EXISTS`. Either policy fails with `EXPIRED` for an expired Stream. - - A create has no Retention. Retention is a setting of the Store, as it's a setting of the - namespace for Workflows. It's the only lifetime setting of a Stream. It starts at the create, - and each append starts it again. When it passes, the Stream is expired. + `FAIL` returns `ALREADY_EXISTS` for an existing Stream. `USE_EXISTING` returns `created` false. + A retry with the original create request id returns `created` true, even with `FAIL`. + Either policy returns `EXPIRED` while the Store remembers an expired Stream. + + Retention is a Store setting. It starts at create and restarts when an append writes a new batch. + Reads and resends keep the existing expiry. (-- api-linter: core::0133=disabled aip.dev/not-precedent: The request identifies a Stream by its id. --) """ @@ -60,9 +57,7 @@ global___CreateStreamRequest = CreateStreamRequest @typing.final class CreateStreamResponse(google.protobuf.message.Message): - """Experimental. Might change in the future. - The result of a create. - """ + """Experimental. Might change in the future.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -81,13 +76,9 @@ global___CreateStreamResponse = CreateStreamResponse @typing.final class AppendRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Appends one batch of Records as one Producer. If the same batch arrives again, with the same - Producer, attempt and request id, the Store writes it only once while it remembers the id, and it - returns the offsets of the first write. A caller that got no response sends the batch again with - the same request id. A Store remembers the request ids of the most recent batches of each - Producer of the Stream. How many it remembers is a setting of the Store, so a try that arrives - after more batches than that is written again. When the request id is empty, a retry is written - again. + Retries must use the same Producer, attempt, request id and batch. A remembered request id + returns the original offsets without writing again. The Store sets its resend window per + Producer. An empty or forgotten request id permits a second write. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -161,8 +152,7 @@ global___AppendRecordsResponse = AppendRecordsResponse @typing.final class ReadRecordsRequest(google.protobuf.message.Message): """Experimental. Might change in the future. - Reads one page of Records after an offset. When no Record is left, the read waits for a new - one, so a reader long-polls. + Reads after an offset. When no Record is available, `wait` controls how long the read waits. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -182,12 +172,12 @@ class ReadRecordsRequest(google.protobuf.message.Message): aip.dev/not-precedent: "from" marks the start of a range of offsets. --) """ max_records: builtins.int - """The maximum number of Records in one page. Zero means no limit.""" + """The maximum number of Records in one page. Zero uses the Store default.""" max_bytes: builtins.int """The maximum total size of the Records in one page, in bytes. A caller sets it so that a page fits a limit of its own, such as the size of a History marker. A Record larger than - this is still returned, alone in its page, so a read always makes progress. Zero means no - limit. + this is still returned, alone in its page, so a read always makes progress. Zero uses the + Store default. """ @property def wait(self) -> google.protobuf.duration_pb2.Duration: @@ -227,9 +217,7 @@ global___ReadRecordsRequest = ReadRecordsRequest @typing.final class ReadRecordsResponse(google.protobuf.message.Message): - """Experimental. Might change in the future. - One page of a read. - """ + """Experimental. Might change in the future.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -268,9 +256,7 @@ global___ReadRecordsResponse = ReadRecordsResponse @typing.final class DescribeStreamRequest(google.protobuf.message.Message): - """Experimental. Might change in the future. - Gets the newest offset of a Stream. - """ + """Experimental. Might change in the future.""" DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -291,8 +277,7 @@ global___DescribeStreamRequest = DescribeStreamRequest @typing.final class DescribeStreamResponse(google.protobuf.message.Message): """Experimental. Might change in the future. - The state of a Stream. It doesn't include Retention, which is a setting of the Store and not - of one Stream. + Retention is a Store setting and is not returned here. """ DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/temporalio/bridge/sdk-core b/temporalio/bridge/sdk-core index 8990e6c4ef..e4c897fc15 160000 --- a/temporalio/bridge/sdk-core +++ b/temporalio/bridge/sdk-core @@ -1 +1 @@ -Subproject commit 8990e6c4ef9fc848d3dda015974db240b2535c63 +Subproject commit e4c897fc15692371651af68253e77bd609eb23eb diff --git a/temporalio/nexus/system/stream_service/_poll.py b/temporalio/nexus/system/stream_service/_poll.py index a7628506cc..0e37001d0f 100644 --- a/temporalio/nexus/system/stream_service/_poll.py +++ b/temporalio/nexus/system/stream_service/_poll.py @@ -17,7 +17,7 @@ class PollIterator(typing.Generic[_PollRequestT, _PollItemT]): ``next_request`` is the request to resume with. After an item, the resume helper gives it. Without a resume helper, it reads the item's page again. After a page's last item, - it is the page helper's request, which is ``None`` after the last page. + it is the page helper's request. It is ``None`` when the page helper returns ``None``. """ def __init__( diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index 7c43097ee6..5f867edbfb 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -152,7 +152,7 @@ async def create_stream( ) -> Stream[typing.Any]: """ Args: - id: The Stream id, 1 to 4096 bytes. + id: The Stream id. It must not be empty. store: The registered name of the Store. If empty, the SDK picks a Store. id_conflict_policy: What the create does if the Stream already exists. Unspecified means fail. diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index 38eddafec7..afa0d63b5d 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -2,6 +2,7 @@ from __future__ import annotations +import asyncio as _asyncio import collections.abc import datetime import typing @@ -121,15 +122,16 @@ async def read_pages( rpc_metadata: collections.abc.Mapping[str, str | bytes] | None = None, rpc_timeout: datetime.timedelta | None = None, ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: - """Yield each response of ``read_page`` until the poll helper stops. + """Yield each response of ``read_page`` until the poll helper returns ``None``. Read one page of Records. The poll iterator keeps reading after a page with no Record. Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record before an empty page. + max_records: The maximum number of Records in one page. Zero uses the Store + default. + wait: How long to wait for a new Record. Unset returns immediately. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ @@ -155,6 +157,8 @@ async def read_pages( yield response if next_request is None: return + if not response.records: + await _asyncio.sleep(0) request = next_request def read( @@ -170,15 +174,16 @@ def read( """Yield each item of ``read_pages``, page by page. ``next_request`` resumes after the last item that the iterator yielded. It is - ``None`` after the last page. + ``None`` when the page helper returns ``None``. Read one page of Records. The poll iterator keeps reading after a page with no Record. Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record before an empty page. + max_records: The maximum number of Records in one page. Zero uses the Store + default. + wait: How long to wait for a new Record. Unset returns immediately. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ diff --git a/temporalio/nexus/system/stream_service/models.py b/temporalio/nexus/system/stream_service/models.py index d5b815af33..ceee812dc9 100644 --- a/temporalio/nexus/system/stream_service/models.py +++ b/temporalio/nexus/system/stream_service/models.py @@ -195,7 +195,7 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class AppendRecordsRequest(typing.Generic[BodyT]): - """Append one batch. The Store writes a batch that arrives again only once.""" + """Append one batch. Retries are deduplicated within the Store resend window.""" ref: StreamRef[BodyT] records: list[AppendRecord[BodyT]] @@ -319,7 +319,7 @@ def to_transfer_type( @dataclasses.dataclass(slots=True) class Producer: - """The writer of a batch. A later attempt supersedes an earlier one.""" + """The writer of a batch. Attempts compare only within the same Producer.""" kind: ProducerKind | None = None diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 9c34780667..2e2ea161d4 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -87,15 +87,16 @@ async def read_pages( wait: datetime.timedelta | None = None, max_bytes: int | None = None, ) -> collections.abc.AsyncGenerator[ReadRecordsResponse[BodyT], None]: - """Yield each response of ``read_page`` until the poll helper stops. + """Yield each response of ``read_page`` until the poll helper returns ``None``. Read one page of Records. The poll iterator keeps reading after a page with no Record. Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record before an empty page. + max_records: The maximum number of Records in one page. Zero uses the Store + default. + wait: How long to wait for a new Record. Unset returns immediately. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ @@ -125,15 +126,16 @@ def read( """Yield each item of ``read_pages``, page by page. ``next_request`` resumes after the last item that the iterator yielded. It is - ``None`` after the last page. + ``None`` when the page helper returns ``None``. Read one page of Records. The poll iterator keeps reading after a page with no Record. Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. - wait: How long the read waits for a new Record before an empty page. + max_records: The maximum number of Records in one page. Zero uses the Store + default. + wait: How long to wait for a new Record. Unset returns immediately. max_bytes: The maximum bytes of Records in a page. A larger Record is returned alone. """ diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 2655d6483f..87a71b768a 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -69,7 +69,7 @@ async def create_stream( ) -> Stream[typing.Any]: """ Args: - id: The Stream id, 1 to 4096 bytes. + id: The Stream id. It must not be empty. store: The registered name of the Store. If empty, the SDK picks a Store. id_conflict_policy: What the create does if the Stream already exists. Unspecified means fail. From 839a3e4d599a28e58637b7cd7ee1e6d7690e989e Mon Sep 17 00:00:00 2001 From: Mohammad Dashti Date: Fri, 27 Nov 2026 02:18:37 -0700 Subject: [PATCH 21/24] Clarify generated read limits and pin the final generator --- scripts/gen_nexus_system_api.py | 2 +- temporalio/api/sdk/v1/stream_pb2.pyi | 2 ++ temporalio/bridge/sdk-core | 2 +- .../stream_service/client/_resources/stream.py | 14 ++++++-------- .../stream_service/workflow/_resources/stream.py | 14 ++++++-------- 5 files changed, 16 insertions(+), 18 deletions(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index 4212ea775d..f5c63d7e94 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -27,7 +27,7 @@ stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service" workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py" # Empty-page polls need the cancellation fix before its nexgen release. -NEX_GEN_REVISION = "cb6dccfa158bab4c0662b85a31d3da63d0b8179b" +NEX_GEN_REVISION = "09bdf2a6b9c690a92f65e3964d58d5db9b2c0a32" proto_files = [ gen_protos.api_proto_dir / "temporal" diff --git a/temporalio/api/sdk/v1/stream_pb2.pyi b/temporalio/api/sdk/v1/stream_pb2.pyi index b9640b060b..a2be9f27b5 100644 --- a/temporalio/api/sdk/v1/stream_pb2.pyi +++ b/temporalio/api/sdk/v1/stream_pb2.pyi @@ -174,7 +174,9 @@ class ReadRecordsRequest(google.protobuf.message.Message): aip.dev/not-precedent: "from" marks the start of a range of offsets. --) """ max_records: builtins.int + """Zero uses the configured default.""" max_bytes: builtins.int + """One Record can exceed this target unless an SDK hard limit rejects it.""" @property def ref(self) -> global___StreamRef: """Required.""" diff --git a/temporalio/bridge/sdk-core b/temporalio/bridge/sdk-core index e4c897fc15..5a2059e5ca 160000 --- a/temporalio/bridge/sdk-core +++ b/temporalio/bridge/sdk-core @@ -1 +1 @@ -Subproject commit e4c897fc15692371651af68253e77bd609eb23eb +Subproject commit 5a2059e5ca05f01c75f5a68b4f9c81bcf15e5010 diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index afa0d63b5d..04f5b6ca44 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -129,11 +129,10 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. Zero uses the Store - default. + max_records: The maximum Records per page. Zero uses the configured default. wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The maximum bytes of Records in a page. A larger Record is - returned alone. + max_bytes: The page byte target. One larger Record can be returned unless an + SDK hard limit rejects it. """ request = ReadRecordsRequest( ref=self.ref, @@ -181,11 +180,10 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. Zero uses the Store - default. + max_records: The maximum Records per page. Zero uses the configured default. wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The maximum bytes of Records in a page. A larger Record is - returned alone. + max_bytes: The page byte target. One larger Record can be returned unless an + SDK hard limit rejects it. """ request = ReadRecordsRequest( ref=self.ref, diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index 2e2ea161d4..c85d0dc354 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -94,11 +94,10 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. Zero uses the Store - default. + max_records: The maximum Records per page. Zero uses the configured default. wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The maximum bytes of Records in a page. A larger Record is - returned alone. + max_bytes: The page byte target. One larger Record can be returned unless an + SDK hard limit rejects it. """ request = ReadRecordsRequest( ref=self.ref, @@ -133,11 +132,10 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. - max_records: The maximum number of Records in one page. Zero uses the Store - default. + max_records: The maximum Records per page. Zero uses the configured default. wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The maximum bytes of Records in a page. A larger Record is - returned alone. + max_bytes: The page byte target. One larger Record can be returned unless an + SDK hard limit rejects it. """ request = ReadRecordsRequest( ref=self.ref, From 5c8be99da44cc0d0a6a6a84467cc6652ea474603 Mon Sep 17 00:00:00 2001 From: Mohammad Dashti Date: Fri, 27 Nov 2026 02:24:26 -0700 Subject: [PATCH 22/24] Remove the temporary generator comment --- scripts/gen_nexus_system_api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index f5c63d7e94..cb308ebeff 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -26,7 +26,6 @@ notification_output_dir = base_dir / "temporalio" / "nexus" / "notifications" stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service" workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py" -# Empty-page polls need the cancellation fix before its nexgen release. NEX_GEN_REVISION = "09bdf2a6b9c690a92f65e3964d58d5db9b2c0a32" proto_files = [ gen_protos.api_proto_dir From 844bd0f8cc2163f869a4ff906bcc67ded37e7eed Mon Sep 17 00:00:00 2001 From: Mohammad Dashti Date: Sat, 28 Nov 2026 03:41:05 -0700 Subject: [PATCH 23/24] Regenerate Streams with reviewed creation and polling rules --- scripts/gen_nexus_system_api.py | 2 +- temporalio/api/sdk/v1/stream_pb2.pyi | 2 +- temporalio/api/stream/v1/message_pb2.pyi | 12 ++++--- .../streamservice/v1/request_response_pb2.pyi | 8 ++--- temporalio/bridge/Cargo.lock | 36 +++++++++---------- temporalio/bridge/sdk-core | 2 +- .../stream_service/client/_extensions.py | 14 +++----- .../client/_resources/stream.py | 17 ++++----- .../workflow/_resources/stream.py | 14 ++++---- .../workflow/operations/create_stream.py | 10 ++---- 10 files changed, 57 insertions(+), 60 deletions(-) diff --git a/scripts/gen_nexus_system_api.py b/scripts/gen_nexus_system_api.py index cb308ebeff..ff799b653d 100644 --- a/scripts/gen_nexus_system_api.py +++ b/scripts/gen_nexus_system_api.py @@ -26,7 +26,7 @@ notification_output_dir = base_dir / "temporalio" / "nexus" / "notifications" stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service" workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py" -NEX_GEN_REVISION = "09bdf2a6b9c690a92f65e3964d58d5db9b2c0a32" +NEX_GEN_REVISION = "5983b56b047cea94acbdb4760ca76f145f5a55d7" proto_files = [ gen_protos.api_proto_dir / "temporal" diff --git a/temporalio/api/sdk/v1/stream_pb2.pyi b/temporalio/api/sdk/v1/stream_pb2.pyi index a2be9f27b5..3e4a146b2c 100644 --- a/temporalio/api/sdk/v1/stream_pb2.pyi +++ b/temporalio/api/sdk/v1/stream_pb2.pyi @@ -30,7 +30,7 @@ class StreamRef(google.protobuf.message.Message): STORE_FIELD_NUMBER: builtins.int id: builtins.str store: builtins.str - """The registered Store name. Empty selects the configured default. + """When empty, the SDK uses its Store selector or the only registered Store. This field is local to the SDK. Store and server requests omit it. """ def __init__( diff --git a/temporalio/api/stream/v1/message_pb2.pyi b/temporalio/api/stream/v1/message_pb2.pyi index 5ed310d1ec..4bae4ecb18 100644 --- a/temporalio/api/stream/v1/message_pb2.pyi +++ b/temporalio/api/stream/v1/message_pb2.pyi @@ -197,8 +197,8 @@ class LocalActivityProducer(google.protobuf.message.Message): run_id: builtins.str """Required.""" activity_id: builtins.str - """Required. Local Activities have no scheduled event, so this id distinguishes calls in a run. - The SDK assigns an id from its counter unless the user sets one. Do not reuse it within a run. + """Required. Local Activities have no scheduled event, so this id must be unique in the run. + The SDK assigns an id unless the caller supplies one. """ @property def attempt(self) -> global___LocalActivityAttempt: @@ -491,11 +491,13 @@ class StreamRecord(google.protobuf.message.Message): BODY_FIELD_NUMBER: builtins.int OFFSET_FIELD_NUMBER: builtins.int offset: builtins.bytes - """Required and nonempty. Offsets are unique within a Stream. Unsigned byte order matches - Record order. Gaps cannot be used to count Records. Offsets do not identify their Stream. + """Required. Record offsets are 1 to 1,024 bytes and unique within a Stream. Unsigned byte order + matches Record order. Offsets can have gaps and do not identify the Stream. """ @property - def producer(self) -> global___Producer: ... + def producer(self) -> global___Producer: + """Stores must return the Producer that appended this Record.""" + @property def body(self) -> temporalio.api.common.v1.message_pb2.Payload: ... def __init__( diff --git a/temporalio/api/streamservice/v1/request_response_pb2.pyi b/temporalio/api/streamservice/v1/request_response_pb2.pyi index b7abc4d67d..123c5607a3 100644 --- a/temporalio/api/streamservice/v1/request_response_pb2.pyi +++ b/temporalio/api/streamservice/v1/request_response_pb2.pyi @@ -133,7 +133,9 @@ class AppendRecordsResponse(google.protobuf.message.Message): FIRST_OFFSET_FIELD_NUMBER: builtins.int LAST_OFFSET_FIELD_NUMBER: builtins.int first_offset: builtins.bytes + """Required and nonempty.""" last_offset: builtins.bytes + """Required and nonempty.""" def __init__( self, *, @@ -174,10 +176,8 @@ class ReadRecordsRequest(google.protobuf.message.Message): max_records: builtins.int """The maximum number of Records in one page. Zero uses the Store default.""" max_bytes: builtins.int - """The maximum total size of the Records in one page, in bytes. A caller sets it so that a - page fits a limit of its own, such as the size of a History marker. A Record larger than - this is still returned, alone in its page, so a read always makes progress. Zero uses the - Store default. + """The target size of a page in bytes. A larger Record is returned alone so the read can + advance. Zero uses the Store default. """ @property def wait(self) -> google.protobuf.duration_pb2.Duration: diff --git a/temporalio/bridge/Cargo.lock b/temporalio/bridge/Cargo.lock index 5a39070232..d0304f3887 100644 --- a/temporalio/bridge/Cargo.lock +++ b/temporalio/bridge/Cargo.lock @@ -227,9 +227,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02f0e023adb368345ce0ca6cdfc0f24a06554468d0e8503e14a0841de79bfa69" +checksum = "95e45cf2980b2d467be49a9ed942c9179b701063a7ca3d037de7ee9bd67f8d66" dependencies = [ "find-msvc-tools", "jobserver", @@ -311,9 +311,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eb6feb175df65d0a3ccd3e73484e940d0ac664e8034f0519fd49a93db3071d9" +checksum = "144e7f1de087984240b7816d47f698b414979faa6f40839c5b86d6bd47db57b7" dependencies = [ "rustversion", ] @@ -566,9 +566,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" +checksum = "3e44f110d1777dc6559a51e7d45083945ded4f1bf3305494350f693b6d20b9c8" [[package]] name = "fixedbitset" @@ -2925,9 +2925,9 @@ dependencies = [ [[package]] name = "toml" -version = "1.2.2+spec-1.1.0" +version = "1.2.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5426cb1b964690d913f6c5c1a1ae0b42f428ec506bb4d452876d7a209c9bca3b" +checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" dependencies = [ "indexmap", "serde_core", @@ -2949,9 +2949,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.19+spec-1.1.0" +version = "0.25.21+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218" +checksum = "88497dab46de5bf343ec66b05c251e48c6213f3e9170c70a70a823f7abe886a4" dependencies = [ "indexmap", "toml_datetime", @@ -2961,9 +2961,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.1.6+spec-1.1.0" +version = "1.1.7+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6769c452d71ba30696c6b37770c439a9cc9110f47f7d5cdbeda79840ef5ea31" +checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" dependencies = [ "winnow", ] @@ -3704,18 +3704,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.65" +version = "0.8.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32bc8a75f879cd6fe53a6bedf3c28f0e1b914c77424fc2be9e2ec85d7d25aff5" +checksum = "cba8a86aee14fc8cc6c208af60854b3d4ab7185a9a369a12c648faa2716ff42a" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.65" +version = "0.8.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8bfd2644ea1681f60cf95029ff18aa8ad1cc3f7b8fe37286f8e473bb29f816b" +checksum = "f89bca3b96ceb3cfcb4572790402f977442270d252b9a8504ebc258760c55f94" dependencies = [ "proc-macro2", "quote", @@ -3798,9 +3798,9 @@ dependencies = [ [[package]] name = "zip" -version = "9.8.2" +version = "9.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8dbe089cf6b0448b78f5fc50139ab5aaa40d08ac07cdc1baf2c13add35fcce" +checksum = "07db37dec4a7c468df4723fba4cadb4822d1d0f10dbea367100b6a6881b2a9c9" dependencies = [ "bzip2", "constant_time_eq", diff --git a/temporalio/bridge/sdk-core b/temporalio/bridge/sdk-core index 5a2059e5ca..cc22dcdeef 160000 --- a/temporalio/bridge/sdk-core +++ b/temporalio/bridge/sdk-core @@ -1 +1 @@ -Subproject commit 5a2059e5ca05f01c75f5a68b4f9c81bcf15e5010 +Subproject commit cc22dcdeef9349365e2bd8be4215761db4ffb3c9 diff --git a/temporalio/nexus/system/stream_service/client/_extensions.py b/temporalio/nexus/system/stream_service/client/_extensions.py index 5f867edbfb..b9eb96d9ee 100644 --- a/temporalio/nexus/system/stream_service/client/_extensions.py +++ b/temporalio/nexus/system/stream_service/client/_extensions.py @@ -13,6 +13,8 @@ if typing.TYPE_CHECKING: import temporalio.client +import temporalio.nexus.system._support as _support + from ..models import ( CreateStreamRequest, CreateStreamResult, @@ -107,14 +109,7 @@ async def _stream_service_create_stream( rpc_timeout=rpc_timeout, ) result = await handle.result() - if result.ref is None: - raise RuntimeError("CreateStream answered without `ref`") - resource = Stream[body_type]( - nexus_client, - ref=result.ref, - created=result.created or None, - ) - return resource + return _support.stream_from_create(result, nexus_client, body_type) @typing.overload async def create_stream( @@ -153,7 +148,8 @@ async def create_stream( """ Args: id: The Stream id. It must not be empty. - store: The registered name of the Store. If empty, the SDK picks a Store. + store: If empty, the SDK uses its Store selector or the only registered + Store. id_conflict_policy: What the create does if the Stream already exists. Unspecified means fail. """ diff --git a/temporalio/nexus/system/stream_service/client/_resources/stream.py b/temporalio/nexus/system/stream_service/client/_resources/stream.py index 04f5b6ca44..09a85cd7bd 100644 --- a/temporalio/nexus/system/stream_service/client/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/client/_resources/stream.py @@ -130,9 +130,10 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum Records per page. Zero uses the configured default. - wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The page byte target. One larger Record can be returned unless an - SDK hard limit rejects it. + wait: Wait per page. Unset reads immediately, then iterators use a + one-minute wait. + max_bytes: Page byte target. A larger Record can exceed it within SDK hard + limits. """ request = ReadRecordsRequest( ref=self.ref, @@ -156,8 +157,7 @@ async def read_pages( yield response if next_request is None: return - if not response.records: - await _asyncio.sleep(0) + await _asyncio.sleep(0) request = next_request def read( @@ -181,9 +181,10 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum Records per page. Zero uses the configured default. - wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The page byte target. One larger Record can be returned unless an - SDK hard limit rejects it. + wait: Wait per page. Unset reads immediately, then iterators use a + one-minute wait. + max_bytes: Page byte target. A larger Record can exceed it within SDK hard + limits. """ request = ReadRecordsRequest( ref=self.ref, diff --git a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py index c85d0dc354..221f06df3c 100644 --- a/temporalio/nexus/system/stream_service/workflow/_resources/stream.py +++ b/temporalio/nexus/system/stream_service/workflow/_resources/stream.py @@ -95,9 +95,10 @@ async def read_pages( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum Records per page. Zero uses the configured default. - wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The page byte target. One larger Record can be returned unless an - SDK hard limit rejects it. + wait: Wait per page. Unset reads immediately, then iterators use a + one-minute wait. + max_bytes: Page byte target. A larger Record can exceed it within SDK hard + limits. """ request = ReadRecordsRequest( ref=self.ref, @@ -133,9 +134,10 @@ def read( Args: from_offset: Read after this offset. Empty means from the beginning. max_records: The maximum Records per page. Zero uses the configured default. - wait: How long to wait for a new Record. Unset returns immediately. - max_bytes: The page byte target. One larger Record can be returned unless an - SDK hard limit rejects it. + wait: Wait per page. Unset reads immediately, then iterators use a + one-minute wait. + max_bytes: Page byte target. A larger Record can exceed it within SDK hard + limits. """ request = ReadRecordsRequest( ref=self.ref, diff --git a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py index 87a71b768a..e800388793 100644 --- a/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py +++ b/temporalio/nexus/system/stream_service/workflow/operations/create_stream.py @@ -5,6 +5,7 @@ import typing import temporalio.nexus.system +import temporalio.nexus.system._support as _support import temporalio.workflow from ...models import ( @@ -32,12 +33,7 @@ async def _create_stream( output_type=CreateStreamResult[body_type], ) result = await handle - if result.ref is None: - raise RuntimeError("CreateStream answered without `ref`") - return Stream[body_type]( - ref=result.ref, - created=result.created or None, - ) + return _support.stream_from_create(result, nexus_client, body_type) @typing.overload @@ -70,7 +66,7 @@ async def create_stream( """ Args: id: The Stream id. It must not be empty. - store: The registered name of the Store. If empty, the SDK picks a Store. + store: If empty, the SDK uses its Store selector or the only registered Store. id_conflict_policy: What the create does if the Stream already exists. Unspecified means fail. """ From 207b339cc7ba2533c649d85d567fac4ff27e6111 Mon Sep 17 00:00:00 2001 From: Mohammad Dashti Date: Sat, 28 Nov 2026 04:11:15 -0700 Subject: [PATCH 24/24] Include the generated Stream binding helpers --- temporalio/_workflow_context.py | 9 +- temporalio/activity.py | 3 + temporalio/client/_client.py | 2 + temporalio/nexus/system/__init__.py | 4 + temporalio/nexus/system/_support.py | 251 +++++++++++++++++++++++++++- 5 files changed, 267 insertions(+), 2 deletions(-) diff --git a/temporalio/_workflow_context.py b/temporalio/_workflow_context.py index 2a9041dcec..7b35f4568b 100644 --- a/temporalio/_workflow_context.py +++ b/temporalio/_workflow_context.py @@ -31,9 +31,16 @@ class _WorkflowLogicFlag(IntEnum): # Remove the explicit overrides for this flag from tests/worker/test_workflow_flags.py # when enabling it. Then remove this reminder. DECODE_DATETIME_PROXIES = 3 + USE_LAST_STREAM_RECORD_OFFSET = 4 + REPORT_EXISTING_STREAM_AS_FALSE = 5 -_DEFAULT_ENABLED_WORKFLOW_LOGIC_FLAGS: frozenset[_WorkflowLogicFlag] = frozenset() +_DEFAULT_ENABLED_WORKFLOW_LOGIC_FLAGS: frozenset[_WorkflowLogicFlag] = frozenset( + { + _WorkflowLogicFlag.USE_LAST_STREAM_RECORD_OFFSET, + _WorkflowLogicFlag.REPORT_EXISTING_STREAM_AS_FALSE, + } +) @dataclass(frozen=True) diff --git a/temporalio/activity.py b/temporalio/activity.py index b2afae0179..640450db55 100644 --- a/temporalio/activity.py +++ b/temporalio/activity.py @@ -181,6 +181,9 @@ class Info: This API is experimental and unstable. """ + _scheduled_event_id: int = 0 + """Allow Stream writes when the task token has no scheduling event ID.""" + @property def in_workflow(self) -> bool: """Was this activity started by a workflow?""" diff --git a/temporalio/client/_client.py b/temporalio/client/_client.py index efef5cb528..18c9d27a58 100644 --- a/temporalio/client/_client.py +++ b/temporalio/client/_client.py @@ -2,6 +2,7 @@ from __future__ import annotations +import uuid from collections.abc import ( Awaitable, Callable, @@ -291,6 +292,7 @@ def __init__( header_codec_behavior=header_codec_behavior, ) self._initial_config = config.copy() + self._stream_producer_id = str(uuid.uuid4()) for plugin in plugins: config = plugin.configure_client(config) diff --git a/temporalio/nexus/system/__init__.py b/temporalio/nexus/system/__init__.py index 1f8f7c6d29..da102bd304 100644 --- a/temporalio/nexus/system/__init__.py +++ b/temporalio/nexus/system/__init__.py @@ -194,3 +194,7 @@ def _get_serialization_context( # pyright: ignore[reportUnusedFunction] "TEMPORAL_SYSTEM_ENDPOINT", "is_system_endpoint", ] + +# `temporalio.workflow` and the generated Workflow modules of a system service import each +# other. It's loaded here last, so that any of those modules can be the first import. +import temporalio.workflow # noqa: E402 # pyright: ignore[reportUnusedImport] diff --git a/temporalio/nexus/system/_support.py b/temporalio/nexus/system/_support.py index 1ff5f64c52..9f4cd52d5b 100644 --- a/temporalio/nexus/system/_support.py +++ b/temporalio/nexus/system/_support.py @@ -1,8 +1,11 @@ import collections.abc +import dataclasses import typing -from datetime import timedelta +from datetime import datetime, timedelta import google.protobuf.duration_pb2 +import google.protobuf.message +import google.protobuf.timestamp_pb2 import temporalio.api.common.v1.message_pb2 as common_pb2 import temporalio.api.enums.v1.workflow_pb2 as workflow_enums_pb2 @@ -12,6 +15,29 @@ import temporalio.common import temporalio.converter import temporalio.nexus.system +from temporalio._workflow_context import _current_workflow_flags, _WorkflowLogicFlag +from temporalio.converter._payload_converter import _get_transfer_type_converter + +if typing.TYPE_CHECKING: + import temporalio.activity + import temporalio.client + from temporalio.client import NexusClient as ClientNexusClient + from temporalio.nexus.system.stream_service.client import Stream as ClientStream + from temporalio.nexus.system.stream_service.models import ( + CreateStreamResult, + Producer, + ReadRecordsRequest, + ReadRecordsResponse, + StreamRecord, + Timestamp, + ) + from temporalio.nexus.system.stream_service.workflow._resources import ( + Stream as WorkflowStream, + ) + from temporalio.workflow import NexusClient as WorkflowNexusClient + +_BodyT = typing.TypeVar("_BodyT") +_ModelT = typing.TypeVar("_ModelT") class SignalWithStartWorkflowModelRequest(typing.Protocol): @@ -19,6 +45,229 @@ class SignalWithStartWorkflowModelRequest(typing.Protocol): id: str +def model_to_proto( + model: object, + payload_converter: temporalio.converter.PayloadConverter, + failure_converter: temporalio.converter.FailureConverter, +) -> google.protobuf.message.Message: + """Convert a system Nexus model to its proto message, with no payload in between.""" + converter = _get_transfer_type_converter(type(model)) + if converter is None: + raise TypeError(f"{type(model).__name__} is not a system Nexus model") + with temporalio.nexus.system._user_converter_context( + temporalio.nexus.system._SystemNexusUserConverters( + payload_converter, failure_converter + ) + ): + return converter.to_transfer_type(model) + + +def model_from_proto( + proto: google.protobuf.message.Message, + model_type: type[_ModelT], + payload_converter: temporalio.converter.PayloadConverter, + failure_converter: temporalio.converter.FailureConverter, +) -> _ModelT: + """Convert a proto message to the system Nexus model of ``model_type``.""" + converter = _get_transfer_type_converter(model_type) + if converter is None: + raise TypeError(f"{model_type} is not a system Nexus model") + with temporalio.nexus.system._user_converter_context( + temporalio.nexus.system._SystemNexusUserConverters( + payload_converter, failure_converter + ) + ): + return converter.from_transfer_type(proto, model_type) + + +@typing.overload +def stream_from_create( + result: "CreateStreamResult[_BodyT]", + nexus_client: "ClientNexusClient[typing.Any]", + body_type: type[_BodyT], +) -> "ClientStream[_BodyT]": ... + + +@typing.overload +def stream_from_create( + result: "CreateStreamResult[_BodyT]", + nexus_client: "WorkflowNexusClient[typing.Any]", + body_type: type[_BodyT], +) -> "WorkflowStream[_BodyT]": ... + + +def stream_from_create( + result: "CreateStreamResult[_BodyT]", + nexus_client: "ClientNexusClient[typing.Any] | WorkflowNexusClient[typing.Any]", + body_type: type[_BodyT], +) -> "ClientStream[_BodyT] | WorkflowStream[_BodyT]": + import temporalio.workflow + + if result.ref is None: + raise RuntimeError("CreateStream answered without `ref`") + created: bool | None = bool(result.created) + if isinstance(nexus_client, temporalio.workflow.NexusClient): + from temporalio.nexus.system.stream_service.workflow._resources import ( + Stream as WorkflowStream, + ) + + if not created: + flags = _current_workflow_flags.get() + # Unflagged replay must retain None, including responses from interceptors. + if flags is not None and not flags.is_flag_enabled( + _WorkflowLogicFlag.REPORT_EXISTING_STREAM_AS_FALSE + ): + created = None + return WorkflowStream[body_type]( # type: ignore[valid-type, reportInvalidTypeForm] + ref=result.ref, created=created + ) + + from temporalio.nexus.system.stream_service.client import Stream as ClientStream + + return ClientStream[body_type]( # type: ignore[valid-type, reportInvalidTypeForm] + nexus_client, ref=result.ref, created=created + ) + + +def default_producer( + nexus_client: "temporalio.client.NexusClient[typing.Any]", +) -> "Producer": + """Return the Producer of a write of Activity or client code.""" + import temporalio.activity + from temporalio.nexus.system.stream_service import models + + if temporalio.activity.in_activity(): + return activity_producer(temporalio.activity.info()) + client: temporalio.client.Client = nexus_client._client # type: ignore[attr-defined] + return models.Producer( + kind=models.ProducerKindClient( + models.ClientProducer( + namespace=client.namespace, id=client._stream_producer_id + ) + ) + ) + + +def workflow_producer() -> "Producer": + """Return the Producer of the Workflow run. It has no attempt, which Core sets.""" + from temporalio.nexus.system.stream_service import models + from temporalio.workflow import info + + return models.Producer( + kind=models.ProducerKindWorkflow( + models.WorkflowProducer( + namespace=info().namespace, + workflow_id=info().workflow_id, + run_id=info().run_id, + ) + ) + ) + + +def activity_producer(info: "temporalio.activity.Info") -> "Producer": + """Return the Producer of an attempt of an Activity, of the kind of the Activity.""" + from temporalio.nexus.system.stream_service import models + + workflow_id, run_id = info.workflow_id or "", info.workflow_run_id or "" + if info.is_local: + task = info.workflow_task + if task is None: + raise RuntimeError( + "Local Activity has no Workflow Task, which its Producer requires" + ) + local_attempt = models.LocalActivityAttempt( + task=models.WorkflowTaskAttempt( + started_event_id=task.started_event_id, + attempt=task.attempt, + started_time=_timestamp(task.started_time) + if task.started_time + else None, + ), + attempt=info.attempt, + ) + return models.Producer( + kind=models.ProducerKindLocalActivity( + models.LocalActivityProducer( + namespace=info.namespace, + workflow_id=workflow_id, + run_id=run_id, + activity_id=info.activity_id, + attempt=local_attempt, + ) + ) + ) + attempt = models.ActivityAttempt( + attempt_scheduled_time=_timestamp(info.current_attempt_scheduled_time), + attempt=info.attempt, + ) + if run_id: + # Zero is a task whose scheduled event Core couldn't read. + scheduled_event_id = info._scheduled_event_id or None # pyright: ignore[reportPrivateUsage] + return models.Producer( + kind=models.ProducerKindWorkflowActivity( + models.WorkflowActivityProducer( + namespace=info.namespace, + workflow_id=workflow_id, + run_id=run_id, + activity_id=info.activity_id, + scheduled_event_id=scheduled_event_id, + attempt=attempt, + ) + ) + ) + if not info.activity_run_id: + raise RuntimeError( + "Standalone Activity has no run id, which its Producer requires" + ) + return models.Producer( + kind=models.ProducerKindStandaloneActivity( + models.StandaloneActivityProducer( + namespace=info.namespace, + activity_id=info.activity_id, + run_id=info.activity_run_id, + attempt=attempt, + ) + ) + ) + + +def _timestamp(time: datetime) -> "Timestamp": + from temporalio.nexus.system.stream_service import models + + proto = google.protobuf.timestamp_pb2.Timestamp() + proto.FromDatetime(time) + return models.Timestamp(seconds=proto.seconds, nanos=proto.nanos) + + +DEFAULT_READ_WAIT = timedelta(minutes=1) +"""Default wait after the first page of ``read`` and ``read_pages``.""" + + +def next_read_request( + request: "ReadRecordsRequest[_BodyT]", response: "ReadRecordsResponse[_BodyT]" +) -> "ReadRecordsRequest[_BodyT] | None": + cursor = response.last_offset or request.from_offset + if not response.last_offset and response.records: + # An unflagged replay must issue its next read at the recorded request cursor. + flags = _current_workflow_flags.get() + if flags is None or flags.is_flag_enabled( + _WorkflowLogicFlag.USE_LAST_STREAM_RECORD_OFFSET + ): + cursor = response.records[-1].offset + # Empty pages don't end a Stream. The default wait avoids busy polling. + return dataclasses.replace( + request, + from_offset=cursor, + wait=DEFAULT_READ_WAIT if request.wait is None else request.wait, + ) + + +def resume_read_request( + request: "ReadRecordsRequest[_BodyT]", item: "StreamRecord[_BodyT]" +) -> "ReadRecordsRequest[_BodyT]": + return dataclasses.replace(request, from_offset=item.offset) + + def retry_policy_from_proto( proto: common_pb2.RetryPolicy, ) -> temporalio.common.RetryPolicy: