internal

package
v0.0.0-...-4590e31 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Conn() *grpc.ClientConn
}

Client interface wraps the Conn method.

func NewClient

func NewClient(target string, middlewares ClientMiddlewaresConf, opts ...ClientOption) (Client, error)

NewClient returns a Client.

type ClientMiddlewaresConf

type ClientMiddlewaresConf struct {
	Trace      bool `json:",default=true"`
	Duration   bool `json:",default=true"`
	Prometheus bool `json:",default=true"`
	Breaker    bool `json:",default=true"`
	Timeout    bool `json:",default=true"`
}

ClientMiddlewaresConf defines whether to use client middlewares.

type ClientOption

type ClientOption func(options *ClientOptions)

ClientOption defines the method to customize a ClientOptions.

func WithDialOption

func WithDialOption(opt grpc.DialOption) ClientOption

WithDialOption returns a func to customize a ClientOptions with given dial option.

func WithNonBlock

func WithNonBlock() ClientOption

WithNonBlock sets the dialing to be nonblock.

func WithStreamClientInterceptor

func WithStreamClientInterceptor(interceptor grpc.StreamClientInterceptor) ClientOption

WithStreamClientInterceptor returns a func to customize a ClientOptions with given interceptor.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout returns a func to customize a ClientOptions with given timeout.

func WithTransportCredentials

func WithTransportCredentials(creds credentials.TransportCredentials) ClientOption

WithTransportCredentials return a func to make the gRPC calls secured with given credentials.

func WithUnaryClientInterceptor

func WithUnaryClientInterceptor(interceptor grpc.UnaryClientInterceptor) ClientOption

WithUnaryClientInterceptor returns a func to customize a ClientOptions with given interceptor.

type ClientOptions

type ClientOptions struct {
	NonBlock    bool
	Timeout     time.Duration
	Secure      bool
	DialOptions []grpc.DialOption
}

A ClientOptions is a client options.

type Logger

type Logger struct{}

A Logger is a rpc logger.

func (*Logger) Error

func (l *Logger) Error(args ...any)

Error logs the given args into error log.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

Errorf logs the given args with format into error log.

func (*Logger) Errorln

func (l *Logger) Errorln(args ...any)

Errorln logs the given args into error log with newline.

func (*Logger) Fatal

func (l *Logger) Fatal(args ...any)

Fatal logs the given args into error log.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...any)

Fatalf logs the given args with format into error log.

func (*Logger) Fatalln

func (l *Logger) Fatalln(args ...any)

Fatalln logs args into error log with newline.

func (*Logger) Info

func (l *Logger) Info(args ...any)

Info ignores the grpc info logs.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

Infof ignores the grpc info logs.

func (*Logger) Infoln

func (l *Logger) Infoln(args ...any)

Infoln ignores the grpc info logs.

func (*Logger) V

func (l *Logger) V(v int) bool

V checks if meet required log level.

func (*Logger) Warning

func (l *Logger) Warning(args ...any)

Warning ignores the grpc warning logs.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...any)

Warningf ignores the grpc warning logs.

func (*Logger) Warningln

func (l *Logger) Warningln(args ...any)

Warningln ignores the grpc warning logs.

type MethodTimeoutConf

type MethodTimeoutConf = serverinterceptors.MethodTimeoutConf

MethodTimeoutConf defines specified timeout for gRPC methods.

type RegisterFn

type RegisterFn func(*grpc.Server)

RegisterFn defines the method to register a server.

type Server

type Server interface {
	AddOptions(options ...grpc.ServerOption)
	AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
	AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
	SetName(string)
	Start(register RegisterFn) error
}

Server interface represents a rpc server.

func NewRpcPubServer

func NewRpcPubServer(etcd discov.EtcdConf, listenOn string, middlewares ServerMiddlewaresConf,
	opts ...ServerOption) (Server, error)

NewRpcPubServer returns a Server.

func NewRpcServer

func NewRpcServer(addr string, middlewares ServerMiddlewaresConf, opts ...ServerOption) Server

NewRpcServer returns a Server.

type ServerMiddlewaresConf

type ServerMiddlewaresConf struct {
	Trace      bool     `json:",default=true"`
	Recover    bool     `json:",default=true"`
	Stat       bool     `json:",default=true"`
	StatConf   StatConf `json:",optional"`
	Prometheus bool     `json:",default=true"`
	Breaker    bool     `json:",default=true"`
}

ServerMiddlewaresConf defines whether to use server middlewares.

type ServerOption

type ServerOption func(options *rpcServerOptions)

ServerOption defines the method to customize a rpcServerOptions.

func WithMetrics

func WithMetrics(metrics *stat.Metrics) ServerOption

WithMetrics returns a func that sets metrics to a Server.

func WithRpcHealth

func WithRpcHealth(health bool) ServerOption

WithRpcHealth returns a func that sets rpc health switch to a Server.

type StatConf

type StatConf = serverinterceptors.StatConf

StatConf defines the stat config.

Directories

Path Synopsis
balancer
p2c

Jump to

Keyboard shortcuts

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