Documentation
¶
Overview ¶
Package subproc provides bounded-duration subprocess execution for short-lived read-only commands (git status, docker ps). Each call emits a warning to stderr after warnAfter and is cancelled at timeout.
Index ¶
Constants ¶
View Source
const ( DefaultWarnAfter = 3 * time.Second DefaultTimeout = 10 * time.Second )
Default thresholds for RunWithWarnAndTimeout.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner interface {
// RunWithWarnAndTimeout runs `name args...` bounded by the configured
// warnAfter/timeout. On timeout it returns a non-nil error and the
// caller should treat the operation as skipped.
//
// op is a human-readable operation label used in warn/skip messages
// (e.g. "git status --porcelain").
RunWithWarnAndTimeout(
ctx context.Context,
op string,
name string,
args ...string,
) ([]byte, error)
// RunWithWarnAndTimeoutDir is identical to RunWithWarnAndTimeout but sets
// cmd.Dir = dir before running, preserving the working directory.
RunWithWarnAndTimeoutDir(
ctx context.Context,
op string,
dir string,
name string,
args ...string,
) ([]byte, error)
}
Runner runs short subprocesses with warn + timeout semantics.
func NewRunner ¶
func NewRunner() Runner
NewRunner returns a Runner using the default 3s/10s thresholds.
func NewRunnerWithThresholds ¶
NewRunnerWithThresholds returns a Runner with custom thresholds (for tests).
Click to show internal directories.
Click to hide internal directories.