Documentation
¶
Index ¶
- Constants
- Variables
- func NewNotSupported(q *Query) error
- func NewQueryError(q *Query) error
- type BaseCommandExecutor
- func (executor *BaseCommandExecutor) Delete(conn *Conn, q *Query) (int32, error)
- func (executor *BaseCommandExecutor) ExecuteBuildInfo(cmd *Command) (bson.Document, error)
- func (executor *BaseCommandExecutor) ExecuteCommand(cmd *Command) (bson.Document, error)
- func (executor *BaseCommandExecutor) ExecuteGetLastError(cmd *Command) (bson.Document, error)
- func (executor *BaseCommandExecutor) ExecuteIsMaster(cmd *Command) (bson.Document, error)
- func (executor *BaseCommandExecutor) Find(conn *Conn, q *Query) ([]bson.Document, error)
- func (executor *BaseCommandExecutor) Insert(conn *Conn, q *Query) (int32, error)
- func (executor *BaseCommandExecutor) SetDatabaseCommandExecutor(fn DatabaseCommandExecutor)
- func (executor *BaseCommandExecutor) SetUserCommandExecutor(fn UserCommandExecutor)
- func (executor *BaseCommandExecutor) Update(conn *Conn, q *Query) (int32, error)
- type BaseMessageHandler
- func (handler *BaseMessageHandler) OpDelete(conn *Conn, msg *OpDelete) (bson.Document, error)
- func (handler *BaseMessageHandler) OpGetMore(conn *Conn, msg *OpGetMore) (bson.Document, error)
- func (handler *BaseMessageHandler) OpInsert(conn *Conn, msg *OpInsert) (bson.Document, error)
- func (handler *BaseMessageHandler) OpKillCursors(conn *Conn, msg *OpKillCursors) (bson.Document, error)
- func (handler *BaseMessageHandler) OpMsg(conn *Conn, msg *OpMsg) (bson.Document, error)
- func (handler *BaseMessageHandler) OpQuery(conn *Conn, msg *OpQuery) (bson.Document, error)
- func (handler *BaseMessageHandler) OpUpdate(conn *Conn, msg *OpUpdate) (bson.Document, error)
- func (handler *BaseMessageHandler) SetCommandExecutor(fn CommandExecutor)
- func (handler *BaseMessageHandler) SetMessageExecutor(fn MessageExecutor)
- type Client
- func (client *Client) Close() error
- func (client *Client) Connect() error
- func (client *Client) GetCollection() string
- func (client *Client) GetDatabase() string
- func (client *Client) GetHost() string
- func (client *Client) GetPort() int
- func (client *Client) GetTimeout() time.Duration
- func (client *Client) InsertOne(doc interface{}) error
- func (client *Client) SetCollection(col string)
- func (client *Client) SetDatabase(db string)
- func (client *Client) SetHost(host string)
- func (client *Client) SetPort(port int)
- func (client *Client) SetTimeout(d time.Duration)
- type Command
- type CommandExecutor
- type Config
- func (config *Config) GetCompressions() []string
- func (config *Config) GetLogicalSessionTimeoutMinutes() int32
- func (config *Config) GetMaxBsonObjectSize() int32
- func (config *Config) GetMaxMessageSizeBytes() int32
- func (config *Config) GetMaxWireVersion() int32
- func (config *Config) GetMaxWriteBatchSize() int32
- func (config *Config) GetMinWireVersion() int32
- func (config *Config) GetReadOnly() bool
- func (config *Config) GetVersion() string
- func (config *Config) IsMaster() bool
- type Conn
- type DatabaseCommandExecutor
- type DiagnosticCommandExecutor
- type Document
- type MessageExecutor
- type MessageListener
- type OpDelete
- type OpFlag
- type OpGetMore
- type OpInsert
- type OpKillCursors
- type OpMessage
- type OpMessageHandler
- type OpMsg
- type OpQuery
- type OpReply
- type OpUpdate
- type Query
- type QueryCommandExecutor
- type ReplicationCommandExecutor
- type Server
- func (server *Server) ExecuteBuildInfo(cmd *Command) (bson.Document, error)
- func (server *Server) ExecuteIsMaster(cmd *Command) (bson.Document, error)
- func (server *Server) GetPort() int
- func (server *Server) Restart() error
- func (server *Server) SetMessageHandler(h OpMessageHandler)
- func (server *Server) SetMessageListener(l MessageListener)
- func (server *Server) SetPort(port int)
- func (server *Server) SetTracer(t tracer.Tracer)
- func (server *Server) Start() error
- func (server *Server) Stop() error
- type UserCommandExecutor
- type WriteOperationExecutor
Constants ¶
const ( // PackageName is the package name. PackageName = "go-mongo" // DefaultHost is the default host for MongoDB servers. DefaultHost string = "localhost" // DefaultPort is the default port for mongod and mongos. DefaultPort int = 27017 // DefaultTimeoutSecond is the default request timeout for MongoDB servers. DefaultTimeoutSecond = 5 )
const (
Version = "v0.9.5"
)
Variables ¶
var ErrQuery = errors.New("query error")
var ErrQueryNotSupported = errors.New("query not supported")
Functions ¶
func NewNotSupported ¶ added in v0.9.1
func NewQueryError ¶ added in v0.9.1
Types ¶
type BaseCommandExecutor ¶
type BaseCommandExecutor struct { UserCommandExecutor DatabaseCommandExecutor }
BaseCommandExecutor is a complete hander for CommandExecutor.
func NewBaseCommandExecutor ¶
func NewBaseCommandExecutor() *BaseCommandExecutor
NewBaseCommandExecutor returns a complete null executor for CommandExecutor.
func (*BaseCommandExecutor) Delete ¶
func (executor *BaseCommandExecutor) Delete(conn *Conn, q *Query) (int32, error)
Delete hadles OP_DELETE and 'delete' query of OP_MSG.
func (*BaseCommandExecutor) ExecuteBuildInfo ¶
func (executor *BaseCommandExecutor) ExecuteBuildInfo(cmd *Command) (bson.Document, error)
ExecuteBuildInfo returns statistics about the MongoDB build.
func (*BaseCommandExecutor) ExecuteCommand ¶
func (executor *BaseCommandExecutor) ExecuteCommand(cmd *Command) (bson.Document, error)
ExecuteCommand handles query commands other than those explicitly specified above.
func (*BaseCommandExecutor) ExecuteGetLastError ¶
func (executor *BaseCommandExecutor) ExecuteGetLastError(cmd *Command) (bson.Document, error)
ExecuteGetLastError returns statistics about the MongoDB build.
func (*BaseCommandExecutor) ExecuteIsMaster ¶
func (executor *BaseCommandExecutor) ExecuteIsMaster(cmd *Command) (bson.Document, error)
ExecuteIsMaster returns information about this member’s role in the replica set, including whether it is the master.
func (*BaseCommandExecutor) Insert ¶
func (executor *BaseCommandExecutor) Insert(conn *Conn, q *Query) (int32, error)
Insert hadles OP_INSERT and 'insert' query of OP_MSG.
func (*BaseCommandExecutor) SetDatabaseCommandExecutor ¶
func (executor *BaseCommandExecutor) SetDatabaseCommandExecutor(fn DatabaseCommandExecutor)
SetDatabaseCommandExecutor sets a command exector for database operation commands.
func (*BaseCommandExecutor) SetUserCommandExecutor ¶
func (executor *BaseCommandExecutor) SetUserCommandExecutor(fn UserCommandExecutor)
SetUserCommandExecutor sets a command exector for database operation commands.
type BaseMessageHandler ¶
type BaseMessageHandler struct { CommandExecutor MessageExecutor }
BaseMessageHandler is a complete hander for MessageHandler.
func NewBaseMessageHandler ¶
func NewBaseMessageHandler() *BaseMessageHandler
NewBaseMessageHandler returns a complete null handler for MessageHandler.
func (*BaseMessageHandler) OpKillCursors ¶
func (handler *BaseMessageHandler) OpKillCursors(conn *Conn, msg *OpKillCursors) (bson.Document, error)
OpKillCursors handles OP_KILL_CURSORS of MongoDB wire protocol.
func (*BaseMessageHandler) SetCommandExecutor ¶
func (handler *BaseMessageHandler) SetCommandExecutor(fn CommandExecutor)
SetCommandExecutor sets a exector for OP_QUERY of MongoDB wire protocol.
func (*BaseMessageHandler) SetMessageExecutor ¶
func (handler *BaseMessageHandler) SetMessageExecutor(fn MessageExecutor)
SetMessageExecutor sets a exector for OP_MSG of MongoDB wire protocol.
type Client ¶
type Client struct { Host string Port int Database string Collection string Timeout time.Duration // contains filtered or unexported fields }
Client is an instance for Graphite protocols.
func (*Client) GetCollection ¶
GetCollection returns a destination collection.
func (*Client) GetDatabase ¶
GetDatabase returns a destination database.
func (*Client) GetTimeout ¶
GetTimeout return the timeout for the request.
func (*Client) SetCollection ¶
SetCollection sets a destination collection.
func (*Client) SetDatabase ¶
SetDatabase sets a destination database.
func (*Client) SetTimeout ¶
SetTimeout sets a timeout for the request.
type CommandExecutor ¶
type CommandExecutor interface { // ExecuteCommand handles query commands other than those explicitly specified above. ExecuteCommand(cmd *Command) (bson.Document, error) }
CommandExecutor represents an interface for MongoDB database commands.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config stores server configuration parammeters.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns a default configuration instance.
func (*Config) GetCompressions ¶
GetCompressions should return supported compress strings.
func (*Config) GetLogicalSessionTimeoutMinutes ¶
GetLogicalSessionTimeoutMinutes should return a settion timeout value.
func (*Config) GetMaxBsonObjectSize ¶
GetMaxBsonObjectSize should return a max limitation value of BSON object size.
func (*Config) GetMaxMessageSizeBytes ¶
GetMaxMessageSizeBytes should return a max limitation value of message size.
func (*Config) GetMaxWireVersion ¶
GetMaxWireVersion should return a max supported version.
func (*Config) GetMaxWriteBatchSize ¶
GetMaxWriteBatchSize should return a max limitation value of write batch size.
func (*Config) GetMinWireVersion ¶
GetMinWireVersion should return a min supported version.
func (*Config) GetReadOnly ¶
GetReadOnly should return true when the instance does not support write operations.
func (*Config) GetVersion ¶
GetVersion should return supported MongoDB version string.
type Conn ¶ added in v0.9.2
type Conn struct { sync.Map tracer.SpanContext // contains filtered or unexported fields }
Conn represents a connection of Wire protocol.
type DatabaseCommandExecutor ¶
type DatabaseCommandExecutor interface { ReplicationCommandExecutor DiagnosticCommandExecutor WriteOperationExecutor }
DatabaseCommandExecutor represents an executor interface for MongoDB operation commands.
type DiagnosticCommandExecutor ¶
DiagnosticCommandExecutor represents an executor interface for MongoDB diagnostic commands.
type MessageExecutor ¶
type MessageExecutor interface { QueryCommandExecutor }
MessageExecutor represents an executor interface for MongoDB message.
type MessageListener ¶
type MessageListener interface { protocol.MessageListener }
MessageListener represents a listener for MongoDB messages.
type OpKillCursors ¶
type OpKillCursors = protocol.KillCursors
OpKillCursors (OP_KILL_CURSORS:2007) notifies database that the client has finished with the cursor.
type OpMessageHandler ¶
type OpMessageHandler interface { // Update handles OP_UPDATE of MongoDB wire protocol. OpUpdate(conn *Conn, q *OpUpdate) (bson.Document, error) // Insert handles OP_INSERT of MongoDB wire protocol. OpInsert(conn *Conn, q *OpInsert) (bson.Document, error) // Query handles OP_QUERY of MongoDB wire protocol. OpQuery(conn *Conn, q *OpQuery) (bson.Document, error) // GetMore handles GET_MORE of MongoDB wire protocol. OpGetMore(conn *Conn, q *OpGetMore) (bson.Document, error) // Delete handles OP_DELETE of MongoDB wire protocol. OpDelete(conn *Conn, q *OpDelete) (bson.Document, error) // KillCursors handles OP_KILL_CURSORS of MongoDB wire protocol. OpKillCursors(conn *Conn, q *OpKillCursors) (bson.Document, error) // Msg handles OP_MSG of MongoDB wire protocol. OpMsg(conn *Conn, q *OpMsg) (bson.Document, error) }
OpMessageHandler represents an interface for MongoDB query request.
type QueryCommandExecutor ¶ added in v0.9.2
type QueryCommandExecutor interface { // Insert hadles OP_INSERT and 'insert' query of OP_MSG. Insert(*Conn, *Query) (int32, error) // Update hadles OP_UPDATE and 'update' query of OP_MSG. Update(*Conn, *Query) (int32, error) // Find hadles 'find' query of OP_MSG. Find(*Conn, *Query) ([]bson.Document, error) // Delete hadles OP_DELETE and 'delete' query of OP_MSG. Delete(*Conn, *Query) (int32, error) }
QueryCommandExecutor represents an executor interface for MongoDB queries.
type ReplicationCommandExecutor ¶
ReplicationCommandExecutor represents an executor interface for MongoDB replication commands.
type Server ¶
type Server struct { *Config tracer.Tracer Addr string Port int MessageHandler OpMessageHandler *BaseMessageHandler *BaseCommandExecutor // contains filtered or unexported fields }
Server is an instance for MongoDB protocols.
func (*Server) ExecuteBuildInfo ¶
ExecuteBuildInfo returns statistics about the MongoDB build.
func (*Server) ExecuteIsMaster ¶
ExecuteIsMaster displays information about this member’s role in the replica set, including whether it is the master.
func (*Server) SetMessageHandler ¶
func (server *Server) SetMessageHandler(h OpMessageHandler)
SetMessageHandler sets a message handler.
func (*Server) SetMessageListener ¶
func (server *Server) SetMessageListener(l MessageListener)
SetMessageListener sets a message listener.
type UserCommandExecutor ¶
type UserCommandExecutor interface { QueryCommandExecutor }
UserCommandExecutor represents an executor interface for MongoDB query commands.