const ( // DefaultZlibLevel is the default level for zlib compression DefaultZlibLevel = 6 // DefaultZstdLevel is the default level for zstd compression. // Matches https://github.com/wiredtiger/wiredtiger/blob/f08bc4b18612ef95a39b12166abcccf207f91596/ext/compressors/zstd/zstd_compress.c#L299 DefaultZstdLevel = 6 )
func AppendCompressedCompressedMessage(dst []byte, msg []byte) []byte
AppendCompressedCompressedMessage appends the compressed wiremessage to dst.
func AppendCompressedCompressorID(dst []byte, id CompressorID) []byte
AppendCompressedCompressorID appends the ID of the compressor to dst.
func AppendCompressedOriginalOpCode(dst []byte, opcode OpCode) []byte
AppendCompressedOriginalOpCode appends the original opcode to dst.
func AppendCompressedUncompressedSize(dst []byte, size int32) []byte
AppendCompressedUncompressedSize appends the uncompressed size of a compressed wiremessage to dst.
func AppendGetMoreCursorID(dst []byte, cursorID int64) []byte
AppendGetMoreCursorID appends the cursorID field to dst.
func AppendGetMoreFullCollectionName(dst []byte, ns string) []byte
AppendGetMoreFullCollectionName appends the fullCollectionName field to dst.
func AppendGetMoreNumberToReturn(dst []byte, numToReturn int32) []byte
AppendGetMoreNumberToReturn appends the numberToReturn field to dst.
func AppendGetMoreZero(dst []byte) []byte
AppendGetMoreZero appends the zero field to dst.
func AppendHeader(dst []byte, length, reqid, respto int32, opcode OpCode) []byte
AppendHeader appends a header to dst.
func AppendHeaderStart(dst []byte, reqid, respto int32, opcode OpCode) (index int32, b []byte)
AppendHeaderStart appends a header to the dst slice and returns an index where the wire message starts in dst and the updated slice.
func AppendKillCursorsCursorIDs(dst []byte, cursors []int64) []byte
AppendKillCursorsCursorIDs appends each the cursorIDs field to dst.
func AppendKillCursorsNumberIDs(dst []byte, numIDs int32) []byte
AppendKillCursorsNumberIDs appends the numberOfCursorIDs field to dst.
func AppendKillCursorsZero(dst []byte) []byte
AppendKillCursorsZero appends the zero field to dst.
func AppendMsgFlags(dst []byte, flags MsgFlag) []byte
AppendMsgFlags appends the flags for an OP_MSG wire message.
func AppendMsgSectionType(dst []byte, stype SectionType) []byte
AppendMsgSectionType appends the section type to dst.
func AppendQueryFlags(dst []byte, flags QueryFlag) []byte
AppendQueryFlags appends the flags for an OP_QUERY wire message.
func AppendQueryFullCollectionName(dst []byte, ns string) []byte
AppendQueryFullCollectionName appends the full collection name to dst.
func AppendQueryNumberToReturn(dst []byte, nor int32) []byte
AppendQueryNumberToReturn appends the number to return to dst.
func AppendQueryNumberToSkip(dst []byte, skip int32) []byte
AppendQueryNumberToSkip appends the number to skip to dst.
func AppendReplyCursorID(dst []byte, id int64) []byte
AppendReplyCursorID appends the cursor ID to dst.
func AppendReplyFlags(dst []byte, flags ReplyFlag) []byte
AppendReplyFlags appends the flags for an OP_REPLY wire message.
func AppendReplyNumberReturned(dst []byte, nr int32) []byte
AppendReplyNumberReturned appends the number returned to dst.
func AppendReplyStartingFrom(dst []byte, sf int32) []byte
AppendReplyStartingFrom appends the starting from field to dst.
func IsMsgMoreToCome(wm []byte) bool
IsMsgMoreToCome returns if the provided wire message is an OP_MSG with the more to come flag set.
func NextRequestID() int32
NextRequestID returns the next request ID.
func ReadCompressedCompressedMessage(src []byte, length int32) (msg []byte, rem []byte, ok bool)
ReadCompressedCompressedMessage reads the compressed wiremessage to dst.
func ReadCompressedUncompressedSize(src []byte) (size int32, rem []byte, ok bool)
ReadCompressedUncompressedSize reads the uncompressed size of a compressed wiremessage to dst.
func ReadKillCursorsCursorIDs(src []byte, numIDs int32) (cursorIDs []int64, rem []byte, ok bool)
ReadKillCursorsCursorIDs reads numIDs cursor IDs from src.
func ReadKillCursorsNumberIDs(src []byte) (numIDs int32, rem []byte, ok bool)
ReadKillCursorsNumberIDs reads the numberOfCursorIDs field from src.
func ReadKillCursorsZero(src []byte) (zero int32, rem []byte, ok bool)
ReadKillCursorsZero reads the zero field from src.
func ReadMsgChecksum(src []byte) (checksum uint32, rem []byte, ok bool)
ReadMsgChecksum reads a checksum from src.
func ReadMsgSectionDocumentSequence(src []byte) (identifier string, docs []bsoncore.Document, rem []byte, ok bool)
ReadMsgSectionDocumentSequence reads an identifier and document sequence from src and returns the document sequence data parsed into a slice of BSON documents.
func ReadMsgSectionRawDocumentSequence(src []byte) (identifier string, data []byte, rem []byte, ok bool)
ReadMsgSectionRawDocumentSequence reads an identifier and document sequence from src and returns the raw document sequence data.
func ReadMsgSectionSingleDocument(src []byte) (doc bsoncore.Document, rem []byte, ok bool)
ReadMsgSectionSingleDocument reads a single document from src.
func ReadQueryFullCollectionName(src []byte) (collname string, rem []byte, ok bool)
ReadQueryFullCollectionName reads the full collection name from src.
Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions instead.
func ReadQueryNumberToReturn(src []byte) (ntr int32, rem []byte, ok bool)
ReadQueryNumberToReturn reads the number to return from src.
Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions instead.
func ReadQueryNumberToSkip(src []byte) (nts int32, rem []byte, ok bool)
ReadQueryNumberToSkip reads the number to skip from src.
Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions instead.
func ReadQueryQuery(src []byte) (query bsoncore.Document, rem []byte, ok bool)
ReadQueryQuery reads the query from src.
Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions instead.
func ReadQueryReturnFieldsSelector(src []byte) (rfs bsoncore.Document, rem []byte, ok bool)
ReadQueryReturnFieldsSelector reads a return fields selector document from src.
Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions instead.
func ReadReplyCursorID(src []byte) (cursorID int64, rem []byte, ok bool)
ReadReplyCursorID reads a cursor ID from src.
func ReadReplyDocument(src []byte) (doc bsoncore.Document, rem []byte, ok bool)
ReadReplyDocument reads a reply document from src.
func ReadReplyDocuments(src []byte) (docs []bsoncore.Document, rem []byte, ok bool)
ReadReplyDocuments reads as many documents as possible from src
func ReadReplyNumberReturned(src []byte) (numberReturned int32, rem []byte, ok bool)
ReadReplyNumberReturned reads the numbered returned from src.
func ReadReplyStartingFrom(src []byte) (startingFrom int32, rem []byte, ok bool)
ReadReplyStartingFrom reads the starting from from src.
CompressorID is the ID for each type of Compressor.
type CompressorID uint8
These constants represent the individual compressor IDs for an OP_COMPRESSED.
const ( CompressorNoOp CompressorID = iota CompressorSnappy CompressorZLib CompressorZstd )
func ReadCompressedCompressorID(src []byte) (id CompressorID, rem []byte, ok bool)
ReadCompressedCompressorID reads the ID of the compressor to dst.
func (id CompressorID) String() string
String implements the fmt.Stringer interface.
MsgFlag represents the flags on an OP_MSG message.
type MsgFlag uint32
These constants represent the individual flags on an OP_MSG message.
const ( ChecksumPresent MsgFlag = 1 << iota MoreToCome ExhaustAllowed MsgFlag = 1 << 16 )
func ReadMsgFlags(src []byte) (flags MsgFlag, rem []byte, ok bool)
ReadMsgFlags reads the OP_MSG flags from src.
OpCode represents a MongoDB wire protocol opcode.
type OpCode int32
These constants are the valid opcodes for the version of the wireprotocol supported by this library. The skipped OpCodes are historical OpCodes that are no longer used.
const ( OpReply OpCode = 1 OpUpdate OpCode = 2001 OpInsert OpCode = 2002 // Deprecated: Use OpMsg instead. OpQuery OpCode = 2004 OpGetMore OpCode = 2005 OpDelete OpCode = 2006 OpKillCursors OpCode = 2007 OpCommand OpCode = 2010 OpCommandReply OpCode = 2011 OpCompressed OpCode = 2012 OpMsg OpCode = 2013 )
func ReadCompressedOriginalOpCode(src []byte) (opcode OpCode, rem []byte, ok bool)
ReadCompressedOriginalOpCode reads the original opcode from src.
func ReadHeader(src []byte) (length, requestID, responseTo int32, opcode OpCode, rem []byte, ok bool)
ReadHeader reads a wire message header from src.
func (oc OpCode) String() string
String implements the fmt.Stringer interface.
QueryFlag represents the flags on an OP_QUERY message.
type QueryFlag int32
These constants represent the individual flags on an OP_QUERY message.
const ( TailableCursor QueryFlag SecondaryOK OplogReplay NoCursorTimeout AwaitData Exhaust Partial )
func ReadQueryFlags(src []byte) (flags QueryFlag, rem []byte, ok bool)
ReadQueryFlags reads OP_QUERY flags from src.
Deprecated: Construct wiremessages with OpMsg and use the ReadMsg* functions instead.
func (qf QueryFlag) String() string
String implements the fmt.Stringer interface.
ReplyFlag represents the flags of an OP_REPLY message.
type ReplyFlag int32
These constants represent the individual flags of an OP_REPLY message.
const ( CursorNotFound ReplyFlag = 1 << iota QueryFailure ShardConfigStale AwaitCapable )
func ReadReplyFlags(src []byte) (flags ReplyFlag, rem []byte, ok bool)
ReadReplyFlags reads OP_REPLY flags from src.
func (rf ReplyFlag) String() string
String implements the fmt.Stringer interface.
SectionType represents the type for 1 section in an OP_MSG
type SectionType uint8
These constants represent the individual section types for a section in an OP_MSG
const ( SingleDocument SectionType = iota DocumentSequence )
func ReadMsgSectionType(src []byte) (stype SectionType, rem []byte, ok bool)
ReadMsgSectionType reads the section type from src.
WireMessage represents a MongoDB wire message in binary form.
type WireMessage []byte