grpclient

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProxyAuthorization used by signature, both gateway and grpc
	ProxyAuthorization = "proxy-authorization"
)
View Source
const (
	// Trace ID
	TraceID = "trace-id"
)

Variables

This section is empty.

Functions

func GenerateSign

func GenerateSign(secret string, message []byte) (auth string, err error)

func New

func New(target string, options ...Option) (*grpc.ClientConn, error)

func ProtoMessage2JSON

func ProtoMessage2JSON(message proto.Message) (string, error)

ProtoMessage2JSON marshal protobuf message to json string

func ProtoMessage2Map

func ProtoMessage2Map(message proto.Message) (map[string]interface{}, error)

ProtoMessage2Map marshal protobuf message to map[string]interface{}

Types

type ClientInterceptor

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

ClientInterceptor the client's interceptor

func NewClientInterceptor

func NewClientInterceptor(sign Sign, trace *trace.Trace, grpc *trace.Grpc) *ClientInterceptor

NewClientInterceptor create a client interceptor

func (*ClientInterceptor) UnaryInterceptor

func (c *ClientInterceptor) UnaryInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err error)

UnaryInterceptor a interceptor for client unary operations

type Option

type Option func(*option)

func WithCredential

func WithCredential(credential credentials.TransportCredentials) Option

WithCredential setup credential for tls

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) Option

WithDialTimeout setup the dial timeout

func WithKeepAlive

func WithKeepAlive(keepalive *keepalive.ClientParameters) Option

WithKeepAlive setup keepalive parameters

func WithSign

func WithSign(sign Sign) Option

WithSign setup the signature handler

func WithTrace

func WithTrace(t Trace) Option

WithTrace setup trace info

type Sign

type Sign func(message []byte) (auth string, err error)

type Trace

type Trace = trace.T

Jump to

Keyboard shortcuts

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