client

package
v0.0.0-...-784d6ec Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

支持连接https+grpc共享端口的版本,也支持非证书版 Usage: conn, err := client.NewClientConn("localhost:63333", "server.crt", "server.grpc.io", grpc.WithPerRPCCredentials(&rpc.X{Value: "abc", Key: "x"})) client := rpc.NewHelloServiceClient(conn)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(httpCtx *hfw.HTTPContext, c configs.GrpcConfig,
	call func(ctx context.Context, conn *grpc.ClientConn) (interface{}, error),
	timeout time.Duration,
) (resp interface{}, err error)

如果有特殊需求,请自行修改 如GetConn里的authValue,这里是空 如GetConn里的grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(52428800))

和grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(52428800))

func GetConn

func GetConn(ctx context.Context, c configs.GrpcConfig, opt ...grpc.DialOption) (conn *grpc.ClientConn, err error)

func GetConnWithAuth

func GetConnWithAuth(ctx context.Context, c configs.GrpcConfig, authValue string, opt ...grpc.DialOption) (conn *grpc.ClientConn, err error)

func NewClientConn

func NewClientConn(ctx context.Context, address string, opt ...grpc.DialOption) (*grpc.ClientConn, error)

func NewClientConnWithSecurity

func NewClientConnWithSecurity(ctx context.Context, address, certFile, serverName string,
	opt ...grpc.DialOption) (*grpc.ClientConn, error)

Types

type ClientCreds

type ClientCreds struct {
	ServerName string
	CaFile     string
	CertFile   string
	KeyFile    string
}

func (*ClientCreds) GetCredentials

func (t *ClientCreds) GetCredentials() (credentials.TransportCredentials, error)

func (*ClientCreds) GetCredentialsByCA

func (t *ClientCreds) GetCredentialsByCA() (credentials.TransportCredentials, error)

func (*ClientCreds) GetTLSCredentials

func (t *ClientCreds) GetTLSCredentials() (credentials.TransportCredentials, error)

Jump to

Keyboard shortcuts

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