Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BearerAuth ¶
func BearerAuth(check TokenFunc, public ...string) ggrpc.UnaryServerInterceptor
BearerAuth returns a unary interceptor that requires "authorization: Bearer <token>" metadata on every call except the methods listed in public (full names, such as "/greeter.Greeter/Ping") and the health service. A missing or rejected token answers codes.Unauthenticated.
Types ¶
type Config ¶
type Config struct {
// Addr is where the server listens. Default GRPC_ADDR, then ":50051".
Addr string
// Register adds your services to the server. Called once, before it starts.
Register func(s *ggrpc.Server)
// Reflection exposes the service list to tools like grpcurl. Nil means on
// outside production (APP_ENV != "production"); GRPC_REFLECTION overrides.
Reflection *bool
// Unary and Stream interceptors run after the built-in recovery and
// logging ones, in order.
Unary []ggrpc.UnaryServerInterceptor
Stream []ggrpc.StreamServerInterceptor
// Options are passed to grpc.NewServer as they are (TLS credentials,
// message size limits, keepalive).
Options []ggrpc.ServerOption
// ShutdownTimeout bounds the graceful stop; after it, open calls are
// cancelled. Default 10s.
ShutdownTimeout time.Duration
// Logger receives one line per call. Default log.Printf; set Quiet to
// turn call logs off.
Logger func(format string, args ...any)
Quiet bool
}
Config configures the gRPC server.
type Plugin ¶
type Plugin struct {
nimbus.BasePlugin
// contains filtered or unexported fields
}
Plugin runs a gRPC server alongside the HTTP server.
func New ¶
New creates the gRPC plugin. Settings left empty come from the environment, then from the defaults above.
func (*Plugin) Addr ¶
Addr reports where the server is listening once it has started (useful with Addr ":0" in tests).
func (*Plugin) Server ¶
Server builds the gRPC server with the built-in interceptors, health and reflection, and your services. Start calls it; tests can call it directly.
func (*Plugin) Shutdown ¶
Shutdown implements nimbus.HasShutdown: health turns NOT_SERVING, open calls get ShutdownTimeout to finish, then the rest are cancelled.