Skip to content

Commit

Permalink
Merge branch 'master' into feature/ephemeral_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
goya813 authored Nov 21, 2022
2 parents 0c529c6 + 048fbe4 commit 3eebbdc
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/tests_placebo.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,63 @@ def test_add_event_source(self, session):
session,
dry=True,
)
event_source = {
"arn": "sqs:sqs:sqs:sqs",
"events": [
{
"function": "function_name",
"event_source": {
"arn": "dummy",
"batch_size": 100,
"batch_window": 10,
"functionResponseType": "ReportBatchItemFailures",
"enabled": True,
},
}
],
}
add_event_source(
event_source,
"sqs:sqs:sqs:sqs",
"test_settings.callback",
session,
dry=True,
)
remove_event_source(
event_source,
"sqs:sqs:sqs:sqs",
"test_settings.callback",
session,
dry=True,
)
event_source = {
"arn": "sqs:sqs:sqs:sqs",
"events": [
{
"function": "function_name",
"event_source": {
"arn": "dummy",
"batch_size": 100,
"functionResponseType": "ReportBatchItemFailures",
"enabled": True,
},
}
],
}
add_event_source(
event_source,
"sqs:sqs:sqs:sqs",
"test_settings.callback",
session,
dry=True,
)
remove_event_source(
event_source,
"sqs:sqs:sqs:sqs",
"test_settings.callback",
session,
dry=True,
)
# get_event_source_status(event_source, 'lambda:lambda:lambda:lambda', 'test_settings.callback', session, dry=True)

@placebo_session
Expand Down
6 changes: 6 additions & 0 deletions zappa/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ def __init__(self, context, config):
super().__init__(context, config)
self._lambda = kappa.awsclient.create_client("lambda", context.session)

@property
def batch_window(self):
return self._config.get("batch_window", 1 if self.batch_size > 10 else 0)

def _get_uuid(self, function):
uuid = None
response = self._lambda.call(
Expand All @@ -284,6 +288,7 @@ def add(self, function):
FunctionName=function.name,
EventSourceArn=self.arn,
BatchSize=self.batch_size,
MaximumBatchingWindowInSeconds=self.batch_window,
Enabled=self.enabled,
)
LOG.debug(response)
Expand Down Expand Up @@ -322,6 +327,7 @@ def update(self, function):
response = self._lambda.call(
"update_event_source_mapping",
BatchSize=self.batch_size,
MaximumBatchingWindowInSeconds=self.batch_window,
Enabled=self.enabled,
FunctionName=function.arn,
)
Expand Down

0 comments on commit 3eebbdc

Please sign in to comment.