api

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 3 Imported by: 7

Documentation

Index

Constants

View Source
const DefaultStopSignal = "SIGTERM"
View Source
const DefaultStopTimeout = 5 // in seconds
View Source
const MaxStopTimeout = 30 // in seconds

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecOptions

type ExecOptions struct {
	Cmd       []string `json:"cmd"`
	TimeoutMs int      `json:"timeout_ms"`
}

func (*ExecOptions) GetTimeout

func (e *ExecOptions) GetTimeout() time.Duration

type ExecResult

type ExecResult struct {
	Stderr   string
	Stdout   string
	ExitCode int
}

type Fleet

type Fleet struct {
	Id        string      `json:"id"`
	Namespace string      `json:"namespace"`
	Name      string      `json:"name"`
	CreatedAt time.Time   `json:"created_at"`
	Status    FleetStatus `json:"status"`
}

type FleetStatus

type FleetStatus string
const (
	FleetStatusActive    FleetStatus = "active"
	FleetStatusDestroyed FleetStatus = "destroyed"
)

type Gateway

type Gateway struct {
	Id         string `json:"id"`
	Name       string `json:"name"`
	Namespace  string `json:"namespace"`
	FleetId    string `json:"fleet_id"`
	Protocol   string `json:"protocol"`
	TargetPort int    `json:"target_port"`
}

type GuestConfig

type GuestConfig struct {
	CpuKind  string `json:"cpu_kind"`
	MemoryMB int    `json:"memory_mb" minimum:"1"`
	Cpus     int    `json:"cpus" minimum:"1"`
}

type InitConfig

type InitConfig struct {
	Cmd        []string `json:"cmd,omitempty"`
	Entrypoint []string `json:"entrypoint,omitempty"`
	User       string   `json:"user,omitempty"`
}

type LogEntry

type LogEntry struct {
	Timestamp  int64  `json:"timestamp,omitempty"`
	InstanceId string `json:"instance_id,omitempty"`
	Source     string `json:"source,omitempty"`
	Level      string `json:"level,omitempty"`
	Message    string `json:"message,omitempty"`
}

type Machine

type Machine struct {
	Id             string         `json:"id"`
	Namespace      string         `json:"namespace"`
	FleetId        string         `json:"fleet"`
	InstanceId     string         `json:"instance_id"`
	MachineVersion string         `json:"machine_version"`
	Region         string         `json:"region"`
	Config         MachineConfig  `json:"config"`
	CreatedAt      time.Time      `json:"created_at"`
	UpdatedAt      time.Time      `json:"updated_at"`
	Events         []MachineEvent `json:"events"`
	Status         MachineStatus  `json:"state"`
}

type MachineConfig

type MachineConfig struct {
	Image       string      `json:"image"`
	Guest       GuestConfig `json:"guest"`
	Workload    Workload    `json:"workload"`
	StopConfig  *StopConfig `json:"stop_config,omitempty"`
	AutoDestroy bool        `json:"auto_destroy,omitempty"`
}

type MachineDestroyEventPayload

type MachineDestroyEventPayload struct {
	AutoDestroy bool   `json:"auto_destroy"`
	Reason      string `json:"reason"`
	Force       bool   `json:"force"`
}

type MachineEvent

type MachineEvent struct {
	Id         ulid.ULID           `json:"id"`
	MachineId  string              `json:"machine_id"`
	InstanceId string              `json:"instance_id"`
	Status     MachineStatus       `json:"status"`
	Type       MachineEventType    `json:"type"`
	Origin     Origin              `json:"origin"`
	Payload    MachineEventPayload `json:"payload"`
	Timestamp  time.Time           `json:"timestamp"`
}

type MachineEventPayload

type MachineEventPayload struct {
	PrepareFailed *MachinePrepareFailedEventPayload `json:"prepare_failed,omitempty"`
	Stop          *MachineStopEventPayload          `json:"stop,omitempty"`
	Start         *MachineStartEventPayload         `json:"start,omitempty"`
	StartFailed   *MachineStartFailedEventPayload   `json:"start_failed,omitempty"`
	Started       *MachineStartedEventPayload       `json:"started,omitempty"`
	Exited        *MachineExitedEventPayload        `json:"stopped,omitempty"`
	Destroy       *MachineDestroyEventPayload       `json:"destroy,omitempty"`
}

type MachineEventType

type MachineEventType string
const (
	MachineCreated       MachineEventType = "machine.created"
	MachinePrepare       MachineEventType = "machine.prepare"
	MachinePrepared      MachineEventType = "machine.prepared"
	MachinePrepareFailed MachineEventType = "machine.prepare_failed"
	MachineStart         MachineEventType = "machine.start"
	MachineStartFailed   MachineEventType = "machine.start_failed"
	MachineStarted       MachineEventType = "machine.started"
	MachineStop          MachineEventType = "machine.stop"
	MachineStopFailed    MachineEventType = "machine.stop_failed"
	MachineExited        MachineEventType = "machine.exited"
	MachineDestroy       MachineEventType = "machine.destroy"
	MachineDestroyed     MachineEventType = "machine.destroyed"
)

type MachineExitedEventPayload

type MachineExitedEventPayload struct {
	ExitCode int       `json:"exit_code"`
	ExitedAt time.Time `json:"exited_at"`
}

type MachinePrepareFailedEventPayload

type MachinePrepareFailedEventPayload struct {
	Error string `json:"error"`
}

type MachineStartEventPayload

type MachineStartEventPayload struct {
	IsRestart bool `json:"is_restart"`
}

type MachineStartFailedEventPayload

type MachineStartFailedEventPayload struct {
	Error string `json:"error"`
}

type MachineStartedEventPayload

type MachineStartedEventPayload struct {
	StartedAt time.Time `json:"started_at"`
}

type MachineStatus

type MachineStatus string
const (
	MachineStatusCreated    MachineStatus = "created"
	MachineStatusPreparing  MachineStatus = "preparing"
	MachineStatusStarting   MachineStatus = "starting"
	MachineStatusRunning    MachineStatus = "running"
	MachineStatusStopping   MachineStatus = "stopping"
	MachineStatusStopped    MachineStatus = "stopped"
	MachineStatusDestroying MachineStatus = "destroying"
	MachineStatusDestroyed  MachineStatus = "destroyed"
)

type MachineStopEventPayload

type MachineStopEventPayload struct {
	Config *StopConfig `json:"config,omitempty"`
}

type MachineVersion

type MachineVersion struct {
	Id        string        `json:"id"`
	MachineId string        `json:"machine_id"`
	Namespace string        `json:"namespace"`
	Config    MachineConfig `json:"config"`
	Resources Resources     `json:"resources"`
}

type Namespace

type Namespace struct {
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
}

type Node

type Node struct {
	Id            string    `json:"id"`
	Address       string    `json:"address"`
	AgentPort     int       `json:"agent_port"`
	HttpProxyPort int       `json:"proxy_port"`
	Region        string    `json:"region"`
	HeartbeatedAt time.Time `json:"heartbeated_at"`
}

func (*Node) AgentAddress

func (n *Node) AgentAddress() string

func (*Node) HttpProxyAddress

func (n *Node) HttpProxyAddress() string

type Origin

type Origin string
const (
	OriginRavel Origin = "ravel"
	OriginUser  Origin = "user"
)

type Resources

type Resources struct {
	CpusMHz  int `json:"cpus_mhz" toml:"cpus_mhz"`   // in MHz
	MemoryMB int `json:"memory_mb" toml:"memory_mb"` // in MB
}

func (*Resources) Add

func (r *Resources) Add(other Resources) Resources

Add returns a new Resources object which is the sum of the resources.

func (*Resources) GT

func (r *Resources) GT(other Resources) bool

GT returns true if the resources are greater than the other resources.

func (*Resources) Sub

func (r *Resources) Sub(other Resources) Resources

type RestartPolicy

type RestartPolicy string
const (
	RestartPolicyAlways    RestartPolicy = "always"
	RestartPolicyOnFailure RestartPolicy = "on-failure"
	RestartPolicyNever     RestartPolicy = "never"
)

type RestartPolicyConfig

type RestartPolicyConfig struct {
	Policy     RestartPolicy `json:"policy,omitempty"`
	MaxRetries int           `json:"max_retries,omitempty"`
}

type StopConfig

type StopConfig struct {
	Timeout *int    `json:"timeout,omitempty"` // in seconds
	Signal  *string `json:"signal,omitempty"`
}

func GetDefaultStopConfig

func GetDefaultStopConfig() *StopConfig

type Workload

type Workload struct {
	Restart RestartPolicyConfig `json:"restart,omitempty"`
	Env     []string            `json:"env,omitempty"`
	Init    InitConfig          `json:"init,omitempty"`
}

Jump to

Keyboard shortcuts

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