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

[Feature Request] Expose UpdateID in an update handler #293

Open
1 of 7 tasks
Quinn-With-Two-Ns opened this issue Jul 5, 2023 · 2 comments
Open
1 of 7 tasks

[Feature Request] Expose UpdateID in an update handler #293

Quinn-With-Two-Ns opened this issue Jul 5, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Quinn-With-Two-Ns
Copy link
Contributor

Quinn-With-Two-Ns commented Jul 5, 2023

Is your feature request related to a problem? Please describe.

Add a way for users to obtain an update requests UpdateID in a handler.

Describe the solution you'd like

In Go I would implement it through Info call like GetUpdateInfo

func Counter(ctx workflow.Context) (int, error) {
	log := workflow.GetLogger(ctx)
	counter := 0

	if err := workflow.SetUpdateHandlerWithOptions(
		ctx,
		FetchAndAdd,
		func(ctx workflow.Context, i int) (int, error) {
                        updateID := workflow.GetUpdateInfo(ctx).UpdateID
			tmp := counter
			counter += i
			log.Info("counter updated", "addend", i, "new-value", counter, "update ID", updateID)
			return tmp, nil
		},
		workflow.UpdateHandlerOptions{Validator: nonNegative},
	); err != nil {
		return 0, err
	}

Additional context

We should also consider adding UpdateID to the interceptors as well

@Quinn-With-Two-Ns Quinn-With-Two-Ns added the enhancement New feature or request label Jul 5, 2023
@stephanos
Copy link

Out of curiosity, what's the use case behind this request?

@Quinn-With-Two-Ns
Copy link
Contributor Author

@stephanos There are multiple use cases for knowing an update ID including for continue as new (see typescript issue temporalio/sdk-typescript#1317), wanting to interact with specific update requests in a workflow (see cancellation POC temporalio/samples-go#297), or the update ID may also have some significance for the business process.

@sync-by-unito sync-by-unito bot closed this as completed Jul 12, 2024
@josh-berry josh-berry reopened this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants