Documentation
¶
Overview ¶
Package server hosts the daemon's gRPC + REST API on a single TLS port (ALPN-dispatch like the broker) and its own /metrics surface on a separate TLS port.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
APIPort int
MetricsPort int
Cert *tls.Certificate
Service pb.DaemonServiceServer
Registry *prometheus.Registry
Logger *zap.SugaredLogger
}
Config carries the inputs needed to build the daemon's servers.
type Querier ¶
type Querier interface {
GetMetrics(name string, lookbackSeconds int64) (*rater.WindowedResult, error)
// GetPeerCardDrift returns the current drift-comparison state for
// name's peers: for each peer, the daemon's own stability-gated
// AgentCard hash alongside what each of name's live pods currently
// reports for that peer. See rater.PeerCardDrift.
GetPeerCardDrift(ctx context.Context, name string) (map[string]rater.PeerCardDrift, error)
}
Querier is the subset of *rater.Rater that the service needs. It exists so unit tests can stub responses without spinning up a real rater.
type Servers ¶
type Servers struct {
APIServer *http.Server
MetricsServer *http.Server
// contains filtered or unexported fields
}
Servers bundles the two HTTP servers the daemon runs so callers can shut both down together.
func New ¶
New constructs the daemon's two servers but does not start them. Callers invoke ListenAndServeTLS on each, typically in goroutines.
func (*Servers) GracefulStop ¶
GracefulStop stops the gRPC server cleanly and shuts down both HTTP servers within the deadline implied by ctx.
type Service ¶
type Service struct {
pb.UnimplementedDaemonServiceServer
// contains filtered or unexported fields
}
Service implements pb.DaemonServiceServer over a Querier.
func NewService ¶
func (*Service) GetAgentDeployMetrics ¶
func (s *Service) GetAgentDeployMetrics(_ context.Context, req *pb.GetAgentDeployMetricsRequest) (*pb.GetAgentDeployMetricsResponse, error)
GetAgentDeployMetrics translates a Querier result into the protobuf response shape:
- NotFound when the AgentDeploy is unknown.
- Unavailable when no samples have accumulated yet.
- OK with a populated AgentDeployMetrics otherwise. Empty per- window maps inside the response mean "data exists but we couldn't compute that specific window."
func (*Service) GetPeerCardDrift ¶ added in v0.7.0
func (s *Service) GetPeerCardDrift(ctx context.Context, req *pb.GetPeerCardDriftRequest) (*pb.GetPeerCardDriftResponse, error)
GetPeerCardDrift translates a Querier result into the protobuf response shape:
- NotFound when the AgentDeploy is unknown.
- OK with a populated GetPeerCardDriftResponse otherwise. A peer with no reported hashes from any pod is still present in the map (empty ReportedHashes) - see rater.PeerCardDrift.