srvrun

package
v0.0.0-...-1dd1f65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package srvrun contains various ways to run, or pretend to run, services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DryRunner

type DryRunner struct {
	io.Writer
}

DryRunner is a runner that just outputs all commands to be run to itself.

func (DryRunner) Run

Run dumps r to the dry runner's writer.

func (DryRunner) WithGrace

func (d DryRunner) WithGrace(_ time.Duration) service.Runner

WithGrace just returns the same runner, ignoring the override.

func (DryRunner) WithStderr

func (d DryRunner) WithStderr(_ io.Writer) service.Runner

WithStderr just returns the same runner, ignoring the override.

func (DryRunner) WithStdout

func (d DryRunner) WithStdout(_ io.Writer) service.Runner

WithStdout just returns the same runner, ignoring the override.

type ExecOption

type ExecOption func(*ExecRunner)

ExecOption is the type of options used when constructing a ExecRunner.

func ExecOptions

func ExecOptions(os ...ExecOption) ExecOption

ExecOptions applies each option in os.

func StderrTo

func StderrTo(w io.Writer) ExecOption

StderrTo redirects standard error of any commands run by the runner to w.

func WithGrace

func WithGrace(d time.Duration) ExecOption

WithGrace sets a timeout grace period of d.

If an ExecRunner's context closes and it has a timeout grace period, and the OS supports it, it will SIGTERM the program, wait d, and then SIGKILL.

type ExecRunner

type ExecRunner struct {
	// contains filtered or unexported fields
}

ExecRunner represents runs of services using exec.

func NewExecRunner

func NewExecRunner(os ...ExecOption) *ExecRunner

NewExecRunner constructs an exec-based runner using the options in os.

func (ExecRunner) Run

Run runs the command specified by r using exec, on context ctx.

func (ExecRunner) WithGrace

func (e ExecRunner) WithGrace(d time.Duration) service.Runner

WithGrace returns a new ExecRunner with the timeout grace period set as d.

func (ExecRunner) WithStderr

func (e ExecRunner) WithStderr(w io.Writer) service.Runner

WithStderr returns a new ExecRunner with standard error rerouted to w.

func (ExecRunner) WithStdout

func (e ExecRunner) WithStdout(w io.Writer) service.Runner

WithStdout returns a new ExecRunner with standard output rerouted to w.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL