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

connector

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package connector is the Go client of the harness HTTP API, for every connector that runs in Go: the CLI and the TUI ship in the device binary and call the harness only through it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Login

func Login(ctx context.Context, token string) (c Client, old Client, version string, err error)

Login finds the harness of an api key, checks that it takes the key, and saves both. It returns the client, the login it replaced (empty for none), and the release the harness runs.

func Path

func Path() (string, error)

Path is the login file, ~/.mainplane/login.json.

Types

type Client

type Client struct {
	URL     string `json:"url"`
	Key     string `json:"key"`
	Harness string `json:"harness"`
	Mesh    string `json:"-"`
}

Client is what login wrote: the harness's key, the URL it was last found at, and the api key's secret. On a worker of that harness, calls go to its node on the mesh, at Mesh.

func Load

func Load(ctx context.Context) (Client, error)

Load is what login wrote, with the harness on the mesh when the worker on this machine follows the same harness key, else proved at its URL, or found again through the pointer and saved.

func (Client) Call

func (c Client) Call(ctx context.Context, method, path, ctype string, body io.Reader, out any) error

Call does one request, and decodes a JSON reply into out when out is given.

func (Client) Create

func (c Client) Create(ctx context.Context, cr harness.Create, via string) (string, error)

Create makes a session and returns its id.

func (Client) Do

func (c Client) Do(ctx context.Context, method, path, ctype string, body io.Reader) (*http.Response, error)

Do does one request; a status outside 2xx is an error in the harness's own words.

func (*Client) Find

func (c *Client) Find(ctx context.Context) error

Find proves the harness at its URL, or finds it again through the pointer and saves it.

func (Client) Info

func (c Client) Info(ctx context.Context, id string) (harness.Info, error)

func (Client) Post

func (c Client) Post(ctx context.Context, id, via, text string, files []string) (int, error)

Post appends text and files as one turn: a single text/plain body, or one multipart part per piece, each typed by its extension. A file with no type is refused, not guessed. Returns the last record's n.

func (Client) Records

func (c Client) Records(ctx context.Context, id string, after int, wait string) ([]statefile.Record, error)

Records is the file after record n; with wait, a long poll.

func (Client) Save

func (c Client) Save() error

func (Client) Sessions

func (c Client) Sessions(ctx context.Context, status string, limit int) ([]harness.Info, error)

Sessions lists sessions, newest updated first.

func (Client) SetWorkers

func (c Client) SetWorkers(ctx context.Context, id, via string, ws []statefile.Worker) error

SetWorkers makes ws the session's workers from its next step on.

func (Client) Stop

func (c Client) Stop(ctx context.Context, id, via string) error

func (Client) Version

func (c Client) Version(ctx context.Context) (string, error)

Version is the release the harness runs.

func (Client) Workers

func (c Client) Workers(ctx context.Context) ([]Worker, error)

Workers lists the workers the harness knows.

type Worker

type Worker struct {
	Name    string `json:"name"`
	Refused string `json:"refused,omitempty"`
}

Worker is a worker as GET /workers lists it: connected, unless refused.

Directories

Path Synopsis
tui
Package tui is the Mainplane terminal app: a retained tree of components on the term engine, and its screens: login, and the session.
Package tui is the Mainplane terminal app: a retained tree of components on the term engine, and its screens: login, and the session.
term
Package term owns the terminal for a full screen app: raw mode and the alternate screen with a guaranteed restore, capability queries, input decoding, a cell buffer and a diff renderer.
Package term owns the terminal for a full screen app: raw mode and the alternate screen with a guaranteed restore, capability queries, input decoding, a cell buffer and a diff renderer.

Jump to

Keyboard shortcuts

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