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

feat: upsert search attributes #275

Merged
merged 3 commits into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aggregatedpool/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ func (wp *Workflow) handleMessage(msg *internal.Message) error {
WorkflowTaskTimeout: command.Options.WorkflowTaskTimeout,
})

case *internal.UpsertWorkflowSearchAttributes:
err := wp.env.UpsertSearchAttributes(command.SearchAttributes)
if err != nil {
return errors.E(op, err)
}

case *internal.SignalExternalWorkflow:
wp.env.SignalExternalWorkflow(
command.Namespace,
Expand Down
21 changes: 16 additions & 5 deletions internal/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ const (
executeChildWorkflowCommand = "ExecuteChildWorkflow"
getChildWorkflowExecutionCommand = "GetChildWorkflowExecution"

newTimerCommand = "NewTimer"
sideEffectCommand = "SideEffect"
getVersionCommand = "GetVersion"
completeWorkflowCommand = "CompleteWorkflow"
continueAsNewCommand = "ContinueAsNew"
newTimerCommand = "NewTimer"
sideEffectCommand = "SideEffect"
getVersionCommand = "GetVersion"
completeWorkflowCommand = "CompleteWorkflow"
continueAsNewCommand = "ContinueAsNew"
upsertWorkflowSearchAttributesCommand = "UpsertWorkflowSearchAttributes"

signalExternalWorkflowCommand = "SignalExternalWorkflow"
cancelExternalWorkflowCommand = "CancelExternalWorkflow"
Expand Down Expand Up @@ -230,6 +231,11 @@ type ContinueAsNew struct {
} `json:"options"`
}

// UpsertWorkflowSearchAttributes allows to upsert search attributes
type UpsertWorkflowSearchAttributes struct {
SearchAttributes map[string]any `json:"searchAttributes"`
}

// SignalExternalWorkflow sends signal to external workflow.
type SignalExternalWorkflow struct {
Namespace string `json:"namespace"`
Expand Down Expand Up @@ -379,6 +385,8 @@ func CommandName(cmd any) (string, error) {
return completeWorkflowCommand, nil
case ContinueAsNew, *ContinueAsNew:
return continueAsNewCommand, nil
case UpsertWorkflowSearchAttributes, *UpsertWorkflowSearchAttributes:
return upsertWorkflowSearchAttributesCommand, nil
case SignalExternalWorkflow, *SignalExternalWorkflow:
return signalExternalWorkflowCommand, nil
case CancelExternalWorkflow, *CancelExternalWorkflow:
Expand Down Expand Up @@ -447,6 +455,9 @@ func InitCommand(name string) (any, error) {
case continueAsNewCommand:
return &ContinueAsNew{}, nil

case upsertWorkflowSearchAttributesCommand:
return &UpsertWorkflowSearchAttributes{}, nil

case signalExternalWorkflowCommand:
return &SignalExternalWorkflow{}, nil

Expand Down