bsonrpc

package
v2.0.0-alpha3+incompat... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2015 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package bsonrpc provides codecs for bsonrpc communication

Index

Constants

View Source
const DefaultBufferSize = 4096

DefaultBufferSize holds the default value for buffer size

Variables

This section is empty.

Functions

func DialHTTP

func DialHTTP(network, address string, connectTimeout time.Duration) (*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 ServeCustomRPC

func ServeCustomRPC(handler *http.ServeMux, server *rpc.Server)

ServeCustomRPC serves bsonrpc codec with a custom rpc server

func ServeRPC

func ServeRPC()

ServeRPC serves bsonrpc codec with the default 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) Close

func (cc *ClientCodec) Close() error

Close closes the codec

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

type RequestBson struct {
	*rpc.Request
}

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

type ResponseBson struct {
	*rpc.Response
}

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) Close

func (sc *ServerCodec) Close() error

Close closes the codec

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL