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 GetJobID(ctx context.Context) string
- func RegisterMetrics(r prometheus.Registerer)
- func WithJobID(ctx context.Context, jobID string) context.Context
- type ActiveCommand
- type Cmd
- func (c *Cmd) CombinedOutput() ([]byte, error)
- func (c *Cmd) Log() *slog.Logger
- func (c *Cmd) LogError(err error, debug bool)
- func (c *Cmd) Output() ([]byte, 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
- func (c *Cmd) WithStderrOutput(b []byte) *Cmd
- 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 ¶
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.
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) WithLogError ¶
func (*Cmd) WithPipeLen ¶
func (*Cmd) WithStderrOutput ¶ added in v0.8.10
type Report ¶
type Report struct {
Active []ActiveCommand
}
Click to show internal directories.
Click to hide internal directories.