Skip to content

Commit c38c80d

Browse files
Add create event publisher/reciver methods to protocol
1 parent c6b60fd commit c38c80d

File tree

1 file changed

+51
-2
lines changed
  • packages/smithy-core/src/smithy_core/aio/interfaces

1 file changed

+51
-2
lines changed

packages/smithy-core/src/smithy_core/aio/interfaces/__init__.py

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33
from collections.abc import AsyncIterable
4-
from typing import Protocol, runtime_checkable, TYPE_CHECKING, Any
4+
from typing import Protocol, runtime_checkable, TYPE_CHECKING, Any, Callable
55

6+
from ...exceptions import UnsupportedStreamException
67
from ...interfaces import URI, Endpoint, TypedProperties
78
from ...interfaces import StreamingBlob as SyncStreamingBlob
89

10+
from .eventstream import EventPublisher, EventReceiver
11+
912

1013
if TYPE_CHECKING:
1114
from ...schemas import APIOperation
1215
from ...shapes import ShapeID
1316
from ...serializers import SerializeableShape
14-
from ...deserializers import DeserializeableShape
17+
from ...deserializers import DeserializeableShape, ShapeDeserializer
1518

1619

1720
@runtime_checkable
@@ -138,3 +141,49 @@ async def deserialize_response[
138141
:param context: A context bag for the request.
139142
"""
140143
...
144+
145+
def create_event_publisher[
146+
OperationInput: "SerializeableShape",
147+
OperationOutput: "DeserializeableShape",
148+
Event: "SerializeableShape",
149+
](
150+
self,
151+
*,
152+
operation: "APIOperation[OperationInput, OperationOutput]",
153+
request: I,
154+
event_type: type[Event],
155+
context: TypedProperties,
156+
) -> EventPublisher[Event]:
157+
"""Creates an event publisher for a protocol event stream.
158+
159+
:param operation: The event stream operation.
160+
:param request: The transport request that was sent for this stream.
161+
:param event_type: The type of event to publish.
162+
:param context: A context bag for the request.
163+
"""
164+
raise UnsupportedStreamException()
165+
166+
def create_event_receiver[
167+
OperationInput: "SerializeableShape",
168+
OperationOutput: "DeserializeableShape",
169+
Event: "DeserializeableShape",
170+
](
171+
self,
172+
*,
173+
operation: "APIOperation[OperationInput, OperationOutput]",
174+
request: I,
175+
response: O,
176+
event_type: type[Event],
177+
event_deserializer: Callable[["ShapeDeserializer"], Event],
178+
context: TypedProperties,
179+
) -> EventReceiver[Event]:
180+
"""Creates an event receiver for a protocol event stream.
181+
182+
:param operation: The event stream operation.
183+
:param request: The transport request that was sent for this stream.
184+
:param response: The transport response that was received for this stream.
185+
:param event_type: The type of event to publish.
186+
:param event_deserializer: The deserializer to be used to deserialize events.
187+
:param context: A context bag for the request.
188+
"""
189+
raise UnsupportedStreamException()

0 commit comments

Comments
 (0)