client

package
v0.0.0-...-5870b03 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: GPL-3.0 Imports: 25 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, opts ...grpc.DialOption,
) (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, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)

func GetConnWithAuth

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

func GetConnWithDefaultInterceptor

func GetConnWithDefaultInterceptor(ctx context.Context, c configs.GrpcConfig, opts ...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)

func StreamClientInterceptor

func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string,
	streamer grpc.Streamer, opts ...grpc.CallOption) (cs grpc.ClientStream, err error)

func UnaryClientInterceptor

func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{},
	cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) (err 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