Skip to content

Add coalesce example #281

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add coalesce example #281

wants to merge 2 commits into from

Conversation

jackkleeman
Copy link
Contributor

No description provided.

@jackkleeman jackkleeman requested a review from gvdongen May 12, 2025 17:31
Copy link
Collaborator

@gvdongen gvdongen left a comment

Choose a reason for hiding this comment

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

I think it's a good example but I think it needs a bit more context/explanation/comments. It takes a while to understand the purpose, how things fit together, and why just an idempotency key/attach was unsufficient.

## Coalesce Workflows
[<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg">](src/coalesce/coalesce.ts)

This example shows how incoming requests can be deduplicated such that all concurrent clients see the same result.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be improved to explain how the behavior here is different from just using an idempotency key?

const workflowID = `${ctx.key}-${count}`;
const handle = ctx
.workflowSendClient(TargetWorkflow, workflowID)
.run(input);

Choose a reason for hiding this comment

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

Thank you for putting together this example. I guess here we could also do genericSend and pass the target workflow in as a parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

certainly yes!

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.

3 participants