Documentation ¶
Index ¶
- Variables
- func ClientStubs(...) func(ctx context.Context, method string, req, reply interface{}, ...) error
- func ServerStubs(...) grpc.UnaryServerInterceptor
- type Client
- type ClientConn
- type ClientOptional
- type ClientOptionals
- func (ClientOptionals) WithConf(conf config.Config) ClientOptional
- func (ClientOptionals) WithDialOptions(options ...grpc.DialOption) ClientOptional
- func (ClientOptionals) WithLogger(logger log.Logger) ClientOptional
- func (ClientOptionals) WithMetrics(metrics *ggp.ClientMetrics) ClientOptional
- func (ClientOptionals) WithTracer(tracer opentracing2.Tracer) ClientOptional
- type ClientOptions
- type Server
- type ServerOption
- type ServerOptions
- func (ServerOptions) WithServerConf(conf config.Config) ServerOption
- func (ServerOptions) WithServerLogger(logger log.Logger) ServerOption
- func (ServerOptions) WithServerOption(options ...grpc.ServerOption) ServerOption
- func (ServerOptions) WithTracer(tracer opentracing2.Tracer) ServerOption
- func (ServerOptions) WithUnarySrvItcp(options ...grpc.UnaryServerInterceptor) ServerOption
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalStub func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
GlobalStub is test double and it is used when we cannot or don’t want to involve real server. Instead of the real server, we introduced a stub and defined what data should be returned. Example: func(ctx context.Context,
method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { if method == "/helloworld.Greeter/SayHello" { reply.(*pb.HelloReply).Message = "hello" } return nil }
Functions ¶
func ClientStubs ¶
func ClientStubs(stubsFunc func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error) func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func ServerStubs ¶
func ServerStubs(stubsFunc func( ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (resp interface{}, err error)) grpc.UnaryServerInterceptor
Types ¶
type Client ¶ added in v0.0.9
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(clientOptions *ClientOptions) *Client
NewClient create Client for business. clientOptions clientOptions can not nil. Deprecated: use NewClientWithOptionals instead.
func NewClientWithOptionals ¶ added in v0.1.4
func NewClientWithOptionals(options ...ClientOptional) *Client
func (*Client) DialContext ¶ added in v0.0.9
type ClientConn ¶
type ClientConn struct {
// contains filtered or unexported fields
}
Collect the grpc.ClientConn instances.
func NewClientConn ¶
func NewClientConn(logger log.Logger) *ClientConn
func (*ClientConn) Close ¶
func (cc *ClientConn) Close()
Close unity closes the grpc.ClientConn instances.
func (*ClientConn) CollectConn ¶
func (cc *ClientConn) CollectConn(conn *grpc.ClientConn)
Examples:
client := grpc.NewClient(clientOptions) ctx := context.Background() conn := client.DialContext(ctx, ":50051") clientConn := NewClientConn() clientConn.CollectConn(conn).
func (*ClientConn) State ¶
func (cc *ClientConn) State() []string
State unity show the grpc.ClientConn state.
type ClientOptional ¶
type ClientOptional func(c *ClientOptions)
type ClientOptionals ¶
type ClientOptionals struct{}
func (ClientOptionals) WithConf ¶
func (ClientOptionals) WithConf(conf config.Config) ClientOptional
func (ClientOptionals) WithDialOptions ¶
func (ClientOptionals) WithDialOptions(options ...grpc.DialOption) ClientOptional
func (ClientOptionals) WithLogger ¶
func (ClientOptionals) WithLogger(logger log.Logger) ClientOptional
func (ClientOptionals) WithMetrics ¶
func (ClientOptionals) WithMetrics(metrics *ggp.ClientMetrics) ClientOptional
func (ClientOptionals) WithTracer ¶
func (ClientOptionals) WithTracer(tracer opentracing2.Tracer) ClientOptional
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
func NewClientOptions ¶
func NewClientOptions(options ...ClientOptional) *ClientOptions
type Server ¶ added in v0.0.9
func NewServer ¶ added in v0.0.9
func NewServer(target string, options ...ServerOption) *Server
func (*Server) GracefulShutDown ¶ added in v0.0.9
func (gs *Server) GracefulShutDown()
type ServerOption ¶
type ServerOption func(c *Server)
type ServerOptions ¶
type ServerOptions struct{}
func (ServerOptions) WithServerConf ¶
func (ServerOptions) WithServerConf(conf config.Config) ServerOption
func (ServerOptions) WithServerLogger ¶
func (ServerOptions) WithServerLogger(logger log.Logger) ServerOption
func (ServerOptions) WithServerOption ¶ added in v0.0.9
func (ServerOptions) WithServerOption(options ...grpc.ServerOption) ServerOption
func (ServerOptions) WithTracer ¶
func (ServerOptions) WithTracer(tracer opentracing2.Tracer) ServerOption
func (ServerOptions) WithUnarySrvItcp ¶
func (ServerOptions) WithUnarySrvItcp(options ...grpc.UnaryServerInterceptor) ServerOption
Click to show internal directories.
Click to hide internal directories.