modmex-lambda 0.7.3__py3-none-any.whl → 0.8.0__py3-none-any.whl
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.
- modmex_lambda/connectors/dynamodb.py +42 -1
- modmex_lambda/event_handler/api_gateway.py +21 -4
- modmex_lambda/mcp/__init__.py +11 -1
- modmex_lambda/stream/runner.py +23 -5
- modmex_lambda/stream/sources/base.py +3 -0
- modmex_lambda/stream/sources/dynamodb.py +4 -0
- modmex_lambda/stream/sources/kinesis.py +4 -0
- modmex_lambda/stream/sources/s3.py +4 -0
- modmex_lambda/stream/sources/sns.py +4 -0
- modmex_lambda/stream/sources/sqs.py +4 -0
- {modmex_lambda-0.7.3.dist-info → modmex_lambda-0.8.0.dist-info}/METADATA +36 -1
- {modmex_lambda-0.7.3.dist-info → modmex_lambda-0.8.0.dist-info}/RECORD +14 -14
- {modmex_lambda-0.7.3.dist-info → modmex_lambda-0.8.0.dist-info}/WHEEL +1 -1
- {modmex_lambda-0.7.3.dist-info → modmex_lambda-0.8.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -68,6 +68,10 @@ class Connector(IDynamodbConnector):
|
|
|
68
68
|
return self._unmarshall_response(response)
|
|
69
69
|
|
|
70
70
|
def query_all(self, input_params):
|
|
71
|
+
# Paginate on a copy: callers often reuse a module-level params dict
|
|
72
|
+
# across warm invocations, and a leftover ExclusiveStartKey would make
|
|
73
|
+
# the next call silently start from the last page.
|
|
74
|
+
input_params = dict(input_params)
|
|
71
75
|
items = []
|
|
72
76
|
while True:
|
|
73
77
|
result = self.query(input_params)
|
|
@@ -79,7 +83,19 @@ class Connector(IDynamodbConnector):
|
|
|
79
83
|
return items
|
|
80
84
|
|
|
81
85
|
def batch_get(self, input_params):
|
|
82
|
-
|
|
86
|
+
chunks = _batch_get_chunks(input_params)
|
|
87
|
+
if len(chunks) == 1:
|
|
88
|
+
return self._batch_get(chunks[0], [])
|
|
89
|
+
results = [self._batch_get(chunk, []) for chunk in chunks]
|
|
90
|
+
responses: dict = {}
|
|
91
|
+
for result in results:
|
|
92
|
+
for table, items in result.get('Responses', {}).items():
|
|
93
|
+
responses.setdefault(table, []).extend(items)
|
|
94
|
+
return {
|
|
95
|
+
**results[-1],
|
|
96
|
+
'Responses': responses,
|
|
97
|
+
'attempts': [attempt for result in results for attempt in result.get('attempts', [])],
|
|
98
|
+
}
|
|
83
99
|
|
|
84
100
|
def _batch_get(self, params, attempts):
|
|
85
101
|
assert_max_retries(attempts, self.retry_config['max_retries'])
|
|
@@ -255,6 +271,31 @@ class Connector(IDynamodbConnector):
|
|
|
255
271
|
}
|
|
256
272
|
|
|
257
273
|
|
|
274
|
+
BATCH_GET_MAX_KEYS = 100 # DynamoDB BatchGetItem limit, across all tables
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def _batch_get_chunks(params):
|
|
278
|
+
"""Split a BatchGetItem request into requests of at most 100 keys in total."""
|
|
279
|
+
pairs = [
|
|
280
|
+
(table, key)
|
|
281
|
+
for table, request in params.get('RequestItems', {}).items()
|
|
282
|
+
for key in request.get('Keys', [])
|
|
283
|
+
]
|
|
284
|
+
if len(pairs) <= BATCH_GET_MAX_KEYS:
|
|
285
|
+
return [params]
|
|
286
|
+
chunks = []
|
|
287
|
+
for start in range(0, len(pairs), BATCH_GET_MAX_KEYS):
|
|
288
|
+
request_items = {}
|
|
289
|
+
for table, key in pairs[start:start + BATCH_GET_MAX_KEYS]:
|
|
290
|
+
table_request = request_items.setdefault(
|
|
291
|
+
table,
|
|
292
|
+
{**params['RequestItems'][table], 'Keys': []},
|
|
293
|
+
)
|
|
294
|
+
table_request['Keys'].append(key)
|
|
295
|
+
chunks.append({**params, 'RequestItems': request_items})
|
|
296
|
+
return chunks
|
|
297
|
+
|
|
298
|
+
|
|
258
299
|
def unprocessed(params, resp):
|
|
259
300
|
return {
|
|
260
301
|
**params,
|
|
@@ -171,15 +171,27 @@ class ApiGatewayResolver(BaseRouter, IApiGatewayResolver):
|
|
|
171
171
|
def include_router(self, router: Router, prefix: str = "") -> None:
|
|
172
172
|
self._router.include_router(router, prefix=prefix)
|
|
173
173
|
|
|
174
|
-
def include_mcp(
|
|
175
|
-
|
|
174
|
+
def include_mcp(
|
|
175
|
+
self,
|
|
176
|
+
server: Any,
|
|
177
|
+
*,
|
|
178
|
+
path: str = "/mcp",
|
|
179
|
+
allowed_origins: list[str] | None = None,
|
|
180
|
+
) -> None:
|
|
181
|
+
"""Mount a transport-neutral MCP server as a normal HTTP route.
|
|
182
|
+
|
|
183
|
+
``allowed_origins`` is an allowlist for the ``Origin`` header (MCP asks
|
|
184
|
+
servers to validate it against DNS-rebinding attacks); ``None`` leaves the
|
|
185
|
+
policy to the infrastructure in front of the function, ``[]`` denies every
|
|
186
|
+
browser origin.
|
|
187
|
+
"""
|
|
176
188
|
from modmex_lambda.mcp import MCPServer
|
|
177
189
|
from modmex_lambda.mcp.transport import MCPHttpTransport
|
|
178
190
|
|
|
179
191
|
if not isinstance(server, MCPServer):
|
|
180
192
|
raise TypeError("include_mcp expects an MCPServer")
|
|
181
193
|
|
|
182
|
-
transport = MCPHttpTransport(server)
|
|
194
|
+
transport = MCPHttpTransport(server, allowed_origins=allowed_origins)
|
|
183
195
|
|
|
184
196
|
@self.route(path, method="POST", status_code=200)
|
|
185
197
|
def mcp_handler(request: Request) -> Response:
|
|
@@ -252,7 +264,12 @@ class ApiGatewayResolver(BaseRouter, IApiGatewayResolver):
|
|
|
252
264
|
return path[len(prefix) :]
|
|
253
265
|
|
|
254
266
|
if isinstance(prefix, Pattern):
|
|
255
|
-
path
|
|
267
|
+
# A prefix only strips the start of the path. re.sub removed every
|
|
268
|
+
# match, so "/v\d+" turned "/v1/users/7/v2/x" into "/users/7/x"
|
|
269
|
+
# and routed the request to a different handler.
|
|
270
|
+
match = prefix.match(path)
|
|
271
|
+
if match is not None and match.end() > 0:
|
|
272
|
+
path = path[match.end():]
|
|
256
273
|
|
|
257
274
|
if not path:
|
|
258
275
|
return "/"
|
modmex_lambda/mcp/__init__.py
CHANGED
|
@@ -13,7 +13,6 @@ from modmex_lambda.mcp.resource import MCPResource
|
|
|
13
13
|
from modmex_lambda.mcp.prompt import MCPPrompt
|
|
14
14
|
from modmex_lambda.mcp.transport import MCPHttpTransport, MCPStreamingHttpTransport, StreamingHTTPResponse, SSEEvent, encode_sse, encode_sse_stream, MCP_JSON_CONTENT_TYPE, MCP_SSE_CONTENT_TYPE
|
|
15
15
|
from modmex_lambda.mcp.middleware import MCPContext, MCPMiddleware, MCPNextMiddleware, MCPProgressReporter, MCPCancellationToken
|
|
16
|
-
from modmex_lambda.mcp.web_adapter import LambdaWebAdapterResolver
|
|
17
16
|
|
|
18
17
|
__all__ = [
|
|
19
18
|
"JSONRPCError",
|
|
@@ -41,3 +40,14 @@ __all__ = [
|
|
|
41
40
|
"MCPCancellationToken",
|
|
42
41
|
"LambdaWebAdapterResolver",
|
|
43
42
|
]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __getattr__(name):
|
|
46
|
+
# LambdaWebAdapterResolver pulls in http.server and is only needed with the
|
|
47
|
+
# Lambda Web Adapter; load it on first access, not with every MCP import.
|
|
48
|
+
if name == "LambdaWebAdapterResolver":
|
|
49
|
+
from modmex_lambda.mcp.web_adapter import LambdaWebAdapterResolver
|
|
50
|
+
|
|
51
|
+
globals()[name] = LambdaWebAdapterResolver
|
|
52
|
+
return LambdaWebAdapterResolver
|
|
53
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
modmex_lambda/stream/runner.py
CHANGED
|
@@ -39,7 +39,19 @@ def run(
|
|
|
39
39
|
on_completed=None,
|
|
40
40
|
concurrency=True,
|
|
41
41
|
on_fault: FaultHandler | None = None,
|
|
42
|
+
raise_on_error: bool = True,
|
|
42
43
|
):
|
|
44
|
+
"""Run every registered pipeline over ``events``.
|
|
45
|
+
|
|
46
|
+
Handled failures (wrapped with ``faulty``) are published as fault events and
|
|
47
|
+
do not fail the invocation. An unexpected error that ends a pipeline is
|
|
48
|
+
re-raised once all pipelines finished and faults were flushed, so the Lambda
|
|
49
|
+
invocation fails and AWS retries the batch instead of acknowledging records
|
|
50
|
+
that were never processed. ``on_error`` is still called first (observability).
|
|
51
|
+
Pass ``raise_on_error=False`` to only report such errors through ``on_error``.
|
|
52
|
+
"""
|
|
53
|
+
pipeline_errors: list[BaseException] = []
|
|
54
|
+
token: Token = active_fault_handler.set(on_fault)
|
|
43
55
|
try:
|
|
44
56
|
opt = {
|
|
45
57
|
'bus_name': os.getenv('BUS_NAME'),
|
|
@@ -51,8 +63,6 @@ def run(
|
|
|
51
63
|
pipeline_logger = opt.get('logger') or Logger()
|
|
52
64
|
|
|
53
65
|
|
|
54
|
-
token: Token = active_fault_handler.set(on_fault)
|
|
55
|
-
|
|
56
66
|
def make_lines(flavor):
|
|
57
67
|
source = from_list( # pylint: disable=E1102
|
|
58
68
|
copy.deepcopy(events)
|
|
@@ -88,9 +98,12 @@ def run(
|
|
|
88
98
|
on_next(pipeline_id, uow)
|
|
89
99
|
|
|
90
100
|
def _on_error(pipeline_id, err):
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
pipeline_errors.append(err)
|
|
102
|
+
try:
|
|
103
|
+
if on_error:
|
|
104
|
+
on_error(pipeline_id, err)
|
|
105
|
+
finally:
|
|
106
|
+
mark_completed()
|
|
94
107
|
|
|
95
108
|
def _on_completed(pipeline_id):
|
|
96
109
|
if on_completed:
|
|
@@ -117,3 +130,8 @@ def run(
|
|
|
117
130
|
|
|
118
131
|
finally:
|
|
119
132
|
active_fault_handler.reset(token)
|
|
133
|
+
|
|
134
|
+
if pipeline_errors and raise_on_error:
|
|
135
|
+
for extra in pipeline_errors[1:]:
|
|
136
|
+
pipeline_logger.error(f"Additional pipeline error: {extra!r}")
|
|
137
|
+
raise pipeline_errors[0]
|
|
@@ -23,6 +23,7 @@ class SourceHandler(Generic[S, E]):
|
|
|
23
23
|
on_error: Optional[Callable] = None,
|
|
24
24
|
on_completed: Optional[Callable] = None,
|
|
25
25
|
on_fault: Optional[Callable] = None,
|
|
26
|
+
raise_on_error: bool = True,
|
|
26
27
|
logger: Optional[object] = None,
|
|
27
28
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
28
29
|
) -> None:
|
|
@@ -33,6 +34,7 @@ class SourceHandler(Generic[S, E]):
|
|
|
33
34
|
self.on_error = on_error
|
|
34
35
|
self.on_completed = on_completed
|
|
35
36
|
self.on_fault = on_fault
|
|
37
|
+
self.raise_on_error = raise_on_error
|
|
36
38
|
self.logger = logger or Logger()
|
|
37
39
|
self.dependency_resolver = dependency_resolver or default_dependency_resolver()
|
|
38
40
|
self.registry.bind(self.dependency_resolver)
|
|
@@ -60,4 +62,5 @@ class SourceHandler(Generic[S, E]):
|
|
|
60
62
|
on_completed=self.on_completed,
|
|
61
63
|
concurrency=self.concurrency,
|
|
62
64
|
on_fault=self.on_fault,
|
|
65
|
+
raise_on_error=self.raise_on_error,
|
|
63
66
|
)
|
|
@@ -25,6 +25,7 @@ class DynamoDBSource(SourceHandler[DynamoDBStreamEvent, DynamoDBEvent]):
|
|
|
25
25
|
on_error: Optional[Callable] = None,
|
|
26
26
|
on_completed: Optional[Callable] = None,
|
|
27
27
|
on_fault: Optional[Callable] = None,
|
|
28
|
+
raise_on_error: bool = True,
|
|
28
29
|
logger: Optional[object] = None,
|
|
29
30
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
30
31
|
parser_options: Optional[DynamodbParserOptions] = None,
|
|
@@ -45,6 +46,7 @@ class DynamoDBSource(SourceHandler[DynamoDBStreamEvent, DynamoDBEvent]):
|
|
|
45
46
|
on_error=on_error,
|
|
46
47
|
on_completed=on_completed,
|
|
47
48
|
on_fault=on_fault,
|
|
49
|
+
raise_on_error=raise_on_error,
|
|
48
50
|
logger=logger,
|
|
49
51
|
dependency_resolver=dependency_resolver,
|
|
50
52
|
)
|
|
@@ -58,6 +60,7 @@ def dynamodb_source(
|
|
|
58
60
|
on_error: Optional[Callable] = None,
|
|
59
61
|
on_completed: Optional[Callable] = None,
|
|
60
62
|
on_fault: Optional[Callable] = None,
|
|
63
|
+
raise_on_error: bool = True,
|
|
61
64
|
logger: Optional[object] = None,
|
|
62
65
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
63
66
|
parser_options: Optional[DynamodbParserOptions] = None,
|
|
@@ -69,6 +72,7 @@ def dynamodb_source(
|
|
|
69
72
|
on_error=on_error,
|
|
70
73
|
on_completed=on_completed,
|
|
71
74
|
on_fault=on_fault,
|
|
75
|
+
raise_on_error=raise_on_error,
|
|
72
76
|
logger=logger,
|
|
73
77
|
dependency_resolver=dependency_resolver,
|
|
74
78
|
parser_options=parser_options,
|
|
@@ -16,6 +16,7 @@ class KinesisSource(SourceHandler):
|
|
|
16
16
|
on_error: Optional[Callable] = None,
|
|
17
17
|
on_completed: Optional[Callable] = None,
|
|
18
18
|
on_fault: Optional[Callable] = None,
|
|
19
|
+
raise_on_error: bool = True,
|
|
19
20
|
logger: Optional[object] = None,
|
|
20
21
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
21
22
|
) -> None:
|
|
@@ -27,6 +28,7 @@ class KinesisSource(SourceHandler):
|
|
|
27
28
|
on_error=on_error,
|
|
28
29
|
on_completed=on_completed,
|
|
29
30
|
on_fault=on_fault,
|
|
31
|
+
raise_on_error=raise_on_error,
|
|
30
32
|
logger=logger,
|
|
31
33
|
dependency_resolver=dependency_resolver,
|
|
32
34
|
)
|
|
@@ -40,6 +42,7 @@ def kinesis_source(
|
|
|
40
42
|
on_error: Optional[Callable] = None,
|
|
41
43
|
on_completed: Optional[Callable] = None,
|
|
42
44
|
on_fault: Optional[Callable] = None,
|
|
45
|
+
raise_on_error: bool = True,
|
|
43
46
|
logger: Optional[object] = None,
|
|
44
47
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
45
48
|
):
|
|
@@ -50,6 +53,7 @@ def kinesis_source(
|
|
|
50
53
|
on_error=on_error,
|
|
51
54
|
on_completed=on_completed,
|
|
52
55
|
on_fault=on_fault,
|
|
56
|
+
raise_on_error=raise_on_error,
|
|
53
57
|
logger=logger,
|
|
54
58
|
dependency_resolver=dependency_resolver,
|
|
55
59
|
)
|
|
@@ -20,6 +20,7 @@ class S3Source(SourceHandler):
|
|
|
20
20
|
on_error: Optional[Callable] = None,
|
|
21
21
|
on_completed: Optional[Callable] = None,
|
|
22
22
|
on_fault: Optional[Callable] = None,
|
|
23
|
+
raise_on_error: bool = True,
|
|
23
24
|
logger: Optional[object] = None,
|
|
24
25
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
25
26
|
) -> None:
|
|
@@ -31,6 +32,7 @@ class S3Source(SourceHandler):
|
|
|
31
32
|
on_error=on_error,
|
|
32
33
|
on_completed=on_completed,
|
|
33
34
|
on_fault=on_fault,
|
|
35
|
+
raise_on_error=raise_on_error,
|
|
34
36
|
logger=logger,
|
|
35
37
|
dependency_resolver=dependency_resolver,
|
|
36
38
|
)
|
|
@@ -56,6 +58,7 @@ def s3_source(
|
|
|
56
58
|
on_error: Optional[Callable] = None,
|
|
57
59
|
on_completed: Optional[Callable] = None,
|
|
58
60
|
on_fault: Optional[Callable] = None,
|
|
61
|
+
raise_on_error: bool = True,
|
|
59
62
|
logger: Optional[object] = None,
|
|
60
63
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
61
64
|
):
|
|
@@ -66,6 +69,7 @@ def s3_source(
|
|
|
66
69
|
on_error=on_error,
|
|
67
70
|
on_completed=on_completed,
|
|
68
71
|
on_fault=on_fault,
|
|
72
|
+
raise_on_error=raise_on_error,
|
|
69
73
|
logger=logger,
|
|
70
74
|
dependency_resolver=dependency_resolver,
|
|
71
75
|
)
|
|
@@ -16,6 +16,7 @@ class SnsSource(SourceHandler):
|
|
|
16
16
|
on_error: Optional[Callable] = None,
|
|
17
17
|
on_completed: Optional[Callable] = None,
|
|
18
18
|
on_fault: Optional[Callable] = None,
|
|
19
|
+
raise_on_error: bool = True,
|
|
19
20
|
logger: Optional[object] = None,
|
|
20
21
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
21
22
|
) -> None:
|
|
@@ -27,6 +28,7 @@ class SnsSource(SourceHandler):
|
|
|
27
28
|
on_error=on_error,
|
|
28
29
|
on_completed=on_completed,
|
|
29
30
|
on_fault=on_fault,
|
|
31
|
+
raise_on_error=raise_on_error,
|
|
30
32
|
logger=logger,
|
|
31
33
|
dependency_resolver=dependency_resolver,
|
|
32
34
|
)
|
|
@@ -40,6 +42,7 @@ def sns_source(
|
|
|
40
42
|
on_error: Optional[Callable] = None,
|
|
41
43
|
on_completed: Optional[Callable] = None,
|
|
42
44
|
on_fault: Optional[Callable] = None,
|
|
45
|
+
raise_on_error: bool = True,
|
|
43
46
|
logger: Optional[object] = None,
|
|
44
47
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
45
48
|
):
|
|
@@ -50,6 +53,7 @@ def sns_source(
|
|
|
50
53
|
on_error=on_error,
|
|
51
54
|
on_completed=on_completed,
|
|
52
55
|
on_fault=on_fault,
|
|
56
|
+
raise_on_error=raise_on_error,
|
|
53
57
|
logger=logger,
|
|
54
58
|
dependency_resolver=dependency_resolver,
|
|
55
59
|
)
|
|
@@ -16,6 +16,7 @@ class SqsSource(SourceHandler):
|
|
|
16
16
|
on_error: Optional[Callable] = None,
|
|
17
17
|
on_completed: Optional[Callable] = None,
|
|
18
18
|
on_fault: Optional[Callable] = None,
|
|
19
|
+
raise_on_error: bool = True,
|
|
19
20
|
logger: Optional[object] = None,
|
|
20
21
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
21
22
|
) -> None:
|
|
@@ -27,6 +28,7 @@ class SqsSource(SourceHandler):
|
|
|
27
28
|
on_error=on_error,
|
|
28
29
|
on_completed=on_completed,
|
|
29
30
|
on_fault=on_fault,
|
|
31
|
+
raise_on_error=raise_on_error,
|
|
30
32
|
logger=logger,
|
|
31
33
|
dependency_resolver=dependency_resolver,
|
|
32
34
|
)
|
|
@@ -40,6 +42,7 @@ def sqs_source(
|
|
|
40
42
|
on_error: Optional[Callable] = None,
|
|
41
43
|
on_completed: Optional[Callable] = None,
|
|
42
44
|
on_fault: Optional[Callable] = None,
|
|
45
|
+
raise_on_error: bool = True,
|
|
43
46
|
logger: Optional[object] = None,
|
|
44
47
|
dependency_resolver: Optional[DependencyResolver] = None,
|
|
45
48
|
):
|
|
@@ -50,6 +53,7 @@ def sqs_source(
|
|
|
50
53
|
on_error=on_error,
|
|
51
54
|
on_completed=on_completed,
|
|
52
55
|
on_fault=on_fault,
|
|
56
|
+
raise_on_error=raise_on_error,
|
|
53
57
|
logger=logger,
|
|
54
58
|
dependency_resolver=dependency_resolver,
|
|
55
59
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: modmex-lambda
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0
|
|
4
4
|
Summary: Ultra-lightweight AWS Lambda utilities for API Gateway routing and event handling.
|
|
5
5
|
Author: Modmex
|
|
6
6
|
License: MIT
|
|
@@ -474,6 +474,19 @@ def on_domain_error(exc: DomainError):
|
|
|
474
474
|
If a custom exception handler raises, the resolver falls back to the default
|
|
475
475
|
error response when one exists.
|
|
476
476
|
|
|
477
|
+
An exception with no handler is re-raised: the invocation fails, so Lambda's
|
|
478
|
+
`Errors` metric and alarms see it, and API Gateway answers with a generic 5xx.
|
|
479
|
+
That response carries no CORS headers, so a browser reports a CORS error instead
|
|
480
|
+
of the 500. If browsers call the API, register a catch-all handler, which gets
|
|
481
|
+
the route's CORS headers, and log the exception so it stays visible:
|
|
482
|
+
|
|
483
|
+
```python
|
|
484
|
+
@app.exception_handler(Exception)
|
|
485
|
+
def on_unexpected(exc: Exception):
|
|
486
|
+
logger.exception("Unhandled error")
|
|
487
|
+
return Response(status_code=500, body={"message": "Internal server error"})
|
|
488
|
+
```
|
|
489
|
+
|
|
477
490
|
## CORS
|
|
478
491
|
|
|
479
492
|
Pass `CORSConfig` to the resolver to add CORS headers and automatic preflight
|
|
@@ -865,6 +878,23 @@ handler = KinesisSource(
|
|
|
865
878
|
|
|
866
879
|
Use `concurrency=False` in tests when deterministic order matters.
|
|
867
880
|
|
|
881
|
+
Handled failures (steps wrapped with `faulty`) are published as `fault` events and
|
|
882
|
+
do not fail the invocation. An **unexpected** error that stops a pipeline (a bug,
|
|
883
|
+
an unwrapped step) is re-raised after every pipeline finished and pending faults
|
|
884
|
+
were flushed, so the Lambda invocation fails and AWS retries the batch: records
|
|
885
|
+
after the failure were never processed and must not be acknowledged. `on_error`
|
|
886
|
+
is still called first. Pass `raise_on_error=False` to a source (or `run`) only if
|
|
887
|
+
you deliberately want such errors reported through `on_error` alone.
|
|
888
|
+
|
|
889
|
+
Because a failing batch is retried, bound the retries on the event source so a
|
|
890
|
+
record that always fails (a poison pill) cannot block the stream:
|
|
891
|
+
|
|
892
|
+
- DynamoDB Streams / Kinesis: set `MaximumRetryAttempts`,
|
|
893
|
+
`BisectBatchOnFunctionError: true` (isolates the failing record) and an
|
|
894
|
+
on-failure destination (SQS/SNS) on the event source mapping. Otherwise the
|
|
895
|
+
shard retries until the record expires (24 h by default).
|
|
896
|
+
- SQS: configure a dead-letter queue (`maxReceiveCount` in the redrive policy).
|
|
897
|
+
|
|
868
898
|
### Publisher Options
|
|
869
899
|
|
|
870
900
|
Flavors that publish to EventBridge use a shared publisher. Configure it with
|
|
@@ -1304,6 +1334,11 @@ app.include_mcp(mcp, path="/mcp")
|
|
|
1304
1334
|
handler = app.handler
|
|
1305
1335
|
```
|
|
1306
1336
|
|
|
1337
|
+
Pass `allowed_origins=["https://app.example.com"]` to `include_mcp` to reject
|
|
1338
|
+
requests whose `Origin` header is not in the list (403). MCP asks servers to
|
|
1339
|
+
validate `Origin` against DNS-rebinding attacks; the default `None` leaves it to
|
|
1340
|
+
the infrastructure in front of the function, and `[]` denies every browser origin.
|
|
1341
|
+
|
|
1307
1342
|
### Choosing the resolver
|
|
1308
1343
|
|
|
1309
1344
|
Choose the resolver from the AWS transport and whether the function must
|
|
@@ -14,7 +14,7 @@ modmex_lambda/tracing.py,sha256=WWA2xAqfa23phxoQzRnr6UtdK3S770jPODYh4CwFk0M,5739
|
|
|
14
14
|
modmex_lambda/validation.py,sha256=64uWzSnkxzN1t7DAqC_0TYzhupQUtAWnrLATEFAEfzs,7130
|
|
15
15
|
modmex_lambda/connectors/__init__.py,sha256=-3G8Q5Qo_O6xlD8oWLYW7XCgMln50BTjhrUncAePnUA,716
|
|
16
16
|
modmex_lambda/connectors/cloudwatch.py,sha256=8NnP6m7IGZwwFZaHw6EO2Q1g4yHUfFqagpkVpzlgW8E,455
|
|
17
|
-
modmex_lambda/connectors/dynamodb.py,sha256=
|
|
17
|
+
modmex_lambda/connectors/dynamodb.py,sha256=tZLAMl52miVeWtaW9486vh_W0DXqYzw5GRL1Z2lfjHo,10467
|
|
18
18
|
modmex_lambda/connectors/eventbridge.py,sha256=atY6R4XqRL-n6y5-ajn3b-t0gDwaBvz1w5rU4yMmq1U,473
|
|
19
19
|
modmex_lambda/connectors/eventbridge_scheduler.py,sha256=3iFM8iYXTPwip8xmxAsG8RZDZuetKTd0gh9niitFCmk,648
|
|
20
20
|
modmex_lambda/connectors/icloudwatch.py,sha256=LAxYgMgzda4wtGGRwhsPlZikpGlA3oiUsk73jlJ7ghk,463
|
|
@@ -37,7 +37,7 @@ modmex_lambda/data_classes/api_gateway_websocket_event.py,sha256=EGFqQ4SrC-ssb50
|
|
|
37
37
|
modmex_lambda/data_classes/cognito_user_pool_event.py,sha256=DwHa9xtqpFYnFKdUi1Y9RRgxvkVGJQXhFkRh7_4iAf4,18582
|
|
38
38
|
modmex_lambda/data_classes/common.py,sha256=8saOnaCxH25G-jQumUJMg6CuOhuJ6ugw4vAWH-Fn4Ls,13656
|
|
39
39
|
modmex_lambda/event_handler/__init__.py,sha256=qzzH6nrRHyJxLsKeUxnIdvYyC4wn5Wg-dpMdNCy_BFA,1394
|
|
40
|
-
modmex_lambda/event_handler/api_gateway.py,sha256=
|
|
40
|
+
modmex_lambda/event_handler/api_gateway.py,sha256=rsIEh8X271FexdCM3ozpkfhES4t6BbJIhzAOlibRYsg,13368
|
|
41
41
|
modmex_lambda/event_handler/constants.py,sha256=x53p_BZw2lmISpkO5v6d1nfuP-De9uUsUtwgJLaBHKw,28
|
|
42
42
|
modmex_lambda/event_handler/content_types.py,sha256=FcnCaAVhEOewQXAbkStMBNC63NFMxqwmEFnXcGholug,282
|
|
43
43
|
modmex_lambda/event_handler/cors.py,sha256=j8H81NdPxqRl5ikW8Wdf7o6pEIx7dGkAsCtSysYI1nc,3516
|
|
@@ -58,7 +58,7 @@ modmex_lambda/event_handler/dependencies/dependency_middleware.py,sha256=c_N7Ugt
|
|
|
58
58
|
modmex_lambda/event_handler/dependencies/depends.py,sha256=pJ1rcMoA99vSaQTPxJ0zkYppPDKU0-lm9URc9Gifmdw,7110
|
|
59
59
|
modmex_lambda/event_handler/dependencies/params.py,sha256=eTQf_HWRZHEGtk5RnE2HSPqZ6ZMdVMvxOD_fm_pIpbg,9948
|
|
60
60
|
modmex_lambda/event_handler/dependencies/types.py,sha256=5VA8zl-EjQDNKXOrNT7sRv_vNs40Lz8aMP-sf-lf8sk,376
|
|
61
|
-
modmex_lambda/mcp/__init__.py,sha256=
|
|
61
|
+
modmex_lambda/mcp/__init__.py,sha256=Cup2KFL8XLt7XajfpA_qZ3FKrCs_mjD1XPI_B7IZMjU,1767
|
|
62
62
|
modmex_lambda/mcp/middleware.py,sha256=ddLLAZRkppKXpOVYDBS43D2L1gQFPg7syrtysDsPfeQ,3464
|
|
63
63
|
modmex_lambda/mcp/prompt.py,sha256=FiWS-b5WbCZV6HJwdclM4q5cXok5J3v_n3XSz6ha96E,2403
|
|
64
64
|
modmex_lambda/mcp/protocol.py,sha256=MiG2rHcJuN9so_TjtVArIL5ROMpHJoPtHTYzX8D6o2Y,1562
|
|
@@ -84,7 +84,7 @@ modmex_lambda/shared/types.py,sha256=lH3i9MF7EQa1et8dD_qagEjlNzqznNHc0YZawp3toMc
|
|
|
84
84
|
modmex_lambda/stream/__init__.py,sha256=tqNJ8T6nKPn4BUYoOi5vUPjOGQYPxVd8Dxr-JNujAQ4,98
|
|
85
85
|
modmex_lambda/stream/irules_registry.py,sha256=oJTuRowJDd0obVRUXHEL1RIsFozI9tTKsvFIGAulzw4,484
|
|
86
86
|
modmex_lambda/stream/rules_registry.py,sha256=OHoPr9DygfvhdRFc_G1dHmyvt4FB0HVCB2ht3I59eWk,1320
|
|
87
|
-
modmex_lambda/stream/runner.py,sha256=
|
|
87
|
+
modmex_lambda/stream/runner.py,sha256=u2iNCwQ9TwMx5La3zuNiQ-EVeLD__KoW5wpWSqTPjtY,4439
|
|
88
88
|
modmex_lambda/stream/schedulers.py,sha256=A_wFD1e7CGFGO6--QHln8Eho08fdH5W-OVWfhoK0ahE,532
|
|
89
89
|
modmex_lambda/stream/events/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
90
|
modmex_lambda/stream/events/dynamodb.py,sha256=T1g9j4QpWC1gBYaFm11YdcQ9Ma0konHIVF48mOAD_PE,4895
|
|
@@ -123,12 +123,12 @@ modmex_lambda/stream/operators/scheduler.py,sha256=KlVXQswqmD2XrpYNyT-nKV3lfu05T
|
|
|
123
123
|
modmex_lambda/stream/operators/sns.py,sha256=9LoaQp_JsmP0xPzLF9XMcd5qbK7lg7daViaU4vkozG0,1740
|
|
124
124
|
modmex_lambda/stream/operators/sqs.py,sha256=4y2wrfVCl-TygrieFpfTEPjGUYcFV9gpYUT77cfyYm4,2464
|
|
125
125
|
modmex_lambda/stream/sources/__init__.py,sha256=mWJYsGBy-eZkR-B31JPicH-q00CdO-YUIvG5giACuKE,2469
|
|
126
|
-
modmex_lambda/stream/sources/base.py,sha256=
|
|
127
|
-
modmex_lambda/stream/sources/dynamodb.py,sha256=
|
|
128
|
-
modmex_lambda/stream/sources/kinesis.py,sha256=
|
|
129
|
-
modmex_lambda/stream/sources/s3.py,sha256=
|
|
130
|
-
modmex_lambda/stream/sources/sns.py,sha256=
|
|
131
|
-
modmex_lambda/stream/sources/sqs.py,sha256=
|
|
126
|
+
modmex_lambda/stream/sources/base.py,sha256=QozO9WQGV_PKiQTanEyLy3fB7LYbCGhQNWAEu1Sm-GM,2216
|
|
127
|
+
modmex_lambda/stream/sources/dynamodb.py,sha256=EQ_KH0AJp2r5RImVuBAyzXWEIVylneBTKw3VOWEHdZ0,2697
|
|
128
|
+
modmex_lambda/stream/sources/kinesis.py,sha256=5RoE5YMN8GmMr-EuGUFWf3dJfisaInjTGyUlgJEopfc,1846
|
|
129
|
+
modmex_lambda/stream/sources/s3.py,sha256=JqxFZ1ORzWmrWIeOMArZe3zzRmjFSMPHGY4hDLIzNUE,2491
|
|
130
|
+
modmex_lambda/stream/sources/sns.py,sha256=Y8Je--sl26KOY8kzUqCPuYUYyAF8DUEUP_PXFkDnlQk,1822
|
|
131
|
+
modmex_lambda/stream/sources/sqs.py,sha256=kZhMEXnfX0hbQI56_HUyS-sDQDBWaSkik1p9Z_JJaYE,1822
|
|
132
132
|
modmex_lambda/stream/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
133
133
|
modmex_lambda/stream/utils/apigateway.py,sha256=HXMIVuBF_OuSsB8aBHZbrJIC57y4m9fHqOIBkj-wXIU,1361
|
|
134
134
|
modmex_lambda/stream/utils/aws.py,sha256=hgSEma3tteVongNdq79jfZhhttYS2CFJfEcCvgzYB5I,140
|
|
@@ -156,7 +156,7 @@ modmex_lambda/stream/utils/time.py,sha256=dnsL2xeWpa1FXm2p8y9rWXtICMBlCBkgLaJ_en
|
|
|
156
156
|
modmex_lambda/stream/utils/uow.py,sha256=8WSPVE7AiHInkFDfBEeKOvdirY6GAgBoS7qkF1f1JVM,3207
|
|
157
157
|
modmex_lambda/stream/utils/data_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
158
158
|
modmex_lambda/stream/utils/data_classes/dynamodb.py,sha256=h_7MtUyRkvvV1r2QECrRDu7RR4Hh94SwSjc_8K2_XGM,363
|
|
159
|
-
modmex_lambda-0.
|
|
160
|
-
modmex_lambda-0.
|
|
161
|
-
modmex_lambda-0.
|
|
162
|
-
modmex_lambda-0.
|
|
159
|
+
modmex_lambda-0.8.0.dist-info/METADATA,sha256=IRXDD0fpzSAn6gicXRBnD8pY5p1Zx7YI2t20YJcU8jw,46681
|
|
160
|
+
modmex_lambda-0.8.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
161
|
+
modmex_lambda-0.8.0.dist-info/licenses/LICENSE,sha256=_C2TDTOsYeJvE4vn9VB51laKvleBKbdNnn96wJVtXhQ,1063
|
|
162
|
+
modmex_lambda-0.8.0.dist-info/RECORD,,
|
|
File without changes
|