Documentation ¶
Overview ¶
Package grpc implements gRPC clients. Package grpc also contains implementations for gRPC-Web and gRPC reflection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMutualAuthParamsAreNotEnough = errors.New("cert and certkey are required to authenticate mutually")
Functions ¶
This section is empty.
Types ¶
type BidiStream ¶
type Client ¶
type Client interface { // Invoke invokes a request req to the gRPC server. Then, Invoke decodes the response to res. Invoke(ctx context.Context, fqrn string, req, res interface{}) (header, trailer metadata.MD, _ error) // NewClientStream creates a new client stream. NewClientStream(ctx context.Context, streamDesc *grpc.StreamDesc, fqrn string) (ClientStream, error) // NewServerStream creates a new server stream. NewServerStream(ctx context.Context, streamDesc *grpc.StreamDesc, fqrn string) (ServerStream, error) // NewBidiStream creates a new bidirectional stream. NewBidiStream(ctx context.Context, streamDesc *grpc.StreamDesc, fqrn string) (BidiStream, error) // Close closes all connections the client has. Close(ctx context.Context) error // Header returns all request headers (metadata) Client has. Header() Headers grpcreflection.Client }
Client represents the gRPC client.
func NewClient ¶
func NewClient(addr, serverName string, useReflection, useTLS bool, cacert, cert, certKey string, headers map[string][]string) (Client, error)
NewClient creates a new gRPC client. It dials to the server specified by addr. addr format is the same as the first argument of grpc.Dial. If serverName is not empty, it overrides the gRPC server name used to verify the hostname on the returned certificates. If useReflection is true, the gRPC client enables gRPC reflection. If useTLS is true, the gRPC client establishes a secure connection with the server.
The set of cert and certKey enables mutual authentication if useTLS is enabled. If one of it is not found, NewClient returns ErrMutualAuthParamsAreNotEnough. If useTLS is false, cacert, cert and certKey are ignored.
type ClientStream ¶
type Headers ¶
Headers represents gRPC headers. A key corresponds to one or more values.
type RPC ¶
type RPC struct { Name string FullyQualifiedName string RequestType *Type ResponseType *Type IsServerStreaming bool IsClientStreaming bool }
RPC represents a RPC which belongs to a gRPC service.
type ServerStream ¶
type Type ¶
type Type struct { // Name is the name of Type. Name string // FullyQualifiedName is the name that contains the package name this Type belongs. FullyQualifiedName string // New instantiates a new instance of Type. It is used for decode requests and responses. New func() interface{} }
Type is a type for representing requests/responses.
Directories ¶
Path | Synopsis |
---|---|
Package grpcreflection provides gRPC reflection client.
|
Package grpcreflection provides gRPC reflection client. |