diff options
author | Valery Piashchynski <[email protected]> | 2022-08-05 00:07:41 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-08-05 00:07:41 +0200 |
commit | 92cd5ee254861fe22d26bc175aa966c4a8f64374 (patch) | |
tree | 33c3842cc7dba268446a840e87fb9a2504ef04ac /internal/cli/jobs/subcommands.go | |
parent | 024b54348c6d3ac34f48dc17c098d66554385d83 (diff) | |
parent | 478ae2e769514ae52dce05727e112e84b94088b1 (diff) |
[#1242]: feat: Jobs `pause`, `resume`, `destroy`, `list` `CLI` commands
Diffstat (limited to 'internal/cli/jobs/subcommands.go')
-rw-r--r-- | internal/cli/jobs/subcommands.go | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/internal/cli/jobs/subcommands.go b/internal/cli/jobs/subcommands.go new file mode 100644 index 00000000..fe47f33f --- /dev/null +++ b/internal/cli/jobs/subcommands.go @@ -0,0 +1,70 @@ +package jobs + +import ( + "net/rpc" + "os" + + jobsv1 "go.buf.build/protocolbuffers/go/roadrunner-server/api/proto/jobs/v1" +) + +func pause(client *rpc.Client, pause []string, silent *bool) error { + pipes := &jobsv1.Pipelines{Pipelines: pause} + er := &jobsv1.Empty{} + + err := client.Call(pauseRPC, pipes, er) + if err != nil { + return err + } + + if !*silent { + renderPipelines(os.Stdout, pause).Render() + } + + return nil +} + +func resume(client *rpc.Client, resume []string, silent *bool) error { + pipes := &jobsv1.Pipelines{Pipelines: resume} + er := &jobsv1.Empty{} + + err := client.Call(resumeRPC, pipes, er) + if err != nil { + return err + } + + if !*silent { + renderPipelines(os.Stdout, resume).Render() + } + + return nil +} + +func destroy(client *rpc.Client, destroy []string, silent *bool) error { + pipes := &jobsv1.Pipelines{Pipelines: destroy} + resp := &jobsv1.Pipelines{} + + err := client.Call(destroyRPC, pipes, resp) + if err != nil { + return err + } + + if !*silent { + renderPipelines(os.Stdout, resp.GetPipelines()).Render() + } + + return nil +} + +func list(client *rpc.Client) error { + resp := &jobsv1.Pipelines{} + er := &jobsv1.Empty{} + + err := client.Call(listRPC, er, resp) + if err != nil { + return err + } + + renderPipelines(os.Stdout, resp.GetPipelines()).Render() + + return nil +} |