mongoparser

package
v2.0.0-alpha56 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

README

Mongo Package Documentation

The mongo package encompasses the parser and mapping logic required to read MongoDB wire messages and capture or stub the outputs. Utilized by the hooks package, it assists in redirecting outgoing calls for the purpose of recording or stubbing the outputs.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Emoji = "\U0001F430" + " Keploy:"

Functions

func IsIsMasterDoc

func IsIsMasterDoc(doc bsoncore.Document) bool

func IsIsMasterValueTruthy

func IsIsMasterValueTruthy(val bsoncore.Value) bool

func IsWrite

func IsWrite(command Command) bool

Types

type Command

type Command string
const (
	Unknown           Command = "unknown"
	AbortTransaction  Command = "abortTransaction"
	Aggregate         Command = "aggregate"
	CommitTransaction Command = "commandTransaction"
	Count             Command = "count"
	CreateIndexes     Command = "createIndexes"
	Delete            Command = "delete"
	Distinct          Command = "distinct"
	Drop              Command = "drop"
	DropDatabase      Command = "dropDatabase"
	DropIndexes       Command = "dropIndexes"
	EndSessions       Command = "endSessions"
	Find              Command = "find"
	FindAndModify     Command = "findAndModify"
	GetMore           Command = "getMore"
	Insert            Command = "insert"
	IsMaster          Command = "isMaster"
	Ismaster          Command = "ismaster"
	ListCollections   Command = "listCollections"
	ListIndexes       Command = "listIndexes"
	ListDatabases     Command = "listDatabases"
	MapReduce         Command = "mapReduce"
	Update            Command = "update"
)

func CommandAndCollection

func CommandAndCollection(msg bsoncore.Document) (Command, string)

type Message

type Message struct {
	Wm []byte
	Op Operation
}

type MongoParser

type MongoParser struct {
	// contains filtered or unexported fields
}

func NewMongoParser

func NewMongoParser(logger *zap.Logger, h *hooks.Hook, authPassword string) *MongoParser

func (*MongoParser) OutgoingType

func (m *MongoParser) OutgoingType(buffer []byte) bool

IsOutgoingMongo function determines if the outgoing network call is Mongo by comparing the message format with that of a mongo wire message.

func (*MongoParser) ProcessOutgoing

func (m *MongoParser) ProcessOutgoing(requestBuffer []byte, clientConn, destConn net.Conn, ctx context.Context)

type Operation

type Operation interface {
	fmt.Stringer
	OpCode() wiremessage.OpCode
	Encode(responseTo, requestId int32) []byte
	IsIsMaster() bool
	IsIsAdminDB() bool
	CursorID() (cursorID int64, ok bool)
	RequestID() int32
	Error() error
	Unacknowledged() bool
	CommandAndCollection() (Command, string)
	TransactionDetails() *TransactionDetails
}

func Decode

func Decode(wm []byte, logger *zap.Logger) (Operation, models.MongoHeader, interface{}, error)

see https://github.com/mongodb/mongo-go-driver/blob/v1.7.2/x/mongo/driver/operation.go#L1361-L1426 func Decode(wm []byte) (Operation, int32, int32, int32, int32, error) {

type TransactionDetails

type TransactionDetails struct {
	LsID               []byte
	TxnNumber          int64
	IsStartTransaction bool
}

Jump to

Keyboard shortcuts

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