Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ESM/Pipes stream pollers: add shards to init params #12659

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

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from localstack.services.lambda_.event_source_mapping.event_processor import (
EventProcessor,
)
from localstack.services.lambda_.event_source_mapping.pipe_utils import get_current_time
from localstack.services.lambda_.event_source_mapping.pollers.stream_poller import StreamPoller

LOG = logging.getLogger(__name__)
Expand All @@ -21,6 +22,7 @@ def __init__(
processor: EventProcessor | None = None,
partner_resource_arn: str | None = None,
esm_uuid: str | None = None,
shards: dict[str, str] | None = None,
):
super().__init__(
source_arn,
Expand All @@ -29,6 +31,7 @@ def __init__(
processor,
esm_uuid=esm_uuid,
partner_resource_arn=partner_resource_arn,
shards=shards,
)

@property
Expand Down Expand Up @@ -107,7 +110,7 @@ def get_approximate_arrival_time(self, record: dict) -> float:
# Optional according to AWS docs:
# https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_StreamRecord.html
# TODO: parse float properly if present from ApproximateCreationDateTime -> now works, compare via debug!
return record["dynamodb"].get("todo", datetime.utcnow().timestamp())
return record["dynamodb"].get("todo", get_current_time().timestamp())

def format_datetime(self, time: datetime) -> str:
return f"{time.isoformat(timespec='seconds')}Z"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
invoke_identity_arn: str | None = None,
kinesis_namespace: bool = False,
esm_uuid: str | None = None,
shards: dict[str, str] | None = None,
):
super().__init__(
source_arn,
Expand All @@ -45,6 +46,7 @@ def __init__(
processor,
esm_uuid=esm_uuid,
partner_resource_arn=partner_resource_arn,
shards=shards,
)
self.invoke_identity_arn = invoke_identity_arn
self.kinesis_namespace = kinesis_namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ def __init__(
processor: EventProcessor | None = None,
partner_resource_arn: str | None = None,
esm_uuid: str | None = None,
shards: dict[str, str] | None = None,
):
super().__init__(source_arn, source_parameters, source_client, processor)
self.partner_resource_arn = partner_resource_arn
self.esm_uuid = esm_uuid
self.shards = {}
self.shards = shards if shards is not None else {}
self.iterator_over_shards = None

self._is_shutdown = threading.Event()
Expand Down
Loading