Skip to content

Maintenance: revisit async/sync processing for batch utility #1603

Closed
@dreamorosi

Description

@dreamorosi

Summary

The current implementation of the Batch Processing utility allows you to register an handler function that is executed for each record in a batch. This function can be both synchronous and asynchronous. In order to allow for async functions the current process() method has been implemented as async and always returns a Promise.

This requires the caller to have to await the result and handle the promise. When the caller passes a synchronous handler this might result counterintuitive, even though the addition of a Promise technically is a no-op.

This discussion arose during the review of the first PR for the utility (here), however at that time it was too early to make a decision and so we have decided to postpone the topic until later in the implementation.

Why is this needed?

So that we can review whether the current implementation is appropriate and decide if we need to change the types, add a new methods to distinguish between sync/async processing, or split the classes entirely.

Which area does this relate to?

Other

Solution

No response

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

batchThis item relates to the Batch Processing UtilitycompletedThis item is complete and has been merged/shippedinternalPRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)

Type

No type

Projects

Status

Shipped

Relationships

None yet

Development

No branches or pull requests

Issue actions