client

package
v5.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2019 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultName prefix client name
	DefaultName = "client"
)

Variables

This section is empty.

Functions

func WrapperStreamClient

func WrapperStreamClient(interceptors ...grpc.StreamClientInterceptor) grpc.StreamClientInterceptor

WrapperStreamClient creates a single interceptor out of a chain of many interceptors Execution is done in right-to-left order

func WrapperUnaryClient

func WrapperUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor

WrapperUnaryClient creates a single interceptor out of a chain of many interceptors Execution is done in right-to-left order

Types

type Client

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

A Client defines parameters for making calls to an HTTP server. The zero value for Client is a valid configuration.

func New

func New(opts ...Option) *Client

New create a new client

func (*Client) Close

func (c *Client) Close() error

Close not implemented

func (*Client) Dial

func (c *Client) Dial(opts ...Option) (*grpc.ClientConn, error)

Dial create a gRPC channel to communicate with the server

func (*Client) Health

func (c *Client) Health() *healthpb.HealthCheckResponse

Health health check on client take in consideration a round trip to a server

func (*Client) Init

func (c *Client) Init(opts ...Option)

Init initialize logger and interceptors

func (*Client) Name

func (c *Client) Name() string

Name returns client name

func (*Client) Stub

func (c *Client) Stub(conn *grpc.ClientConn) interface{}

Stub to perform RPCs

func (*Client) WithOptions

func (c *Client) WithOptions(opts ...Option) *Client

WithOptions clones the current Client, applies the supplied Options, and returns the resulting Client. It's safe to use concurrently.

type ClientStreamWithContext

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

func WrapClientStreamWithContext

func WrapClientStreamWithContext(stream grpc.ClientStream) *ClientStreamWithContext

WrapClientStreamWithContext returns a ClientStream that has the ability to overwrite context.

func (*ClientStreamWithContext) CloseSend

func (w *ClientStreamWithContext) CloseSend() error

func (*ClientStreamWithContext) Context

Stream interface

func (*ClientStreamWithContext) Header

func (w *ClientStreamWithContext) Header() (metadata.MD, error)

ClientStream interface

func (*ClientStreamWithContext) RecvMsg

func (w *ClientStreamWithContext) RecvMsg(msg interface{}) error

func (*ClientStreamWithContext) SendMsg

func (w *ClientStreamWithContext) SendMsg(msg interface{}) error

func (*ClientStreamWithContext) SetContext

func (w *ClientStreamWithContext) SetContext(ctx context.Context)

func (*ClientStreamWithContext) Trailer

func (w *ClientStreamWithContext) Trailer() metadata.MD

type Config

type Config struct {
	ID           string
	Name         string
	Description  string
	Target       string // TCP address (e.g. localhost:8000) to listen on, ":http" if empty
	Format       string
	GRPCRegister func(*grpc.ClientConn) interface{}
	Timeout      time.Duration

	UnaryClientInterceptors  []grpc.UnaryClientInterceptor  // gRPC interceptors
	StreamClientInterceptors []grpc.StreamClientInterceptor // gRPC interceptors
	// contains filtered or unexported fields
}

Config client configuaration options

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used to set options for the service.

func Description

func Description(d string) Option

Description client description

func GRPCRegister

func GRPCRegister(fn func(*grpc.ClientConn) interface{}) Option

GRPCRegister register client gRPC function

func ID

func ID(id string) Option

ID client id

func Logger

func Logger(l zerolog.Logger) Option

Logger sets a shallow copy from an input logger

func Name

func Name(n string) Option

Name client name

func StreamClientInterceptors

func StreamClientInterceptors(uci []grpc.StreamClientInterceptor) Option

StreamClientInterceptors ...

func Target

func Target(t string) Option

Target server address

func Timeout

func Timeout(d time.Duration) Option

Timeout returns an Option that configures a timeout for dialing a ClientConn initially. This is valid if and only if WithBlock() is present.

func UnaryClientInterceptors

func UnaryClientInterceptors(uci []grpc.UnaryClientInterceptor) Option

UnaryClientInterceptors ...

Jump to

Keyboard shortcuts

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