Skip to content

feat(plugin): add onOperationChange hook#527

Open
nvasiu wants to merge 1 commit into
mainfrom
operation-change-hook
Open

feat(plugin): add onOperationChange hook#527
nvasiu wants to merge 1 commit into
mainfrom
operation-change-hook

Conversation

@nvasiu

@nvasiu nvasiu commented Jul 10, 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

#513

Description

Adds an onOperationChange plugin hook, matching the one in the JS SDK. This hook fires when a checkpoint response changes the status of one or more operations.

Changes

MODIFICATIONS

ExecutionManager.java

  • The ExecutionManager class now has a Lambda Context field and constructor parameter. The context is used to retrieve the request ID, to pass to the onOperationChange hook.
  • The checkpoint handler onCheckpointComplete has been updated:
    • It now checks if operations have changed their status since the last checkpoint.
    • If there are 1+ changed operations, the onOperationChange hook is called. The request ID, execution ARN, list of changed operations, and a snapshot of all operations are passed to the hook.

DurableExecutor.java

  • Now passes lambdaContext into the ExecutionManager constructor.

BaseDurableOperation.java

  • The extractErrorFromOperation and getErrorObject helpers have been made public static so that they can be reused in PluginInfoConverter.java

ADDITIONS

OperationChangeItemInfo.java

  • New record that stores info per operation, contained inside OperationChangeInfo.java.
  • Contains the same fields that OperationInfo.java contains, with the addition of error (Throwable type) and status (AWS OperationStatus type) fields.

OperationChangeInfo.java

  • New record that stores an execution ARN, a map of updated operations and a map of all operations from a checkpoint (the maps store <String, OperationChangeItemInfo>).

DurableExecutionPlugin.java

  • Added the onOperationChange(OperationChangeInfo) hook.

PluginInfoConverter.java

  • Added toOperationChangeItemInfo() which converts raw Operations into OperationChangeItemInfo records.
    • This reuses extractErrorFromOperation from BaseDurableOperation.java to get the throwable from the raw Operation.
  • Added toOperationChangeInfo() which creates OperationChangeInfo records, and their associated maps.

PluginRunner.java

  • Added onOperationChange dispatch.

TESTS

PluginRunnerTest.java

  • Added onOperationChange call to the existing all-hooks test.

PluginIntegrationTest.java

  • Added 2 integration tests, one for a successful operation, and one for a failed operation.

All existing tests constructing ExecutionManager were updated to pass null to the new context parameter.

Demo/Screenshots

Checklist

  • I have filled out every section of the PR template
  • I have thoroughly tested this change

Testing

Unit Tests

Have unit tests been written for these changes? YES

Integration Tests

Have integration tests been written for these changes? YES

Examples

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

@nvasiu nvasiu requested a review from a team July 10, 2026 22:51
@nvasiu nvasiu force-pushed the operation-change-hook branch from dbeb887 to 885579d Compare July 10, 2026 23:04
durableConfig
.getPluginRunner()
.onOperationChange(PluginInfoConverter.toOperationChangeInfo(
requestId, durableExecutionArn, updatedOperations, operationStorage.values()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a concern to pass the same object to multiple plugins? One plugin could potentially modify the object and impact the others

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, the maps inside OperationChangeInfo are now immutable, so this shouldnt be a concern anymore.

@nvasiu nvasiu force-pushed the operation-change-hook branch from 885579d to 11a94fd Compare July 10, 2026 23:28
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.

2 participants