grpc

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

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) Close added in v0.0.9

func (gc *Client) Close()

func (*Client) DialContext added in v0.0.9

func (gc *Client) DialContext(ctx context.Context, target string) *grpc.ClientConn

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) 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

type ClientOptions

type ClientOptions struct {
	// contains filtered or unexported fields
}

func NewClientOptions

func NewClientOptions(options ...ClientOptional) *ClientOptions

type Server added in v0.0.9

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

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()

func (*Server) Start added in v0.0.9

func (gs *Server) Start()

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

Jump to

Keyboard shortcuts

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