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

Adding Accumulator Example #355

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

Conversation

joshmsmith
Copy link

What was changed

Adding accumulator pattern sample: accumulator and associated readme changes

Why?

This is a pattern that's pretty common, and I wanted to have a sample that I could share about it. Gathering a lot of signals, managing continue as new, demonstrating signal with start, all good stuff to have.

Checklist

  1. Closes N/A

  2. How was this tested:
    Tested locally, tests in accumulate_signals_workflow_test.go

  3. Any docs updates needed?
    No

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

There's still a lot of little stuff, but I did a first skim for obvious things

accumulator/accumulate_signals_activities.go Outdated Show resolved Hide resolved
accumulator/accumulate_signals_activities.go Outdated Show resolved Hide resolved
accumulator/accumulate_signals_activities.go Outdated Show resolved Hide resolved
accumulator/accumulate_signals_activities.go Outdated Show resolved Hide resolved
accumulator/accumulate_signals_workflow.go Outdated Show resolved Hide resolved
accumulator/accumulate_signals_workflow.go Outdated Show resolved Hide resolved
accumulator/starter/main.go Outdated Show resolved Hide resolved
accumulator/starter/main.go Outdated Show resolved Hide resolved
accumulator/starter/main.go Outdated Show resolved Hide resolved
accumulator/starter/main.go Outdated Show resolved Hide resolved
}

log.Debug("Awaiting for " + timeout.String())
gotSignalBeforeTimeout, _ := workflow.AwaitWithTimeout(ctx, timeout, func() bool {
Copy link
Member

@cretz cretz Jun 27, 2024

Choose a reason for hiding this comment

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

May be worth noting that you're adding two events for every task that has a signal here. You are adding a timer start and potentially a timer cancel. This is technically fine, but may be worth noting. Some users choose to try to reuse timers instead of creating a new one each time.

Copy link
Author

Choose a reason for hiding this comment

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

I reworked this due to your feedback above about using a timer with a selector.

@cretz
Copy link
Member

cretz commented Jun 27, 2024

@Quinn-With-Two-Ns - unsure if you want to give this a review

@Quinn-With-Two-Ns
Copy link
Contributor

@cretz I saw this, I just had no additional comments to add after yours

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.

None yet

3 participants