Help us shape the future of Go! Take the 2026 Go Developer Survey

runners

package
v0.0.82 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForwardLogs

func ForwardLogs(r io.ReadCloser, ws ...io.Writer)

func RequireExec added in v0.0.75

func RequireExec(bins ...string) ([]string, bool)

func Track added in v0.0.71

func Track(ctx context.Context, trackers []*runtimev1.Tracker) (chan Event, error)

Types

type Action added in v0.0.71

type Action struct {
	Type   ActionType
	Unique string
}

Action represents an action to be taken on a service by the runner

type ActionType added in v0.0.71

type ActionType int
const (
	Noop ActionType = iota
	Init
	Start   // Start the service
	Stop    // Stop the service
	Restart // Restart the service
)

type CPU added in v0.0.71

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

type ContainerInstance

type ContainerInstance struct {
	ID    string
	Name  string
	Image string
	Host  string
	Port  int
}

type CreateDockerInput

type CreateDockerInput struct {
	DockerImage
	ApplicationEndpointInstance *network.ApplicationEndpointInstance
}

type DockerImage

type DockerImage struct {
	Image string
}

type DockerOption

type DockerOption func(option *Option)

func WithCmd

func WithCmd(cmd ...string) DockerOption

func WithEnvironmentVariable

func WithEnvironmentVariable(key, value string) DockerOption

func WithVolume

func WithVolume(source, target string) DockerOption

type DockerRunner

type DockerRunner struct {
	Containers []*ContainerInstance
	// contains filtered or unexported fields
}

func NewDockerRunner

func NewDockerRunner(ctx context.Context, forwarder io.Writer) (*DockerRunner, error)

NewDockerRunner creates a new docker runner

func (*DockerRunner) ContainerReady

func (r *DockerRunner) ContainerReady(ctx context.Context, name string) (bool, error)

func (*DockerRunner) CreateContainer

func (r *DockerRunner) CreateContainer(ctx context.Context, input CreateDockerInput, opts ...DockerOption) error

func (*DockerRunner) EnsureImage

func (r *DockerRunner) EnsureImage(ctx context.Context, imageName string) error

func (*DockerRunner) IP

func (*DockerRunner) Start

func (r *DockerRunner) Start(ctx context.Context) error

func (*DockerRunner) StartContainer

func (r *DockerRunner) StartContainer(ctx context.Context, c *ContainerInstance) error

func (*DockerRunner) Stop

func (r *DockerRunner) Stop(ctx context.Context) error

type Event added in v0.0.71

type Event struct {
	// Err is the state of error of the service
	Err error

	// Status is the state of the service
	ProcessState

	// CPU
	*observabilityv1.CPU

	// Memory
	*observabilityv1.Memory
}

Event represents data of a **running** service Generic so most fields will be nil

type Memory added in v0.0.71

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

type Option

type Option struct {
	Cmd     []string
	Volumes []VolumeMount
	Envs    []string
}

type ProcessState added in v0.0.71

type ProcessState int
const (
	Unknown  ProcessState = iota
	NotFound ProcessState = iota
	Running
	InterruptibleSleep
	UninterruptibleSleep
	Stopped
	Zombie
	Dead
	TracingStop
	Idle
	Parked
	Waking
)

func (ProcessState) String added in v0.0.71

func (ps ProcessState) String() string

type Runner

type Runner struct {
	Name  string
	Bin   string
	Args  []string
	Dir   string
	Debug bool
	Envs  []string
}

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) (*WrappedCmdOutput, error)

type RunnerEvent added in v0.0.75

type RunnerEvent struct {
	Err     error
	Message string
}

type Tracked added in v0.0.71

type Tracked interface {
	GetState(ctx context.Context) (ProcessState, error)
	GetCPU(ctx context.Context) (*CPU, error)
	GetMemory(ctx context.Context) (*Memory, error)
}

func NewTracked added in v0.0.71

func NewTracked(tracker *runtimev1.Tracker) (Tracked, error)

type TrackedProcess added in v0.0.71

type TrackedProcess struct {
	PID    int
	Killed bool
}

func (*TrackedProcess) GetCPU added in v0.0.71

func (p *TrackedProcess) GetCPU(ctx context.Context) (*CPU, error)

func (*TrackedProcess) GetMemory added in v0.0.71

func (p *TrackedProcess) GetMemory(ctx context.Context) (*Memory, error)

func (*TrackedProcess) GetState added in v0.0.71

func (p *TrackedProcess) GetState(ctx context.Context) (ProcessState, error)

func (*TrackedProcess) Proto added in v0.0.71

func (p *TrackedProcess) Proto() *runtimev1.Tracker

type VolumeMount

type VolumeMount struct {
	Source string
	Target string
}

type WrappedCmd added in v0.0.75

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

func NewWrappedCmd added in v0.0.75

func NewWrappedCmd(cmd *exec.Cmd, writer io.Writer) (*WrappedCmd, error)

func (*WrappedCmd) Start added in v0.0.75

func (run *WrappedCmd) Start() (*WrappedCmdOutput, error)

type WrappedCmdOutput added in v0.0.75

type WrappedCmdOutput struct {
	PID    int
	Events chan RunnerEvent
}

Jump to

Keyboard shortcuts

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