Documentation
¶
Overview ¶
Package server provides a batteries-included gRPC server builder for Infoblox services. It assembles the framework interceptor chain (request-ID, error mapping, tenant-ID, fail-closed authz, field-mask validation, ETag preconditions, read-mask response shaping) and, optionally, an HTTP/JSON gateway in front of the gRPC endpoint.
Index ¶
- Constants
- type Config
- type Server
- func (s *Server) GRPCAddr() string
- func (s *Server) GRPCServer() *grpc.Server
- func (s *Server) GatewayMux() *runtime.ServeMux
- func (s *Server) HTTPAddr() string
- func (s *Server) LROStore() lro.Store
- func (s *Server) RegisterGateway(fn func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error)
- func (s *Server) Rules() []authz.MethodRule
- func (s *Server) Serve(ctx context.Context) error
Constants ¶
const DefaultGRPCAddr = ":9090"
DefaultGRPCAddr is the default listen address for the gRPC endpoint.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// GRPCAddr is the TCP address to listen on (e.g. ":9090" or ":0"). Required.
GRPCAddr string
// HTTPAddr is the optional gateway address (e.g. ":8080"). Empty disables
// the HTTP gateway.
HTTPAddr string
// Rules are the declared authz rules; they feed both grpcauthz (enforcement)
// and the field-mask interceptor (verb lookup).
Rules []authz.MethodRule
// Authorizer is the pluggable decision point. Defaults to
// authz.NewDevAuthorizer(nil) if nil.
Authorizer authz.Authorizer
// PrincipalFunc derives the authenticated authz.Principal from each request's
// context. When nil the principal is empty, so — with a default-deny
// Authorizer — every non-public method is denied (fail closed). For local
// development set grpcauthz.DevPrincipalFunc() to derive the principal from
// request metadata; in production supply one backed by a verified token.
PrincipalFunc grpcauthz.PrincipalFunc
// Interceptors are additional unary interceptors appended after the
// framework chain.
Interceptors []grpc.UnaryServerInterceptor
// DeduplicationStore is the idempotency store for DeduplicateUnary. Defaults to MemoryDeduplicationStore (10-minute TTL) when nil.
DeduplicationStore middleware.DeduplicationStore
// LROStore is the operation store for long-running operations (AIP-151).
// Defaults to lro.NewMemoryStore(1h) when nil.
LROStore lro.Store
}
Config carries the options for constructing a Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the assembled gRPC server (plus optional HTTP gateway).
func New ¶
New validates cfg and constructs a Server. It builds the framework interceptor chain and wires the authz rules into both the authorizer and the field-mask validator. Returns an error if any required field is missing.
func (*Server) GRPCAddr ¶
GRPCAddr returns the actual bound gRPC address once Serve has started (useful when GRPCAddr was ":0"); before that it returns the configured address.
func (*Server) GRPCServer ¶
GRPCServer returns the underlying *grpc.Server so callers can register their service implementations on it.
func (*Server) GatewayMux ¶
GatewayMux returns the HTTP gateway mux, or nil when no HTTP gateway is configured.
func (*Server) HTTPAddr ¶
HTTPAddr returns the actual bound HTTP gateway address once Serve has started (useful when HTTPAddr was ":0"); before that it returns the configured address. Returns "" when no HTTP gateway is configured.
func (*Server) LROStore ¶
LROStore returns the long-running operation store this server was configured with.
func (*Server) RegisterGateway ¶
func (s *Server) RegisterGateway(fn func(context.Context, *runtime.ServeMux, *grpc.ClientConn) error)
RegisterGateway records a gateway registration function to be invoked against the gateway mux and the in-process gRPC connection when Serve starts. It is a no-op at runtime unless an HTTP gateway is configured.
func (*Server) Rules ¶
func (s *Server) Rules() []authz.MethodRule
Rules returns the declared MethodRules this server was configured with.