Documentation ¶
Overview ¶
Package bsonrpc provides codecs for bsonrpc communication
Index ¶
- Constants
- func DialAuthHTTP(network, address, user, password string, connectTimeout time.Duration, ...) (*rpc.Client, error)
- func DialHTTP(network, address string, connectTimeout time.Duration, config *tls.Config) (*rpc.Client, error)
- func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
- func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec
- func ServeAuthRPC()
- func ServeCustomRPC(handler *http.ServeMux, server *rpc.Server, useAuth bool)
- func ServeRPC()
- type ClientCodec
- type RequestBson
- type ResponseBson
- type ServerCodec
Constants ¶
const DefaultBufferSize = 4096
DefaultBufferSize holds the default value for buffer size
Variables ¶
This section is empty.
Functions ¶
func DialAuthHTTP ¶
func DialAuthHTTP(network, address, user, password string, connectTimeout time.Duration, config *tls.Config) (*rpc.Client, error)
DialAuthHTTP dials a HTTP endpoint with bsonrpc codec as authentication enabled
func DialHTTP ¶
func DialHTTP(network, address string, connectTimeout time.Duration, config *tls.Config) (*rpc.Client, error)
DialHTTP dials a HTTP endpoint with bsonrpc codec
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
NewClientCodec creates a new client codec for bsonrpc communication
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser) rpc.ServerCodec
NewServerCodec creates a new server codec for bsonrpc communication
func ServeAuthRPC ¶
func ServeAuthRPC()
ServeAuthRPC serves bsonrpc codec with the default authentication enabled rpc server
func ServeCustomRPC ¶
ServeCustomRPC serves bsonrpc codec with a custom rpc server
Types ¶
type ClientCodec ¶
type ClientCodec struct {
// contains filtered or unexported fields
}
ClientCodec holds required parameters for providing a client codec for bsonrpc
func (*ClientCodec) ReadResponseBody ¶
func (cc *ClientCodec) ReadResponseBody(body interface{}) error
ReadResponseBody reads the body of server response
func (*ClientCodec) ReadResponseHeader ¶
func (cc *ClientCodec) ReadResponseHeader(r *rpc.Response) error
ReadResponseHeader reads the header of server response
func (*ClientCodec) WriteRequest ¶
func (cc *ClientCodec) WriteRequest(r *rpc.Request, body interface{}) error
WriteRequest sends the request to the server
type RequestBson ¶
RequestBson provides bson rpc request parameters
func (*RequestBson) MarshalBson ¶
func (req *RequestBson) MarshalBson(buf *bytes2.ChunkedWriter, key string)
MarshalBson marshals request to the given writer with optional prefix
func (*RequestBson) UnmarshalBson ¶
func (req *RequestBson) UnmarshalBson(buf *bytes.Buffer, kind byte)
UnmarshalBson unmarshals request to the given byte buffer as verifying the kind
type ResponseBson ¶
ResponseBson provides bson rpc request parameters
func (*ResponseBson) MarshalBson ¶
func (resp *ResponseBson) MarshalBson(buf *bytes2.ChunkedWriter, key string)
MarshalBson marshals response to the given writer with optional prefix
func (*ResponseBson) UnmarshalBson ¶
func (resp *ResponseBson) UnmarshalBson(buf *bytes.Buffer, kind byte)
UnmarshalBson unmarshals response to the given byte buffer as verifying the kind
type ServerCodec ¶
type ServerCodec struct {
// contains filtered or unexported fields
}
ServerCodec holds required parameters for providing a server codec for bsonrpc
func (*ServerCodec) ReadRequestBody ¶
func (sc *ServerCodec) ReadRequestBody(body interface{}) error
ReadRequestBody reads the body of the request
func (*ServerCodec) ReadRequestHeader ¶
func (sc *ServerCodec) ReadRequestHeader(r *rpc.Request) error
ReadRequestHeader reads the header of the request
func (*ServerCodec) WriteResponse ¶
func (sc *ServerCodec) WriteResponse(r *rpc.Response, body interface{}, last bool) error
WriteResponse send the response of the request to the client