-
Notifications
You must be signed in to change notification settings - Fork 24
Add timeout error classification #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 7 commits
1c8bed7
06ece22
264f02a
f35ddd1
92dd38f
ecb05aa
9e37c52
70100ee
39dfa0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| from collections.abc import AsyncIterable, Callable | ||
| from dataclasses import dataclass | ||
| from typing import TYPE_CHECKING, Any, Protocol, runtime_checkable | ||
|
|
||
| from ...documents import TypeRegistry | ||
|
|
@@ -10,6 +11,15 @@ | |
| from ...interfaces import StreamingBlob as SyncStreamingBlob | ||
| from .eventstream import EventPublisher, EventReceiver | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class ClientErrorInfo: | ||
| """Information about an error from a transport.""" | ||
|
|
||
| is_timeout_error: bool | ||
| """Whether this error represents a timeout condition.""" | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| from typing_extensions import TypeForm | ||
|
|
||
|
|
@@ -86,7 +96,23 @@ async def resolve_endpoint(self, params: EndpointResolverParams[Any]) -> Endpoin | |
|
|
||
|
|
||
| class ClientTransport[I: Request, O: Response](Protocol): | ||
| """Protocol-agnostic representation of a client tranport (e.g. an HTTP client).""" | ||
| """Protocol-agnostic representation of a client transport (e.g. an HTTP client). | ||
|
|
||
| Transport implementations must define the get_error_info method to determine which | ||
| exceptions represent timeout conditions for that transport. | ||
| """ | ||
|
|
||
| def get_error_info(self, exception: Exception, **kwargs: Any) -> ClientErrorInfo: | ||
|
||
| """Get information about an exception. | ||
|
|
||
| Args: | ||
| exception: The exception to analyze | ||
| **kwargs: Additional context for analysis | ||
|
|
||
| Returns: | ||
| ClientErrorInfo with timeout information. | ||
| """ | ||
| ... | ||
|
|
||
| async def send(self, request: I) -> O: | ||
| """Send a request over the transport and receive the response.""" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.