Skip to content

Commit 215a8b6

Browse files
authored
Add experimental warning around activity batch operations (#966)
## What was changed Add experimental warning around pause/update-options/unpause/reset activity by type or use of --query flag with activity operations. ## Why? These have been experimental commands and should have been marked experimental from the beginning. ## Checklist 1. Closes NA 2. How was this tested: manually built and verified 3. Any docs updates needed?
1 parent 40c4db9 commit 215a8b6

3 files changed

Lines changed: 101 additions & 16 deletions

File tree

internal/temporalcli/commands.activity.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ func (c *TemporalActivityUpdateOptionsCommand) run(cctx *CommandContext, args []
156156
updatePath = append(updatePath, "retry_policy.maximum_attempts")
157157
}
158158

159+
// workflowExecOrBatch is defined on SingleWorkflowOrBatchOptions; bridge via
160+
// manual copy from the embedded SingleActivityOrBatchOptions fields.
159161
opts := SingleWorkflowOrBatchOptions{
160162
WorkflowId: c.WorkflowId,
161163
RunId: c.RunId,
@@ -271,6 +273,8 @@ func (c *TemporalActivityUnpauseCommand) run(cctx *CommandContext, args []string
271273
}
272274
defer cl.Close()
273275

276+
// workflowExecOrBatch is defined on SingleWorkflowOrBatchOptions; bridge via
277+
// manual copy from the embedded SingleActivityOrBatchOptions fields.
274278
opts := SingleWorkflowOrBatchOptions{
275279
WorkflowId: c.WorkflowId,
276280
RunId: c.RunId,
@@ -344,6 +348,8 @@ func (c *TemporalActivityResetCommand) run(cctx *CommandContext, args []string)
344348
}
345349
defer cl.Close()
346350

351+
// workflowExecOrBatch is defined on SingleWorkflowOrBatchOptions; bridge via
352+
// manual copy from the embedded SingleActivityOrBatchOptions fields.
347353
opts := SingleWorkflowOrBatchOptions{
348354
WorkflowId: c.WorkflowId,
349355
RunId: c.RunId,

internal/temporalcli/commands.gen.go

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,28 @@ func (v *DeploymentReferenceOptions) BuildFlags(f *pflag.FlagSet) {
151151
_ = cobra.MarkFlagRequired(f, "build-id")
152152
}
153153

154+
type SingleActivityOrBatchOptions struct {
155+
WorkflowId string
156+
Query string
157+
RunId string
158+
Reason string
159+
Yes bool
160+
Rps float32
161+
Headers []string
162+
FlagSet *pflag.FlagSet
163+
}
164+
165+
func (v *SingleActivityOrBatchOptions) BuildFlags(f *pflag.FlagSet) {
166+
v.FlagSet = f
167+
f.StringVarP(&v.WorkflowId, "workflow-id", "w", "", "Workflow ID. You must set either --workflow-id or --query.")
168+
f.StringVarP(&v.Query, "query", "q", "", "Content for an SQL-like `QUERY` List Filter. You must set either --workflow-id or --query. Note: Using --query for batch activity operations is an experimental feature and may change in the future.")
169+
f.StringVarP(&v.RunId, "run-id", "r", "", "Run ID. Only use with --workflow-id. Cannot use with --query.")
170+
f.StringVar(&v.Reason, "reason", "", "Reason for batch operation. Only use with --query. Defaults to user name.")
171+
f.BoolVarP(&v.Yes, "yes", "y", false, "Don't prompt to confirm signaling. Only allowed when --query is present.")
172+
f.Float32Var(&v.Rps, "rps", 0, "Limit batch's requests per second. Only allowed if query is present.")
173+
f.StringArrayVar(&v.Headers, "headers", nil, "Temporal workflow headers in 'KEY=VALUE' format. Keys must be identifiers, and values must be JSON values. May be passed multiple times to set multiple Temporal headers. Note: These are workflow headers, not gRPC headers.")
174+
}
175+
154176
type SingleWorkflowOrBatchOptions struct {
155177
WorkflowId string
156178
Query string
@@ -508,7 +530,7 @@ func NewTemporalActivityPauseCommand(cctx *CommandContext, parent *TemporalActiv
508530
type TemporalActivityResetCommand struct {
509531
Parent *TemporalActivityCommand
510532
Command cobra.Command
511-
SingleWorkflowOrBatchOptions
533+
SingleActivityOrBatchOptions
512534
ActivityId string
513535
ActivityType string
514536
KeepPaused bool
@@ -532,15 +554,15 @@ func NewTemporalActivityResetCommand(cctx *CommandContext, parent *TemporalActiv
532554
}
533555
s.Command.Args = cobra.NoArgs
534556
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to reset. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.")
535-
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will be reset. Mutually exclusive with `--match-all` and `activity-id`.")
557+
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will be reset. Mutually exclusive with `--match-all` and `activity-id`. Note: Resetting Activity by Type is an experimental feature and may change in the future.")
536558
s.Command.Flags().BoolVar(&s.KeepPaused, "keep-paused", false, "If the activity was paused, it will stay paused.")
537559
s.Command.Flags().BoolVar(&s.ResetAttempts, "reset-attempts", false, "Reset the activity attempts.")
538560
s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats. Only works with --reset-attempts.")
539-
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be reset. Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`.")
561+
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be reset. Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. Note: This is an experimental feature and may change in the future.")
540562
s.Jitter = 0
541563
s.Command.Flags().Var(&s.Jitter, "jitter", "The activity will reset at random a time within the specified duration. Can only be used with --query.")
542564
s.Command.Flags().BoolVar(&s.RestoreOriginalOptions, "restore-original-options", false, "Restore the original options of the activity.")
543-
s.SingleWorkflowOrBatchOptions.BuildFlags(s.Command.Flags())
565+
s.SingleActivityOrBatchOptions.BuildFlags(s.Command.Flags())
544566
s.Command.Run = func(c *cobra.Command, args []string) {
545567
if err := s.run(cctx, args); err != nil {
546568
cctx.Options.Fail(err)
@@ -552,7 +574,7 @@ func NewTemporalActivityResetCommand(cctx *CommandContext, parent *TemporalActiv
552574
type TemporalActivityUnpauseCommand struct {
553575
Parent *TemporalActivityCommand
554576
Command cobra.Command
555-
SingleWorkflowOrBatchOptions
577+
SingleActivityOrBatchOptions
556578
ActivityId string
557579
ActivityType string
558580
ResetAttempts bool
@@ -574,13 +596,13 @@ func NewTemporalActivityUnpauseCommand(cctx *CommandContext, parent *TemporalAct
574596
}
575597
s.Command.Args = cobra.NoArgs
576598
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to unpause. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.")
577-
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will unpause. Can only be used without --match-all. Either `activity-id` or `activity-type` must be provided, but not both.")
599+
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will unpause. Can only be used without --match-all. Either `activity-id` or `activity-type` must be provided, but not both. Note: Unpausing Activity by Type is an experimental feature and may change in the future.")
578600
s.Command.Flags().BoolVar(&s.ResetAttempts, "reset-attempts", false, "Reset the activity attempts.")
579601
s.Command.Flags().BoolVar(&s.ResetHeartbeats, "reset-heartbeats", false, "Reset the Activity's heartbeats. Only works with --reset-attempts.")
580-
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every paused activity should be unpaused. This flag is ignored if activity-type is provided.")
602+
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every paused activity should be unpaused. This flag is ignored if activity-type is provided. Note: This is an experimental feature and may change in the future.")
581603
s.Jitter = 0
582604
s.Command.Flags().Var(&s.Jitter, "jitter", "The activity will start at random a time within the specified duration. Can only be used with --query.")
583-
s.SingleWorkflowOrBatchOptions.BuildFlags(s.Command.Flags())
605+
s.SingleActivityOrBatchOptions.BuildFlags(s.Command.Flags())
584606
s.Command.Run = func(c *cobra.Command, args []string) {
585607
if err := s.run(cctx, args); err != nil {
586608
cctx.Options.Fail(err)
@@ -592,7 +614,7 @@ func NewTemporalActivityUnpauseCommand(cctx *CommandContext, parent *TemporalAct
592614
type TemporalActivityUpdateOptionsCommand struct {
593615
Parent *TemporalActivityCommand
594616
Command cobra.Command
595-
SingleWorkflowOrBatchOptions
617+
SingleActivityOrBatchOptions
596618
ActivityId string
597619
ActivityType string
598620
MatchAll bool
@@ -621,8 +643,8 @@ func NewTemporalActivityUpdateOptionsCommand(cctx *CommandContext, parent *Tempo
621643
}
622644
s.Command.Args = cobra.NoArgs
623645
s.Command.Flags().StringVarP(&s.ActivityId, "activity-id", "a", "", "The Activity ID to update options. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.")
624-
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will be updated. Mutually exclusive with `--match-all` and `activity-id`.")
625-
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`.")
646+
s.Command.Flags().StringVar(&s.ActivityType, "activity-type", "", "Activities of this Type will be updated. Mutually exclusive with `--match-all` and `activity-id`. Note: Updating Activity options by Type is an experimental feature and may change in the future.")
647+
s.Command.Flags().BoolVar(&s.MatchAll, "match-all", false, "Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`. Note: This is an experimental feature and may change in the future.")
626648
s.Command.Flags().StringVar(&s.TaskQueue, "task-queue", "", "Name of the task queue for the Activity.")
627649
s.ScheduleToCloseTimeout = 0
628650
s.Command.Flags().Var(&s.ScheduleToCloseTimeout, "schedule-to-close-timeout", "Indicates how long the caller is willing to wait for an activity completion. Limits how long retries will be attempted.")
@@ -639,7 +661,7 @@ func NewTemporalActivityUpdateOptionsCommand(cctx *CommandContext, parent *Tempo
639661
s.Command.Flags().Float32Var(&s.RetryBackoffCoefficient, "retry-backoff-coefficient", 0, "Coefficient used to calculate the next retry interval. The next retry interval is previous interval multiplied by the backoff coefficient. Must be 1 or larger.")
640662
s.Command.Flags().IntVar(&s.RetryMaximumAttempts, "retry-maximum-attempts", 0, "Maximum number of attempts. When exceeded the retries stop even if not expired yet. Setting this value to 1 disables retries. Setting this value to 0 means unlimited attempts(up to the timeouts).")
641663
s.Command.Flags().BoolVar(&s.RestoreOriginalOptions, "restore-original-options", false, "Restore the original options of the activity.")
642-
s.SingleWorkflowOrBatchOptions.BuildFlags(s.Command.Flags())
664+
s.SingleActivityOrBatchOptions.BuildFlags(s.Command.Flags())
643665
s.Command.Run = func(c *cobra.Command, args []string) {
644666
if err := s.run(cctx, args); err != nil {
645667
cctx.Options.Fail(err)

internal/temporalcli/commands.yaml

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ commands:
278278
type: string
279279
description: |
280280
Activities of this Type will be updated. Mutually exclusive with `--match-all` and `activity-id`.
281+
Note: Updating Activity options by Type is an experimental feature and may change in the future.
281282
- name: match-all
282283
type: bool
283284
description: |
284285
Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`.
286+
Note: This is an experimental feature and may change in the future.
285287
- name: task-queue
286288
type: string
287289
description: Name of the task queue for the Activity.
@@ -338,7 +340,7 @@ commands:
338340
type: bool
339341
description: Restore the original options of the activity.
340342
option-sets:
341-
- single-workflow-or-batch
343+
- single-activity-or-batch
342344

343345
- name: temporal activity pause
344346
summary: Pause an Activity
@@ -429,6 +431,7 @@ commands:
429431
type: string
430432
description: |
431433
Activities of this Type will unpause. Can only be used without --match-all. Either `activity-id` or `activity-type` must be provided, but not both.
434+
Note: Unpausing Activity by Type is an experimental feature and may change in the future.
432435
- name: reset-attempts
433436
type: bool
434437
description: Reset the activity attempts.
@@ -440,13 +443,14 @@ commands:
440443
type: bool
441444
description: |
442445
Every paused activity should be unpaused. This flag is ignored if activity-type is provided.
446+
Note: This is an experimental feature and may change in the future.
443447
- name: jitter
444448
type: duration
445449
description: |
446450
The activity will start at random a time within the specified duration.
447451
Can only be used with --query.
448452
option-sets:
449-
- single-workflow-or-batch
453+
- single-activity-or-batch
450454

451455
- name: temporal activity reset
452456
summary: Reset an Activity
@@ -506,7 +510,9 @@ commands:
506510
description: The Activity ID to reset. Mutually exclusive with `--query`, `--match-all`, and `--activity-type`. Requires `--workflow-id` to be specified.
507511
- name: activity-type
508512
type: string
509-
description: Activities of this Type will be reset. Mutually exclusive with `--match-all` and `activity-id`.
513+
description: |
514+
Activities of this Type will be reset. Mutually exclusive with `--match-all` and `activity-id`.
515+
Note: Resetting Activity by Type is an experimental feature and may change in the future.
510516
- name: keep-paused
511517
type: bool
512518
description: If the activity was paused, it will stay paused.
@@ -521,6 +527,7 @@ commands:
521527
type: bool
522528
description: |
523529
Every activity should be reset. Every activity should be updated. Mutually exclusive with `--activity-id` and `--activity-type`.
530+
Note: This is an experimental feature and may change in the future.
524531
- name: jitter
525532
type: duration
526533
description: |
@@ -531,7 +538,7 @@ commands:
531538
description: |
532539
Restore the original options of the activity.
533540
option-sets:
534-
- single-workflow-or-batch
541+
- single-activity-or-batch
535542

536543
- name: temporal batch
537544
summary: Manage running batch jobs
@@ -4441,6 +4448,56 @@ option-sets:
44414448
description: Build ID for a Worker Deployment.
44424449
required: true
44434450

4451+
# Duplicate of single-workflow-or-batch with an experimental note on --query.
4452+
# Cannot extend the shared option set because workflow commands that also use
4453+
# it (workflow cancel, workflow count, etc.) are not experimental.
4454+
- name: single-activity-or-batch
4455+
options:
4456+
- name: workflow-id
4457+
type: string
4458+
short: w
4459+
description: |
4460+
Workflow ID.
4461+
You must set either --workflow-id or --query.
4462+
- name: query
4463+
type: string
4464+
short: q
4465+
description: |
4466+
Content for an SQL-like `QUERY` List Filter.
4467+
You must set either --workflow-id or --query.
4468+
Note: Using --query for batch activity operations is an experimental feature and may change in the future.
4469+
- name: run-id
4470+
type: string
4471+
short: r
4472+
description: |
4473+
Run ID.
4474+
Only use with --workflow-id.
4475+
Cannot use with --query.
4476+
- name: reason
4477+
type: string
4478+
description: |
4479+
Reason for batch operation.
4480+
Only use with --query.
4481+
Defaults to user name.
4482+
- name: yes
4483+
type: bool
4484+
short: y
4485+
description: |
4486+
Don't prompt to confirm signaling.
4487+
Only allowed when --query is present.
4488+
- name: rps
4489+
type: float
4490+
description: |
4491+
Limit batch's requests per second.
4492+
Only allowed if query is present.
4493+
- name: headers
4494+
type: string[]
4495+
description: |
4496+
Temporal workflow headers in 'KEY=VALUE' format.
4497+
Keys must be identifiers, and values must be JSON values.
4498+
May be passed multiple times to set multiple Temporal headers.
4499+
Note: These are workflow headers, not gRPC headers.
4500+
44444501
- name: single-workflow-or-batch
44454502
options:
44464503
- name: workflow-id

0 commit comments

Comments
 (0)