Skip to content

feat(sdk): add distributed map processor and reader helpers - #919

Draft
nvasiu wants to merge 1 commit into
feat/distributed-map-wire-typesfrom
feat/distributed-map-helpers
Draft

nvasiu wants to merge 1 commit into
feat/distributed-map-wire-typesfrom
feat/distributed-map-helpers

Conversation

@nvasiu

@nvasiu nvasiu commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Issue Link, if available

#912

Description

Adds the helpers a processor or reader Lambda calls in its handler. PR 4 of 6 (see the issue). It needs no new Lambda model and depends on PR 3 (#918), for the events and responses.

dmap/DistributedMapHelpers.java

Authoring helpers for the processor and reader Lambdas, which a customer calls inside their own handler, so they write a plain function rather than the item or batch protocol.

  • processDistributedMapItems, processDistributedMapBatch and readDistributedMapPage.
  • The item and batch helpers work in both non-durable and durable handlers. In a durable handler, the item helper runs items with a FLAT ctx.map by default, with a nesting option.
  • processDistributedMapItems writes one ERROR log line for each failed item, with distributedMapRunArn, itemId and the error it reports.

dmap/

  • ItemContext, BatchContext and ReaderContext: the run ARN and item ids passed to the customer's function.
  • ReaderPage: what a customer's reader function returns.

execution/DurableExecutor.java

  • A processor's invocation input, result and error are read and written with the default JSON serdes, because the service defines their format. Durable operations inside the processor still use the config's serdes.

Demo/Screenshots

N/A

Design

See Rules for every change.

  • Design note (rule 3), for a new feature, a new option or a public API change: Feature planned internally.
  • Simpler options considered (rule 2), if the change adds logic: N/A
  • Root cause (rule 5), for a bug fix: N/A
  • Net change in source lines and in public API members:
    • +634 lines in src/main and +1173 in src/test.
    • New public members: the 3 helpers in DistributedMapHelpers with their 2 functional interfaces, and 4 records in dmap/.

Assumptions

Each assumption about the service, Lambda, the runtime or another library, with its evidence, or marked "unverified" (rule 6):

  • The service reads a processor's or reader's outcome from the handler's return value. Unverified.

Decisions not covered by the issue or the design note

One line each, with the reason (rule 7):

  • DurableExecutor picks the default JSON serdes when the input type is ProcessorEvent, so a customer serdes cannot change the format the service defines, with no new public method or DurableConfig option.
  • A processor record with no item id fails the invocation before any item handler runs, rather than failing that record alone, because an outcome cannot be reported for an item that was not named.
  • The context records are passed as the last argument, because Java's other operations pass their context last. The durable item helper keeps DurableContext first.
  • The durable item helper runs items with FLAT nesting by default, because it uses fewer operations. ctx.map's own default stays NESTED.
  • A null reader item is sent as "null", and a non-null value that serializes to null is rejected, because the service requires every item to be a string.

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change
  • Every new branch has a test that fails without it (rule 4)
  • For a bug fix: the description or commit order shows the regression test failing before the fix and passing after it (rule 5)
  • Every edited test expectation is listed in the description, with the reason (rule 5)

Testing

Unit Tests

Have unit tests been written for these changes?

Yes. dmap/DistributedMapHelpersTest and dmap/DistributedMapDurableHelpersTest: helper tests, checking that they process items, report failures, pass the run ARN and item ids, reject bad inputs, run in FLAT and nested modes, and write the error log line.

Integration Tests

Have integration tests been written for these changes?

No. LocalDurableTestRunner does not support distributed map yet.

Examples

Has a new example been added for the change? (if applicable)

No.

@nvasiu
nvasiu force-pushed the feat/distributed-map-helpers branch from b8d1091 to 13b1303 Compare November 26, 2026 21:09
@nvasiu

nvasiu commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Update to this PR:

  • The ERROR line the processor helpers log for each failed item now includes the run ARN, item id, error type and error message in its text, with unknown and no detail as fallbacks. This only changes the log output, not the processor response.

@nvasiu
nvasiu force-pushed the feat/distributed-map-wire-types branch from ec9537b to 3c2216a Compare December 4, 2026 22:35
Add the helpers a customer calls inside a processor or reader handler to
read the service's event, call their function and return the response
the service expects.
@nvasiu
nvasiu force-pushed the feat/distributed-map-helpers branch from 13b1303 to 1e3c7a8 Compare December 4, 2026 22:35

This branch has not been deployed

No deployments
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.

1 participant