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 ¶
- func Login(ctx context.Context, token string) (c *Client, old *Client, version string, err error)
- func Path() (string, error)
- type Client
- func (c *Client) At() string
- func (c *Client) Call(ctx context.Context, method, path, ctype string, body io.Reader, out any) error
- func (c *Client) Create(ctx context.Context, cr harness.Create, via string) (string, error)
- func (c *Client) Delete(ctx context.Context, id, via string) error
- func (c *Client) Do(ctx context.Context, method, path, ctype string, body io.Reader) (*http.Response, error)
- func (c *Client) Find(ctx context.Context) error
- func (c *Client) Info(ctx context.Context, id string) (harness.Info, error)
- func (c *Client) Join(ctx context.Context) (string, error)
- func (c *Client) Network(ctx context.Context) (string, error)
- func (c *Client) NewKey(ctx context.Context, name string) (string, error)
- func (c *Client) Post(ctx context.Context, id, via, text string, files []string) (int, error)
- func (c *Client) Providers(ctx context.Context) ([]harness.ProviderInfo, error)
- func (c *Client) Records(ctx context.Context, id string, after int, wait string) ([]statefile.Record, error)
- func (c *Client) Save() error
- func (c *Client) Sessions(ctx context.Context, status string, limit int) ([]harness.Info, error)
- func (c *Client) SetDrive(ctx context.Context, name, server string, workers []string) error
- func (c *Client) SetName(ctx context.Context, id, via, name string) error
- func (c *Client) SetProvider(ctx context.Context, name, shape, u, region, session, key string) error
- func (c *Client) SetWorkers(ctx context.Context, id, via string, ws []statefile.Worker) error
- func (c *Client) SignIn(ctx context.Context, name, shape, u string) (provider.LoginState, error)
- func (c *Client) SignInPaste(ctx context.Context, name, text string) error
- func (c *Client) SignInWait(ctx context.Context, name string) error
- func (c *Client) Stop(ctx context.Context, id, via string) error
- func (c *Client) Version(ctx context.Context) (string, error)
- func (c *Client) Workers(ctx context.Context) ([]Worker, error)
- type StatusError
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
URL string `json:"url"`
Key string `json:"key"`
Harness string `json:"harness"`
Local string `json:"-"`
Mesh string `json:"-"`
// contains filtered or unexported fields
}
Client is what login wrote: the harness's key, the URL it was last found at, none when login found it on this machine, and the api key's secret. On the harness's own machine, calls go to it on loopback, at Local; on a worker of that harness, to its node on the mesh, at Mesh. A call that fails at URL finds the harness again, so one Client is shared, not copied.
func Load ¶
Load is what login wrote, with the harness on loopback when it is the one installed on this machine, 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) 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 ¶
Find proves the harness at its URL, or finds it again through the pointer and saves it.
func (*Client) Join ¶ added in v0.5.5
Join is the network name and device code that make a machine a worker.
func (*Client) Network ¶ added in v0.5.5
Network is the state of the harness's tunnel: starting, ready, or its error.
func (*Client) NewKey ¶ added in v0.5.5
NewKey mints an api key named name and returns its token. A name in use is a StatusError of 409.
func (*Client) Post ¶
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) Providers ¶ added in v0.5.4
Providers lists the providers the harness serves, by the name a model starts with.
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) SetDrive ¶ added in v0.5.5
SetDrive makes or changes the drive name, served by server to workers, "*" for all.
func (*Client) SetProvider ¶ added in v0.5.4
func (c *Client) SetProvider(ctx context.Context, name, shape, u, region, session, key string) error
SetProvider makes the harness serve provider name with this shape, url, region, session header and key, at once.
func (*Client) SetWorkers ¶
SetWorkers makes ws the session's workers from its next step on.
func (*Client) SignIn ¶ added in v0.5.5
SignIn starts provider name's login on the harness, with the shape and url for a provider it does not have, and returns its first prompt, or its end. The prompt may wait on a download, such as a provider's binary.
func (*Client) SignInPaste ¶ added in v0.5.5
SignInPaste hands the login what its prompt asked the user to paste.
func (*Client) SignInWait ¶ added in v0.5.5
SignInWait waits for the login to end, and is an error unless it signed in.
type StatusError ¶ added in v0.5.5
StatusError is a reply outside 2xx, in the harness's own words.
func (*StatusError) Error ¶ added in v0.5.5
func (e *StatusError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
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. |