Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add multiple events support to waitForEvent #1046

Open
elbalexandre opened this issue Jan 22, 2024 · 0 comments
Open

Add multiple events support to waitForEvent #1046

elbalexandre opened this issue Jan 22, 2024 · 0 comments
Assignees
Labels
feature New feature or request

Comments

@elbalexandre
Copy link

elbalexandre commented Jan 22, 2024

Is your feature request related to a problem? Please describe.
Waiting for multiple events (using step.waitForEvent) result in multiple function invocations.

Describe the solution you'd like
As we can send a batch of event, it could be suitable to be able to wait for a batch of event with a single request. The function waiting for theses event could be invoked a single time (after waitForEvent) when all the awaited event have been triggered.

api:

await step.waitForEvent(`wait-all-objects-sync-completed`, object.map(object => ({
  event: 'object/sync.completed',
  timeout: '1 day',
  if: `async.data.objectId == '${object.id}'`,
}))

Describe alternatives you've considered
N/A

Additional context
We are using waitForEvent for a variable number of event. This number can be large.

const eventsPromise = Promise.all(objects.map(object => step.waitForEvent(`wait-sync-completed-${object.id}`, {
  event: 'object/sync.completed',
  timeout: '1 day',
  if: `async.data.objectId == '${object.id}'`,
})))
 
// theses event will trigger 'object/sync.completed' after their completion
await step.sendEvent(
  'start-object-sync',
  objects.map(object => ({
    name: 'object/sync.requested',
    data: { objectId: object.id },
  }))
);
 
await eventsPromise;
@elbalexandre elbalexandre added the feature New feature or request label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants