Helped with a SQS event processor #244
Iamrodos
started this conversation in
Show and tell
Replies: 0 comments
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.
-
We have an SQS-triggered Lambda that processes events, where each event can have multiple handlers (send email, update records, trigger downstream events, etc.). Before durable functions, if handler 3 of 5 failed, the SQS retry would reprocess handlers 1-2 unnecessarily. These handlers were not always idempotent, causing duplicate side effects. Its been a TODO to resolve and durable functions turned into an easy way to do this.
We wrapped our event processor in
@durable_executionand usectx.step()to checkpoint:We use a
DURABLE_EXECUTION_ENABLEDenv var to switch between durable and standard BatchProcessor paths. This lets us roll back instantly without code changes if issues arise.We include the handler index in step names (
handler-0-send_email) to avoid collisions when multiple handlers share the same__name__.The only issue we hit was a circular dependency on CloudFromation when trying to write the role for the Lambda. The IAM role needs the Lambda ARN for checkpoint permissions, but the Lambda needs the Role ARN. Would like to find a way to solve that.
Beta Was this translation helpful? Give feedback.
All reactions