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
}
Is your feature request related to a problem? Please describe.
Add a way for users to obtain an update requests
UpdateIDin a handler.Describe the solution you'd like
In Go I would implement it through
Infocall likeGetUpdateInfoAdditional context
We should also consider adding
UpdateIDto the interceptors as wellupdateIdto Update handlers sdk-typescript#1317