Documentation
¶
Overview ¶
Package wire provides wire protocol implementation.
Index ¶
- Constants
- 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 ¶
Types ¶
type MsgBody ¶
type MsgBody interface {
encoding.BinaryUnmarshaler
encoding.BinaryMarshaler
fmt.Stringer
// 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) SetSections ¶
func (msg *OpMsg) SetSections(sections ...OpMsgSection) error
SetSections of the OpMsg.
func (*OpMsg) String ¶ added in v0.0.6
String returns a string representation for logging.
Currently, it uses FJSON, but that may change in the future.
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) 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) String ¶
func (f OpMsgFlags) String() string
String returns OpMsgFlags as a string.
type OpMsgSection ¶
type OpMsgSection struct {
Kind byte
Identifier string
Documents []*types.Document // TODO https://github.com/FerretDB/FerretDB/issues/274
}
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 // may be nil
}
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) String ¶ added in v0.0.6
String returns a string representation for logging.
Currently, it uses FJSON, but that may change in the future.
func (*OpQuery) UnmarshalBinary ¶
UnmarshalBinary reads an OpQuery from a byte array.
type OpQueryFlagBit ¶
type OpQueryFlagBit flagBit
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) 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) String ¶ added in v0.0.6
String returns a string representation for logging.
Currently, it uses FJSON, but that may change in the future.
func (*OpReply) UnmarshalBinary ¶
UnmarshalBinary reads an OpReply from a byte array.
type OpReplyFlagBit ¶
type OpReplyFlagBit flagBit
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) String ¶
func (f OpReplyFlags) String() string