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

server

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	Dir = "/var/lib/mainplane-server"
)

Variables

View Source
var Conf = filepath.Join(Dir, "config.json")

Conf is the config the installed harness runs from.

Functions

func Harness

func Harness(ctx context.Context, c Config) 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.

func Install

func Install(c Config) (string, error)

Install makes this machine run the harness at every boot, from a copy of an expanded c at Conf, and returns its URL once it answers there. Dir is root's alone: the copy holds the keys.

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. Dir stays: it holds the sessions.

func Up

func Up(c Config) 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 {
	Admin     string              `json:"admin"`            // directory holding sessions, the auth table and the tunnel
	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"`
}

Config is the self-hosted config file. Provider values are expanded from the environment, so a key can be "$ANTHROPIC_API_KEY".

func Default added in v0.1.1

func Default() (Config, error)

Default is the config install writes when given none: the tunnel carries workers and connectors to port 8080 on loopback, sessions live under Dir, and every provider whose key is set in this environment serves.

func Load

func Load(path string) (Config, error)

func (Config) Auth

func (c Config) Auth() auth.Store

func (*Config) Expand

func (c *Config) Expand() error

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

func (Config) Key added in v0.2.0

func (c Config) Key() (ed25519.PrivateKey, error)

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

type Provider

type Provider struct {
	Key    string `json:"key"`
	URL    string `json:"url,omitempty"`    // openai-chat
	Region string `json:"region,omitempty"` // bedrock
}

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