core

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstanceEventSubject added in v0.0.2

func InstanceEventSubject(m, i string) string

func IsAlreadyExists

func IsAlreadyExists(err error) bool

func IsFailedPrecondition

func IsFailedPrecondition(err error) bool

func IsInternal

func IsInternal(err error) bool

func IsInvalidArgument

func IsInvalidArgument(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsNotImplemented

func IsNotImplemented(err error) bool

func IsResourcesExhausted

func IsResourcesExhausted(err error) bool

func IsUnknown

func IsUnknown(err error) bool

func NewAlreadyExists

func NewAlreadyExists(msg string) error

func NewDeadlineExceeded

func NewDeadlineExceeded(msg string) error

func NewFailedPrecondition

func NewFailedPrecondition(msg string) error

func NewInvalidArgument

func NewInvalidArgument(msg string) error

func NewNotFound

func NewNotFound(msg string) error

func NewNotImplemented

func NewNotImplemented(msg string) error

func NewResourcesExhausted

func NewResourcesExhausted(msg string) error

func NewUnknown

func NewUnknown(msg string) error

func OverrideHumaErrorBuilder

func OverrideHumaErrorBuilder()

Types

type Agent

type Agent interface {
	CreateInstance(ctx context.Context, options CreateInstancePayload) (*Instance, error)
	ListInstances(ctx context.Context) ([]Instance, error)
	GetInstance(ctx context.Context, id string) (*Instance, error)
	DestroyInstance(ctx context.Context, id string, force bool) error
	StartInstance(ctx context.Context, id string) error
	StopInstance(ctx context.Context, id string, opt *StopConfig) error
	InstanceExec(ctx context.Context, id string, opt InstanceExecOptions) (*ExecResult, error)
	SubscribeToInstanceLogs(ctx context.Context, id string) (<-chan []*LogEntry, error)
	GetInstanceLogs(ctx context.Context, id string) ([]*LogEntry, error)
}

type Allocation

type Allocation struct {
	Id        string
	Status    string
	Resources Resources
}

type AllocationStatus

type AllocationStatus string
const (
	AllocationStatusDangling  AllocationStatus = "dangling"
	AllocationStatusSuspended AllocationStatus = "suspended"
	AllocationStatusConfirmed AllocationStatus = "confirmed"
)

type Code

type Code string

type CreateInstancePayload

type CreateInstancePayload struct {
	MachineId      string         `json:"machine_id"`
	MachineVersion string         `json:"machine_version"`
	FleetId        string         `json:"fleet_id"`
	Namespace      string         `json:"namespace"`
	Config         InstanceConfig `json:"config"`
	Start          bool           `json:"start"`
}

type ErrorDetail

type ErrorDetail = huma.ErrorDetail

type ExecResult

type ExecResult struct {
	ExitCode int    `json:"exit_code"`
	Stdout   string `json:"stdout"`
	Stderr   string `json:"stderr"`
}

type Fleet

type Fleet struct {
	Id        string    `json:"id"`
	Namespace string    `json:"namespace"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	Destroyed bool      `json:"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 Instance

type Instance struct {
	Id        string `json:"id"`
	Namespace string `json:"namespace"`
	NodeId    string `json:"node_id"`
	MachineId string `json:"machine_id"`
	FleetId   string `json:"fleet_id"`

	Config         InstanceConfig `json:"config"`
	MachineVersion string         `json:"machine_version"`
	LocalIPV4      string         `json:"local_ipv4"`
	ReservationId  string         `json:"reservation_id"`

	State     InstanceState `json:"state"`
	CreatedAt time.Time     `json:"created_at"`
}

type InstanceConfig

type InstanceConfig struct {
	Guest      InstanceGuestConfig
	Workload   Workload
	StopConfig StopConfig
}

type InstanceCreatedEventPayload

type InstanceCreatedEventPayload struct {
}

type InstanceDestroyEventPayload

type InstanceDestroyEventPayload struct {
	Force  bool   `json:"force"`
	Reason string `json:"reason"`
}

type InstanceDestroyedEventPayload

type InstanceDestroyedEventPayload struct {
}

type InstanceEvent

type InstanceEvent struct {
	Id         ulid.ULID            `json:"id"`
	Type       InstanceEventType    `json:"type"`
	Origin     Origin               `json:"origin"`
	Payload    InstanceEventPayload `json:"payload"`
	MachineId  string               `json:"machine_id"`
	InstanceId string               `json:"instance_id"`
	Status     InstanceStatus       `json:"status"`
	Timestamp  time.Time            `json:"timestamp"`
}

type InstanceEventPayload

type InstanceEventPayload struct {
	Created           *InstanceCreatedEventPayload           `json:"created,omitempty"`
	Prepare           *InstancePrepareEventPayload           `json:"prepare,omitempty"`
	Prepared          *InstancePreparedEventPayload          `json:"prepared,omitempty"`
	PreparationFailed *InstancePreparationFailedEventPayload `json:"preparation_failed,omitempty"`
	Exited            *InstanceExitedEventPayload            `json:"exited,omitempty"`
	Start             *InstanceStartEventPayload             `json:"start,omitempty"`
	StartFailed       *InstanceStartFailedEventPayload       `json:"start_failed,omitempty"`
	Started           *InstanceStartedEventPayload           `json:"started,omitempty"`
	Stop              *InstanceStopEventPayload              `json:"stop,omitempty"`
	StopFailed        *InstanceStopFailedEventPayload        `json:"stop_failed,omitempty"`
	Destroy           *InstanceDestroyEventPayload           `json:"destroy,omitempty"`
	Destroyed         *InstanceDestroyedEventPayload         `json:"destroyed,omitempty"`
}

type InstanceEventType

type InstanceEventType string
const (
	InstanceCreated           InstanceEventType = "instance.created"
	InstancePrepare           InstanceEventType = "instance.prepare"
	InstancePrepared          InstanceEventType = "instance.prepared"
	InstancePreparationFailed InstanceEventType = "instance.preparation_failed"
	InstanceStart             InstanceEventType = "instance.start"
	InstanceStartFailed       InstanceEventType = "instance.start_failed"
	InstanceStarted           InstanceEventType = "instance.started"
	InstanceStop              InstanceEventType = "instance.stop"
	InstanceExited            InstanceEventType = "instance.exited"
	InstanceDestroy           InstanceEventType = "instance.destroy"
	InstanceDestroyed         InstanceEventType = "instance.destroyed"
)

type InstanceExecOptions

type InstanceExecOptions struct {
	Timeout *time.Duration `json:"timeout,omitempty"`
	Cmd     []string       `json:"cmd"`
}

func (*InstanceExecOptions) GetTimeout

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

type InstanceExitedEventPayload

type InstanceExitedEventPayload struct {
	Success   bool      `json:"success"`
	ExitCode  *int64    `json:"exit_code,omitempty"`
	Requested bool      `json:"requested"`
	ExitedAt  time.Time `json:"exited_at"`
}

type InstanceGuestConfig

type InstanceGuestConfig struct {
	MemoryMB int `json:"memory_mb"`
	VCpus    int `json:"vcpus"` // number of virtual CPUs (correspond to ch vcpus process threads)
	Cpus     int `json:"cpus"`  // in MHz
}

type InstancePreparationFailedEventPayload

type InstancePreparationFailedEventPayload struct {
	Error string
}

type InstancePrepareEventPayload

type InstancePrepareEventPayload struct {
	Retries int `json:"retries"`
}

type InstancePreparedEventPayload

type InstancePreparedEventPayload struct{}

type InstanceStartEventPayload

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

type InstanceStartFailedEventPayload

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

type InstanceStartedEventPayload

type InstanceStartedEventPayload struct {
}

type InstanceState

type InstanceState struct {
	DesiredStatus InstanceStatus `json:"desired_status"`
	Status        InstanceStatus `json:"status"`
	Restarts      int            `json:"restarts"`
}

type InstanceStatus

type InstanceStatus = MachineStatus

type InstanceStopEventPayload

type InstanceStopEventPayload struct {
	Signal string `json:"signal"`
}

type InstanceStopFailedEventPayload

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

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_id"`
	InstanceId     string    `json:"instance_id"`
	MachineVersion ulid.ULID `json:"machine_version"`
	Node           string    `json:"node"`
	Region         string    `json:"region"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
	Destroyed      bool      `json:"destroyed"`
}

type MachineConfig

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

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 MachineVersion

type MachineVersion struct {
	Id        ulid.ULID     `json:"id"`
	MachineId string        `json:"machine_id"`
	Config    MachineConfig `json:"config"`
}

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"`
	Region        string    `json:"region"`
	HeartbeatedAt time.Time `json:"heartbeated_at"`
}

type Origin

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

type RavelError

type RavelError struct {
	RavelCode Code           `json:"code"`
	Status    int            `json:"status"`
	Title     string         `json:"title"`
	Detail    string         `json:"detail"`
	Errors    []*ErrorDetail `json:"errors,omitempty"`
	// contains filtered or unexported fields
}

func FromHTTPResponse

func FromHTTPResponse(resp *http.Response) *RavelError

func (*RavelError) Code

func (r *RavelError) Code() Code

func (*RavelError) Error

func (r *RavelError) Error() string

func (*RavelError) GetStatus

func (r *RavelError) GetStatus() int

type RegistryAuthConfig

type RegistryAuthConfig struct {
	ServerAddress string `json:"server_address"`
	Username      string `json:"username"`
	Password      string `json:"password"`
	Auth          string `json:"auth"`
	IdentityToken string `json:"identitytoken"`
}

type Resources

type Resources struct {
	Cpus   int `json:"cpus"`   // in MHz
	Memory int `json:"memory"` // 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 {
	MaxRetries int           `json:"max_retries,omitempty"`
	Policy     RestartPolicy `json:"policy,omitempty"`
}

type Service

type Service struct {
	Id               string `json:"id"`
	InstanceId       string `json:"instance_id"`
	Name             string `json:"name"`
	FleetId          string `json:"fleet_id"`
	LocalIPV4Address string `json:"local_ipv4_address"`
	LocalPort        int    `json:"local_port"`
	HostAddress      string `json:"host_address"`
	HostPort         int    `json:"host_port"`
}

type StopConfig

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

func (*StopConfig) GetSignal

func (s *StopConfig) GetSignal() string

func (*StopConfig) GetTimeout

func (s *StopConfig) GetTimeout() time.Duration

type Workload

type Workload struct {
	Image         string              `json:"image"`
	RestartPolicy RestartPolicyConfig `json:"restart_policy,omitempty"`
	Env           []string            `json:"env,omitempty"`
	Init          InitConfig          `json:"init,omitempty"`
}

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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