base

package
v0.1.88 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForRuntimes

func CheckForRuntimes(ctx context.Context, requirements []*agentv0.Runtime) error

func CheckPythonPath

func CheckPythonPath() (string, error)

func ContainerName

func ContainerName(name string) string

func DockerEngineRunning

func DockerEngineRunning(ctx context.Context) bool

func Forward

func Forward(ctx context.Context, reader io.Reader, writer io.Writer)

func ForwardLogs

func ForwardLogs(ctx context.Context, wg *sync.WaitGroup, reader io.Reader, writer io.Writer)

func IsFreePort

func IsFreePort(port int) bool

func PrintDownloadPercentage

func PrintDownloadPercentage(reader io.ReadCloser, out io.Writer)

func WaitForPortUnbound

func WaitForPortUnbound(ctx context.Context, port int) error

WaitForPortUnbound waits for the portMappings to be unbound

Types

type CPU

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

type DockerContainerInstance

type DockerContainerInstance struct {
	ID string
}

type DockerEnvironment

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

func NewDockerEnvironment

func NewDockerEnvironment(ctx context.Context, image *configurations.DockerImage, dir string, name string) (*DockerEnvironment, error)

NewDockerEnvironment creates a new docker runner

func NewDockerHeadlessEnvironment

func NewDockerHeadlessEnvironment(ctx context.Context, image *configurations.DockerImage, name string) (*DockerEnvironment, error)

NewDockerHeadlessEnvironment creates a new docker runner

func (*DockerEnvironment) Clear

func (docker *DockerEnvironment) Clear(ctx context.Context) error

func (*DockerEnvironment) ContainerID

func (docker *DockerEnvironment) ContainerID() (string, error)

func (*DockerEnvironment) GetContainer

func (docker *DockerEnvironment) GetContainer(ctx context.Context) error

func (*DockerEnvironment) GetImageIfNotPresent added in v0.1.87

func (docker *DockerEnvironment) GetImageIfNotPresent(ctx context.Context, imag *configurations.DockerImage) error

func (*DockerEnvironment) ImageExists

func (docker *DockerEnvironment) ImageExists(ctx context.Context, imag *configurations.DockerImage) (bool, error)

func (*DockerEnvironment) Init

func (docker *DockerEnvironment) Init(ctx context.Context) error

func (*DockerEnvironment) IsContainerPresent

func (docker *DockerEnvironment) IsContainerPresent(ctx context.Context) (bool, error)

func (*DockerEnvironment) NewProcess

func (docker *DockerEnvironment) NewProcess(bin string, args ...string) (Proc, error)

func (*DockerEnvironment) Shutdown

func (docker *DockerEnvironment) Shutdown(ctx context.Context) error

func (*DockerEnvironment) Stop

func (docker *DockerEnvironment) Stop(ctx context.Context) error

func (*DockerEnvironment) WithCommand

func (docker *DockerEnvironment) WithCommand(cmd ...string)

func (*DockerEnvironment) WithDir

func (docker *DockerEnvironment) WithDir(dir string)

func (*DockerEnvironment) WithEnvironmentVariables

func (docker *DockerEnvironment) WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)

func (*DockerEnvironment) WithMount

func (docker *DockerEnvironment) WithMount(sourceDir string, targetDir string)

func (*DockerEnvironment) WithOutput

func (docker *DockerEnvironment) WithOutput(logger io.Writer)

func (*DockerEnvironment) WithPause

func (docker *DockerEnvironment) WithPause()

func (*DockerEnvironment) WithPort

func (docker *DockerEnvironment) WithPort(ctx context.Context, port uint16)

func (*DockerEnvironment) WithPortMapping

func (docker *DockerEnvironment) WithPortMapping(ctx context.Context, local uint16, container uint16)

func (*DockerEnvironment) WithWorkDir

func (docker *DockerEnvironment) WithWorkDir(dir string)

type DockerPortMapping

type DockerPortMapping struct {
	Host      uint16
	Container uint16
}

type DockerProc

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

DockerProc is a process running inside a Docker container

func (*DockerProc) FindPid added in v0.1.88

func (proc *DockerProc) FindPid(ctx context.Context, command []string) (int, error)

func (*DockerProc) Run

func (proc *DockerProc) Run(ctx context.Context) error

func (*DockerProc) Start

func (proc *DockerProc) Start(ctx context.Context) error

func (*DockerProc) Stop

func (proc *DockerProc) Stop(ctx context.Context) error

func (*DockerProc) WithEnvironmentVariables

func (proc *DockerProc) WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)

func (*DockerProc) WithOutput

func (proc *DockerProc) WithOutput(output io.Writer)

type DockerPullResponse

type DockerPullResponse struct {
	ID             string         `json:"id"`
	Status         string         `json:"status"`
	ProgressDetail ProgressDetail `json:"progressDetail"`
}

type Event

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

	// Status is the state of the service
	ProcessState

	// CPU
	*observabilityv0.CPU

	// Memory
	*observabilityv0.Memory
}

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

type LocalEnvironment

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

func NewLocalEnvironment

func NewLocalEnvironment(ctx context.Context, dir string) (*LocalEnvironment, error)

NewLocalEnvironment creates a new docker runner

func (*LocalEnvironment) Clear

func (local *LocalEnvironment) Clear(context.Context) error

func (*LocalEnvironment) Init

func (local *LocalEnvironment) Init(ctx context.Context) error

func (*LocalEnvironment) NewProcess

func (local *LocalEnvironment) NewProcess(bin string, args ...string) (Proc, error)

func (*LocalEnvironment) Shutdown

func (local *LocalEnvironment) Shutdown(context.Context) error

func (*LocalEnvironment) Stop

func (local *LocalEnvironment) Stop(context.Context) error

func (*LocalEnvironment) WithEnvironmentVariables

func (local *LocalEnvironment) WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)

type LocalProc

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

func (*LocalProc) Forward

func (proc *LocalProc) Forward(_ context.Context, w io.Reader)

func (*LocalProc) Run

func (proc *LocalProc) Run(ctx context.Context) error

func (*LocalProc) Start

func (proc *LocalProc) Start(ctx context.Context) error

func (*LocalProc) Stop

func (proc *LocalProc) Stop(ctx context.Context) error

func (*LocalProc) WithEnvironmentVariables

func (proc *LocalProc) WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)

func (*LocalProc) WithOutput

func (proc *LocalProc) WithOutput(output io.Writer)

type Memory

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

type Proc

type Proc interface {
	Start(ctx context.Context) error
	Run(ctx context.Context) error
	Stop(ctx context.Context) error

	WithOutput(w io.Writer)
	WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)
}

type Process

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

func NewProcess

func NewProcess(ctx context.Context, bin string) (*Process, error)

func (*Process) Finish

func (runner *Process) Finish()

func (*Process) Finished

func (runner *Process) Finished() bool

func (*Process) Init

func (runner *Process) Init(_ context.Context) error

func (*Process) Run

func (runner *Process) Run(ctx context.Context) error

Run executes and wait

func (*Process) Start

func (runner *Process) Start(ctx context.Context) error

Start executing and return

func (*Process) Stop

func (runner *Process) Stop() error

func (*Process) Wait

func (runner *Process) Wait() error

func (*Process) WithArguments

func (runner *Process) WithArguments(args ...string)

func (*Process) WithBin

func (runner *Process) WithBin(bin string)

func (*Process) WithDebug

func (runner *Process) WithDebug(debug bool)

func (*Process) WithDir

func (runner *Process) WithDir(dir string)

func (*Process) WithEnvironmentVariables

func (runner *Process) WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)

func (*Process) WithOutput

func (runner *Process) WithOutput(w io.Writer)

type ProcessState

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

func (ProcessState) String

func (ps ProcessState) String() string

type ProgressDetail

type ProgressDetail struct {
	Current int `json:"current"`
	Total   int `json:"total"`
}

type Runner

type Runner interface {
	WithDir(dir string)
	WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)
	WithBin(bin string)
	WithArguments(args ...string)
	WithOutput(w io.Writer)

	Init(ctx context.Context) error

	Run(ctx context.Context) error
	Start(ctx context.Context) error

	Stop() error
}

type RunnerEnvironment

type RunnerEnvironment interface {
	// Init setup the environment
	Init(ctx context.Context) error

	// Clear removes all resources
	Clear(ctx context.Context) error

	// NewProcess creates a new process for the environment
	NewProcess(bin string, args ...string) (Proc, error)

	// Stop the environment: can potentially be restarted
	Stop(ctx context.Context) error

	// Shutdown the environment: all resources will be deleted
	Shutdown(ctx context.Context) error

	// WithEnvironmentVariables sets the environment variables
	WithEnvironmentVariables(envs ...configurations.EnvironmentVariable)
}

A RunnerEnvironment controls running processes. Implementations: - local - docker - kubernetes (future)

type Tracked

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

type TrackedProcess

type TrackedProcess struct {
	PID    int
	Killed bool
}

func (*TrackedProcess) GetCPU

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

func (*TrackedProcess) GetMemory

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

func (*TrackedProcess) GetState

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

Jump to

Keyboard shortcuts

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