Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultRecoveryHandler(p interface{}) (err error)
- func GetClientIP(ctx context.Context) string
- func SetGrpcLogger()
- func ShouldFail4Code(c codes.Code) bool
- func StreamClientCtxInterceptor() ...
- func StreamClientPerfCounterInterceptor(service string) ...
- func StreamClientTimeOutInterceptor(defaultTimeout time.Duration) ...
- func StreamServerCtxInterceptor() ...
- func StreamServerLoggerInterceptor() grpc.StreamServerInterceptor
- func StreamServerPerfCounterInterceptor(service string) ...
- func UnaryClientCtxInterceptor() func(ctx context.Context, method string, req, reply interface{}, ...) error
- func UnaryClientPerfCounterInterceptor(service string) func(ctx context.Context, method string, req, reply interface{}, ...) error
- func UnaryClientTimeOutInterceptor(defaultTimeout time.Duration) func(ctx context.Context, method string, req, reply interface{}, ...) error
- func UnaryServerCtxInterceptor() ...
- func UnaryServerLoggerInterceptor() grpc.UnaryServerInterceptor
- func UnaryServerPerfCounterInterceptor(service string) ...
- type GrpcClient
- func (c *GrpcClient) DefaultClient() (*grpc.ClientConn, error)
- func (c *GrpcClient) GetCredentialsByCA() (credentials.TransportCredentials, error)
- func (c *GrpcClient) GetRawClient() interface{}
- func (c *GrpcClient) GetTLSCredentials() (credentials.TransportCredentials, error)
- func (c *GrpcClient) Start(makeRawClient func(conn *grpc.ClientConn) (interface{}, error)) error
- func (c *GrpcClient) Stop()
- func (c *GrpcClient) WaitClientReady(ctx context.Context, cc *grpc.ClientConn) error
- type GrpcLogger
- func (l *GrpcLogger) Error(args ...interface{})
- func (l *GrpcLogger) Errorf(format string, args ...interface{})
- func (l *GrpcLogger) Errorln(args ...interface{})
- func (l *GrpcLogger) Fatal(args ...interface{})
- func (l *GrpcLogger) Fatalf(format string, args ...interface{})
- func (l *GrpcLogger) Fatalln(args ...interface{})
- func (l *GrpcLogger) Info(args ...interface{})
- func (l *GrpcLogger) Infof(format string, args ...interface{})
- func (l *GrpcLogger) Infoln(args ...interface{})
- func (l *GrpcLogger) LogWithDepthAndLevel(level dlog.Level, args ...interface{})
- func (l *GrpcLogger) V(level int) bool
- func (l *GrpcLogger) Warning(args ...interface{})
- func (l *GrpcLogger) Warningf(format string, args ...interface{})
- func (l *GrpcLogger) Warningln(args ...interface{})
- type GrpcServer
- type IRegisterHandler
- type InterceptorOption
- func WithClientTimeOutInterceptor(defaultTimeout time.Duration) InterceptorOption
- func WithGlInterceptor() InterceptorOption
- func WithLogInterceptor() InterceptorOption
- func WithPerfCounterInterceptor(service string) InterceptorOption
- func WithRecoveryInterceptor(handler func(p interface{}) (err error)) InterceptorOption
- func WithRetryInterceptor(option ...grpc_retry.CallOption) InterceptorOption
- type OptionHolder
Constants ¶
View Source
const (
DefaultCertServiceName = "gd"
)
View Source
const LogTag = "GRPC_PROCESS"
Variables ¶
View Source
var Logger = &GrpcLogger{}
Functions ¶
func DefaultRecoveryHandler ¶
func DefaultRecoveryHandler(p interface{}) (err error)
func GetClientIP ¶
func SetGrpcLogger ¶
func SetGrpcLogger()
func ShouldFail4Code ¶
func StreamClientCtxInterceptor ¶
func StreamClientCtxInterceptor() func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
func StreamClientPerfCounterInterceptor ¶
func StreamClientPerfCounterInterceptor(service string) func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
func StreamClientTimeOutInterceptor ¶
func StreamClientTimeOutInterceptor(defaultTimeout time.Duration) func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
func StreamServerCtxInterceptor ¶
func StreamServerCtxInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
func StreamServerLoggerInterceptor ¶
func StreamServerLoggerInterceptor() grpc.StreamServerInterceptor
func StreamServerPerfCounterInterceptor ¶
func StreamServerPerfCounterInterceptor(service string) func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
func UnaryClientCtxInterceptor ¶
func UnaryClientCtxInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func UnaryClientPerfCounterInterceptor ¶
func UnaryClientPerfCounterInterceptor(service string) func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func UnaryClientTimeOutInterceptor ¶
func UnaryClientTimeOutInterceptor(defaultTimeout time.Duration) func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func UnaryServerCtxInterceptor ¶
func UnaryServerCtxInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
func UnaryServerLoggerInterceptor ¶
func UnaryServerLoggerInterceptor() grpc.UnaryServerInterceptor
func UnaryServerPerfCounterInterceptor ¶
func UnaryServerPerfCounterInterceptor(service string) func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
Types ¶
type GrpcClient ¶
type GrpcClient struct { Target string ServiceName string Timeout int MaxRetries int PerCallTimeoutInMs int RetryCodes []codes.Code // 指定重试的状态码,默认情况下只有codes.ResourceExhausted, codes.Unavailable才会重试 WaitReady bool UseTls bool CertServerName string GrpcCaPemFile string GrpcClientKeyFile string GrpcClientPemFile string // contains filtered or unexported fields }
func (*GrpcClient) DefaultClient ¶
func (c *GrpcClient) DefaultClient() (*grpc.ClientConn, error)
func (*GrpcClient) GetCredentialsByCA ¶
func (c *GrpcClient) GetCredentialsByCA() (credentials.TransportCredentials, error)
func (*GrpcClient) GetRawClient ¶
func (c *GrpcClient) GetRawClient() interface{}
func (*GrpcClient) GetTLSCredentials ¶
func (c *GrpcClient) GetTLSCredentials() (credentials.TransportCredentials, error)
func (*GrpcClient) Start ¶
func (c *GrpcClient) Start(makeRawClient func(conn *grpc.ClientConn) (interface{}, error)) error
func (*GrpcClient) Stop ¶
func (c *GrpcClient) Stop()
func (*GrpcClient) WaitClientReady ¶
func (c *GrpcClient) WaitClientReady(ctx context.Context, cc *grpc.ClientConn) error
type GrpcLogger ¶
type GrpcLogger struct{}
func (*GrpcLogger) Error ¶
func (l *GrpcLogger) Error(args ...interface{})
func (*GrpcLogger) Errorf ¶
func (l *GrpcLogger) Errorf(format string, args ...interface{})
func (*GrpcLogger) Errorln ¶
func (l *GrpcLogger) Errorln(args ...interface{})
func (*GrpcLogger) Fatal ¶
func (l *GrpcLogger) Fatal(args ...interface{})
func (*GrpcLogger) Fatalf ¶
func (l *GrpcLogger) Fatalf(format string, args ...interface{})
func (*GrpcLogger) Fatalln ¶
func (l *GrpcLogger) Fatalln(args ...interface{})
func (*GrpcLogger) Info ¶
func (l *GrpcLogger) Info(args ...interface{})
func (*GrpcLogger) Infof ¶
func (l *GrpcLogger) Infof(format string, args ...interface{})
func (*GrpcLogger) Infoln ¶
func (l *GrpcLogger) Infoln(args ...interface{})
func (*GrpcLogger) LogWithDepthAndLevel ¶
func (l *GrpcLogger) LogWithDepthAndLevel(level dlog.Level, args ...interface{})
func (*GrpcLogger) V ¶
func (l *GrpcLogger) V(level int) bool
func (*GrpcLogger) Warning ¶
func (l *GrpcLogger) Warning(args ...interface{})
func (*GrpcLogger) Warningf ¶
func (l *GrpcLogger) Warningf(format string, args ...interface{})
func (*GrpcLogger) Warningln ¶
func (l *GrpcLogger) Warningln(args ...interface{})
type GrpcServer ¶
type GrpcServer struct { GrpcRunHost int `inject:"grpcRunHost"` RegisterHandler IRegisterHandler `inject:"registerHandler"` ServiceName string `inject:"serviceName"` UseTls bool `inject:"grpcUseTls" canNil:"true"` GrpcCaPemFile string `inject:"grpcCaPemFile" canNil:"true"` GrpcServerKeyFile string `inject:"grpcServerKeyFile" canNil:"true"` GrpcServerPemFile string `inject:"grpcServerPemFile" canNil:"true"` // contains filtered or unexported fields }
func (*GrpcServer) Close ¶ added in v1.7.2
func (s *GrpcServer) Close()
func (*GrpcServer) DefaultServer ¶
func (s *GrpcServer) DefaultServer() (*grpc.Server, error)
func (*GrpcServer) GetCredentialsByCA ¶
func (s *GrpcServer) GetCredentialsByCA() (credentials.TransportCredentials, error)
func (*GrpcServer) GetTLSCredentials ¶
func (s *GrpcServer) GetTLSCredentials() (credentials.TransportCredentials, error)
func (*GrpcServer) Start ¶ added in v1.7.2
func (s *GrpcServer) Start() error
type IRegisterHandler ¶
type InterceptorOption ¶
type InterceptorOption func(*OptionHolder)
func WithClientTimeOutInterceptor ¶
func WithClientTimeOutInterceptor(defaultTimeout time.Duration) InterceptorOption
func WithGlInterceptor ¶
func WithGlInterceptor() InterceptorOption
func WithLogInterceptor ¶
func WithLogInterceptor() InterceptorOption
func WithPerfCounterInterceptor ¶
func WithPerfCounterInterceptor(service string) InterceptorOption
func WithRecoveryInterceptor ¶
func WithRecoveryInterceptor(handler func(p interface{}) (err error)) InterceptorOption
func WithRetryInterceptor ¶
func WithRetryInterceptor(option ...grpc_retry.CallOption) InterceptorOption
type OptionHolder ¶
type OptionHolder struct { UnaryServerInterceptors []grpc.UnaryServerInterceptor StreamServerInterceptors []grpc.StreamServerInterceptor UnaryClientInterceptors []grpc.UnaryClientInterceptor StreamClientInterceptors []grpc.StreamClientInterceptor }
func GetOptionHolder ¶
func GetOptionHolder(option ...InterceptorOption) *OptionHolder
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
helloworld
Package helloworld is a generated protocol buffer package.
|
Package helloworld is a generated protocol buffer package. |
Click to show internal directories.
Click to hide internal directories.