msg

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package msg is not for public use.

The API for packages in the 'private' directory have no stability guarantee.

The packages within the 'private' directory would normally be put into an 'internal' directory to prohibit their use outside the 'mongo' directory. However, some MongoDB tools require very low-level access to the building blocks of a driver, so we have placed them under 'private' to allow these packages to be imported by projects that need them.

These package APIs may be modified in backwards-incompatible ways at any time.

You are strongly discouraged from directly using any packages under 'private'.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMeta

func AddMeta(r Request, meta map[string]*bson.Document) error

AddMeta wraps the query with meta data.

func CurrentRequestID

func CurrentRequestID() int32

CurrentRequestID gets the current request id.

func NextRequestID

func NextRequestID() int32

NextRequestID gets the next request id.

Types

type Codec

type Codec interface {
	Encoder
	Decoder
}

Codec encodes and decodes messages.

func NewWireProtocolCodec

func NewWireProtocolCodec() Codec

NewWireProtocolCodec creates a MessageReadWriter for the binary message format.

type Decoder

type Decoder interface {
	// Decode decodes one message from the reader.
	Decode(io.Reader) (Message, error)
}

Decoder decodes messages.

type Encoder

type Encoder interface {
	// Encode encodes a number of messages to the writer.
	Encode(io.Writer, ...Message) error
}

Encoder encodes messages.

type Message

type Message interface {
	// contains filtered or unexported methods
}

Message represents a MongoDB message.

type Query

type Query struct {
	ReqID                int32
	Flags                QueryFlags
	FullCollectionName   string
	NumberToSkip         int32
	NumberToReturn       int32
	Query                interface{}
	ReturnFieldsSelector interface{}
}

Query is a message sent to the server.

func (*Query) RequestID

func (m *Query) RequestID() int32

RequestID gets the request id of the message.

type QueryFlags

type QueryFlags int32

QueryFlags are the flags in a Query.

const (
	TailableCursor QueryFlags
	SlaveOK
	OplogReplay
	NoCursorTimeout
	AwaitData
	Exhaust
	Partial
)

QueryFlags constants.

type Reply

type Reply struct {
	ReqID          int32
	RespTo         int32
	ResponseFlags  ReplyFlags
	CursorID       int64
	StartingFrom   int32
	NumberReturned int32
	DocumentsBytes []byte
}

Reply is a message received from the server.

func (*Reply) Iter

func (m *Reply) Iter() *ReplyIter

Iter returns a ReplyIter to iterate over each document returned by the server.

func (*Reply) ResponseTo

func (m *Reply) ResponseTo() int32

ResponseTo gets the request id the message was in response to.

type ReplyFlags

type ReplyFlags int32

ReplyFlags are the flags in a Reply.

const (
	CursorNotFound ReplyFlags = 1 << iota
	QueryFailure

	AwaitCapable
)

ReplayMessageFlags constants.

type ReplyIter

type ReplyIter struct {
	// contains filtered or unexported fields
}

ReplyIter iterates over the documents returned in a Reply.

func (*ReplyIter) Err

func (i *ReplyIter) Err() error

Err indicates if there was an error unmarshalling the last document attempted.

func (*ReplyIter) NextBytes

func (i *ReplyIter) NextBytes() (bson.Reader, error)

NextBytes reads the next document and returns it as a bson.Reader.

type Request

type Request interface {
	Message
	RequestID() int32
}

Request is a message sent to the server.

func NewCommand

func NewCommand(requestID int32, dbName string, slaveOK bool, cmd interface{}) Request

NewCommand creates a new RequestMessage to be set as a command.

type Response

type Response interface {
	Message
	ResponseTo() int32
}

Response is a message received from the server.

Jump to

Keyboard shortcuts

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