Documentation
¶
Overview ¶
Package agentgateway pkg/agentgateway/gateway_client.go
Index ¶
- Variables
- type GatewayClient
- func (g *GatewayClient) Connect(ctx context.Context) error
- func (g *GatewayClient) ControlStream(ctx context.Context) (...)
- func (g *GatewayClient) Disconnect() error
- func (g *GatewayClient) GetConfig(ctx context.Context, req *proto.AgentConfigRequest) (*proto.AgentConfigResponse, error)
- func (g *GatewayClient) GetGatewayID() string
- func (g *GatewayClient) GetReconnectDelay() time.Duration
- func (g *GatewayClient) Hello(ctx context.Context, req *proto.AgentHelloRequest) (*proto.AgentHelloResponse, error)
- func (g *GatewayClient) IsConnected() bool
- func (g *GatewayClient) PushStatus(ctx context.Context, req *proto.GatewayStatusRequest) (*proto.GatewayStatusResponse, error)
- func (g *GatewayClient) ReconnectWithBackoff(ctx context.Context) error
- func (g *GatewayClient) StreamStatus(ctx context.Context, chunks []*proto.GatewayStatusChunk) (*proto.GatewayStatusResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrGatewayNotConnected indicates the gateway client is not connected. ErrGatewayNotConnected = errors.New("gateway client not connected") // ErrGatewayAddrRequired indicates gateway_addr is required in configuration. ErrGatewayAddrRequired = errors.New("gateway_addr is required for push mode") // ErrEnrollmentRejected indicates the gateway rejected agent enrollment. ErrEnrollmentRejected = errors.New("agent enrollment rejected by gateway") // ErrSecurityRequired indicates security configuration is required for production. ErrSecurityRequired = errors.New("security configuration required: set SR_ALLOW_INSECURE=true for development") // ErrNoChunksToSend indicates no valid status chunks were provided for streaming. ErrNoChunksToSend = errors.New("no status chunks to send") // ErrConnectionShutdown indicates the gRPC connection entered shutdown state. ErrConnectionShutdown = errors.New("connection shutdown") )
Functions ¶
This section is empty.
Types ¶
type GatewayClient ¶
type GatewayClient struct {
// contains filtered or unexported fields
}
GatewayClient manages the connection to the agent-gateway and pushes status updates.
func NewGatewayClient ¶
func NewGatewayClient(addr string, security *models.SecurityConfig, log logger.Logger) *GatewayClient
NewGatewayClient creates a new gateway client.
func (*GatewayClient) Connect ¶
func (g *GatewayClient) Connect(ctx context.Context) error
Connect establishes a connection to the gateway.
func (*GatewayClient) ControlStream ¶ added in v1.0.91
func (g *GatewayClient) ControlStream(ctx context.Context) (grpc.BidiStreamingClient[proto.ControlStreamRequest, proto.ControlStreamResponse], error)
ControlStream opens the bidirectional control stream for commands and push-config.
func (*GatewayClient) Disconnect ¶
func (g *GatewayClient) Disconnect() error
Disconnect closes the connection to the gateway.
func (*GatewayClient) GetConfig ¶
func (g *GatewayClient) GetConfig(ctx context.Context, req *proto.AgentConfigRequest) (*proto.AgentConfigResponse, error)
GetConfig fetches the agent's configuration from the gateway. Supports versioning - returns not_modified if config hasn't changed.
func (*GatewayClient) GetGatewayID ¶ added in v1.0.90
func (g *GatewayClient) GetGatewayID() string
GetGatewayID returns the gateway ID assigned during enrollment.
func (*GatewayClient) GetReconnectDelay ¶
func (g *GatewayClient) GetReconnectDelay() time.Duration
GetReconnectDelay returns the current reconnect delay.
func (*GatewayClient) Hello ¶
func (g *GatewayClient) Hello(ctx context.Context, req *proto.AgentHelloRequest) (*proto.AgentHelloResponse, error)
Hello sends an enrollment request to the gateway. This should be called on agent startup to announce the agent and register with the gateway.
func (*GatewayClient) IsConnected ¶
func (g *GatewayClient) IsConnected() bool
IsConnected returns whether the client is currently connected.
func (*GatewayClient) PushStatus ¶
func (g *GatewayClient) PushStatus(ctx context.Context, req *proto.GatewayStatusRequest) (*proto.GatewayStatusResponse, error)
PushStatus sends a batch of service statuses to the gateway.
func (*GatewayClient) ReconnectWithBackoff ¶
func (g *GatewayClient) ReconnectWithBackoff(ctx context.Context) error
ReconnectWithBackoff attempts to reconnect with exponential backoff.
func (*GatewayClient) StreamStatus ¶
func (g *GatewayClient) StreamStatus(ctx context.Context, chunks []*proto.GatewayStatusChunk) (*proto.GatewayStatusResponse, error)
StreamStatus streams service status chunks to the gateway.