Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Overview

Package server assembles the roles a mainplane-server process runs. Today that is one role, harness.

Index

Constants

This section is empty.

Variables

Dir is the installed harness's, and Conf the config it runs from. Admin serves the sessions drive from Dir on Linux.

Functions

func Auth added in v0.5.0

func Auth(dir string) auth.Store

Auth is the auth table of the harness in dir.

func Harness

func Harness(ctx context.Context, path string) error

Harness runs the harness role on one loopback port, behind the user's own tunnel or a quick one, until ctx ends or the listener, the mesh node or the tunnel fails: /id proves the harness key to anyone before they send a secret, /ts2021 coordinates the mesh, /derp relays between its nodes, connectors call every other route with an api key, every session that was open on start resumes. The harness joins its own mesh, and workers dial it there. The pointer and the relay map follow the tunnel's URL. The config at path is read again when it changes: providers, links and drives apply at once.

func Install

func Install(c *Config, keep bool) error

Install makes this machine run the harness at every boot, from a copy of an expanded c at Conf, or with keep from the config already there, as it is, which c becomes, and makes it the worker admin. It returns while the tunnel starts: the tokens it prints name no URL, and Reached waits for one. Dir is root's and the operator's alone: the config holds the keys, and admin runs code as the operator so that it may read and edit them.

func Key added in v0.5.0

func Key(dir string) (ed25519.PrivateKey, error)

Key is the harness key every token carries, made on first use.

func Reached added in v0.5.2

func Reached(key string) (string, error)

Reached waits for the pointer to name a URL where the harness with key proves it, through Cloudflare, as a worker finds it, and returns that URL. A tunnel that stops the harness fails it at once.

func SetTunnel added in v0.2.0

func SetTunnel(t *Tunnel) (string, error)

SetTunnel makes the installed harness reached through t, or through a quick tunnel when t is nil, restarts it, and returns its URL once it answers there. Workers follow through the pointer.

func Uninstall added in v0.1.1

func Uninstall() error

Uninstall stops the harness and removes its service and binary, and the worker admin. Dir stays: it holds the sessions.

func Up

func Up(path string) error

Up runs the harness until SIGINT or SIGTERM, which systemd and launchd send to stop it.

func Update

func Update(v string) error

Update makes the installed harness release v, the newest stable release when v is empty, prints what the changelog says changed, and restarts it. Workers follow at their next hello, so one command updates the fleet.

Types

type Config

type Config struct {
	HTTP        string                       `json:"http"`             // loopback address the tunnel carries connectors and workers to
	Tunnel      *Tunnel                      `json:"tunnel,omitempty"` // the user's own; none is a quick tunnel
	Providers   map[string]Provider          `json:"providers"`
	Links       [][2]string                  `json:"links,omitempty"`        // pairs of workers, by name, that reach each other on the mesh
	Drives      map[string]coordinator.Drive `json:"drives,omitempty"`       // by name: each one's server and workers
	DataSharing *DataSharing                 `json:"data_sharing,omitempty"` // whether the user has opted in to data sharing; none: not asked yet
}

Config is the self-hosted config file. Provider values are expanded from the environment, so a key can be "$ANTHROPIC_API_KEY". The directory it is in is the harness's: the harness key, the auth table, the mesh and the tunnel are there, and sessions in sessions/ under it, the one directory a drive may ever share.

func Default added in v0.1.1

func Default() Config

Default is the config install writes when given none and none is installed: the tunnel carries workers and connectors to port 8080 on loopback, and every provider whose key is set in this environment serves. With none set, keys go in the config after install.

func Load

func Load(path string) (Config, error)

func (*Config) Expand

func (c *Config) Expand() error

Expand fills provider values in from this process's environment, which a service will not have, and refuses a provider the harness does not know.

type DataSharing added in v0.5.6

type DataSharing struct {
	Share bool      `json:"share"`
	At    time.Time `json:"at,omitzero"`
	Via   string    `json:"via,omitempty"`
	Text  string    `json:"text,omitempty"`
}

DataSharing is the answer to data sharing permission: which, when, through which connector, and to which words.

type Network added in v0.5.2

type Network struct {
	Name string `json:"name"`
	Code string `json:"code"`
}

Network is what a person types to make a machine a worker of the harness: its name on the pointer, then its device code.

func Cycle added in v0.5.2

func Cycle() (Network, error)

Cycle gives the installed harness a new device code. Its workers stay; a machine joins with the new code only.

func LoadNetwork added in v0.5.2

func LoadNetwork(dir string) (Network, error)

LoadNetwork is the network of the harness in dir.

func Rename added in v0.5.2

func Rename(name string) (Network, error)

Rename makes name the installed harness's network name. Its workers stay: they know the harness by its key.

func (Network) String added in v0.5.2

func (n Network) String() string

type Provider

type Provider struct {
	Shape   string `json:"shape"`
	Key     string `json:"key,omitempty"`     // none for a shape that logs in
	URL     string `json:"url,omitempty"`     // the base url its SDK takes; none is the vendor's own
	Region  string `json:"region,omitempty"`  // bedrock
	Session string `json:"session,omitempty"` // the header the session's routing key goes in, for a server that routes its cache on one
}

Provider is one the config names. Its name is free, and the catalog's ids are the names connectors know; its shape picks the code.

type Tunnel added in v0.2.0

type Tunnel struct {
	URL   string `json:"url"`
	Token string `json:"token"` // the tunnel's, as Cloudflare shows it
}

Tunnel is a tunnel the user made in Cloudflare, which routes URL to it and it to HTTP.

Jump to

Keyboard shortcuts

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