Documentation ¶
Overview ¶
Package mongo provides functionality for working with MongoDB outgoing calls.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsIsMasterDoc ¶
func IsIsMasterValueTruthy ¶
func NewMongo ¶
func NewMongo(logger *zap.Logger) integrations.Integrations
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 = "tools" )
constants for all the commands that can be proxied
type Mongo ¶
type Mongo struct {
// contains filtered or unexported fields
}
func (*Mongo) MatchType ¶
MatchType determines if the outgoing network call is Mongo by comparing the message format with that of a mongo wire message.
func (*Mongo) MockOutgoing ¶
func (m *Mongo) MockOutgoing(ctx context.Context, src net.Conn, dstCfg *integrations.ConditionalDstCfg, mockDb integrations.MockMemDb, opts models.OutgoingOptions) error
MockOutgoing reads the outgoing mongo requests of the client connection and mocks the responses from the yaml file. The database connection is keep-alive
func (*Mongo) RecordOutgoing ¶
func (m *Mongo) RecordOutgoing(ctx context.Context, src net.Conn, dst net.Conn, mocks chan<- *models.Mock, opts models.OutgoingOptions) error
RecordOutgoing records the outgoing mongo messages of the client connection into the yaml file. The database connection is keep-alive so, this function will be called during the connection establishment.
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 ¶
Decode decodes the wire message binary into the operation and the mongo message.
see https://github.com/mongodb/mongo-go-driver/blob/v1.7.2/x/mongo/driver/operation.go#L1361-L1426