Documentation ¶
Overview ¶
Package zfscmd provides a wrapper around packate os/exec. Functionality provided by the wrapper: - logging start and end of command execution - status report of active commands - prometheus metrics of runtimes
Index ¶
- func GetJobIDOrDefault(ctx context.Context, def string) string
- func RegisterMetrics(r prometheus.Registerer)
- func WithJobID(ctx context.Context, jobID string) context.Context
- type ActiveCommand
- type Cmd
- func (c *Cmd) CombinedOutput() (o []byte, err error)
- func (c *Cmd) Log() Logger
- func (c *Cmd) LogError(err error, debug bool)
- func (c *Cmd) Output() (o []byte, err error)
- func (c *Cmd) PipeFrom(cmds [][]string, stdin io.ReadCloser, stdout, stderr io.Writer) error
- func (c *Cmd) PipeTo(cmds [][]string, stdout io.ReadCloser, stderr io.Writer) (io.ReadCloser, error)
- func (c *Cmd) Process() *os.Process
- func (c *Cmd) Runtime() time.Duration
- func (c *Cmd) SetStdio(stdio Stdio)
- func (c *Cmd) Start() error
- func (c *Cmd) StartPipe() error
- func (c *Cmd) StdoutPipeWithErrorBuf(w io.Writer) (io.ReadCloser, error)
- func (c *Cmd) String() string
- func (c *Cmd) TestOnly_ExecCmd() *exec.Cmd
- func (c *Cmd) Wait() (err error)
- func (c *Cmd) WaitPipe() error
- func (c *Cmd) WithCommand(name string, args []string) *Cmd
- func (c *Cmd) WithLogError(v bool) *Cmd
- func (c *Cmd) WithPipeLen(n int) *Cmd
- type Logger
- type Report
- type Stdio
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterMetrics ¶
func RegisterMetrics(r prometheus.Registerer)
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
func (*Cmd) CombinedOutput ¶
err.(*exec.ExitError).Stderr will NOT be set
func (*Cmd) PipeTo ¶ added in v0.8.3
func (c *Cmd) PipeTo(cmds [][]string, stdout io.ReadCloser, stderr io.Writer, ) (io.ReadCloser, error)
func (*Cmd) Process ¶
Get the underlying os.Process.
Only call this method after a successful call to .Start().
func (*Cmd) Start ¶
Start the command.
This creates a new trace.WithTask as a child task of the ctx passed to CommandContext. If the process is successfully started (err == nil), it is the CALLER'S RESPONSIBILITY to ensure that the spawned process does not outlive the ctx's trace.Task.
If this method returns an error, the Cmd instance is invalid. Start must not be called repeatedly.
func (*Cmd) StdoutPipeWithErrorBuf ¶
func (*Cmd) TestOnly_ExecCmd ¶
func (*Cmd) Wait ¶
Blocking wait for the process to exit. May be called concurrently and repeatly (exec.Cmd.Wait() semantics apply).
Only call this method after a successful call to .Start().
func (*Cmd) WithCommand ¶ added in v0.8.0
func (*Cmd) WithLogError ¶
func (*Cmd) WithPipeLen ¶ added in v0.8.0
type Report ¶
type Report struct {
Active []ActiveCommand
}