rpc

package
v0.43.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogUnaryServerInterceptor

func LogUnaryServerInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor

LogUnaryServerInterceptor logs handled unary gRPC requests.

func RequestValidationUnaryServerInterceptor

func RequestValidationUnaryServerInterceptor() grpc.UnaryServerInterceptor

RequestValidationUnaryServerInterceptor validates the request payload if the request implements requestValidator interface. An InvalidArgument with the detail message will be returned to client if the validation was not passed.

Types

type Option

type Option func(*Server)

Option defines a function to set configurable field of Server.

func WithAPIKeyAuthUnaryInterceptor

func WithAPIKeyAuthUnaryInterceptor(verifier rpcauth.APIKeyVerifier, logger *zap.Logger) Option

WithAPIKeyAuthUnaryInterceptor sets an interceptor for validating API key.

func WithGRPCReflection

func WithGRPCReflection() Option

WithGRPCReflection enables gRPC reflection service for debugging.

func WithGracePeriod

func WithGracePeriod(d time.Duration) Option

WithGracePeriod sets maximum time to wait for gracefully shutdown.

func WithJWTAuthUnaryInterceptor

func WithJWTAuthUnaryInterceptor(verifier jwt.Verifier, authorizer rpcauth.RBACAuthorizer, logger *zap.Logger) Option

WithJWTAuthUnaryInterceptor sets an interceprot for checking JWT token.

func WithLogUnaryInterceptor

func WithLogUnaryInterceptor(logger *zap.Logger) Option

WithLogUnaryInterceptor sets an interceptor for logging handled request.

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger sets logger to server.

func WithPipedTokenAuthStreamInterceptor

func WithPipedTokenAuthStreamInterceptor(verifier rpcauth.PipedTokenVerifier, logger *zap.Logger) Option

WithPipedTokenAuthStreamInterceptor sets an interceptor for validating piped key.

func WithPipedTokenAuthUnaryInterceptor

func WithPipedTokenAuthUnaryInterceptor(verifier rpcauth.PipedTokenVerifier, logger *zap.Logger) Option

WithPipedTokenAuthUnaryInterceptor sets an interceptor for validating piped key.

func WithPort

func WithPort(port int) Option

WithPort sets grpc port number.

func WithPrometheusUnaryInterceptor

func WithPrometheusUnaryInterceptor() Option

WithPrometheusUnaryInterceptor sets an interceptor for Prometheus monitoring.

func WithRequestValidationUnaryInterceptor

func WithRequestValidationUnaryInterceptor() Option

WithRequestValidationUnaryInterceptor sets an interceptor for validating request payload.

func WithService

func WithService(service Service) Option

WithService appends gPRC service to server.

func WithTLS

func WithTLS(certFile, keyFile string) Option

WithTLS configures TLS files.

type Server

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

Server used to register gRPC services then start and serve incoming requests.

func NewServer

func NewServer(service Service, opts ...Option) *Server

NewServer creates a new server for handling gPRC services.

func (*Server) Run

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

Run starts running gRPC server for handling incoming requests.

type Service

type Service interface {
	Register(server *grpc.Server)
}

Service represents a gRPC service will be registered to server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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