Replies: 1 comment
|
from functools import partial
from aws_lambda_powertools.utilities import parameters
from aws_lambda_powertools.utilities.batch import process_partial_response
def record_handler(record, *, settings):
# use settings while processing this record
...
def lambda_handler(event, context):
settings = parameters.get_parameters("/my/service/", max_age=60)
return process_partial_response(
event=event,
record_handler=partial(record_handler, settings=settings),
processor=processor,
context=context,
)This fetches once for the invocation, not once per record, and keeps invocation-specific state out of globals. If the values may safely be reused across warm invocations, Powertools Parameters already has an in-memory TTL cache, so a module-level provider plus an appropriate The important part is that the bound callable still accepts |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi --
I'm following the documentation for batch-processing SQS messages, and it works well. I'd like to know if there are any examples / best practices for how to pass additional information from the lambda_handler to the record_handler. For example, I want to retrieve some SSM parameters in the lambda_handler code and make them available to the record_handler code. Is there a good way to do this?
Thanks!
--Colin
All reactions