Documentation ¶
Index ¶
- type Client
- type ClientMiddlewaresConf
- type ClientOption
- func WithDialOption(opt grpc.DialOption) ClientOption
- func WithNonBlock() ClientOption
- func WithStreamClientInterceptor(interceptor grpc.StreamClientInterceptor) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- func WithTransportCredentials(creds credentials.TransportCredentials) ClientOption
- func WithUnaryClientInterceptor(interceptor grpc.UnaryClientInterceptor) ClientOption
- type ClientOptions
- type Logger
- func (l *Logger) Error(args ...any)
- func (l *Logger) Errorf(format string, args ...any)
- func (l *Logger) Errorln(args ...any)
- func (l *Logger) Fatal(args ...any)
- func (l *Logger) Fatalf(format string, args ...any)
- func (l *Logger) Fatalln(args ...any)
- func (l *Logger) Info(_ ...any)
- func (l *Logger) Infof(_ string, _ ...any)
- func (l *Logger) Infoln(_ ...any)
- func (l *Logger) V(v int) bool
- func (l *Logger) Warning(_ ...any)
- func (l *Logger) Warningf(_ string, _ ...any)
- func (l *Logger) Warningln(_ ...any)
- type MethodTimeoutConf
- type RegisterFn
- type Server
- type ServerMiddlewaresConf
- type ServerOption
- type StatConf
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 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.
type MethodTimeoutConf ¶
type MethodTimeoutConf = serverinterceptors.MethodTimeoutConf
MethodTimeoutConf defines specified timeout for gRPC methods.
type RegisterFn ¶
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 ¶
NewRpcPubServer returns a Server.
func NewRpcServer ¶
func NewRpcServer(addr string, 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 WithRpcHealth ¶
func WithRpcHealth(health bool) ServerOption
WithRpcHealth returns a func that sets rpc health switch to a Server.