grpc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundServer

type BackgroundServer struct {
	*grpc.Server
	// contains filtered or unexported fields
}

BackgroundServer wrapper

func NewServer

func NewServer(builder *ServerOptionsBuilder) *BackgroundServer

NewServer instance

func (*BackgroundServer) GetName

func (s *BackgroundServer) GetName() string

GetName of the task

func (*BackgroundServer) GetSeverity

func (s *BackgroundServer) GetSeverity() background.ProcessSeverity

GetSeverity of the task

func (*BackgroundServer) OnStart

func (s *BackgroundServer) OnStart(_ context.Context) error

OnStart event to be called when main loop will be started

func (*BackgroundServer) OnStop

func (s *BackgroundServer) OnStop(_ context.Context) error

OnStop event to be called when main loop will be started

type Middleware

type Middleware func(RequestHandler) RequestHandler

Middleware to do some actions between gRPC requests

type MiddlewareComposer

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

MiddlewareComposer keeps middlewares and keeps it sorted by filter

func NewMiddlewareComposer

func NewMiddlewareComposer() *MiddlewareComposer

NewMiddlewareComposer instance

func (*MiddlewareComposer) ExtendContext

func (mc *MiddlewareComposer) ExtendContext(baseCtx context.Context, newCtxMetadata RequestContextMetadata) context.Context

ExtendContext baseCtx with new RequestContextMetadata

func (*MiddlewareComposer) PassToNext

func (mc *MiddlewareComposer) PassToNext(m ...Middleware) Middleware

PassToNext delegate to next middleware to execute

func (*MiddlewareComposer) Register

func (mc *MiddlewareComposer) Register(filter string, mw ...Middleware)

Register middleware with filter

func (*MiddlewareComposer) Search

func (mc *MiddlewareComposer) Search(requestPath string) []Middleware

Search middleware that related to filtered request

type Options

type Options func(o *BackgroundServer)

Options sets options such as credentials, keepalive parameters, etc.

type RequestContextMetadata

type RequestContextMetadata struct {
	Meta       metadata.MD
	FullMethod string
}

RequestContextMetadata context data from interception

func GetContextMetadata

func GetContextMetadata(baseCtx context.Context) (meta RequestContextMetadata, isExist bool)

GetContextMetadata will try get form context.Context metadata about request from middleware during interception

type RequestHandler

type RequestHandler func(ctx context.Context, req interface{}) (interface{}, error)

RequestHandler will be invoked in the gRPC Middleware

type ServerOptionsBuilder

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

ServerOptionsBuilder sets options such as credentials, keepalive parameters, etc, related to gRPC server

func NewServerOptionsBuilder

func NewServerOptionsBuilder() *ServerOptionsBuilder

NewServerOptionsBuilder for gRPC server configuration

func (*ServerOptionsBuilder) AddAdditionalGrpcOptions

func (b *ServerOptionsBuilder) AddAdditionalGrpcOptions(grpcOpts ...grpc.ServerOption) *ServerOptionsBuilder

AddAdditionalGrpcOptions that's needed for gRPC server

func (*ServerOptionsBuilder) AddAddress

AddAddress that will be used in gRPC server endpoint

func (*ServerOptionsBuilder) AddCustomUnaryMiddlewares

func (b *ServerOptionsBuilder) AddCustomUnaryMiddlewares(filter string, mwList ...Middleware) *ServerOptionsBuilder

AddCustomUnaryMiddlewares that have first priority to intercepted request in the middlewares and forwards it to gRPC if needed filter used for calling middleware for example: - /myapp.v1.MyAppAPI/* - Middleware will be executed for all endpoints under "/myapp.v1.MyAppAPI" - /myapp.v1.MyAppAPI/OnlyThatEndpoint - Middleware will be executed only for "OnlyThatEndpoint"

func (*ServerOptionsBuilder) AddGrpcStreamInterceptors

func (b *ServerOptionsBuilder) AddGrpcStreamInterceptors(streamInter ...grpc.StreamServerInterceptor) *ServerOptionsBuilder

AddGrpcStreamInterceptors intercept the execution of a streaming RPC on the server

func (*ServerOptionsBuilder) AddGrpcUnaryInterceptors

func (b *ServerOptionsBuilder) AddGrpcUnaryInterceptors(unaryInter ...grpc.UnaryServerInterceptor) *ServerOptionsBuilder

AddGrpcUnaryInterceptors intercept the execution of a unary RPC on the server

func (*ServerOptionsBuilder) AddListener

AddListener custom value

func (*ServerOptionsBuilder) AddNetwork

AddNetwork type that will be used in gRPC server

func (*ServerOptionsBuilder) AddServicesHealthChecks

AddServicesHealthChecks to verify if gRPC working correctly as health checks

func (*ServerOptionsBuilder) AddShutdownTimeout

func (b *ServerOptionsBuilder) AddShutdownTimeout(t time.Duration) *ServerOptionsBuilder

AddShutdownTimeout for gRPC server

func (*ServerOptionsBuilder) Build

func (b *ServerOptionsBuilder) Build() []Options

Build will make sure that all needed options prepared for server

Jump to

Keyboard shortcuts

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