Skip to content

Commit

Permalink
fix(temporal): fix schedule workflow search attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-nicolas committed Nov 27, 2024
1 parent ba234d8 commit 0ae82c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 14 additions & 0 deletions internal/connectors/engine/activities/temporal_schedule_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"go.temporal.io/api/enums/v1"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)

Expand All @@ -20,6 +21,19 @@ type ScheduleCreateOptions struct {
}

func (a Activities) TemporalScheduleCreate(ctx context.Context, options ScheduleCreateOptions) (string, error) {
attributes := make([]temporal.SearchAttributeUpdate, 0, len(options.SearchAttributes))
for key, value := range options.SearchAttributes {
v, ok := value.(string)
if !ok {
continue
}

attributes = append(attributes,
temporal.NewSearchAttributeKeyKeyword(key).ValueSet(v),
)
}
options.Action.TypedSearchAttributes = temporal.NewSearchAttributes(attributes...)

handle, err := a.temporalClient.ScheduleClient().Create(ctx, client.ScheduleOptions{
ID: options.ScheduleID,
Spec: client.ScheduleSpec{
Expand Down
6 changes: 0 additions & 6 deletions internal/connectors/engine/workflow/plugin_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/pkg/errors"
"go.temporal.io/api/enums/v1"
"go.temporal.io/sdk/client"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)

Expand Down Expand Up @@ -123,11 +122,6 @@ func (w Workflow) run(
task.NextTasks,
},
TaskQueue: connectorID.String(),
// Search attributes are used to query workflows
TypedSearchAttributes: temporal.NewSearchAttributes(
temporal.NewSearchAttributeKeyKeyword(SearchAttributeScheduleID).ValueSet(scheduleID),
temporal.NewSearchAttributeKeyKeyword(SearchAttributeStack).ValueSet(w.stack),
),
},
Overlap: enums.SCHEDULE_OVERLAP_POLICY_SKIP,
TriggerImmediately: true,
Expand Down

0 comments on commit 0ae82c2

Please sign in to comment.