From 98605a3f9b666c51e97877de12f0a89b82b33ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Tue, 1 Mar 2022 08:05:11 -0300 Subject: [PATCH] Added QueueWData and QueueWDataWait to cli. Added Once prop to cron (these will be removed upon execution) --- api/replay/cli.go | 13 +++++++++++++ types/lib.go | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/api/replay/cli.go b/api/replay/cli.go index 91a0054..22f6f9d 100644 --- a/api/replay/cli.go +++ b/api/replay/cli.go @@ -50,6 +50,11 @@ func (c *Cli) ReplayEnvAddr() string { func (c *Cli) ReplayEnvHomeDir() string { return os.Getenv("REPLAY_HOMEDIR") } + +func (c *Cli) ReplayPort() string { + return os.Getenv("REPLAY_PORT") +} + func (c *Cli) ReplayEnvRepo() string { return os.Getenv("REPLAY_REPO") } @@ -140,6 +145,14 @@ func (c *Cli) QueueEnqueue(id uint) error { return c.HttpCli().JsonGet(fmt.Sprintf("/api/v1/robots/op/enqueue/%d", id), nil) } +func (c *Cli) QueueEnqueueWData(id string, bs []byte) ([]byte, error) { + return c.HttpCli().RawPost(fmt.Sprintf("api/v1/queue/add/%s", id), bs) +} + +func (c *Cli) QueueEnqueueWDataWait(id string, bs []byte) ([]byte, error) { + return c.HttpCli().RawPost(fmt.Sprintf("api/v1/queue/addwait?job=%s", id), bs) +} + func (c *Cli) ServiceStopAll() error { return c.HttpCli().JsonGet("/api/v1/service/op/stopall", nil) } diff --git a/types/lib.go b/types/lib.go index 6262908..99c7815 100644 --- a/types/lib.go +++ b/types/lib.go @@ -214,7 +214,11 @@ type Log struct { } func (l *Log) Write(p []byte) (n int, err error) { - os.Stdout.Write([]byte(fmt.Sprintf("- %s\n", string(p)))) + _, err = os.Stdout.Write([]byte(fmt.Sprintf("- %s\n", string(p)))) + if err != nil { + println(fmt.Sprintf("Log.Write:: Error writing log: %s", err.Error())) + return 0, err + } l.AddHistory(string(p)) return len(p), nil } @@ -311,6 +315,7 @@ type Cron struct { Enabled *bool `json:"enabled"` Data string `json:"data"` Comments string `json:"comments"` + Once bool `json:"once"` } //type Resource struct {