agentgw

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package agentgw is the controller's gRPC endpoint for agents (§12). Agents authenticate with client certificates issued by the internal CA; the node identity is the certificate's CommonName, checked against the nodes table (so deleting a node revokes its certificate).

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConnected = errors.New("node is not connected")

Functions

This section is empty.

Types

type Conn

type Conn struct {
	Node   store.Node
	Hello  *agentv1.Hello
	Remote string // IP address the agent connected from
}

Conn describes a newly connected agent.

type Gateway

type Gateway struct {
	agentv1.UnimplementedAgentGatewayServiceServer
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, registry *nodes.Registry, log *slog.Logger) *Gateway

func (*Gateway) AddHooks

func (g *Gateway) AddHooks(h Hooks)

AddHooks registers h. It must be called before Serve.

func (*Gateway) Send

func (g *Gateway) Send(nodeID string, msg *agentv1.ConnectResponse) error

Send queues a command for a connected node.

func (*Gateway) Serve

func (g *Gateway) Serve(ctx context.Context, ca *pki.CA, addr string, hosts []string) error

Serve listens on addr with mTLS until ctx ends. hosts are the names and IPs agents use to reach the gateway (put in the server certificate).

func (*Gateway) ServeListener

func (g *Gateway) ServeListener(ctx context.Context, ca *pki.CA, ln net.Listener, hosts []string) error

ServeListener is Serve on an existing listener.

type Hooks

type Hooks struct {
	// OnConnect runs after the Welcome, with the node's Hello (including its
	// container snapshot) and the IP address it connected from.
	OnConnect func(c Conn)
	// OnTaskStatus runs for every task status the agent reports.
	OnTaskStatus func(node store.Node, s *agentv1.TaskStatus)
	// OnHeartbeat runs for every heartbeat.
	OnHeartbeat func(node store.Node, hb *agentv1.Heartbeat)
	// OnDisconnect runs when the stream ends.
	OnDisconnect func(node store.Node)
	// OnLogs runs for every batch of container output.
	OnLogs func(node store.Node, b *agentv1.LogBatch)
	// OnExecOutput runs for output of interactive exec sessions.
	OnExecOutput func(node store.Node, o *agentv1.ExecOutput)
	// OnUpgradeResult runs when an agent reports a failed self-upgrade.
	OnUpgradeResult func(node store.Node, r *agentv1.UpgradeResult)
}

Hooks let other controller components react to agents. Hooks run on the stream's goroutine and must not block.

Jump to

Keyboard shortcuts

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