protocol

package
v0.3.96 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package protocol is the loomux-plugin/1 protocol's vocabulary: the method names the host calls and the parameter and result types they carry (docs/design/target-providers.md §1.3). It imports nothing of Loomux, so the host, the SDK and any plugin share it without cycles.

Index

Constants

View Source
const (
	// MethodDescribe returns the plugin's manifest: the handshake.
	MethodDescribe = "plugin.describe"
	// MethodConfigure hands the plugin its configuration and what it
	// needs to know about the host (ConfigureParams).
	MethodConfigure = "plugin.configure"
	// MethodCheck asks the plugin to verify its credentials and
	// reachability (CheckResult).
	MethodCheck = "plugin.check"
	// MethodShutdown asks it to stop cleanly.
	MethodShutdown = "plugin.shutdown"
)

Methods of the plugin.* group, which every plugin serves.

View Source
const (
	SeverityWarning = "warning"
	SeverityError   = "error"
)

Problem severities.

View Source
const (
	MethodTargetsDescribe       = "targets.describe"
	MethodTargetsCreate         = "targets.create"
	MethodTargetsGet            = "targets.get"
	MethodTargetsList           = "targets.list"
	MethodTargetsStart          = "targets.start"
	MethodTargetsStop           = "targets.stop"
	MethodTargetsRecreate       = "targets.recreate"
	MethodTargetsDestroy        = "targets.destroy"
	MethodTargetsHealth         = "targets.health"
	MethodTargetsAttachCommands = "targets.attach_commands"
)

The targets.* group: a target provider makes machines on demand (docs/design/target-providers.md §1.3, §1.9). The host calls these only on a plugin whose manifest declares targets.create.

View Source
const (
	CapTargetsCreate         = "targets.create"
	CapTargetsStopStart      = "targets.stop_start"
	CapTargetsRecreate       = "targets.recreate"
	CapTargetsPersistent     = "targets.persistent"
	CapTargetsEphemeral      = "targets.ephemeral"
	CapTargetsEgressPolicy   = "targets.egress_policy"
	CapTargetsAttachCommands = "targets.attach_commands"
)

Capabilities of the targets group, as a manifest declares them.

View Source
const (
	EnvCreating   = "creating"
	EnvStarting   = "starting"
	EnvRunning    = "running"
	EnvStopped    = "stopped"
	EnvRecreating = "recreating"
	EnvDestroying = "destroying"
	EnvLost       = "lost"
	EnvError      = "error"
)

Environment statuses (Environment.Status).

View Source
const (
	LabelInstance    = "loomux.io/instance"
	LabelTarget      = "loomux.io/target"
	LabelEnvironment = "loomux.io/environment"
)

Labels the host puts on every spec, and a plugin on every object it makes, so it only ever touches its own.

View Source
const (
	EgressInternet = "internet"
	EgressNone     = "none"
)

Egress values.

View Source
const (
	SSHProxyNone    = "none"
	SSHProxyDefault = "default"
)

SSH proxy values (TargetsInfo.SSHProxy, Address.Proxy): how the host reaches the machines, as a target's ssh_proxy.

View Source
const NotifyTargetsChanged = "targets.changed"

NotifyTargetsChanged is the one notification a plugin may send the host: a hint that a machine's status changed, never the truth.

View Source
const Version = "loomux-plugin/1"

Version is the protocol this package describes.

Variables

EnvironmentStatuses is every status a plugin may report.

Functions

func RequiredCapability added in v0.3.69

func RequiredCapability(method string) string

RequiredCapability is the capability a manifest must declare for the host to call method; "" for a method outside the targets group.

Types

type Address added in v0.3.69

type Address struct {
	Host  string `json:"host"`
	Port  int    `json:"port"`
	Proxy string `json:"proxy"`
}

Address is how the host reaches a machine's sshd.

type AttachCommand added in v0.3.69

type AttachCommand struct {
	Via     string `json:"via"`
	Command string `json:"command"`
}

AttachCommand is one way a person attaches to a machine's tmux.

type AttachParams added in v0.3.69

type AttachParams struct {
	ID      string `json:"id"`
	Session string `json:"session"`
}

AttachParams are targets.attach_commands'.

type AttachResult added in v0.3.69

type AttachResult struct {
	Commands []AttachCommand `json:"commands"`
}

AttachResult is targets.attach_commands' result.

type CheckResult

type CheckResult struct {
	OK       bool      `json:"ok"`
	Problems []Problem `json:"problems"`
}

CheckResult is plugin.check's result. OK is false when any problem has severity error.

type ConfigureParams

type ConfigureParams struct {
	// Config is the configuration as the manifest's schema describes it,
	// secret fields included: the channel is private to the two
	// processes.
	Config map[string]any `json:"config"`
	Host   HostInfo       `json:"host"`
}

ConfigureParams are plugin.configure's parameters.

type Environment added in v0.3.69

type Environment struct {
	ID          string    `json:"id"`
	Status      string    `json:"status"`
	Reason      string    `json:"reason,omitempty"`
	Address     Address   `json:"address"`
	ImageDigest string    `json:"image_digest,omitempty"`
	Size        string    `json:"size"`
	Persistent  bool      `json:"persistent"`
	Egress      string    `json:"egress"`
	CreatedAt   time.Time `json:"created_at"`
}

Environment is a machine as the plugin sees it.

type EnvironmentHealth added in v0.3.69

type EnvironmentHealth struct {
	Status      string `json:"status"`
	Reason      string `json:"reason,omitempty"`
	Restarts    int    `json:"restarts"`
	ImageDigest string `json:"image_digest,omitempty"`
}

EnvironmentHealth is targets.health's result: the plugin's own view.

type EnvironmentSpec added in v0.3.69

type EnvironmentSpec struct {
	ID         string            `json:"id"`
	TargetID   string            `json:"target_id"`
	Name       string            `json:"name"`
	Size       string            `json:"size"`
	Persistent bool              `json:"persistent"`
	Egress     string            `json:"egress"`
	Image      string            `json:"image"`
	SSH        SSHBootstrap      `json:"ssh"`
	Labels     map[string]string `json:"labels"`
}

EnvironmentSpec is targets.create's parameter: everything a plugin needs for one machine, and nothing else.

type HostInfo

type HostInfo struct {
	// Version is the host's version string.
	Version string `json:"version"`
	// InstanceID labels everything the plugin makes as this server's.
	InstanceID string `json:"instance_id"`
	// DataDir is a directory of the plugin's own on the host's data
	// volume, for a subprocess that needs to keep state.
	DataDir string `json:"data_dir,omitempty"`
}

HostInfo is what a plugin learns about the host at configure.

type IDParams added in v0.3.69

type IDParams struct {
	ID string `json:"id"`
}

Parameters of the id-taking methods.

type ListResult added in v0.3.69

type ListResult struct {
	Environments []Environment `json:"environments"`
}

ListResult is targets.list's result.

type Problem

type Problem struct {
	// Code is stable and machine-readable ("network_policy_not_enforced");
	// Message is for a person.
	Code     string `json:"code"`
	Message  string `json:"message"`
	Severity string `json:"severity"`
}

Problem is one thing plugin.check found.

type RecreateParams added in v0.3.69

type RecreateParams struct {
	ID   string          `json:"id"`
	Spec EnvironmentSpec `json:"spec"`
}

RecreateParams are targets.recreate's.

type SSHBootstrap added in v0.3.69

type SSHBootstrap struct {
	AuthorizedKey  string `json:"authorized_key"`
	HostPrivateKey string `json:"host_private_key"`
	HostPublicKey  string `json:"host_public_key"`
	Port           int    `json:"port"`
}

SSHBootstrap is what a machine needs to be reachable: the target's public key for authorized_keys, and the host key the host generated and pinned.

type Size added in v0.3.69

type Size struct {
	Name   string `json:"name"`
	CPU    string `json:"cpu"`
	Memory string `json:"memory"`
	Disk   string `json:"disk"`
}

Size is one machine size the plugin offers.

type TargetsChanged

type TargetsChanged struct {
	ID     string `json:"id"`
	Status string `json:"status"`
}

TargetsChanged is NotifyTargetsChanged's parameters.

type TargetsInfo added in v0.3.69

type TargetsInfo struct {
	Sizes             []Size   `json:"sizes"`
	PersistentDefault bool     `json:"persistent_default"`
	EgressOptions     []string `json:"egress_options"`
	Image             string   `json:"image"`
	MaxEnvironments   int      `json:"max_environments"`
	Environments      int      `json:"environments"`
	// AddressTemplate is where a machine will be reachable, with {id}
	// for the environment id: the host registers the target before the
	// machine exists.
	AddressTemplate string `json:"address_template"`
	// SSHProxy is how the host reaches the machines: none (directly) or
	// default (through LOOMUX_SSH_PROXY).
	SSHProxy string `json:"ssh_proxy"`
	// User and Port are sshd's in the machine.
	User string `json:"user"`
	Port int    `json:"port"`
}

TargetsInfo is targets.describe's result: what the plugin offers right now.

Jump to

Keyboard shortcuts

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