Skip to content

Commit

Permalink
Adding doc comment to UpsertMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou committed Sep 6, 2022
1 parent cd3cad0 commit bba5194
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
6 changes: 1 addition & 5 deletions internal/internal_event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,11 +426,7 @@ func validateAndSerializeMemo(memoMap map[string]interface{}, dc converter.DataC
if len(memoMap) == 0 {
return nil, errMemoNotSet
}
memo, err := getWorkflowMemo(memoMap, dc)
if err != nil {
return nil, err
}
return memo, nil
return getWorkflowMemo(memoMap, dc)
}

func (wc *workflowEnvironmentImpl) RegisterCancelHandler(handler func()) {
Expand Down
24 changes: 24 additions & 0 deletions internal/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,30 @@ func (wc *workflowEnvironmentInterceptor) UpsertSearchAttributes(ctx Context, at
return wc.env.UpsertSearchAttributes(attributes)
}

// UpsertMemo is used to add or update workflow memo.
// UpsertMemo will merge keys to the existing map in workflow. For example:
//
// func MyWorkflow(ctx workflow.Context, input string) error {
// memo1 := map[string]interface{}{
// "Key1": 1,
// "Key2": true,
// }
// workflow.UpsertMemo(ctx, memo1)
//
// memo2 := map[string]interface{}{
// "Key1": 2,
// "Key3": "seattle",
// }
// workflow.UpsertMemo(ctx, memo2)
// }
//
// The workflow memo will eventually be:
//
// map[string]interface{}{
// "Key1": 2,
// "Key2": true,
// "Key3": "seattle",
// }
func UpsertMemo(ctx Context, memo map[string]interface{}) error {
i := getWorkflowOutboundInterceptor(ctx)
return i.UpsertMemo(ctx, memo)
Expand Down
24 changes: 24 additions & 0 deletions workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,30 @@ func UpsertSearchAttributes(ctx Context, attributes map[string]interface{}) erro
return internal.UpsertSearchAttributes(ctx, attributes)
}

// UpsertMemo is used to add or update workflow memo.
// UpsertMemo will merge keys to the existing map in workflow. For example:
//
// func MyWorkflow(ctx workflow.Context, input string) error {
// memo1 := map[string]interface{}{
// "Key1": 1,
// "Key2": true,
// }
// workflow.UpsertMemo(ctx, memo1)
//
// memo2 := map[string]interface{}{
// "Key1": 2,
// "Key3": "seattle",
// }
// workflow.UpsertMemo(ctx, memo2)
// }
//
// The workflow memo will eventually be:
//
// map[string]interface{}{
// "Key1": 2,
// "Key2": true,
// "Key3": "seattle",
// }
func UpsertMemo(ctx Context, memo map[string]interface{}) error {
return internal.UpsertMemo(ctx, memo)
}
Expand Down

0 comments on commit bba5194

Please sign in to comment.