message

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	IsMaster     = "ismaster"
	BuildInfo    = "buildinfo"
	GetLastError = "getlasterror"
)
View Source
const (
	DefaultMaxBsonObjectSize            = 16 * 1024 * 1024
	DefaultMaxMessageSizeBytes          = 48000000
	DefaultMaxWriteBatchSize            = 100000
	DefaultLogicalSessionTimeoutMinutes = 30
	DefaultMinWireVersion               = 0
	DefaultMaxWireVersion               = 7
)
View Source
const (
	// CurrentDate sets the value of a field to current date, either as a Date or a Timestamp.
	CurrentDate = "$currentDate"
	// Inc increments the value of the field by the specified amount.
	Inc = "$inc"
	// Min only updates the field if the specified value is less than the existing field value.
	Min = "$min"
	// Max only updates the field if the specified value is greater than the existing field value.
	Max = "$max"
	// Mul multiplies the value of the field by the specified amount.
	Mul = "$mul"
	// Rename renames a field.
	Rename = "$rename"
	// Set ets the value of a field in a document.
	Set = "$set"
	// SetOnInsert sets the value of a field if an update results in an insert of a document. Has no effect on update operations that modify existing documents.
	SetOnInsert = "$setOnInsert"
	// Unset removes the specified field from a document.
	Unset = "$unset"
)
View Source
const (
	Delete      = "delete"
	Insert      = "insert"
	Find        = "find"
	Update      = "update"
	LsID        = "lsid"
	ID          = "id"
	Binary      = "$binary"
	Base64      = "base64"
	SubType     = "subType"
	DB          = "$db"
	Filter      = "filter"
	Documents   = "documents"
	KillCursors = "killCursors"
)
View Source
const (
	// DefaultCompatibleVersion = "4.0.12".
	// DefaultCompatibleVersion = "3.6.4".
	DefaultCompatibleVersion = "3.4.22"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildConfig

type BuildConfig interface {
	// GetVersion should return a software version.
	GetVersion() string
}

BuildConfig represents a limit configurations for 'buildInfo' command.

type Command

type Command struct {
	IsAdmin  bool
	Elements []bson.Element
	Type     string
}

Command represents a query command of MongoDB database command.

func NewCommandWithDocument

func NewCommandWithDocument(doc bson.Document) (*Command, error)

NewCommandWithDocument returns a new command instance with the specified BSON document.

func NewCommandWithMsg

func NewCommandWithMsg(msg *protocol.Msg) (*Command, error)

NewCommandWithMsg returns a new command instance with the specified BSON document.

func NewCommandWithQuery

func NewCommandWithQuery(q *protocol.Query) (*Command, error)

NewCommandWithQuery returns a new command instance with the specified BSON document.

func (*Command) GetType

func (cmd *Command) GetType() string

GetType returns a string type.

func (*Command) IsAdminCommand

func (cmd *Command) IsAdminCommand() bool

IsAdminCommand returns true when it is a admin command, otherwise false.

func (*Command) IsType

func (cmd *Command) IsType(typeString string) bool

IsType returns true when the command has the specified element, otherwise false.

func (*Command) String

func (cmd *Command) String() string

String returns the string description.

type Config

type Config interface {
	ServerConfig
	BuildConfig
}

Config represents all configurations for MongoDB.

type Query

type Query struct {
	Database   string
	Collection string
	Type       string
	Conditions []bson.Document
	Documents  []bson.Document
	Operator   string
	Limit      int
}

Query represents a message query.

func NewQuery

func NewQuery() *Query

NewQuery returns a new query.

func NewQueryWithMessage

func NewQueryWithMessage(msg *protocol.Msg) (*Query, error)

NewQueryWithMessage returns a new query with the specified OP_MSG.

func NewQueryWithQuery

func NewQueryWithQuery(msg *protocol.Query) (*Query, error)

NewQueryWithQuery returns a new query with the specified OP_QUERY.

func (*Query) GetConditions

func (q *Query) GetConditions() []bson.Document

GetConditions returns the search conditions.

func (*Query) GetDocuments

func (q *Query) GetDocuments() []bson.Document

GetDocuments returns the search conditions.

func (*Query) GetFullCollectionName

func (q *Query) GetFullCollectionName() string

GetFullCollectionName returns the full collection name.

func (*Query) GetLimit

func (q *Query) GetLimit() int

GetLimit returns the limit value.

func (*Query) GetOperator

func (q *Query) GetOperator() string

GetOperator returns the operator string.

func (*Query) GetType

func (q *Query) GetType() string

GetType returns the section type.

func (*Query) HasConditions added in v0.9.4

func (q *Query) HasConditions() bool

HasConditions returns true if the query has conditions.

func (*Query) ParseMsg

func (q *Query) ParseMsg(msg *protocol.Msg) error

ParseMsg parses the specified OP_MSG.

func (*Query) ParseQuery

func (q *Query) ParseQuery(msg *protocol.Query) error

ParseQuery parses the specified OP_MSG.

type Response

type Response struct {
	*bson.Dictionary
}

Response represents response elements.

func NewBadResponse

func NewBadResponse() *Response

NewBadResponse returns a bad status response.

func NewBuildInfoResponseWithConfig

func NewBuildInfoResponseWithConfig(config Config) *Response

NewBuildInfoResponseWithConfig returns a response instance with the specified configuration.

func NewDefaultBuildInfoResponse

func NewDefaultBuildInfoResponse() *Response

NewDefaultBuildInfoResponse returns a default response instance.

func NewDefaultIsMasterResponse

func NewDefaultIsMasterResponse() *Response

NewDefaultIsMasterResponse returns a default response instance.

func NewDefaultLastErrorResponse

func NewDefaultLastErrorResponse() *Response

NewDefaultLastErrorResponse returns a default response instance.

func NewIsMasterResponseWithConfig

func NewIsMasterResponseWithConfig(config ServerConfig) *Response

NewIsMasterResponseWithConfig returns a response instance with the specified configuration.

func NewMessageReplyWithParameters

func NewMessageReplyWithParameters(ok bool, n int32) *Response

NewMessageReplyWithParameters returns a message response instance.

func NewOkResponse

func NewOkResponse() *Response

NewOkResponse returns a good status response.

func NewResponse

func NewResponse() *Response

NewResponse returns a new response instance.

func NewResponseWithElements

func NewResponseWithElements(elements map[string]interface{}) *Response

NewResponseWithElements returns a new response instance.

func NewResponseWithStatus

func NewResponseWithStatus(status bool) *Response

NewResponseWithStatus returns a simple response which has only a status element.

func (*Response) SetCursorDocuments

func (res *Response) SetCursorDocuments(fullCollectionName string, docs []bson.Document)

SetCursorDocuments sets a resultset.

func (*Response) SetErrorStatus added in v0.9.1

func (res *Response) SetErrorStatus(err error)

SetErrorStatus sets an int32 response result.

func (*Response) SetNumberOfAffectedDocuments

func (res *Response) SetNumberOfAffectedDocuments(n int32)

SetNumberOfAffectedDocuments sets a number of affected documents.

func (*Response) SetNumberOfModifiedDocuments

func (res *Response) SetNumberOfModifiedDocuments(n int32)

SetNumberOfModifiedDocuments sets a number of modified documents.

func (*Response) SetStatus

func (res *Response) SetStatus(flag bool)

SetStatus sets an int32 response result.

func (*Response) SetVersion

func (res *Response) SetVersion(ver string)

SetVersion sets a version string and array of the specified version string.

type ServerConfig

type ServerConfig interface {
	// IsMaster should return true when the instance is running as master, otherwise false
	IsMaster() bool
	// GetMaxBsonObjectSize should return a max limitation value of BSON object size.
	GetMaxBsonObjectSize() int32
	// GetMaxMessageSizeBytes should return a max limitation value of message size.
	GetMaxMessageSizeBytes() int32
	// GetMaxWriteBatchSize should return a max limitation value of write batch size.
	GetMaxWriteBatchSize() int32
	// GetLogicalSessionTimeoutMinutes should return a settion timeout value.
	GetLogicalSessionTimeoutMinutes() int32
	// GetMinWireVersion should return a min supported version.
	GetMinWireVersion() int32
	// GetMaxWireVersion should return a max supported version.
	GetMaxWireVersion() int32
	// GetReadOnly should return true when the instance does not support write operations.
	GetReadOnly() bool
	// GetCompressions should return supported compress strings.
	GetCompressions() []string
}

ServerConfig represents a limit configurations for 'isMaseter' command.

Jump to

Keyboard shortcuts

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