-
Notifications
You must be signed in to change notification settings - Fork 24
Event Signing #438
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
Event Signing #438
Changes from all commits
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 |
|---|---|---|
|
|
@@ -387,7 +387,7 @@ def get_result(self) -> bytes: | |
| raise InvalidHeadersLength(len(result)) | ||
| return result | ||
|
|
||
| def encode_headers(self, headers: HEADERS_DICT): | ||
| def encode_headers(self, headers: HEADERS_DICT) -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand why this method builds an internal buffer - but the interface does seem weird. It seems like we could either:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'd generally agree with this, the encode workflow here is a bit odd. I think we can look at a refactor as follow up, this PR is just fixing the typing issue from the original.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this was intended for streaming out without an intermediary. Then we switched to have an intermediary |
||
| """Encode a map of headers. | ||
|
|
||
| :param headers: A mapping of headers to encode. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import datetime | ||
| import uuid | ||
| from collections.abc import Mapping | ||
| from typing import Protocol | ||
|
|
||
|
|
||
| type HEADER_VALUE = bool | int | bytes | str | datetime.datetime | uuid.UUID | ||
| """A union of valid value types for event headers.""" | ||
|
|
||
|
|
||
| type HEADERS_DICT = Mapping[str, HEADER_VALUE] | ||
| """A dictionary of event headers.""" | ||
|
|
||
|
|
||
| class EventMessage(Protocol): | ||
| """A signable message that may be sent over an event stream.""" | ||
|
|
||
| headers: HEADERS_DICT | ||
| """The headers present in the event message.""" | ||
|
|
||
| payload: bytes | ||
| """The serialized bytes of the message payload.""" | ||
|
|
||
| def encode(self) -> bytes: | ||
| """Encode heads and payload into bytes for transit.""" | ||
| ... | ||
|
|
||
|
|
||
| class EventHeaderEncoder(Protocol): | ||
| """A utility class that encodes event headers into bytes.""" | ||
|
|
||
| def clear(self) -> None: | ||
| """Clear all previously encoded headers.""" | ||
| ... | ||
|
|
||
| def get_result(self) -> bytes: | ||
| """Get all the encoded header bytes.""" | ||
| ... | ||
|
|
||
| def encode_headers(self, headers: HEADERS_DICT) -> None: | ||
| """Encode a map of headers.""" | ||
| ... |
Uh oh!
There was an error while loading. Please reload this page.