orchestrator

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: GPL-3.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDockerStopTimeoutSeconds = 5

	CameraDevice     = "camera"
	MicrophoneDevice = "microphone"
	SpeakerDevice    = "speaker"
)
View Source
const (
	DockerAppLabel     = "cc.arduino.app"
	DockerAppMainLabel = "cc.arduino.app.main"
	DockerAppPathLabel = "cc.arduino.app.path"
)

Variables

View Source
var (
	ErrAppAlreadyExists = fmt.Errorf("app already exists")
	ErrAppDoesntExists  = fmt.Errorf("app doesn't exist")
)

Functions

func AppLogs

func AppLogs(
	ctx context.Context,
	app app.ArduinoApp,
	req AppLogsRequest,
	dockerCli command.Cli,
	staticStore *store.StaticStore,
) (iter.Seq[LogMessage], error)

func AppStatusEvents

func AppStatusEvents(ctx context.Context, cfg config.Configuration, docker command.Cli, idProvider *app.IDProvider) iter.Seq2[AppInfo, error]

func DeleteApp

func DeleteApp(ctx context.Context, app app.ArduinoApp) error

func EditApp

func EditApp(
	req AppEditRequest,
	editApp *app.ArduinoApp,
	cfg config.Configuration,
) (editErr error)

func GetCustomErrorFomDockerEvent

func GetCustomErrorFomDockerEvent(message string) error

func GetDefaultApp

func GetDefaultApp(cfg config.Configuration) (*app.ArduinoApp, error)

func SetDefaultApp

func SetDefaultApp(app *app.ArduinoApp, cfg config.Configuration) error

func StartApp

func StartApp(
	ctx context.Context,
	docker command.Cli,
	provisioner *Provision,
	modelsIndex *modelsindex.ModelsIndex,
	bricksIndex *bricksindex.BricksIndex,
	app app.ArduinoApp,
	cfg config.Configuration,
	staticStore *store.StaticStore,
) iter.Seq[StreamMessage]

func StartDefaultApp

func StartDefaultApp(
	ctx context.Context,
	docker command.Cli,
	provisioner *Provision,
	modelsIndex *modelsindex.ModelsIndex,
	bricksIndex *bricksindex.BricksIndex,
	idProvider *app.IDProvider,
	cfg config.Configuration,
	staticStore *store.StaticStore,
) error

func StopAndDestroyApp

func StopAndDestroyApp(ctx context.Context, app app.ArduinoApp) iter.Seq[StreamMessage]

func StopApp

func StopApp(ctx context.Context, app app.ArduinoApp) iter.Seq[StreamMessage]

func SystemInit

func SystemInit(ctx context.Context, cfg config.Configuration, staticStore *store.StaticStore, docker *command.DockerCli) error

SystemInit pulls necessary Docker images.

Types

type AIModelItem

type AIModelItem struct {
	ID                 string            `json:"id"`
	Name               string            `json:"name"`
	ModuleDescription  string            `json:"description"`
	Runner             string            `json:"runner"`
	Bricks             []string          `json:"brick_ids"`
	Metadata           map[string]string `json:"metadata,omitempty"`
	ModelConfiguration map[string]string `json:"model_configuration,omitempty"`
}

func AIModelDetails

func AIModelDetails(modelsIndex *modelsindex.ModelsIndex, id string) (AIModelItem, bool)

type AIModelsListRequest

type AIModelsListRequest struct {
	FilterByBrickID []string
}

type AIModelsListResult

type AIModelsListResult struct {
	Models []AIModelItem `json:"models"`
}

func AIModelsList

func AIModelsList(req AIModelsListRequest, modelsIndex *modelsindex.ModelsIndex) AIModelsListResult

type AppDetailedBrick

type AppDetailedBrick struct {
	ID       string `json:"id" required:"true"`
	Name     string `json:"name" required:"true"`
	Category string `json:"category,omitempty"`
}

type AppDetailedInfo

type AppDetailedInfo struct {
	ID          app.ID             `json:"id" required:"true" `
	Name        string             `json:"name" required:"true"`
	Path        string             `json:"path"`
	Description string             `json:"description"`
	Icon        string             `json:"icon"`
	Status      Status             `json:"status" required:"true"`
	Example     bool               `json:"example"`
	Default     bool               `json:"default"`
	Bricks      []AppDetailedBrick `json:"bricks,omitempty"`
}

func AppDetails

func AppDetails(
	ctx context.Context,
	docker command.Cli,
	userApp app.ArduinoApp,
	bricksIndex *bricksindex.BricksIndex,
	idProvider *app.IDProvider,
	cfg config.Configuration,
) (AppDetailedInfo, error)

type AppEditRequest

type AppEditRequest struct {
	Name        *string
	Icon        *string
	Description *string
	Default     *bool
}

type AppInfo

type AppInfo struct {
	ID          app.ID `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
	Status      Status `json:"status,omitempty"`
	Example     bool   `json:"example"`
	Default     bool   `json:"default"`
}

type AppLogsRequest

type AppLogsRequest struct {
	ShowAppLogs      bool
	ShowServicesLogs bool
	Follow           bool
	Tail             *uint64
}

type AppStatusInfo

type AppStatusInfo struct {
	AppPath *paths.Path
	Status  Status
}

type AppStreamMessage

type AppStreamMessage struct {
	Type string `json:"type"`
	Data any    `json:"data"`
}

type BrokenAppInfo

type BrokenAppInfo struct {
	Name  string `json:"name"`
	Error string `json:"error"`
}

type CallbackWriter

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

CallbackWriter is a custom writer that processes each line calling the callback.

func NewCallbackWriter

func NewCallbackWriter(process func(line string)) *CallbackWriter

NewCallbackWriter creates a new CallbackWriter.

func (*CallbackWriter) Write

func (p *CallbackWriter) Write(data []byte) (int, error)

Write implements the io.Writer interface.

type CloneAppRequest

type CloneAppRequest struct {
	FromID app.ID

	Name *string
	Icon *string
}

type CloneAppResponse

type CloneAppResponse struct {
	ID app.ID `json:"id"`
}

func CloneApp

func CloneApp(
	ctx context.Context,
	req CloneAppRequest,
	idProvider *app.IDProvider,
	cfg config.Configuration,
) (response CloneAppResponse, cloneErr error)

type ConfigDirectories

type ConfigDirectories struct {
	Data     string `json:"data"`
	Apps     string `json:"apps"`
	Examples string `json:"examples"`
}

type ConfigResponse

type ConfigResponse struct {
	Directories ConfigDirectories `json:"directories"`
}

func GetOrchestratorConfig

func GetOrchestratorConfig(cfg config.Configuration) ConfigResponse

type CreateAppRequest

type CreateAppRequest struct {
	Name        string
	Icon        string
	Description string
	SkipPython  bool
	SkipSketch  bool
}

type CreateAppResponse

type CreateAppResponse struct {
	ID app.ID `json:"id"`
}

func CreateApp

func CreateApp(
	ctx context.Context,
	req CreateAppRequest,
	idProvider *app.IDProvider,
	cfg config.Configuration,
) (CreateAppResponse, error)

type DockerLogConsumer

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

func NewDockerLogConsumer

func NewDockerLogConsumer(
	ctx context.Context,
	cb func(LogMessage) bool,
	mapping map[string]string,
) *DockerLogConsumer

func (*DockerLogConsumer) Err

func (d *DockerLogConsumer) Err(containerName string, message string)

Err implements api.LogConsumer.

func (*DockerLogConsumer) Log

func (d *DockerLogConsumer) Log(containerName string, message string)

Log implements api.LogConsumer.

func (*DockerLogConsumer) Status

func (d *DockerLogConsumer) Status(container string, msg string)

Status implements api.LogConsumer.

type DockerProgressParser

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

DockerProgressParser parses Docker pull logs to extract and aggregate progress information.

func NewDockerProgressParser

func NewDockerProgressParser(historySize int) *DockerProgressParser

NewDockerProgressParser creates a new DockerProgressParser instance.

func (*DockerProgressParser) Parse

func (p *DockerProgressParser) Parse(logLine string) (uint64, bool)

returns the overall progress percentage (0 to 100) and a boolean indicating if parsing was successful.

type LedTrigger

type LedTrigger string
const (
	LedTriggerNone    LedTrigger = "none"
	LedTriggerDefault LedTrigger = "default"
)

type LibraryReleaseID

type LibraryReleaseID struct {
	Name    string
	Version string
}

LibraryReleaseID represents a library release identifier in the form of: - name[@version] Version is optional, if not provided, the latest version available will be used.

func AddSketchLibrary

func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryReleaseID, addDeps bool) ([]LibraryReleaseID, error)

func ListSketchLibraries

func ListSketchLibraries(ctx context.Context, app app.ArduinoApp) ([]LibraryReleaseID, error)

func NewLibraryReleaseID

func NewLibraryReleaseID(name string, version string) LibraryReleaseID

func ParseLibraryReleaseID

func ParseLibraryReleaseID(s string) (LibraryReleaseID, error)

func RemoveSketchLibrary

func RemoveSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryReleaseID) (LibraryReleaseID, error)

func (LibraryReleaseID) MarshalJSON

func (l LibraryReleaseID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for LibraryID.

func (LibraryReleaseID) String

func (l LibraryReleaseID) String() string

type ListAppRequest

type ListAppRequest struct {
	ShowExamples    bool
	ShowOnlyDefault bool
	ShowApps        bool
	StatusFilter    Status

	// IncludeNonStandardLocationApps will include apps that are not in the standard apps directory.
	// We will search by looking for docker container metadata, and add the app not present in the
	// standard apps directory in the result list.
	IncludeNonStandardLocationApps bool
}

type ListAppResult

type ListAppResult struct {
	Apps       []AppInfo       `json:"apps"`
	BrokenApps []BrokenAppInfo `json:"broken_apps"`
}

func ListApps

func ListApps(
	ctx context.Context,
	docker command.Cli,
	req ListAppRequest,
	idProvider *app.IDProvider,
	cfg config.Configuration,
) (ListAppResult, error)

type LogMessage

type LogMessage struct {
	Name      string
	BrickName string
	Content   string
}

type MessageType

type MessageType string
const (
	UnknownType  MessageType = ""
	ProgressType MessageType = "progress"
	InfoType     MessageType = "info"
	ErrorType    MessageType = "error"
)

type Progress

type Progress struct {
	Name     string
	Progress float32
}

type Provision

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

func NewProvision

func NewProvision(
	docker command.Cli,
	cfg config.Configuration,
) (*Provision, error)

func (*Provision) App

func (p *Provision) App(
	ctx context.Context,
	bricksIndex *bricksindex.BricksIndex,
	arduinoApp *app.ArduinoApp,
	cfg config.Configuration,
	mapped_env map[string]string,
	staticStore *store.StaticStore,
) error

type Status

type Status string
const (
	StatusStarting Status = "starting"
	StatusRunning  Status = "running"
	StatusStopping Status = "stopping"
	StatusStopped  Status = "stopped"
	StatusFailed   Status = "failed"
)

func ParseStatus

func ParseStatus(s string) (Status, error)

func StatusFromDockerState

func StatusFromDockerState(s container.ContainerState) Status

func (Status) AllowedStatuses

func (s Status) AllowedStatuses() []Status

func (Status) Validate

func (s Status) Validate() error

type StreamMessage

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

func (*StreamMessage) GetData

func (p *StreamMessage) GetData() string

func (*StreamMessage) GetError

func (p *StreamMessage) GetError() error

func (*StreamMessage) GetProgress

func (p *StreamMessage) GetProgress() *Progress

func (*StreamMessage) GetType

func (p *StreamMessage) GetType() MessageType

func (*StreamMessage) IsData

func (p *StreamMessage) IsData() bool

func (*StreamMessage) IsError

func (p *StreamMessage) IsError() bool

func (*StreamMessage) IsProgress

func (p *StreamMessage) IsProgress() bool

type SystemCPUResource

type SystemCPUResource struct {
	UsedPercent float64 `json:"used_percent"`
}

type SystemCleanupResult

type SystemCleanupResult struct {
	ContainersRemoved int
	ImagesRemoved     int
	RunningAppRemoved bool
	SpaceFreed        int64 // in bytes
}

func SystemCleanup

func SystemCleanup(ctx context.Context, cfg config.Configuration, staticStore *store.StaticStore, docker command.Cli) (SystemCleanupResult, error)

SystemCleanup removes dangling containers and unused images. Also running apps are stopped and removed.

func (SystemCleanupResult) IsEmpty

func (s SystemCleanupResult) IsEmpty() bool

type SystemDiskResource

type SystemDiskResource struct {
	Path  string `json:"path"`
	Used  uint64 `json:"used"`
	Total uint64 `json:"total"`
}

type SystemMemoryResource

type SystemMemoryResource struct {
	Used  uint64 `json:"used"`
	Total uint64 `json:"total"`
}

type SystemResource

type SystemResource interface {
	// contains filtered or unexported methods
}

type SystemResourceConfig

type SystemResourceConfig struct {
	CPUScrapeInterval    time.Duration
	MemoryScrapeInterval time.Duration
	DiskScrapeInterval   time.Duration
}

Directories

Path Synopsis
app

Jump to

Keyboard shortcuts

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