wiremessage

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
const OpmsgWireVersion = 6

OpmsgWireVersion is the minimum wire version needed to use OP_MSG

Variables

This section is empty.

Functions

func AppendCompressedCompressedMessage

func AppendCompressedCompressedMessage(dst []byte, msg []byte) []byte

AppendCompressedCompressedMessage appends the compressed wiremessage to dst.

func AppendCompressedCompressorID

func AppendCompressedCompressorID(dst []byte, id CompressorID) []byte

AppendCompressedCompressorID appends the ID of the compressor to dst.

func AppendCompressedOriginalOpCode

func AppendCompressedOriginalOpCode(dst []byte, opcode OpCode) []byte

AppendCompressedOriginalOpCode appends the original opcode to dst.

func AppendCompressedUncompressedSize

func AppendCompressedUncompressedSize(dst []byte, size int32) []byte

AppendCompressedUncompressedSize appends the uncompressed size of a compressed wiremessage to dst.

func AppendGetMoreCursorID

func AppendGetMoreCursorID(dst []byte, cursorID int64) []byte

AppendGetMoreCursorID appends the cursorID field to dst.

func AppendGetMoreFullCollectionName

func AppendGetMoreFullCollectionName(dst []byte, ns string) []byte

AppendGetMoreFullCollectionName appends the fullCollectionName field to dst.

func AppendGetMoreNumberToReturn

func AppendGetMoreNumberToReturn(dst []byte, numToReturn int32) []byte

AppendGetMoreNumberToReturn appends the numberToReturn field to dst.

func AppendGetMoreZero

func AppendGetMoreZero(dst []byte) []byte

AppendGetMoreZero appends the zero field to dst.

func AppendHeader

func AppendHeader(dst []byte, length, reqid, respto int32, opcode OpCode) []byte

AppendHeader appends a header to dst.

func AppendHeaderStart

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

func AppendKillCursorsCursorIDs(dst []byte, cursors []int64) []byte

AppendKillCursorsCursorIDs appends each the cursorIDs field to dst.

func AppendKillCursorsNumberIDs

func AppendKillCursorsNumberIDs(dst []byte, numIDs int32) []byte

AppendKillCursorsNumberIDs appends the numberOfCursorIDs field to dst.

func AppendKillCursorsZero

func AppendKillCursorsZero(dst []byte) []byte

AppendKillCursorsZero appends the zero field to dst.

func AppendMsgFlags

func AppendMsgFlags(dst []byte, flags MsgFlag) []byte

AppendMsgFlags appends the flags for an OP_MSG wire message.

func AppendMsgSectionType

func AppendMsgSectionType(dst []byte, stype SectionType) []byte

AppendMsgSectionType appends the section type to dst.

func AppendQueryFlags

func AppendQueryFlags(dst []byte, flags QueryFlag) []byte

AppendQueryFlags appends the flags for an OP_QUERY wire message.

func AppendQueryFullCollectionName

func AppendQueryFullCollectionName(dst []byte, ns string) []byte

AppendQueryFullCollectionName appends the full collection name to dst.

func AppendQueryNumberToReturn

func AppendQueryNumberToReturn(dst []byte, nor int32) []byte

AppendQueryNumberToReturn appends the number to return to dst.

func AppendQueryNumberToSkip

func AppendQueryNumberToSkip(dst []byte, skip int32) []byte

AppendQueryNumberToSkip appends the number to skip to dst.

func AppendReplyCursorID

func AppendReplyCursorID(dst []byte, id int64) []byte

AppendReplyCursorID appends the cursor ID to dst.

func AppendReplyFlags

func AppendReplyFlags(dst []byte, flags ReplyFlag) []byte

AppendReplyFlags appends the flags for an OP_REPLY wire message.

func AppendReplyNumberReturned

func AppendReplyNumberReturned(dst []byte, nr int32) []byte

AppendReplyNumberReturned appends the number returned to dst.

func AppendReplyStartingFrom

func AppendReplyStartingFrom(dst []byte, sf int32) []byte

AppendReplyStartingFrom appends the starting from field to dst.

func CurrentRequestID

func CurrentRequestID() int32

CurrentRequestID returns the current request ID.

func IsMsgMoreToCome

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

func NextRequestID() int32

NextRequestID returns the next request ID.

func ReadCompressedCompressedMessage

func ReadCompressedCompressedMessage(src []byte, length int32) (msg []byte, rem []byte, ok bool)

ReadCompressedCompressedMessage reads the compressed wiremessage to dst.

func ReadCompressedUncompressedSize

func ReadCompressedUncompressedSize(src []byte) (size int32, rem []byte, ok bool)

ReadCompressedUncompressedSize reads the uncompressed size of a compressed wiremessage to dst.

func ReadKillCursorsCursorIDs

func ReadKillCursorsCursorIDs(src []byte, numIDs int32) (cursorIDs []int64, rem []byte, ok bool)

ReadKillCursorsCursorIDs reads numIDs cursor IDs from src.

func ReadKillCursorsNumberIDs

func ReadKillCursorsNumberIDs(src []byte) (numIDs int32, rem []byte, ok bool)

ReadKillCursorsNumberIDs reads the numberOfCursorIDs field from src.

func ReadKillCursorsZero

func ReadKillCursorsZero(src []byte) (zero int32, rem []byte, ok bool)

ReadKillCursorsZero reads the zero field from src.

func ReadMsgChecksum

func ReadMsgChecksum(src []byte) (checksum uint32, rem []byte, ok bool)

ReadMsgChecksum reads a checksum from src.

func ReadMsgSectionDocumentSequence

func ReadMsgSectionDocumentSequence(src []byte) (identifier string, docs []bsoncore.Document, rem []byte, ok bool)

ReadMsgSectionDocumentSequence reads an identifier and document sequence from src.

func ReadMsgSectionSingleDocument

func ReadMsgSectionSingleDocument(src []byte) (doc bsoncore.Document, rem []byte, ok bool)

ReadMsgSectionSingleDocument reads a single document from src.

func ReadQueryFullCollectionName

func ReadQueryFullCollectionName(src []byte) (collname string, rem []byte, ok bool)

ReadQueryFullCollectionName reads the full collection name from src.

func ReadQueryNumberToReturn

func ReadQueryNumberToReturn(src []byte) (ntr int32, rem []byte, ok bool)

ReadQueryNumberToReturn reads the number to return from src.

func ReadQueryNumberToSkip

func ReadQueryNumberToSkip(src []byte) (nts int32, rem []byte, ok bool)

ReadQueryNumberToSkip reads the number to skip from src.

func ReadQueryQuery

func ReadQueryQuery(src []byte) (query bsoncore.Document, rem []byte, ok bool)

ReadQueryQuery reads the query from src.

func ReadQueryReturnFieldsSelector

func ReadQueryReturnFieldsSelector(src []byte) (rfs bsoncore.Document, rem []byte, ok bool)

ReadQueryReturnFieldsSelector reads a return fields selector document from src.

func ReadReplyCursorID

func ReadReplyCursorID(src []byte) (cursorID int64, rem []byte, ok bool)

ReadReplyCursorID reads a cursor ID from src.

func ReadReplyDocument

func ReadReplyDocument(src []byte) (doc bsoncore.Document, rem []byte, ok bool)

ReadReplyDocument reads a reply document from src.

func ReadReplyDocuments

func ReadReplyDocuments(src []byte) (docs []bsoncore.Document, rem []byte, ok bool)

ReadReplyDocuments reads as many documents as possible from src

func ReadReplyNumberReturned

func ReadReplyNumberReturned(src []byte) (numberReturned int32, rem []byte, ok bool)

ReadReplyNumberReturned reads the numbered returned from src.

func ReadReplyStartingFrom

func ReadReplyStartingFrom(src []byte) (startingFrom int32, rem []byte, ok bool)

ReadReplyStartingFrom reads the starting from from src.

Types

type CompressorID

type CompressorID uint8

CompressorID is the ID for each type of Compressor.

const (
	CompressorNoOp CompressorID = iota
	CompressorSnappy
	CompressorZLib
	CompressorZstd
)

These constants represent the individual compressor IDs for an OP_COMPRESSED.

func ReadCompressedCompressorID

func ReadCompressedCompressorID(src []byte) (id CompressorID, rem []byte, ok bool)

ReadCompressedCompressorID reads the ID of the compressor to dst.

type MsgFlag

type MsgFlag uint32

MsgFlag represents the flags on an OP_MSG message.

const (
	ChecksumPresent MsgFlag = 1 << iota
	MoreToCome

	ExhaustAllowed MsgFlag = 1 << 16
)

These constants represent the individual flags on an OP_MSG message.

func ReadMsgFlags

func ReadMsgFlags(src []byte) (flags MsgFlag, rem []byte, ok bool)

ReadMsgFlags reads the OP_MSG flags from src.

type OpCode

type OpCode int32

OpCode represents a MongoDB wire protocol opcode.

const (
	OpReply OpCode = 1

	OpUpdate OpCode = 2001
	OpInsert OpCode = 2002

	OpQuery        OpCode = 2004
	OpGetMore      OpCode = 2005
	OpDelete       OpCode = 2006
	OpKillCursors  OpCode = 2007
	OpCommand      OpCode = 2010
	OpCommandReply OpCode = 2011
	OpCompressed   OpCode = 2012
	OpMsg          OpCode = 2013
)

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.

func ReadCompressedOriginalOpCode

func ReadCompressedOriginalOpCode(src []byte) (opcode OpCode, rem []byte, ok bool)

ReadCompressedOriginalOpCode reads the original opcode from src.

func ReadHeader

func ReadHeader(src []byte) (length, requestID, responseTo int32, opcode OpCode, rem []byte, ok bool)

ReadHeader reads a wire message header from src.

func (OpCode) String

func (oc OpCode) String() string

String implements the fmt.Stringer interface.

type QueryFlag

type QueryFlag int32

QueryFlag represents the flags on an OP_QUERY message.

const (
	TailableCursor QueryFlag
	SlaveOK
	OplogReplay
	NoCursorTimeout
	AwaitData
	Exhaust
	Partial
)

These constants represent the individual flags on an OP_QUERY message.

func ReadQueryFlags

func ReadQueryFlags(src []byte) (flags QueryFlag, rem []byte, ok bool)

ReadQueryFlags reads OP_QUERY flags from src.

func (QueryFlag) String

func (qf QueryFlag) String() string

String implements the fmt.Stringer interface.

type ReplyFlag

type ReplyFlag int32

ReplyFlag represents the flags of an OP_REPLY message.

const (
	CursorNotFound ReplyFlag = 1 << iota
	QueryFailure
	ShardConfigStale
	AwaitCapable
)

These constants represent the individual flags of an OP_REPLY message.

func ReadReplyFlags

func ReadReplyFlags(src []byte) (flags ReplyFlag, rem []byte, ok bool)

ReadReplyFlags reads OP_REPLY flags from src.

func (ReplyFlag) String

func (rf ReplyFlag) String() string

String implements the fmt.Stringer interface.

type SectionType

type SectionType uint8

SectionType represents the type for 1 section in an OP_MSG

const (
	SingleDocument SectionType = iota
	DocumentSequence
)

These constants represent the individual section types for a section in an OP_MSG

func ReadMsgSectionType

func ReadMsgSectionType(src []byte) (stype SectionType, rem []byte, ok bool)

ReadMsgSectionType reads the section type from src.

type WireMessage

type WireMessage []byte

WireMessage represents a MongoDB wire message in binary form.

Jump to

Keyboard shortcuts

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