Documentation ¶
Index ¶
Constants ¶
const ContextKeyHeader = ContextKey("TRPC_GATEWAY_GRPC_HEADER")
ContextKeyHeader is the key for the GRPC header information in the context
const Protocol = "grpc"
Protocol is the protocol name
Variables ¶
var ( // DefaultServerCodec is the default encoding/decoding instance for the server DefaultServerCodec = &ServerCodec{} // DefaultClientCodec is the default encoding/decoding instance for the client DefaultClientCodec = &ClientCodec{} )
var DefaultClientTransport = &ClientTransport{ ConnectionPool: &Pool{}, }
DefaultClientTransport is the default client transport layer
Functions ¶
func WithHeader ¶
WithHeader sets the GRPC header information in the context
Types ¶
type ClientCodec ¶
type ClientCodec struct{}
ClientCodec is the codec for the grpc client, it does nothing
type ClientTransport ¶
type ClientTransport struct { ConnectionPool ConnPool StreamClient grpc.ClientStream }
ClientTransport implements the transport.ClientTransport interface of trpc-go, using native grpc transport layer instead of trpc-go transport layer
func (*ClientTransport) RoundTrip ¶
func (c *ClientTransport) RoundTrip(ctx context.Context, _ []byte, roundTripOpts ...transport.RoundTripOption) (rsp []byte, err error)
RoundTrip is the method that implements transport.ClientTransport, invoking native grpc client code
type ConnPool ¶
type ConnPool interface {
Get(address string, timeout time.Duration) (grpc.ClientConnInterface, error)
}
ConnPool connection pool
type Header ¶
type Header struct { Req []byte // request Rsp []byte // response InMetadata metadata.MD // metadata from client OutMetadata metadata.MD // metadata sent to client }
Header is stored in the context to communicate with trpc
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool implements a simple grpc connection pool
type ServerCodec ¶
type ServerCodec struct{}
ServerCodec is the server-side codec for encoding/decoding