rgrpc

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Services = map[string]NewService{}

Services is a map of service name and its new function.

View Source
var StreamInterceptors = map[string]NewStreamInterceptor{}

StreamInterceptors is a map of registered streaming grpc interceptor.

View Source
var UnaryInterceptors = map[string]NewUnaryInterceptor{}

UnaryInterceptors is a map of registered unary grpc interceptors.

Functions

func InitServices

func InitServices(ctx context.Context, services map[string]config.ServicesConfig) (map[string]Service, error)

func Register

func Register(name string, newFunc NewService)

Register registers a new gRPC service with name and new function.

func RegisterStreamInterceptor

func RegisterStreamInterceptor(name string, newFunc NewStreamInterceptor)

RegisterStreamInterceptor registers a new stream interceptor.

func RegisterUnaryInterceptor

func RegisterUnaryInterceptor(name string, newFunc NewUnaryInterceptor)

RegisterUnaryInterceptor registers a new unary interceptor.

Types

type NewService

type NewService func(context.Context, map[string]any) (Service, error)

NewService is the function that gRPC services need to register at init time. It returns an io.Closer to close the service and a list of service endpoints that need to be unprotected.

type NewStreamInterceptor

type NewStreamInterceptor func(m map[string]any) (grpc.StreamServerInterceptor, int, error)

NewStreamInterceptor is the type that stream interceptors need to register.

type NewUnaryInterceptor

type NewUnaryInterceptor func(m map[string]any) (grpc.UnaryServerInterceptor, int, error)

NewUnaryInterceptor is the type that unary interceptors need to register.

type Option

type Option func(*Server)

func EnableReflection

func EnableReflection(enable bool) Option

func WithLogger

func WithLogger(logger zerolog.Logger) Option

func WithServices

func WithServices(services map[string]Service) Option

func WithShutdownDeadline

func WithShutdownDeadline(deadline int) Option

func WithStreamServerInterceptors

func WithStreamServerInterceptors(in []grpc.StreamServerInterceptor) Option

func WithUnaryServerInterceptors

func WithUnaryServerInterceptors(in []grpc.UnaryServerInterceptor) Option

type Server

type Server struct {
	ShutdownDeadline         int
	EnableReflection         bool
	UnaryServerInterceptors  []grpc.UnaryServerInterceptor
	StreamServerInterceptors []grpc.StreamServerInterceptor
	// contains filtered or unexported fields
}

Server is a gRPC server.

func NewServer

func NewServer(o ...Option) (*Server, error)

NewServer returns a new Server.

func (*Server) Address

func (s *Server) Address() string

Address returns the network address.

func (*Server) GracefulStop

func (s *Server) GracefulStop() error

GracefulStop gracefully stops the server.

func (*Server) Network

func (s *Server) Network() string

Network returns the network type.

func (*Server) Start

func (s *Server) Start(ln net.Listener) error

Start starts the server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the server.

type Service

type Service interface {
	Register(ss *grpc.Server)
	io.Closer
	UnprotectedEndpoints() []string
}

Service represents a grpc service.

Directories

Path Synopsis
Package status contains helpers functions to create grpc Status with contextual information, like traces.
Package status contains helpers functions to create grpc Status with contextual information, like traces.
todo

Jump to

Keyboard shortcuts

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