Documentation
¶
Overview ¶
Package grpc implements the config-sync gRPC transport: the control-plane server, the data-plane client, the connection hub, and the auth interceptors and credentials that secure the channel.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScopeFromContext ¶
Types ¶
type AuthInterceptor ¶
type AuthInterceptor struct {
// contains filtered or unexported fields
}
func NewAuthInterceptor ¶
func (*AuthInterceptor) StreamServerInterceptor ¶
func (a *AuthInterceptor) StreamServerInterceptor() grpc.StreamServerInterceptor
func (*AuthInterceptor) UnaryServerInterceptor ¶
func (a *AuthInterceptor) UnaryServerInterceptor() grpc.UnaryServerInterceptor
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the data-plane end of the config-sync transport. It implements configsync.ConfigFetcher (Fetch via GetSnapshot) and configsync.StreamTransport (Watch/Ack via the long-lived Sync stream), reconnecting the Sync stream on break.
func NewClient ¶
NewClient dials the control plane with TLS (or dev-insecure), per-RPC bearer credentials, and keepalive tuning.
func (*Client) Close ¶
Close cancels the Sync stream context and tears down the underlying connection, unblocking any in-flight stream receive.
type ConnectionStore ¶
type ConnectionStore interface {
MarkConnected(ctx context.Context, scope, instanceID string) error
MarkAck(ctx context.Context, scope, instanceID, appliedVersion string) error
MarkDisconnected(ctx context.Context, scope, instanceID string) error
}
ConnectionStore persists the observed lifecycle of data-plane Sync streams so the control plane can answer "is this data plane online?". The Hub calls it best-effort: a nil store or a returned error must never fail a stream or the fail-closed verification path. scope is opaque to the store.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is the registry of connected data-plane Sync streams. Broadcast fans a new version out to every connection through a latest-only, size-1 drop-oldest channel so a slow consumer never blocks the dispatcher and only the newest version is ever delivered. When a ConnectionStore is present the Hub also records each stream's lifecycle best-effort for the admin read API.
func NewHub ¶
func NewHub(logger *slog.Logger, store ConnectionStore) *Hub
NewHub builds an empty Hub. store may be nil, in which case connection lifecycle is not persisted (in-memory-only self-host).
func (*Hub) Broadcast ¶
Broadcast delivers version to every connected data plane, coalescing to the newest version per connection. It never blocks.
func (*Hub) ConnectionCount ¶
ConnectionCount reports the number of registered data-plane streams.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps a *grpc.Server and its listener, implementing the shared server.Server Run/Shutdown lifecycle contract so the control-plane gRPC listener slots into the shared serve loop.
func NewServer ¶
func NewServer(cfg config.ConfigSyncConfig, svc snapshotpb.ConfigSyncServer, auth *AuthInterceptor, logger *slog.Logger) (*Server, error)
NewServer builds the control-plane ConfigSync gRPC listener with TLS (when configured), the auth interceptors, and keepalive enforcement.
type Service ¶
type Service struct {
snapshotpb.UnimplementedConfigSyncServer
// contains filtered or unexported fields
}
Service implements the ConfigSync gRPC server: the bidi Sync control channel and the server-streaming GetSnapshot bulk transfer.
func NewService ¶
func NewService(hub *Hub, source SnapshotSource, logger *slog.Logger) *Service
NewService builds the ConfigSync server implementation.
func (*Service) GetSnapshot ¶
func (s *Service) GetSnapshot(req *snapshotpb.GetSnapshotRequest, stream snapshotpb.ConfigSync_GetSnapshotServer) error
GetSnapshot answers not_modified when the DP's applied_version matches current, otherwise streams a SnapshotHeader followed by fixed-size data chunks.
func (*Service) Sync ¶
func (s *Service) Sync(stream snapshotpb.ConfigSync_SyncServer) error
Sync registers the data plane's stream, pushes an immediate notice when the DP's last-applied version is stale, then forwards broadcasts as VersionNotice messages while draining the DP's Acks.