diff --git a/internal/temporalcli/commands.schedule.go b/internal/temporalcli/commands.schedule.go index 3a18271bd..1a1fc9fe8 100644 --- a/internal/temporalcli/commands.schedule.go +++ b/internal/temporalcli/commands.schedule.go @@ -18,6 +18,7 @@ import ( schedpb "go.temporal.io/api/schedule/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" + "go.temporal.io/sdk/temporal" ) type printableSchedule struct { @@ -35,6 +36,7 @@ type printableSchedule struct { OverlapPolicy enumspb.ScheduleOverlapPolicy // describe only CatchupWindow string // describe only PauseOnFailure bool // describe only + Priority *temporal.Priority `cli:",cardOmitEmpty"` // describe only // Schedule.State Notes string `cli:",cardOmitEmpty"` Paused bool @@ -74,6 +76,14 @@ func describeResultToPrintable(id string, desc *client.ScheduleDescription) *pri } // Schedule.Action out.Action = desc.Schedule.Action + + // Extract priority from workflow action if present + if workflowAction, ok := desc.Schedule.Action.(*client.ScheduleWorkflowAction); ok { + if workflowAction.Priority != (temporal.Priority{}) { + out.Priority = &workflowAction.Priority + } + } + // Schedule.Spec specToPrintable(out, desc.Schedule.Spec) // Schedule.Policy @@ -273,6 +283,7 @@ func toScheduleAction(sw *SharedWorkflowStartOptions, i *PayloadInputOptions) (c Memo: opts.Memo, StaticSummary: opts.StaticSummary, StaticDetails: opts.StaticDetails, + Priority: opts.Priority, } if action.Args, err = i.buildRawInput(); err != nil { return nil, err diff --git a/internal/temporalcli/commands.schedule_test.go b/internal/temporalcli/commands.schedule_test.go index d3bf978d9..ecebf50a4 100644 --- a/internal/temporalcli/commands.schedule_test.go +++ b/internal/temporalcli/commands.schedule_test.go @@ -136,6 +136,33 @@ func (s *SharedServerSuite) TestSchedule_Describe() { s.Equal(schedWfId, j.Schedule.Action.StartWorkflow.Id) } +func (s *SharedServerSuite) TestSchedule_Describe_Priority() { + schedId, _, res := s.createSchedule("--interval", "2s", "--priority-key", "1") + s.NoError(res.Err) + + // json — verify priority is sent to server correctly + res = s.Execute( + "schedule", "describe", + "--address", s.Address(), + "-s", schedId, + "-o", "json", + ) + s.NoError(res.Err) + var j struct { + Schedule struct { + Action struct { + StartWorkflow struct { + Priority struct { + PriorityKey int32 `json:"priorityKey"` + } `json:"priority"` + } `json:"startWorkflow"` + } `json:"action"` + } `json:"schedule"` + } + s.NoError(json.Unmarshal(res.Stdout.Bytes(), &j)) + s.Equal(int32(1), j.Schedule.Action.StartWorkflow.Priority.PriorityKey) +} + func (s *SharedServerSuite) TestSchedule_CreateDescribeCalendar() { schedId, _, res := s.createSchedule("--calendar", `{"hour":"2,4","dayOfWeek":"thu,fri"}`) s.NoError(res.Err)