wire

package
v0.0.0-...-b57e8ac Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
const (
	MsgHeaderLen = 16
	MaxMsgLen    = 48000000
)
View Source
const (
	OpMsgChecksumPresent = OpMsgFlagBit(1 << 0)  // checksumPresent
	OpMsgMoreToCome      = OpMsgFlagBit(1 << 1)  // moreToCome
	OpMsgExhaustAllowed  = OpMsgFlagBit(1 << 16) // exhaustAllowed
)
View Source
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
)
View Source
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

func DumpMsgBody(body MsgBody) string

DumpMsgBody takes a MsgBody and returns as a string.

func DumpMsgHeader

func DumpMsgHeader(header *MsgHeader) string

DumpMsgHeader takes a MsgHeader and returns as a string.

func ReadMessage

func ReadMessage(r *bufio.Reader) (*MsgHeader, MsgBody, error)

func WriteMessage

func WriteMessage(w *bufio.Writer, header *MsgHeader, msg MsgBody) error

Types

type MsgBody

type MsgBody interface {
	encoding.BinaryUnmarshaler
	encoding.BinaryMarshaler
	json.Marshaler
	// contains filtered or unexported methods
}

type MsgHeader

type MsgHeader struct {
	MessageLength int32
	RequestID     int32
	ResponseTo    int32
	OpCode        OpCode
}

MsgHeader in general, each message consists of a standard message header followed by request-specific data.

func (*MsgHeader) MarshalBinary

func (msg *MsgHeader) MarshalBinary() ([]byte, error)

MarshalBinary writes a MsgHeader to a byte array.

type OpCode

type OpCode int32

func (OpCode) MarshalJSON

func (i OpCode) MarshalJSON() ([]byte, error)

func (OpCode) String

func (i OpCode) String() string

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) Document

func (msg *OpMsg) Document() (types.Document, error)

Document returns the value of msg as a types.Document.

func (*OpMsg) MarshalBinary

func (msg *OpMsg) MarshalBinary() ([]byte, error)

MarshalBinary writes an OpMsg to a byte array.

func (*OpMsg) MarshalJSON

func (msg *OpMsg) MarshalJSON() ([]byte, error)

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

func (msg *OpMsg) UnmarshalBinary(b []byte) error

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

type OpMsgSection struct {
	Kind       byte
	Identifier string
	Documents  []types.Document
}

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

func (query *OpQuery) MarshalBinary() ([]byte, error)

MarshalBinary writes an OpQuery to a byte array.

func (*OpQuery) MarshalJSON

func (query *OpQuery) MarshalJSON() ([]byte, error)

MarshalBinary writes an OpQuery in JSON format to byte array.

func (*OpQuery) UnmarshalBinary

func (query *OpQuery) UnmarshalBinary(b []byte) error

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

func (reply *OpReply) MarshalBinary() ([]byte, error)

MarshalBinary writes an OpReply to a byte array.

func (*OpReply) MarshalJSON

func (reply *OpReply) MarshalJSON() ([]byte, error)

MarshalJSON marshals an OpReply in JSON format to a byte array.

func (*OpReply) UnmarshalBinary

func (reply *OpReply) UnmarshalBinary(b []byte) error

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

Jump to

Keyboard shortcuts

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