Help us shape the future of Go! Take the 2026 Go Developer Survey

grpc

package
v0.9.82 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InterceptorPriorityPreprocess     = 1
	InterceptorPriorityObservability  = 2
	InterceptorPriorityAuthentication = 3
	InterceptorPriorityBusinessLogic  = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger.

func WithMaxRecvMsgSize

func WithMaxRecvMsgSize(size int) Option

WithMaxRecvMsgSize sets the maximum receive message size.

func WithMaxSendMsgSize

func WithMaxSendMsgSize(size int) Option

WithMaxSendMsgSize sets the maximum send message size.

func WithRateLimiter

func WithRateLimiter(cacheEngine cache.Engine, rate int, burst int, ttl time.Duration) Option

WithRateLimiter enables/disables rate limiting.

func WithReadinessCheck

func WithReadinessCheck(check func(context.Context) error) Option

func WithReadinessCheckInterval

func WithReadinessCheckInterval(interval time.Duration) Option

func WithReadinessCheckTimeout

func WithReadinessCheckTimeout(timeout time.Duration) Option

func WithReadinessContext added in v0.9.80

func WithReadinessContext(ctx context.Context) Option

WithReadinessContext sets the parent context for the readiness monitor. Cancellation stops the monitor and sets the gRPC health status to NOT_SERVING.

func WithReflection

func WithReflection(enabled bool) Option

WithReflection enables/disables reflection.

func WithStreamInterceptor

func WithStreamInterceptor(priority int, interceptor grpc.StreamServerInterceptor) Option

WithStreamInterceptor adds a stream interceptor with a specific priority.

func WithTLSConfig added in v0.9.79

func WithTLSConfig(clientCAFile, certFile, keyFile string) Option

WithTLSConfig sets certificate files, loaded by New when TLS is enabled. Providing a client CA file requires verified client certificates for mutual TLS.

func WithTLSEnabled added in v0.9.79

func WithTLSEnabled(enabled bool) Option

WithTLSEnabled enables or disables TLS.

func WithTracing

func WithTracing(enabled bool) Option

WithTracing enables/disables tracing.

func WithUnaryInterceptor

func WithUnaryInterceptor(priority int, interceptor grpc.UnaryServerInterceptor) Option

WithUnaryInterceptor adds a unary interceptor with a specific priority.

type PermissionRegistry

type PermissionRegistry struct {
	// contains filtered or unexported fields
}

PermissionRegistry hold list of permissions for each grpc method. It is responsibility of the adapter to register permissions.

func NewPermissionRegistry

func NewPermissionRegistry() *PermissionRegistry

func (*PermissionRegistry) PermissionsForMethod

func (pr *PermissionRegistry) PermissionsForMethod(method string) []string

func (*PermissionRegistry) Register

func (pr *PermissionRegistry) Register(method string, permissions ...string)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Server, error)

func (*Server) Errors added in v0.9.80

func (s *Server) Errors() <-chan error

Errors reports at most one unexpected termination, including startup failures. It closes when serving ends; shutdown requested through Shutdown closes it without an error.

func (*Server) Register

func (s *Server) Register(adapters ...adapterAccessor)

func (*Server) Serve

func (s *Server) Serve(listen string) error

Serve serves requests until the server stops. Call it once after registering adapters. Unexpected termination is also logged and reported through Errors.

func (*Server) Shutdown

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

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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