Documentation
¶
Index ¶
- Constants
- func EncodeHeader(h Header) []byte
- func EncodeRequest(service, method string, req any) ([]byte, error)
- func EncodeResponse(code int32, message string, resp any) ([]byte, error)
- func WriteFrame(w io.Writer, requestID uint64, frameType FrameType, payload []byte) error
- type Client
- type ClientPool
- type ClientPoolConfig
- type ClientStream
- type FrameType
- type Header
- type MethodHandler
- type Registry
- type Request
- type Response
- type Server
- type StreamFunc
- type StreamServer
- type UnaryFunc
Constants ¶
View Source
const ( HeaderLength = 17 MaxPayloadLength = 4 * 1024 * 1024 )
View Source
const ( CodeOK int32 = 0 CodeBadRequest int32 = 100 CodeMethodNotFound int32 = 101 CodeError int32 = 102 )
Variables ¶
This section is empty.
Functions ¶
func EncodeHeader ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
unary
func (*Client) NewClientStream ¶
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
func NewClientPool ¶
func NewClientPool(cnf *ClientPoolConfig) (*ClientPool, error)
func (*ClientPool) Get ¶
func (c *ClientPool) Get() (*Client, error)
type ClientPoolConfig ¶
type ClientStream ¶
type ClientStream struct {
// contains filtered or unexported fields
}
stream
func (*ClientStream) Recv ¶
func (s *ClientStream) Recv(resp any) error
type Header ¶
func DecodeHeader ¶
type MethodHandler ¶
type MethodHandler struct {
UnaryHandler UnaryFunc
StreamHandler StreamFunc
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) LookupStream ¶
func (r *Registry) LookupStream(service, method string) (StreamFunc, bool)
func (*Registry) LookupUnary ¶
type Request ¶
type Request struct {
Service string `json:"service"`
Method string `json:"method"`
Request json.RawMessage `json:"request"`
}
type Response ¶
type Response struct {
Code int32 `json:"code"`
Message string `json:"message"`
Response json.RawMessage `json:"response"`
}
func DecodeResponse ¶
type StreamFunc ¶
type StreamFunc func(ctx context.Context, req json.RawMessage, stream *StreamServer) error
type StreamServer ¶
type StreamServer struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.