Skip to content

Commit 2445cda

Browse files
authored
Implement ListWorkers and DescribeWorker (#867)
## What was changed <!-- Describe what has changed in this PR --> Implemented the ListWorkers and DescribeWorker gRPC requests note: list workers doesn't display all heartbeat information. Open to feedback on if we should display more/all/less fields. See screenshots in testing section for an example. PageSize is also not supported in server for the ListWorkers call, so that was left out. Added a `limit` field to allow users to limit how many results are displayed, similar to other CLI commands. Sample output of the two new commands <img width="1521" height="460" alt="image" src="https://github.com/user-attachments/assets/5a45be14-1071-4e03-a7cc-e26e4d61dbc9" /> ## Why? <!-- Tell your future self why have you made these changes --> New feature. ## Checklist <!--- add/delete as needed ---> 1. Closes #868 2. How was this tested: <!--- Please describe how you tested your changes/how we can test them --> Added tests, because Go SDK doesn't support worker heartbeating yet, we manually send a `RecordWorkerHeartbeatRequest` gRPC request to mimic the behavior of a worker. 3. Any docs updates needed? <!--- update README if applicable or point out where to update docs.temporal.io -->
1 parent 711cdac commit 2445cda

File tree

5 files changed

+658
-0
lines changed

5 files changed

+658
-0
lines changed

temporalcli/commands.gen.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2866,6 +2866,8 @@ func NewTemporalWorkerCommand(cctx *CommandContext, parent *TemporalCommand) *Te
28662866
}
28672867
s.Command.Args = cobra.NoArgs
28682868
s.Command.AddCommand(&NewTemporalWorkerDeploymentCommand(cctx, &s).Command)
2869+
s.Command.AddCommand(&NewTemporalWorkerDescribeCommand(cctx, &s).Command)
2870+
s.Command.AddCommand(&NewTemporalWorkerListCommand(cctx, &s).Command)
28692871
s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags())
28702872
return &s
28712873
}
@@ -3217,6 +3219,63 @@ func NewTemporalWorkerDeploymentUpdateMetadataVersionCommand(cctx *CommandContex
32173219
return &s
32183220
}
32193221

3222+
type TemporalWorkerDescribeCommand struct {
3223+
Parent *TemporalWorkerCommand
3224+
Command cobra.Command
3225+
WorkerInstanceKey string
3226+
}
3227+
3228+
func NewTemporalWorkerDescribeCommand(cctx *CommandContext, parent *TemporalWorkerCommand) *TemporalWorkerDescribeCommand {
3229+
var s TemporalWorkerDescribeCommand
3230+
s.Parent = parent
3231+
s.Command.DisableFlagsInUseLine = true
3232+
s.Command.Use = "describe [flags]"
3233+
s.Command.Short = "Returns information about a specific worker (EXPERIMENTAL)"
3234+
if hasHighlighting {
3235+
s.Command.Long = "Look up information of a specific worker.\n\n\x1b[1mtemporal worker describe --namespace YourNamespace --worker-instance-key YourKey\x1b[0m"
3236+
} else {
3237+
s.Command.Long = "Look up information of a specific worker.\n\n```\ntemporal worker describe --namespace YourNamespace --worker-instance-key YourKey\n```"
3238+
}
3239+
s.Command.Args = cobra.NoArgs
3240+
s.Command.Flags().StringVar(&s.WorkerInstanceKey, "worker-instance-key", "", "Worker instance key to describe. Required.")
3241+
_ = cobra.MarkFlagRequired(s.Command.Flags(), "worker-instance-key")
3242+
s.Command.Run = func(c *cobra.Command, args []string) {
3243+
if err := s.run(cctx, args); err != nil {
3244+
cctx.Options.Fail(err)
3245+
}
3246+
}
3247+
return &s
3248+
}
3249+
3250+
type TemporalWorkerListCommand struct {
3251+
Parent *TemporalWorkerCommand
3252+
Command cobra.Command
3253+
Query string
3254+
Limit int
3255+
}
3256+
3257+
func NewTemporalWorkerListCommand(cctx *CommandContext, parent *TemporalWorkerCommand) *TemporalWorkerListCommand {
3258+
var s TemporalWorkerListCommand
3259+
s.Parent = parent
3260+
s.Command.DisableFlagsInUseLine = true
3261+
s.Command.Use = "list [flags]"
3262+
s.Command.Short = "List worker status information in a specific namespace (EXPERIMENTAL)"
3263+
if hasHighlighting {
3264+
s.Command.Long = "Get a list of workers to the specified namespace.\n\n\x1b[1mtemporal worker list --namespace YourNamespace --query 'taskQueue=\"YourTaskQueue\"'\x1b[0m"
3265+
} else {
3266+
s.Command.Long = "Get a list of workers to the specified namespace.\n\n```\ntemporal worker list --namespace YourNamespace --query 'taskQueue=\"YourTaskQueue\"'\n```"
3267+
}
3268+
s.Command.Args = cobra.NoArgs
3269+
s.Command.Flags().StringVarP(&s.Query, "query", "q", "", "Content for an SQL-like `QUERY` List Filter.")
3270+
s.Command.Flags().IntVar(&s.Limit, "limit", 0, "Maximum number of workers to display.")
3271+
s.Command.Run = func(c *cobra.Command, args []string) {
3272+
if err := s.run(cctx, args); err != nil {
3273+
cctx.Options.Fail(err)
3274+
}
3275+
}
3276+
return &s
3277+
}
3278+
32203279
type TemporalWorkflowCommand struct {
32213280
Parent *TemporalCommand
32223281
Command cobra.Command

0 commit comments

Comments
 (0)