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 ¶
- Variables
- type Conn
- type Gateway
- func (g *Gateway) AddHooks(h Hooks)
- func (g *Gateway) Connect(...) error
- func (g *Gateway) Send(nodeID string, msg *agentv1.ConnectResponse) error
- func (g *Gateway) Serve(ctx context.Context, ca *pki.CA, addr string, hosts []string) error
- func (g *Gateway) ServeListener(ctx context.Context, ca *pki.CA, ln net.Listener, hosts []string) error
- type Hooks
Constants ¶
This section is empty.
Variables ¶
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 (*Gateway) Connect ¶
func (g *Gateway) Connect(stream grpc.BidiStreamingServer[agentv1.ConnectRequest, agentv1.ConnectResponse]) error
func (*Gateway) Send ¶
func (g *Gateway) Send(nodeID string, msg *agentv1.ConnectResponse) error
Send queues a command for a connected node.
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.