server

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

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

View Source
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

func New(cfg Config) (*Server, error)

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

func (s *Server) GRPCAddr() string

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

func (s *Server) GRPCServer() *grpc.Server

GRPCServer returns the underlying *grpc.Server so callers can register their service implementations on it.

func (*Server) GatewayMux

func (s *Server) GatewayMux() *runtime.ServeMux

GatewayMux returns the HTTP gateway mux, or nil when no HTTP gateway is configured.

func (*Server) HTTPAddr

func (s *Server) HTTPAddr() string

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

func (s *Server) LROStore() lro.Store

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.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context) error

Serve starts the gRPC server (and the HTTP gateway when configured) and blocks until ctx is cancelled, after which it shuts both down gracefully. It returns the first fatal error from either server, or nil on clean shutdown.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL