mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 08:31:53 -05:00
feat(lambda): support ScalingConfig.MaximumConcurrency on SQS event source mappings (#490)
* feat(lambda): support ScalingConfig.MaximumConcurrency on SQS event source mappings
Wire-level support for ScalingConfig on CreateEventSourceMapping,
UpdateEventSourceMapping, GetEventSourceMapping, and
ListEventSourceMappings:
- New ScalingConfig model carrying MaximumConcurrency (Integer, nullable).
- Create and Update parse ScalingConfig from the request, validate range
(2-1000), reject non-SQS event sources with InvalidParameterValueException.
- Response includes ScalingConfig only when a cap is set; omitted when
null, matching AWS behavior.
- Update with an empty ScalingConfig clears the cap (AWS reset semantics).
The value is persisted on the EventSourceMapping but not yet enforced at
invocation time — the SQS poller today serializes to one concurrent
invocation per ESM regardless. Real parallel dispatch capped by
MaximumConcurrency is a follow-up (Scope B).
Tests:
- EsmIntegrationTest: 6 new cases covering round-trip, below/above range
rejection, non-SQS rejection, omission when unset, add-then-clear via
update.
- LambdaEsmScalingConfigTest (SDK compat): 5 cases verifying SDK typed
ScalingConfig round-trips, InvalidParameterValueException on range
violations, and add/clear lifecycle via update.
* fix(lambda): reject non-integer MaximumConcurrency and ScalingConfig on non-SQS sources
- parseScalingConfig now detects fractional values (e.g. 2.5) and
returns InvalidParameterValueException instead of silently truncating.
- Empty ScalingConfig ({}) on a non-SQS event source is now rejected.
Previously the non-SQS check only fired when MaximumConcurrency was
non-null, so an empty ScalingConfig on Kinesis / DynamoDB Streams
slipped through.
- Two new integration tests cover both cases.
* fix(lambda): tighten ScalingConfig input validation
- Reject non-object ScalingConfig (e.g. "foo", []) with 400 instead of
silently treating it as absent. In update paths this previously cleared
an existing cap unintentionally.
- Reject non-numeric MaximumConcurrency (e.g. string "7"). AWS expects a
JSON number on the wire; the previous toString + parseInt path accepted
strings that real AWS would reject.
- Use longValue() before range-checking to avoid intValue() overflow on
large inputs (e.g. 5000000000) that would produce a negative value and
a misleading error message.
- Two new integration tests: string MaximumConcurrency and non-object
ScalingConfig.
* fix(lambda): add NaN/Infinity guard and expand ScalingConfig test coverage
- parseScalingConfig now explicitly rejects NaN and Infinity rather than
letting them fall through to longValue() with a misleading error.
- The post-range non-SQS guard was flagged as dead code by the reviewer
but is in fact reachable (non-SQS + valid numeric MaximumConcurrency).
Retained and confirmed by the existing @Order(43) test.
- New tests: update range validation (below/above on PUT), and list
with mixed ScalingConfig presence across ESMs.
This commit is contained in:
1 parent
ca2e5d4153
commit
d8243b8803
7 files changed
+644
-1
No files matched your search
@@ -178,6 +178,34 @@ aws lambda create-event-source-mapping \
|
||||
--endpoint-url $AWS_ENDPOINT_URL
|
||||
```
|
||||
|
||||
### ScalingConfig (SQS only)
|
||||
|
||||
`CreateEventSourceMapping` and `UpdateEventSourceMapping` accept a
|
||||
`ScalingConfig.MaximumConcurrency` integer between 2 and 1000 on SQS
|
||||
event sources, matching the AWS wire format. `GetEventSourceMapping` and
|
||||
`ListEventSourceMappings` echo the value back when set; responses omit
|
||||
the `ScalingConfig` field entirely when no cap is configured.
|
||||
|
||||
```bash
|
||||
aws lambda create-event-source-mapping \
|
||||
--function-name my-function \
|
||||
--event-source-arn $QUEUE_ARN \
|
||||
--scaling-config MaximumConcurrency=5 \
|
||||
--endpoint-url $AWS_ENDPOINT_URL
|
||||
```
|
||||
|
||||
Validation mirrors AWS: values outside 2–1000 are rejected with
|
||||
`InvalidParameterValueException`, and `ScalingConfig` on a non-SQS event
|
||||
source (Kinesis / DynamoDB Streams) is also rejected — those services
|
||||
use `ParallelizationFactor` instead, which is a separate field.
|
||||
|
||||
!!! note "Enforcement status"
|
||||
The configured `MaximumConcurrency` is persisted and returned on the
|
||||
wire, but the SQS poller does not yet cap concurrent invocations at
|
||||
this value (the poller today serializes invocations per ESM to one
|
||||
at a time regardless). Real parallel dispatch capped by
|
||||
`MaximumConcurrency` is tracked as a follow-up.
|
||||
|
||||
## Supported Runtimes
|
||||
|
||||
Any runtime that has an official AWS Lambda container image works with Floci (e.g. `nodejs22.x`, `python3.13`, `java21`, `go1.x`, `provided.al2023`).
|
||||
Reference in new issue
Block a user