async-lambda-unstable 0.6.3__tar.gz → 0.6.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/PKG-INFO +1 -1
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/__init__.py +1 -1
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/controller.py +45 -24
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/.gitignore +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/README.md +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/build_config.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/cli.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/client.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/config.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/defer.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/env.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/middleware.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/__init__.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/api_response.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/case_insensitive_dict.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/__init__.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/api_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/base_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/dynamodb_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/managed_sqs_batch_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/managed_sqs_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/scheduled_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/unmanaged_sqs_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/mock/mock_context.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/mock/mock_event.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/task.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/payload_encoder.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/py.typed +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/util.py +0 -0
- {async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/pyproject.toml +0 -0
|
@@ -21,4 +21,4 @@ from .models.events.managed_sqs_event import ManagedSQSEvent as ManagedSQSEvent
|
|
|
21
21
|
from .models.events.scheduled_event import ScheduledEvent as ScheduledEvent
|
|
22
22
|
from .models.events.unmanaged_sqs_event import UnmanagedSQSEvent as UnmanagedSQSEvent
|
|
23
23
|
|
|
24
|
-
__version__ = "0.6.
|
|
24
|
+
__version__ = "0.6.4"
|
|
@@ -178,6 +178,48 @@ class AsyncLambdaController:
|
|
|
178
178
|
self.delete_s3_payloads = delete_s3_payloads
|
|
179
179
|
self.controller_name = controller_name
|
|
180
180
|
|
|
181
|
+
# itertools.batched is much cleaner but only available in python 3.12+
|
|
182
|
+
@staticmethod
|
|
183
|
+
def _batched(items: Sequence[dict], batch_size: int) -> List[List[dict]]:
|
|
184
|
+
if batch_size <= 0:
|
|
185
|
+
raise ValueError("batch_size must be greater than 0")
|
|
186
|
+
return [
|
|
187
|
+
list(items[i : i + batch_size]) for i in range(0, len(items), batch_size)
|
|
188
|
+
]
|
|
189
|
+
|
|
190
|
+
@classmethod
|
|
191
|
+
def _build_send_to_all_async_lambda_queues_policies(
|
|
192
|
+
cls,
|
|
193
|
+
managed_tasks_resources: List[dict],
|
|
194
|
+
policy_batch_size: int = 30,
|
|
195
|
+
) -> Dict[str, dict]:
|
|
196
|
+
task_ref_policies: Dict[str, dict] = {}
|
|
197
|
+
for chunk_index, resource_chunk in enumerate(
|
|
198
|
+
cls._batched(items=managed_tasks_resources, batch_size=policy_batch_size),
|
|
199
|
+
start=0,
|
|
200
|
+
):
|
|
201
|
+
policy_id = f"SendToAllAsyncLambdaQueuesPolicy{chunk_index}"
|
|
202
|
+
task_ref_policies[policy_id] = {
|
|
203
|
+
"Type": "AWS::IAM::ManagedPolicy",
|
|
204
|
+
"Properties": {
|
|
205
|
+
"ManagedPolicyName": {
|
|
206
|
+
"Fn::Sub": f"${{AWS::StackName}}-send-to-all-queues-{chunk_index}"
|
|
207
|
+
},
|
|
208
|
+
"PolicyDocument": {
|
|
209
|
+
"Version": "2012-10-17",
|
|
210
|
+
"Statement": [
|
|
211
|
+
{
|
|
212
|
+
"Sid": "SendToAllQueues",
|
|
213
|
+
"Effect": "Allow",
|
|
214
|
+
"Action": ["sqs:SendMessage"],
|
|
215
|
+
"Resource": resource_chunk,
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
}
|
|
221
|
+
return task_ref_policies
|
|
222
|
+
|
|
181
223
|
def add_middleware(
|
|
182
224
|
self, event_types: List[Type[BaseEvent]], func: MiddlewareFunction[MET, RT]
|
|
183
225
|
):
|
|
@@ -427,30 +469,9 @@ class AsyncLambdaController:
|
|
|
427
469
|
]
|
|
428
470
|
task_ref_policies = {}
|
|
429
471
|
if len(managed_tasks_resources) > 0:
|
|
430
|
-
task_ref_policies =
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
"Properties": {
|
|
434
|
-
"ManagedPolicyName": {
|
|
435
|
-
"Fn::Sub": "${AWS::StackName}-send-to-all-queues"
|
|
436
|
-
},
|
|
437
|
-
"PolicyDocument": {
|
|
438
|
-
"Version": "2012-10-17",
|
|
439
|
-
"Statement": [
|
|
440
|
-
{
|
|
441
|
-
"Sid": "SendToAllQueues",
|
|
442
|
-
"Effect": "Allow",
|
|
443
|
-
"Action": ["sqs:SendMessage"],
|
|
444
|
-
"Resource": [
|
|
445
|
-
managed_tasks_resource
|
|
446
|
-
for managed_tasks_resource in managed_tasks_resources
|
|
447
|
-
],
|
|
448
|
-
},
|
|
449
|
-
],
|
|
450
|
-
},
|
|
451
|
-
},
|
|
452
|
-
}
|
|
453
|
-
}
|
|
472
|
+
task_ref_policies = self._build_send_to_all_async_lambda_queues_policies(
|
|
473
|
+
managed_tasks_resources
|
|
474
|
+
)
|
|
454
475
|
for key in task_ref_policies.keys():
|
|
455
476
|
template["Resources"][key] = task_ref_policies[key]
|
|
456
477
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/api_response.py
RENAMED
|
File without changes
|
|
File without changes
|
{async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/__init__.py
RENAMED
|
File without changes
|
{async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/api_event.py
RENAMED
|
File without changes
|
{async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/events/base_event.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/mock/mock_context.py
RENAMED
|
File without changes
|
{async_lambda_unstable-0.6.3 → async_lambda_unstable-0.6.4}/async_lambda/models/mock/mock_event.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|