From cd4c54cc8af0398553fefc5d8984ffe31b34a22d Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 7 Sep 2024 09:44:04 -0400 Subject: [PATCH 1/3] Edits --- workflow/workflow.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/workflow.go b/workflow/workflow.go index d9a9c181c..d41bdf9b5 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -522,7 +522,7 @@ func SetQueryHandlerWithOptions(ctx Context, queryType string, handler interface return internal.SetQueryHandlerWithOptions(ctx, queryType, handler, options) } -// SetUpdateHandler forwards to SetUpdateHandlerWithOptions with an +// SetUpdateHandler forwards to SetUpdateHandlerWithOptions with a // zero-initialized UpdateHandlerOptions struct. See SetUpdateHandlerWithOptions // for more details. // From cf9a0eeac2d57cbb20fdd309ee4e7ddc4d6f3579 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 7 Sep 2024 14:24:40 -0400 Subject: [PATCH 2/3] Fix update documentation --- internal/workflow.go | 4 ++-- workflow/workflow.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/workflow.go b/internal/workflow.go index 55c27c543..9dc3ab7f6 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -1990,8 +1990,8 @@ func (wc *workflowEnvironmentInterceptor) SetQueryHandlerWithOptions( // SetUpdateHandler binds an update handler function to the specified // name such that update invocations specifying that name will invoke the // handler. The handler function can take as input any number of parameters so -// long as they can be serialized/deserialized by the system. The handler can -// take a workflow.Context as its first parameter but this is not required. The +// long as they can be serialized/deserialized by the system. The handler must +// take a workflow.Context as its first parameter. The // update handler must return either a single error or a single serializable // object along with a single error. The update handler function is invoked in // the context of the workflow and thus is subject to the same restrictions as diff --git a/workflow/workflow.go b/workflow/workflow.go index d41bdf9b5..4a6843bf7 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -534,8 +534,8 @@ func SetUpdateHandler(ctx Context, updateName string, handler interface{}) error // SetUpdateHandlerWithOptions binds an update handler function to the specified // name such that update invocations specifying that name will invoke the // handler. The handler function can take as input any number of parameters so -// long as they can be serialized/deserialized by the system. The handler can -// take a [workflow.Context] as its first parameter but this is not required. The +// long as they can be serialized/deserialized by the system. The handler must +// take a [workflow.Context] as its first parameter. The // update handler must return either a single error or a single serializable // object along with a single error. The update handler function is invoked in // the context of the workflow and thus is subject to the same restrictions as @@ -561,11 +561,11 @@ func SetUpdateHandler(ctx Context, updateName string, handler interface{}) error // err := workflow.SetUpdateHandlerWithOptions( // ctx, // "add", -// func(val int) (int, error) { // Calls +// func(ctx workflow.Context, val int) (int, error) { // counter += val // note that this mutates workflow state // return counter, nil // }, -// UpdateHandlerOptions{ +// workflow.UpdateHandlerOptions{ // Validator: func(val int) error { // if val < 0 { // reject attempts to add negative values // return fmt.Errorf("invalid addend: %v", val) From 52e6d62905ad3cd477e4e1d0f53eafc31c4cf620 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 7 Sep 2024 14:31:57 -0400 Subject: [PATCH 3/3] Reflow text --- internal/workflow.go | 22 +++++++++++----------- workflow/workflow.go | 14 +++++++------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/workflow.go b/internal/workflow.go index 9dc3ab7f6..b432595a9 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -1987,17 +1987,17 @@ func (wc *workflowEnvironmentInterceptor) SetQueryHandlerWithOptions( return setQueryHandler(ctx, queryType, handler, options) } -// SetUpdateHandler binds an update handler function to the specified -// name such that update invocations specifying that name will invoke the -// handler. The handler function can take as input any number of parameters so -// long as they can be serialized/deserialized by the system. The handler must -// take a workflow.Context as its first parameter. The -// update handler must return either a single error or a single serializable -// object along with a single error. The update handler function is invoked in -// the context of the workflow and thus is subject to the same restrictions as -// workflow code, namely, the update handler must be deterministic. As with -// other workflow code, update code is free to invoke and wait on the results of -// activities. Update handler code is free to mutate workflow state. +// SetUpdateHandler binds an update handler function to the specified name such +// that update invocations specifying that name will invoke the handler. The +// handler function can take as input any number of parameters so long as they +// can be serialized/deserialized by the system. The handler must take a +// workflow.Context as its first parameter. The update handler must return +// either a single error or a single serializable object along with a single +// error. The update handler function is invoked in the context of the workflow +// and thus is subject to the same restrictions as workflow code, namely, the +// update handler must be deterministic. As with other workflow code, update +// code is free to invoke and wait on the results of activities. Update handler +// code is free to mutate workflow state. // // This registration can optionally specify (through UpdateHandlerOptions) an // update validation function. If provided, this function will be invoked before diff --git a/workflow/workflow.go b/workflow/workflow.go index 4a6843bf7..676b145bb 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -535,13 +535,13 @@ func SetUpdateHandler(ctx Context, updateName string, handler interface{}) error // name such that update invocations specifying that name will invoke the // handler. The handler function can take as input any number of parameters so // long as they can be serialized/deserialized by the system. The handler must -// take a [workflow.Context] as its first parameter. The -// update handler must return either a single error or a single serializable -// object along with a single error. The update handler function is invoked in -// the context of the workflow and thus is subject to the same restrictions as -// workflow code, namely, the update handler must be deterministic. As with -// other workflow code, update code is free to invoke and wait on the results of -// activities. Update handler code is free to mutate workflow state. +// take a [workflow.Context] as its first parameter. The update handler must +// return either a single error or a single serializable object along with a +// single error. The update handler function is invoked in the context of the +// workflow and thus is subject to the same restrictions as workflow code, +// namely, the update handler must be deterministic. As with other workflow +// code, update code is free to invoke and wait on the results of activities. +// Update handler code is free to mutate workflow state. // // This registration can optionally specify (through UpdateHandlerOptions) an // update validation function. If provided, this function will be invoked before