base

package
v0.1.107 Latest Latest
Warning

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

Go to latest
Published: May 20, 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 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 *resources.DockerImage, dir string, name string) (*DockerEnvironment, error)

NewDockerEnvironment creates a new docker runner

func NewDockerHeadlessEnvironment

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

NewDockerHeadlessEnvironment creates a new docker runner

func (*DockerEnvironment) ContainerDeleted added in v0.1.89

func (docker *DockerEnvironment) ContainerDeleted() (bool, error)

ContainerDeleted checks if the container with ID is gone

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 *resources.DockerImage) error

func (*DockerEnvironment) GetLogs added in v0.1.89

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

func (*DockerEnvironment) ImageExists

func (docker *DockerEnvironment) ImageExists(ctx context.Context, imag *resources.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) WithBinary added in v0.1.91

func (docker *DockerEnvironment) WithBinary(bin string) 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 ...*resources.EnvironmentVariable)

func (*DockerEnvironment) WithMount

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

func (*DockerEnvironment) WithOutput

func (docker *DockerEnvironment) WithOutput(w 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 {
	ID string
	// contains filtered or unexported fields
}

func (*DockerProc) FindPid added in v0.1.88

func (proc *DockerProc) FindPid(ctx context.Context) (int, error)

func (*DockerProc) Match added in v0.1.89

func (proc *DockerProc) Match(cmd []string) bool

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) WaitOn added in v0.1.107

func (proc *DockerProc) WaitOn(bin string)

func (*DockerProc) WithDir added in v0.1.103

func (proc *DockerProc) WithDir(dir string)

func (*DockerProc) WithEnvironmentVariables

func (proc *DockerProc) WithEnvironmentVariables(envs ...*resources.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 Memory

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

type NativeEnvironment added in v0.1.89

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

func NewNativeEnvironment added in v0.1.89

func NewNativeEnvironment(ctx context.Context, dir string) (*NativeEnvironment, error)

NewNativeEnvironment creates a new docker runner

func (*NativeEnvironment) Init added in v0.1.89

func (native *NativeEnvironment) Init(ctx context.Context) error

func (*NativeEnvironment) NewProcess added in v0.1.89

func (native *NativeEnvironment) NewProcess(bin string, args ...string) (Proc, error)

func (*NativeEnvironment) Shutdown added in v0.1.89

func (native *NativeEnvironment) Shutdown(context.Context) error

func (*NativeEnvironment) Stop added in v0.1.89

func (native *NativeEnvironment) Stop(context.Context) error

func (*NativeEnvironment) WithBinary added in v0.1.91

func (native *NativeEnvironment) WithBinary(bin string) error

func (*NativeEnvironment) WithEnvironmentVariables added in v0.1.89

func (native *NativeEnvironment) WithEnvironmentVariables(envs ...*resources.EnvironmentVariable)

type NativeProc added in v0.1.89

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

func (*NativeProc) Forward added in v0.1.89

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

func (*NativeProc) Run added in v0.1.89

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

func (*NativeProc) Start added in v0.1.89

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

func (*NativeProc) Stop added in v0.1.89

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

func (*NativeProc) WaitOn added in v0.1.107

func (proc *NativeProc) WaitOn(bin string)

func (*NativeProc) WithDir added in v0.1.103

func (proc *NativeProc) WithDir(dir string)

func (*NativeProc) WithEnvironmentVariables added in v0.1.89

func (proc *NativeProc) WithEnvironmentVariables(envs ...*resources.EnvironmentVariable)

func (*NativeProc) WithOutput added in v0.1.89

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

func (*NativeProc) WithRunningCmd added in v0.1.89

func (proc *NativeProc) WithRunningCmd(_ string)

type Proc

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

	// For Run, optional, we can wait on another process
	WaitOn(s string)

	// WithDir overrides the location where the Proc runs
	WithDir(local string)

	// WithOutput output to send the logs
	WithOutput(w io.Writer)

	// WithEnvironmentVariables adds environment variables
	WithEnvironmentVariables(envs ...*resources.EnvironmentVariable)
}

Proc is a generic process interface Implementations: - LocalEnvironment process: obtained from a local environment - Docker process: obtained by running in a Docker environment

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 RunnerEnvironment

type RunnerEnvironment interface {
	// Init setup the environment
	Init(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: stop and remove all resources
	Shutdown(ctx context.Context) error

	// WithBinary ensures a binary is visible in the environment
	WithBinary(bin string) error

	// WithEnvironmentVariables sets the environment variables
	WithEnvironmentVariables(envs ...*resources.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