grpcutils

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0, MIT Imports: 20 Imported by: 8

README

gRPC utils

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ClientPayloadLoggingDecider = func(ctx context.Context, fullMethodName string) bool { return false }
View Source
var DebugCodeToLevel = func(code codes.Code) zapcore.Level {
	return zap.DebugLevel
}
View Source
var DefaultDialOpts = func(logger *zap.Logger) []grpc.DialOption {
	return []grpc.DialOption{
		grpc.WithTransportCredentials(insecure.NewCredentials()),
		grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 60 * time.Second, Timeout: time.Minute * 2, PermitWithoutStream: true}),
	}
}
View Source
var DefaultLoggingDialOpts = func(logger *zap.Logger) []grpc.DialOption {
	return []grpc.DialOption{
		grpc.WithTransportCredentials(insecure.NewCredentials()),
		grpc.WithKeepaliveParams(keepalive.ClientParameters{Time: 60 * time.Second, Timeout: time.Minute * 2, PermitWithoutStream: true}),
	}
}
View Source
var DefaultLoggingServerOptions = func(logger *zap.Logger) []interface{} {
	return []interface{}{
		grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{MinTime: 1 * time.Minute, PermitWithoutStream: true}),
		CtxTagsServerOption(),
		ValidatorServerOption(),
		RecoveryServerOption(),
	}
}
View Source
var DefaultServerOptions = func(logger *zap.Logger) []interface{} {
	return []interface{}{
		grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{MinTime: 1 * time.Minute, PermitWithoutStream: true}),
		CtxTagsServerOption(),
		ValidatorServerOption(),
		RecoveryServerOption(),
	}
}
View Source
var ServerPayloadLoggingDecider = func(ctx context.Context, fullMethodName string, servingObject interface{}) bool { return false }
View Source
var TestSvrOpts = func(logger *zap.Logger) []interface{} {
	return []interface{}{
		CtxTagsServerOption,
		ValidatorServerOption,
		RecoveryServerOption,
	}
}

Functions

This section is empty.

Types

type ClientConnection

type ClientConnection struct {
	Connection *grpc.ClientConn
	// contains filtered or unexported fields
}

func NewClientConnection

func NewClientConnection(addr string) *ClientConnection

func (*ClientConnection) CleanUp

func (c *ClientConnection) CleanUp() error

func (*ClientConnection) Dial

func (c *ClientConnection) Dial(opts ...grpc.DialOption) error

func (*ClientConnection) DialContext

func (c *ClientConnection) DialContext(ctx context.Context, opts ...grpc.DialOption) error

type DialOption

type DialOption struct {
	grpc.EmptyDialOption
	// contains filtered or unexported fields
}

func NewDialOption

func NewDialOption(f func(conn *ClientConnection)) DialOption

type HealthHandler

type HealthHandler struct {
	*health.Server
	GServer *Server
	// contains filtered or unexported fields
}

func NewHealthServer

func NewHealthServer(svrName string, addr string, logger *zap.Logger, healthAddr string) (healthHandler *HealthHandler)

func (*HealthHandler) AddConn

func (s *HealthHandler) AddConn(svrName string, conn *ClientConnection)

func (*HealthHandler) AddService

func (s *HealthHandler) AddService(svrName string, addr string)

func (*HealthHandler) Check

func (*HealthHandler) CheckConnection

func (s *HealthHandler) CheckConnection(ctx context.Context) error

type Server

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

func NewServer

func NewServer(name, addr string) *Server

func (*Server) CleanUp

func (s *Server) CleanUp() error

func (*Server) GetHttpProxy

func (s *Server) GetHttpProxy(httpAddr string, opts []grpc.DialOption, register func(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error) (*http.Server, error)

func (*Server) Init

func (s *Server) Init(opts ...interface{}) error

func (*Server) Serve

func (s *Server) Serve() error

type ServerOption

type ServerOption func(s *Server)

func CtxTagsServerOption

func CtxTagsServerOption() ServerOption

func RecoveryServerOption

func RecoveryServerOption() ServerOption

func ValidatorServerOption

func ValidatorServerOption() ServerOption

Jump to

Keyboard shortcuts

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