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 ¶
- func Do(httpCtx *hfw.HTTPContext, c configs.GrpcConfig, ...) (resp interface{}, err error)
- func GetConn(ctx context.Context, c configs.GrpcConfig, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
- func GetConnWithAuth(ctx context.Context, c configs.GrpcConfig, authValue string, ...) (conn *grpc.ClientConn, err error)
- func GetConnWithDefaultInterceptor(ctx context.Context, c configs.GrpcConfig, opts ...grpc.DialOption) (conn *grpc.ClientConn, err error)
- func NewClientConn(ctx context.Context, address string, opt ...grpc.DialOption) (*grpc.ClientConn, error)
- func NewClientConnWithSecurity(ctx context.Context, address, certFile, serverName string, ...) (*grpc.ClientConn, error)
- func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (cs grpc.ClientStream, err error)
- func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) (err error)
- type ClientCreds
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 ¶
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)
Click to show internal directories.
Click to hide internal directories.