Documentation
¶
Index ¶
- Constants
- func DumpMsgBody(body MsgBody) string
- func DumpMsgHeader(header *MsgHeader) string
- func ReadMessage(r *bufio.Reader) (*MsgHeader, MsgBody, error)
- func WriteMessage(w *bufio.Writer, header *MsgHeader, msg MsgBody) error
- type MsgBody
- type MsgHeader
- type OpCode
- type OpMsg
- type OpMsgFlagBit
- type OpMsgFlags
- type OpMsgSection
- type OpQuery
- type OpQueryFlagBit
- type OpQueryFlags
- type OpReply
- type OpReplyFlagBit
- type OpReplyFlags
Constants ¶
const ( OP_REPLY = OpCode(1) // OP_REPLY OP_UPDATE = OpCode(2001) // OP_UPDATE OP_INSERT = OpCode(2002) // OP_INSERT OP_GET_BY_OID = OpCode(2003) // OP_GET_BY_OID OP_QUERY = OpCode(2004) // OP_QUERY OP_GET_MORE = OpCode(2005) // OP_GET_MORE OP_DELETE = OpCode(2006) // OP_DELETE OP_KILL_CURSORS = OpCode(2007) // OP_KILL_CURSORS OP_COMPRESSED = OpCode(2012) // OP_COMPRESSED OP_MSG = OpCode(2013) // OP_MSG )
const ( MsgHeaderLen = 16 MaxMsgLen = 48000000 )
const ( OpMsgChecksumPresent = OpMsgFlagBit(1 << 0) // checksumPresent OpMsgMoreToCome = OpMsgFlagBit(1 << 1) // moreToCome OpMsgExhaustAllowed = OpMsgFlagBit(1 << 16) // exhaustAllowed )
const ( OpQueryTailableCursor = OpQueryFlagBit(1 << 1) // TailableCursor OpQuerySlaveOk = OpQueryFlagBit(1 << 2) // SlaveOk OpQueryOplogReplay = OpQueryFlagBit(1 << 3) // OplogReplay OpQueryNoCursorTimeout = OpQueryFlagBit(1 << 4) // NoCursorTimeout OpQueryAwaitData = OpQueryFlagBit(1 << 5) // AwaitData OpQueryExhaust = OpQueryFlagBit(1 << 6) // Exhaust OpQueryPartial = OpQueryFlagBit(1 << 7) // Partial )
const ( OpReplyCursorNotFound = OpReplyFlagBit(1 << 0) // CursorNotFound OpReplyQueryFailure = OpReplyFlagBit(1 << 1) // QueryFailure OpReplyShardConfigStale = OpReplyFlagBit(1 << 2) // ShardConfigStale OpReplyAwaitCapable = OpReplyFlagBit(1 << 3) // AwaitCapable )
Variables ¶
This section is empty.
Functions ¶
func DumpMsgBody ¶
DumpMsgBody takes a MsgBody and returns as a string.
func DumpMsgHeader ¶
DumpMsgHeader takes a MsgHeader and returns as a string.
Types ¶
type MsgBody ¶
type MsgBody interface {
encoding.BinaryUnmarshaler
encoding.BinaryMarshaler
json.Marshaler
// contains filtered or unexported methods
}
type MsgHeader ¶
MsgHeader in general, each message consists of a standard message header followed by request-specific data.
func (*MsgHeader) MarshalBinary ¶
MarshalBinary writes a MsgHeader to a byte array.
type OpMsg ¶
type OpMsg struct {
FlagBits OpMsgFlags
Checksum uint32
// contains filtered or unexported fields
}
OpMsg is an extensible message format designed to subsume the functionality of other opcodes.
func (*OpMsg) MarshalBinary ¶
MarshalBinary writes an OpMsg to a byte array.
func (*OpMsg) MarshalJSON ¶
MarshalJSON writes an OpMsg in JSON format to a byte array.
func (*OpMsg) SetSections ¶
func (msg *OpMsg) SetSections(sections ...OpMsgSection) error
SetSections of the OpMsg.
func (*OpMsg) UnmarshalBinary ¶
UnmarshalBinary reads an OpMsg from a byte array.
type OpMsgFlagBit ¶
type OpMsgFlagBit flagBit
OpMsgFlagBit integer is a bitmask encoding flags that modify the format and behavior of OpMsg.
func (OpMsgFlagBit) MarshalJSON ¶
func (i OpMsgFlagBit) MarshalJSON() ([]byte, error)
func (OpMsgFlagBit) String ¶
func (i OpMsgFlagBit) String() string
type OpMsgFlags ¶
type OpMsgFlags flags
OpMsgFlags type unint32.
func (OpMsgFlags) FlagSet ¶
func (f OpMsgFlags) FlagSet(bit OpMsgFlagBit) bool
FlagSet check if flag is set.
func (OpMsgFlags) MarshalJSON ¶
func (f OpMsgFlags) MarshalJSON() ([]byte, error)
MarshalJSON writes the OpMsgFlag in JSON format to a byte array.
func (OpMsgFlags) String ¶
func (f OpMsgFlags) String() string
String returns OpMsgFlags as a string.
type OpMsgSection ¶
OpMsgSection is one or more sections contained in an OpMsg.
type OpQuery ¶
type OpQuery struct {
Flags OpQueryFlags
FullCollectionName string
NumberToSkip int32
NumberToReturn int32
Query types.Document
ReturnFieldsSelector *types.Document
}
OpQuery is used to query the database for documents in a collection.
func (*OpQuery) MarshalBinary ¶
MarshalBinary writes an OpQuery to a byte array.
func (*OpQuery) MarshalJSON ¶
MarshalBinary writes an OpQuery in JSON format to byte array.
func (*OpQuery) UnmarshalBinary ¶
UnmarshalBinary reads an OpQuery from a byte array.
type OpQueryFlagBit ¶
type OpQueryFlagBit flagBit
func (OpQueryFlagBit) MarshalJSON ¶
func (i OpQueryFlagBit) MarshalJSON() ([]byte, error)
func (OpQueryFlagBit) String ¶
func (i OpQueryFlagBit) String() string
type OpQueryFlags ¶
type OpQueryFlags flags
func (OpQueryFlags) FlagSet ¶
func (f OpQueryFlags) FlagSet(bit OpQueryFlagBit) bool
func (OpQueryFlags) MarshalJSON ¶
func (f OpQueryFlags) MarshalJSON() ([]byte, error)
func (OpQueryFlags) String ¶
func (f OpQueryFlags) String() string
type OpReply ¶
type OpReply struct {
ResponseFlags OpReplyFlags
CursorID int64
StartingFrom int32
NumberReturned int32
Documents []types.Document
}
OpReply is a message sent by the MongoDB database in response to an OpQuery.
func (*OpReply) MarshalBinary ¶
MarshalBinary writes an OpReply to a byte array.
func (*OpReply) MarshalJSON ¶
MarshalJSON marshals an OpReply in JSON format to a byte array.
func (*OpReply) UnmarshalBinary ¶
UnmarshalBinary reads an OpReply from a byte array.
type OpReplyFlagBit ¶
type OpReplyFlagBit flagBit
func (OpReplyFlagBit) MarshalJSON ¶
func (i OpReplyFlagBit) MarshalJSON() ([]byte, error)
func (OpReplyFlagBit) String ¶
func (i OpReplyFlagBit) String() string
type OpReplyFlags ¶
type OpReplyFlags flags
func (OpReplyFlags) FlagSet ¶
func (f OpReplyFlags) FlagSet(bit OpReplyFlagBit) bool
func (OpReplyFlags) MarshalJSON ¶
func (f OpReplyFlags) MarshalJSON() ([]byte, error)
func (OpReplyFlags) String ¶
func (f OpReplyFlags) String() string