grpcx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoListener = errors.New("[gRPC] server not bind listener")
)

Functions

func DisableHealth

func DisableHealth() utility.Option[Server]

func WithAddr

func WithAddr(network, addr string) utility.Option[Server]

WithAddr create a listener with network and address WithAddr and WithListener just choose one of them

func WithListener

func WithListener(lis net.Listener) utility.Option[Server]

WithListener uses the given listener WithListener and WithAddr just choose one of them

func WithLogger

func WithLogger(logger *slog.Logger) utility.Option[Server]

func WithMiddleware

func WithMiddleware(middlewares ...middleware.Middleware) utility.Option[Server]

func WithServerOption

func WithServerOption(opts ...grpc.ServerOption) utility.Option[Server]

WithServerOption inject grpc.ServerOption to server

func WithStreamInterceptor

func WithStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) utility.Option[Server]

func WithTLS

func WithTLS(config *tls.Config) utility.Option[Server]

func WithUnaryInterceptor

func WithUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) utility.Option[Server]

Types

type Context

type Context struct {
	context.Context
	*Transport
}

func NewServerContext

func NewServerContext(ctx context.Context) *Context

type Server

type Server struct {
	*types.BaseServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...utility.Option[Server]) *Server

NewServer returns grpc server instance

func (*Server) RegisterService

func (g *Server) RegisterService(services ...types.Service)

RegisterService register server to grpc server

func (*Server) Run

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

func (*Server) Shutdown

func (g *Server) Shutdown(context.Context) error

type Transport

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

func (*Transport) AddHeader

func (t *Transport) AddHeader(key, value string)

func (*Transport) Kind

func (t *Transport) Kind() transport.Kind

func (*Transport) Operation

func (t *Transport) Operation() string

func (*Transport) RequestHeader

func (t *Transport) RequestHeader() transport.Header

func (*Transport) ResponseHeader

func (t *Transport) ResponseHeader() transport.Header

func (*Transport) SetHeader

func (t *Transport) SetHeader(key, value string)

type Transporter

type Transporter interface {
	// Operation is service full method
	// this value is gRPC generated by protobuf
	// eg: /helloworld.Greeter/SayHello
	Operation() string

	SetHeader(key, val string)
}

Jump to

Keyboard shortcuts

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