Documentation
¶
Index ¶
- func DefaultRetryFilter(err error, isAttemptTimeout bool) bool
- func TimeoutRetryFilter(err error, isAttemptTimeout bool) bool
- type Result
- type Spec
- func (c Spec) Run(ctx context.Context) Result
- func (c Spec) WithApp(app string) Spec
- func (c Spec) WithArgs(newArgs ...string) Spec
- func (c Spec) WithAttemptTimeout(timeout time.Duration) Spec
- func (c Spec) WithCmd(app string, args ...string) Spec
- func (c Spec) WithCollectAllOutput(collect bool) Spec
- func (c Spec) WithExtraArgs(extraArgs ...string) Spec
- func (c Spec) WithResetAttemptTimeoutOnOutput(enabled bool) Spec
- func (c Spec) WithRetries(n int) Spec
- func (c Spec) WithRetryFilter(filter func(err error, isAttemptTimeout bool) bool) Spec
- func (c Spec) WithStdErr(writer io.Writer) Spec
- func (c Spec) WithStdErrForwarded() Spec
- func (c Spec) WithStdIn(reader io.Reader) Spec
- func (c Spec) WithStdInForwarded() Spec
- func (c Spec) WithStdOut(writer io.Writer) Spec
- func (c Spec) WithStdOutErrForwarded() Spec
- func (c Spec) WithStdOutForwarded() Spec
- func (c Spec) WithTotalTimeout(timeout time.Duration) Spec
- func (c Spec) WithVerbose(verbose bool) Spec
- func (c Spec) WithWorkingDirectory(wd string) Spec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryFilter ¶
func TimeoutRetryFilter ¶
TimeoutRetryFilter is a simple retry policy that retries on timeouts only
Types ¶
type Spec ¶
type Spec struct {
// Minimum input
App string
Args []string
// Extra options
WorkingDirectory string
AttemptTimeout time.Duration
TotalTimeout time.Duration
ResetAttemptTimeoutOnOutput bool
Retries int
RetryFilter func(err error, isAttemptTimeout bool) bool
// Input/Output
StdIn io.Reader
StdOut io.Writer // if capturing output while running
StdErr io.Writer // if capturing output while running
CollectAllOutput bool // if running for a very long time, set this false to avoid OOM
// debug functionality
Verbose bool
}
func (Spec) WithAttemptTimeout ¶
WithAttemptTimeout sets the timeout for the command This is the total time the command can run, per attempt
func (Spec) WithCollectAllOutput ¶
WithCollectAllOutput sets whether to collect all output. Default is true. If false, you need to inject your own io.Writer
func (Spec) WithExtraArgs ¶
WithExtraArgs appends the arguments to the command
func (Spec) WithResetAttemptTimeoutOnOutput ¶
WithResetAttemptTimeoutOnOutput resets the timeout if output is received from the command
func (Spec) WithRetries ¶
WithRetries sets the number of retries before giving up
func (Spec) WithRetryFilter ¶
WithRetryFilter sets the retry filter
func (Spec) WithStdErr ¶
WithStdErr sets the standard error for the command
func (Spec) WithStdErrForwarded ¶
func (Spec) WithStdInForwarded ¶
WithStdInForwarded sets the standard input to os.Stdin
func (Spec) WithStdOut ¶
WithStdOut sets the standard output for the command
func (Spec) WithStdOutErrForwarded ¶
func (Spec) WithStdOutForwarded ¶
func (Spec) WithTotalTimeout ¶
WithTotalTimeout sets the total timeout for the command including retries
func (Spec) WithVerbose ¶
WithVerbose sets the verbose flag
func (Spec) WithWorkingDirectory ¶
WithWorkingDirectory sets the working directory for the command