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

Fix setUpdateHandler docstring #1625

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dandavison
Copy link
Contributor

Fixes setUpdateHandler docstring to document that first argument must be a workflow.Context.

How this was tested

I ran this code as the workflow in the update sample in the samples repo, with and without the first argument
func Counter(ctx workflow.Context) (int, error) {
	counter := 0
	err := workflow.SetUpdateHandlerWithOptions(
		ctx,
		"add",
		func(ctx workflow.Context, val int) (int, error) {
			counter += val // note that this mutates workflow state
			return counter, nil
		},
		workflow.UpdateHandlerOptions{
			Validator: func(val int) error {
				if val < 0 { // reject attempts to add negative values
					return fmt.Errorf("invalid addend: %v", val)
				}
				return nil
			},
		})
	if err != nil {
		return 0, err
	}
	_ = ctx.Done().Receive(ctx, nil)
	return counter, nil
}

@dandavison dandavison requested a review from a team as a code owner September 7, 2024 18:59
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