Documentation
¶
Index ¶
- func AsHTTPBodyReader(stream grpc.ServerStream, msg proto.Message) (body io.Reader, err error)
- func AsHTTPBodyWriter(stream grpc.ServerStream, msg proto.Message) (body io.Writer, err error)
- func HTTPStatusCode(c codes.Code) int
- func NewOSSignalContext(ctx context.Context) (context.Context, func())
- func NewServer(mux *Mux, opts ...ServerOption) (*http.Server, error)
- func NewStreamContext(ctxFn NewContextFunc) grpc.StreamServerInterceptor
- func NewUnaryContext(ctxFn NewContextFunc) grpc.UnaryServerInterceptor
- func WSStatusCode(c codes.Code) ws.StatusCode
- type Codec
- type CodecJSON
- func (c CodecJSON) Marshal(v interface{}) ([]byte, error)
- func (c CodecJSON) MarshalAppend(b []byte, v interface{}) ([]byte, error)
- func (CodecJSON) Name() string
- func (c CodecJSON) ReadNext(b []byte, r io.Reader, limit int) ([]byte, int, error)
- func (c CodecJSON) Unmarshal(data []byte, v interface{}) error
- func (c CodecJSON) WriteNext(w io.Writer, b []byte) (int, error)
- type CodecProto
- func (c CodecProto) Marshal(v interface{}) ([]byte, error)
- func (c CodecProto) MarshalAppend(b []byte, v interface{}) ([]byte, error)
- func (CodecProto) Name() string
- func (c CodecProto) ReadNext(b []byte, r io.Reader, limit int) ([]byte, int, error)
- func (CodecProto) Unmarshal(data []byte, v interface{}) error
- func (c CodecProto) WriteNext(w io.Writer, b []byte) (int, error)
- type Compressor
- type CompressorGzip
- type Mux
- func (m *Mux) DropConn(ctx context.Context, cc *grpc.ClientConn) bool
- func (m *Mux) RegisterConn(ctx context.Context, cc *grpc.ClientConn) error
- func (m *Mux) RegisterReflectionServer(s *grpc.Server)
- func (m *Mux) RegisterService(sd *grpc.ServiceDesc, ss interface{})
- func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type MuxOption
- func CodecOption(contentType string, c Codec) MuxOption
- func CompressorOption(contentEncoding string, c Compressor) MuxOption
- func ConnectionTimeoutOption(d time.Duration) MuxOption
- func FilesOption(f *protoregistry.Files) MuxOption
- func MaxReceiveMessageSizeOption(s int) MuxOption
- func MaxSendMessageSizeOption(s int) MuxOption
- func ServiceConfigOption(sc *serviceconfig.Service) MuxOption
- func StatsOption(h stats.Handler) MuxOption
- func StreamServerInterceptorOption(interceptor grpc.StreamServerInterceptor) MuxOption
- func TypesOption(t protoregistry.MessageTypeResolver) MuxOption
- func UnaryServerInterceptorOption(interceptor grpc.UnaryServerInterceptor) MuxOption
- type NewContextFunc
- type ServerOption
- type StreamCodec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsHTTPBodyReader ¶ added in v0.3.1
AsHTTPBodyReader returns the reader of a stream of google.api.HttpBody. The first message will be unmarshalled into msg excluding the data field. The returned reader is only valid during the lifetime of the RPC.
func AsHTTPBodyWriter ¶ added in v0.3.1
AsHTTPBodyWriter returns the writer of a stream of google.api.HttpBody. The first message will be marshalled from msg excluding the data field. The returned writer is only valid during the lifetime of the RPC.
func HTTPStatusCode ¶
func NewOSSignalContext ¶
NewOSSignalContext tries to gracefully handle OS closure.
func NewServer ¶
func NewServer(mux *Mux, opts ...ServerOption) (*http.Server, error)
NewServer creates a new http.Server with http2 support. The server is configured with the given options. It is a convenience function for creating a new http.Server.
func NewStreamContext ¶
func NewStreamContext(ctxFn NewContextFunc) grpc.StreamServerInterceptor
NewStreamContext returns a StreamServerInterceptor that calls ctxFn to create a new context for each request.
func NewUnaryContext ¶
func NewUnaryContext(ctxFn NewContextFunc) grpc.UnaryServerInterceptor
NewUnaryContext returns a UnaryServerInterceptor that calls ctxFn to create a new context for each request.
func WSStatusCode ¶
func WSStatusCode(c codes.Code) ws.StatusCode
Types ¶
type Codec ¶
type Codec interface { encoding.Codec // MarshalAppend appends the marshaled form of v to b and returns the result. MarshalAppend([]byte, interface{}) ([]byte, error) }
Codec defines the interface used to encode and decode messages.
type CodecJSON ¶
type CodecJSON struct { protojson.MarshalOptions protojson.UnmarshalOptions }
CodecJSON is a Codec implementation with protobuf json format.
func (CodecJSON) MarshalAppend ¶
type CodecProto ¶
type CodecProto struct {
proto.MarshalOptions
}
CodecProto is a Codec implementation with protobuf binary format.
func (CodecProto) Marshal ¶
func (c CodecProto) Marshal(v interface{}) ([]byte, error)
func (CodecProto) MarshalAppend ¶
func (c CodecProto) MarshalAppend(b []byte, v interface{}) ([]byte, error)
func (CodecProto) Name ¶
func (CodecProto) Name() string
Name == "proto" overwritting internal proto codec
func (CodecProto) ReadNext ¶ added in v0.2.0
ReadNext reads a varint size-delimited wire-format message from r.
func (CodecProto) Unmarshal ¶
func (CodecProto) Unmarshal(data []byte, v interface{}) error
type Compressor ¶ added in v0.3.0
type Compressor interface { encoding.Compressor }
Compressor is used to compress and decompress messages. Based on grpc/encoding.
type CompressorGzip ¶ added in v0.3.0
type CompressorGzip struct { Level *int // contains filtered or unexported fields }
CompressorGzip implements the Compressor interface. Based on grpc/encoding/gzip.
func (*CompressorGzip) Compress ¶ added in v0.3.0
func (c *CompressorGzip) Compress(w io.Writer) (io.WriteCloser, error)
Compress implements the Compressor interface.
func (*CompressorGzip) Decompress ¶ added in v0.3.0
Decompress implements the Compressor interface.
func (*CompressorGzip) Name ¶ added in v0.3.0
func (*CompressorGzip) Name() string
Name returns gzip.
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
func (*Mux) RegisterConn ¶
func (*Mux) RegisterReflectionServer ¶
RegisterReflectionServer registers the server reflection service for multiple proxied gRPC servers. Each individual reflection stream is merged to provide a consistent view at the point of stream creation.
func (*Mux) RegisterService ¶
func (m *Mux) RegisterService(sd *grpc.ServiceDesc, ss interface{})
RegisterService satisfies grpc.ServiceRegistrar for generated service code hooks.
type MuxOption ¶
type MuxOption func(*muxOptions)
MuxOption is an option for a mux.
func CodecOption ¶
CodecOption registers a codec for the given content type.
func CompressorOption ¶ added in v0.3.0
func CompressorOption(contentEncoding string, c Compressor) MuxOption
CompressorOption registers a compressor for the given content encoding.
func ConnectionTimeoutOption ¶
func FilesOption ¶
func FilesOption(f *protoregistry.Files) MuxOption
func ServiceConfigOption ¶
func ServiceConfigOption(sc *serviceconfig.Service) MuxOption
ServiceConfigOption sets the service config for the mux. Currently only http rules will be used to annotate services.
func StatsOption ¶
func StreamServerInterceptorOption ¶
func StreamServerInterceptorOption(interceptor grpc.StreamServerInterceptor) MuxOption
func TypesOption ¶
func TypesOption(t protoregistry.MessageTypeResolver) MuxOption
func UnaryServerInterceptorOption ¶
func UnaryServerInterceptorOption(interceptor grpc.UnaryServerInterceptor) MuxOption
type NewContextFunc ¶
type NewContextFunc func(ctx context.Context, fullMethod string, isClientStream, isServerStream bool) context.Context
NewContextFunc is a function that creates a new context for a request. The returned context is used for the duration of the request.
type ServerOption ¶
type ServerOption func(*serverOptions) error
ServerOption is similar to grpc.ServerOption.
func HTTPHandlerOption ¶
func HTTPHandlerOption(pattern string, handler http.Handler) ServerOption
func MuxHandleOption ¶
func MuxHandleOption(patterns ...string) ServerOption
func TLSCredsOption ¶
func TLSCredsOption(c *tls.Config) ServerOption
type StreamCodec ¶ added in v0.2.0
type StreamCodec interface { Codec // ReadNext returns the size of the next message appended to buf. // ReadNext reads from r until either it has read a complete message or // encountered an error and returns all the data read from r. // The message is contained in dst[:n]. // Excess data read from r is stored in dst[n:]. ReadNext(buf []byte, r io.Reader, limit int) (dst []byte, n int, err error) // WriteNext writes the message to w with a size aware encoding // returning the number of bytes written. WriteNext(w io.Writer, src []byte) (n int, err error) }
StreamCodec is used in streaming RPCs where the message boundaries are determined by the codec.