Skip to content

Commit 24b34d2

Browse files
committed
Add pause/unpause commands
1 parent 754e11f commit 24b34d2

File tree

3 files changed

+134
-6
lines changed

3 files changed

+134
-6
lines changed

temporalcli/commands.gen.go

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,9 @@ func NewTemporalActivityResetCommand(cctx *CommandContext, parent *TemporalActiv
550550
s.Command.Use = "reset [flags]"
551551
s.Command.Short = "Reset an Activity"
552552
if hasHighlighting {
553-
s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify \x1b[1mkeep_paused\x1b[0m to prevent this.\n\nIf the activity is paused and the \x1b[1mkeep_paused\x1b[0m flag is not provided,\nit will be unpaused. If the activity is paused and \x1b[1mkeep_paused\x1b[0m flag\nis provided - it will stay paused.\n\nActivities can be specified by their Activity ID or Activity Type.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the \x1b[1mreset_heartbeats\x1b[0m flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity Type of ID and Workflow IDs:\n\n\x1b[1mtemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\x1b[0m\n\nEither \x1b[1mactivity-id\x1b[0m, \x1b[1mactivity-type\x1b[0m, or \x1b[1m--match-all\x1b[0m must be specified.\n\nActivities can be reset in bulk with a visibility query list filter. \nFor example, if you want to reset activities of type Foo:\n\n\x1b[1mtemporal activity reset \\\n --query 'TemporalResetInfo=\"property:activityType=Foo\"'\x1b[0m"
553+
s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify \x1b[1mkeep_paused\x1b[0m to prevent this.\n\nIf the activity is paused and the \x1b[1mkeep_paused\x1b[0m flag is not provided,\nit will be unpaused. If the activity is paused and \x1b[1mkeep_paused\x1b[0m flag\nis provided - it will stay paused.\n\nActivities can be specified by their Activity ID or Activity Type.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the \x1b[1mreset_heartbeats\x1b[0m flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity Type of ID and Workflow IDs:\n\n\x1b[1mtemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\x1b[0m\n\nEither \x1b[1mactivity-id\x1b[0m, \x1b[1mactivity-type\x1b[0m, or \x1b[1m--match-all\x1b[0m must be specified.\n\nActivities can be reset in bulk with a visibility query list filter.\nFor example, if you want to reset activities of type Foo:\n\n\x1b[1mtemporal activity reset \\\n --query 'TemporalResetInfo=\"property:activityType=Foo\"'\x1b[0m"
554554
} else {
555-
s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify `keep_paused` to prevent this.\n\nIf the activity is paused and the `keep_paused` flag is not provided,\nit will be unpaused. If the activity is paused and `keep_paused` flag\nis provided - it will stay paused.\n\nActivities can be specified by their Activity ID or Activity Type.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the `reset_heartbeats` flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity Type of ID and Workflow IDs:\n\n```\ntemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\n```\n\nEither `activity-id`, `activity-type`, or `--match-all` must be specified.\n\nActivities can be reset in bulk with a visibility query list filter. \nFor example, if you want to reset activities of type Foo:\n\n```\ntemporal activity reset \\\n --query 'TemporalResetInfo=\"property:activityType=Foo\"'\n```"
555+
s.Command.Long = "Reset an activity. This restarts the activity as if it were first being\nscheduled. That is, it will reset both the number of attempts and the\nactivity timeout, as well as, optionally, the\nheartbeat details.\n\nIf the activity may be executing (i.e. it has not yet timed out), the\nreset will take effect the next time it fails, heartbeats, or times out.\nIf is waiting for a retry (i.e. has failed or timed out), the reset\nwill apply immediately.\n\nIf the activity is already paused, it will be unpaused by default.\nYou can specify `keep_paused` to prevent this.\n\nIf the activity is paused and the `keep_paused` flag is not provided,\nit will be unpaused. If the activity is paused and `keep_paused` flag\nis provided - it will stay paused.\n\nActivities can be specified by their Activity ID or Activity Type.\n\n### Resetting activities that heartbeat {#reset-heartbeats}\n\nActivities that heartbeat will receive a Canceled failure\nthe next time they heartbeat after a reset.\n\nIf, in your Activity, you need to do any cleanup when an Activity is\nreset, handle this error and then re-throw it when you've cleaned up.\n\nIf the `reset_heartbeats` flag is set, the heartbeat details will also be cleared.\n\nSpecify the Activity Type of ID and Workflow IDs:\n\n```\ntemporal activity reset \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId\n --keep-paused\n --reset-heartbeats\n```\n\nEither `activity-id`, `activity-type`, or `--match-all` must be specified.\n\nActivities can be reset in bulk with a visibility query list filter.\nFor example, if you want to reset activities of type Foo:\n\n```\ntemporal activity reset \\\n --query 'TemporalResetInfo=\"property:activityType=Foo\"'\n```"
556556
}
557557
s.Command.Args = cobra.NoArgs
558558
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.")
@@ -639,9 +639,9 @@ func NewTemporalActivityUpdateOptionsCommand(cctx *CommandContext, parent *Tempo
639639
s.Command.Use = "update-options [flags]"
640640
s.Command.Short = "Update Activity options"
641641
if hasHighlighting {
642-
s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n\x1b[1mtemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\x1b[0m\n\nYou may follow this command with \x1b[1mtemporal activity reset\x1b[0m, and the new values will apply after the reset.\n\nEither \x1b[1mactivity-id\x1b[0m, \x1b[1mactivity-type\x1b[0m, or \x1b[1m--match-all\x1b[0m must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter. \nFor example, if you want to reset for activities of type Foo, do:\n\n\x1b[1mtemporal activity update-options \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n ...\x1b[0m"
642+
s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n\x1b[1mtemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\x1b[0m\n\nYou may follow this command with \x1b[1mtemporal activity reset\x1b[0m, and the new values will apply after the reset.\n\nEither \x1b[1mactivity-id\x1b[0m, \x1b[1mactivity-type\x1b[0m, or \x1b[1m--match-all\x1b[0m must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter.\nFor example, if you want to reset for activities of type Foo, do:\n\n\x1b[1mtemporal activity update-options \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n ...\x1b[0m"
643643
} else {
644-
s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n```\ntemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\n```\n\nYou may follow this command with `temporal activity reset`, and the new values will apply after the reset.\n\nEither `activity-id`, `activity-type`, or `--match-all` must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter. \nFor example, if you want to reset for activities of type Foo, do:\n\n```\ntemporal activity update-options \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n ...\n```"
644+
s.Command.Long = "Update the options of a running Activity that were passed into it from\na Workflow. Updates are incremental, only changing the specified options.\n\nFor example:\n\n```\ntemporal activity update-options \\\n --activity-id YourActivityId \\\n --workflow-id YourWorkflowId \\\n --task-queue NewTaskQueueName \\\n --schedule-to-close-timeout DURATION \\\n --schedule-to-start-timeout DURATION \\\n --start-to-close-timeout DURATION \\\n --heartbeat-timeout DURATION \\\n --retry-initial-interval DURATION \\\n --retry-maximum-interval DURATION \\\n --retry-backoff-coefficient NewBackoffCoefficient \\\n --retry-maximum-attempts NewMaximumAttempts\n```\n\nYou may follow this command with `temporal activity reset`, and the new values will apply after the reset.\n\nEither `activity-id`, `activity-type`, or `--match-all` must be specified.\n\nActivity options can be updated in bulk with a visibility query list filter.\nFor example, if you want to reset for activities of type Foo, do:\n\n```\ntemporal activity update-options \\\n --query 'TemporalPauseInfo=\"property:activityType=Foo\"'\n ...\n```"
645645
}
646646
s.Command.Args = cobra.NoArgs
647647
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.")
@@ -3155,6 +3155,7 @@ func NewTemporalWorkflowCommand(cctx *CommandContext, parent *TemporalCommand) *
31553155
s.Command.AddCommand(&NewTemporalWorkflowFixHistoryJsonCommand(cctx, &s).Command)
31563156
s.Command.AddCommand(&NewTemporalWorkflowListCommand(cctx, &s).Command)
31573157
s.Command.AddCommand(&NewTemporalWorkflowMetadataCommand(cctx, &s).Command)
3158+
s.Command.AddCommand(&NewTemporalWorkflowPauseCommand(cctx, &s).Command)
31583159
s.Command.AddCommand(&NewTemporalWorkflowQueryCommand(cctx, &s).Command)
31593160
s.Command.AddCommand(&NewTemporalWorkflowResetCommand(cctx, &s).Command)
31603161
s.Command.AddCommand(&NewTemporalWorkflowResultCommand(cctx, &s).Command)
@@ -3166,6 +3167,7 @@ func NewTemporalWorkflowCommand(cctx *CommandContext, parent *TemporalCommand) *
31663167
s.Command.AddCommand(&NewTemporalWorkflowStartUpdateWithStartCommand(cctx, &s).Command)
31673168
s.Command.AddCommand(&NewTemporalWorkflowTerminateCommand(cctx, &s).Command)
31683169
s.Command.AddCommand(&NewTemporalWorkflowTraceCommand(cctx, &s).Command)
3170+
s.Command.AddCommand(&NewTemporalWorkflowUnpauseCommand(cctx, &s).Command)
31693171
s.Command.AddCommand(&NewTemporalWorkflowUpdateCommand(cctx, &s).Command)
31703172
s.Command.AddCommand(&NewTemporalWorkflowUpdateOptionsCommand(cctx, &s).Command)
31713173
s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags())
@@ -3464,6 +3466,31 @@ func NewTemporalWorkflowMetadataCommand(cctx *CommandContext, parent *TemporalWo
34643466
return &s
34653467
}
34663468

3469+
type TemporalWorkflowPauseCommand struct {
3470+
Parent *TemporalWorkflowCommand
3471+
Command cobra.Command
3472+
WorkflowReferenceOptions
3473+
Reason string
3474+
}
3475+
3476+
func NewTemporalWorkflowPauseCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowPauseCommand {
3477+
var s TemporalWorkflowPauseCommand
3478+
s.Parent = parent
3479+
s.Command.DisableFlagsInUseLine = true
3480+
s.Command.Use = "pause [flags]"
3481+
s.Command.Short = "Pause a Workflow Execution (Experimental feature)"
3482+
s.Command.Long = "Pause a Workflow Execution.\nNote: This is an experimental feature and may change in the future."
3483+
s.Command.Args = cobra.NoArgs
3484+
s.Command.Flags().StringVar(&s.Reason, "reason", "", "Reason for pausing the Workflow Execution. Defaults to message with the current user's name.")
3485+
s.WorkflowReferenceOptions.buildFlags(cctx, s.Command.Flags())
3486+
s.Command.Run = func(c *cobra.Command, args []string) {
3487+
if err := s.run(cctx, args); err != nil {
3488+
cctx.Options.Fail(err)
3489+
}
3490+
}
3491+
return &s
3492+
}
3493+
34673494
type TemporalWorkflowQueryCommand struct {
34683495
Parent *TemporalWorkflowCommand
34693496
Command cobra.Command
@@ -3905,6 +3932,31 @@ func NewTemporalWorkflowTraceCommand(cctx *CommandContext, parent *TemporalWorkf
39053932
return &s
39063933
}
39073934

3935+
type TemporalWorkflowUnpauseCommand struct {
3936+
Parent *TemporalWorkflowCommand
3937+
Command cobra.Command
3938+
WorkflowReferenceOptions
3939+
Reason string
3940+
}
3941+
3942+
func NewTemporalWorkflowUnpauseCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowUnpauseCommand {
3943+
var s TemporalWorkflowUnpauseCommand
3944+
s.Parent = parent
3945+
s.Command.DisableFlagsInUseLine = true
3946+
s.Command.Use = "unpause [flags]"
3947+
s.Command.Short = "Unpause a previously paused Workflow Execution (Experimental feature)"
3948+
s.Command.Long = "Unpause a previously paused Workflow Execution.\nNote: This is an experimental feature and may change in the future."
3949+
s.Command.Args = cobra.NoArgs
3950+
s.Command.Flags().StringVar(&s.Reason, "reason", "", "Reason for unpausing the Workflow Execution. Defaults to message with the current user's name.")
3951+
s.WorkflowReferenceOptions.buildFlags(cctx, s.Command.Flags())
3952+
s.Command.Run = func(c *cobra.Command, args []string) {
3953+
if err := s.run(cctx, args); err != nil {
3954+
cctx.Options.Fail(err)
3955+
}
3956+
}
3957+
return &s
3958+
}
3959+
39083960
type TemporalWorkflowUpdateCommand struct {
39093961
Parent *TemporalWorkflowCommand
39103962
Command cobra.Command
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package temporalcli
2+
3+
import (
4+
"go.temporal.io/api/workflowservice/v1"
5+
)
6+
7+
func (c *TemporalWorkflowPauseCommand) run(cctx *CommandContext, args []string) error {
8+
cl, err := c.Parent.ClientOptions.dialClient(cctx)
9+
if err != nil {
10+
return err
11+
}
12+
defer cl.Close()
13+
14+
_, err = cl.WorkflowService().PauseWorkflowExecution(cctx, &workflowservice.PauseWorkflowExecutionRequest{
15+
Namespace: c.Parent.Namespace,
16+
Reason: c.Reason,
17+
WorkflowId: c.WorkflowId,
18+
RunId: c.RunId,
19+
Identity: c.Parent.Identity,
20+
})
21+
if err != nil {
22+
return err
23+
}
24+
25+
cctx.Printer.Println("Workflow Execution paused")
26+
return nil
27+
}
28+
29+
func (c *TemporalWorkflowUnpauseCommand) run(cctx *CommandContext, args []string) error {
30+
cl, err := c.Parent.ClientOptions.dialClient(cctx)
31+
if err != nil {
32+
return err
33+
}
34+
defer cl.Close()
35+
36+
_, err = cl.WorkflowService().UnpauseWorkflowExecution(cctx, &workflowservice.UnpauseWorkflowExecutionRequest{
37+
Namespace: c.Parent.Namespace,
38+
Reason: c.Reason,
39+
WorkflowId: c.WorkflowId,
40+
RunId: c.RunId,
41+
Identity: c.Parent.Identity,
42+
})
43+
if err != nil {
44+
return err
45+
}
46+
47+
return nil
48+
}

temporalcli/commandsgen/commands.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ commands:
360360
361361
Either `activity-id`, `activity-type`, or `--match-all` must be specified.
362362
363-
Activity options can be updated in bulk with a visibility query list filter.
363+
Activity options can be updated in bulk with a visibility query list filter.
364364
For example, if you want to reset for activities of type Foo, do:
365365
366366
```
@@ -592,7 +592,7 @@ commands:
592592
593593
Either `activity-id`, `activity-type`, or `--match-all` must be specified.
594594
595-
Activities can be reset in bulk with a visibility query list filter.
595+
Activities can be reset in bulk with a visibility query list filter.
596596
For example, if you want to reset activities of type Foo:
597597
598598
```
@@ -4248,6 +4248,34 @@ commands:
42484248
description: |
42494249
Assume update inputs are base64-encoded and attempt to decode them.
42504250
4251+
- name: temporal workflow pause
4252+
summary: 'Pause a Workflow Execution (Experimental feature)'
4253+
description: |
4254+
Pause a Workflow Execution.
4255+
Note: This is an experimental feature and may change in the future.
4256+
options:
4257+
- name: reason
4258+
type: string
4259+
description: |
4260+
Reason for pausing the Workflow Execution.
4261+
Defaults to message with the current user's name.
4262+
option-sets:
4263+
- workflow-reference
4264+
4265+
- name: temporal workflow unpause
4266+
summary: 'Unpause a previously paused Workflow Execution (Experimental feature)'
4267+
description: |
4268+
Unpause a previously paused Workflow Execution.
4269+
Note: This is an experimental feature and may change in the future.
4270+
options:
4271+
- name: reason
4272+
type: string
4273+
description: |
4274+
Reason for unpausing the Workflow Execution.
4275+
Defaults to message with the current user's name.
4276+
option-sets:
4277+
- workflow-reference
4278+
42514279
option-sets:
42524280
- name: client
42534281
options:

0 commit comments

Comments
 (0)