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

localapi

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package localapi is the agent's local control socket, used by the CLI.

Index

Constants

View Source
const SocketName = "transporter.sock"

SocketName is the socket's file name inside the state directory.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, path string, b Backend) error

Serve listens on the unix socket at path until ctx is cancelled.

Types

type Backend

type Backend interface {
	Status() Status
	Shutdown()
	// Ping probes target (a peer name or mesh IP), calling fn per result,
	// and returns the address it resolved target to.
	Ping(ctx context.Context, target string, count int, timeout time.Duration, fn func(pingsvc.Result)) (netip.Addr, error)
}

Backend provides the data the API serves.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to a running agent.

func NewClient

func NewClient(path string) *Client

NewClient returns a client for the agent socket at path.

func (*Client) Down

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

Down asks the agent to disconnect and exit.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context, target string, count int, timeout time.Duration, fn func(PingResult)) error

Ping asks the agent to probe target, calling fn for each result line as it arrives. The final line carries the resolved address; a line with only an error means the ping could not start.

func (*Client) Status

func (c *Client) Status(ctx context.Context) (Status, error)

Status fetches the agent status.

type PingResult

type PingResult struct {
	Addr  string  `json:"addr,omitempty"` // first line only
	Seq   uint32  `json:"seq,omitempty"`
	RTTMs float64 `json:"rttMs,omitempty"`
	Error string  `json:"error,omitempty"`
}

PingResult is one line of the GET /v0/ping response.

type Status

type Status struct {
	Coordinator string        `json:"coordinator"`
	NodeID      string        `json:"nodeID"`
	Engine      engine.Status `json:"engine"`
	Error       string        `json:"error,omitempty"`
}

Status is what GET /v0/status returns.

Jump to

Keyboard shortcuts

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