Skip to content

Adds SQS events to zappa#1617

Merged
jneves merged 13 commits intoMiserlou:masterfrom
jneves:feature/sqs
Oct 11, 2018
Merged

Adds SQS events to zappa#1617
jneves merged 13 commits intoMiserlou:masterfrom
jneves:feature/sqs

Conversation

@jneves
Copy link
Collaborator

@jneves jneves commented Sep 20, 2018

Fixes: #1613

Description

Adds support to SQS events.

This version uses an event source based on kappa. It should be removed if garnaat/kappa#133 is merged in kappa.

GitHub Issues

#1613

@coveralls
Copy link

coveralls commented Sep 20, 2018

Coverage Status

Coverage decreased (-1.03%) to 72.84% when pulling 6d8d0c7 on jneves:feature/sqs into 12ac82e on Miserlou:master.

@jneves jneves mentioned this pull request Sep 21, 2018
@jneves
Copy link
Collaborator Author

jneves commented Sep 22, 2018

Tested on 2.7 and 3.6. Relevant configuration: "events": [{ "function": "app.process_event", "event_source": { "arn": "arn:aws:sqs:eu-west-1:539577909625:zappa-test", "batch_size": 10, // Max: 10 "enabled": true // Default is false } }]

@MetricMike
Copy link

Running great on several of my 3.6 functions that use a 2-stage zappa function for webhooks with bursty traffic (one public-facing to persist JSON to an SQS queue with a variable message timer to smooth out the traffic, one private-facing to process them into another API or database). This PR eliminates most of our empty receives and SQS polling code 🍾

@edgarroman edgarroman mentioned this pull request Sep 27, 2018
@mcrowson
Copy link
Collaborator

mcrowson commented Oct 1, 2018

Any way you can squash these commits?

"event_source": {
"arn": "arn:aws:sqs:us-east-1:12341234:your-queue-name-arn",
"batch_size": 10, // Max: 10. Use 1 to trigger immediate processing
"enabled": true // Default is false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? We don't have an enabled field for other event sources. If they are present, they are enabled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably isn't going to test without it and clean up if it works.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strangely, none of the event sources have the 'enabled' knob built into the AWS configuration. See 'Enabled' parameter at end of documentation: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

I suspect it's probably some sort of throttling mechanism that typical SQS event sinks have control over. Agree that it's a little wonky, but I would recommend to leave it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcrowson enabled is false by default on push events - we also have the same behaviour for the other push events (dynamodb and kinesis). Without enabled you need to turn it on in the console, which makes some sense to me if you want to control/test when a consumer is "consuming" information from a queue.

## Executing in Response to AWS Events

Similarly, you can have your functions execute in response to events that happen in the AWS ecosystem, such as S3 uploads, DynamoDB entries, Kinesis streams, and SNS messages.
Similarly, you can have your functions execute in response to events that happen in the AWS ecosystem, such as S3 uploads, DynamoDB entries, Kinesis streams, SNS messages, and SQS queues.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update the default IAM stuff to include SQS perms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's a push event.

@jneves
Copy link
Collaborator Author

jneves commented Oct 1, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants