Documentation ¶
Overview ¶
Package manipmongo provides a MongoDB backed TransactionalManipulator.
Index ¶
- func CompileFilter(f *manipulate.Filter) bson.M
- func CreateCollection(manipulator manipulate.Manipulator, identity elemental.Identity, ...) error
- func CreateIndex(manipulator manipulate.Manipulator, identity elemental.Identity, ...) error
- func DeleteIndex(manipulator manipulate.Manipulator, identity elemental.Identity, ...) error
- func DoesDatabaseExist(manipulator manipulate.Manipulator) (bool, error)
- func DropDatabase(manipulator manipulate.Manipulator) error
- func GetDatabase(manipulator manipulate.Manipulator) (*mgo.Database, func(), error)
- func New(url string, db string, options ...Option) (manipulate.TransactionalManipulator, error)
- func NewMongoManipulator(connectionString string, dbName string, user string, password string, ...) manipulate.TransactionalManipulator
- func SetConsistencyMode(manipulator manipulate.Manipulator, mode mgo.Mode, refresh bool)
- type Option
- func OptionConnectionPoolLimit(poolLimit int) Option
- func OptionConnectionTimeout(connectTimeout time.Duration) Option
- func OptionCredentials(username, password, authsource string) Option
- func OptionDefaultReadConsistencyMode(consistency manipulate.ReadConsistency) Option
- func OptionDefaultWriteConsistencyMode(consistency manipulate.WriteConsistency) Option
- func OptionSharder(sharder Sharder) Option
- func OptionSocketTimeout(socketTimeout time.Duration) Option
- func OptionTLS(tlsConfig *tls.Config) Option
- type Sharder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileFilter ¶
func CompileFilter(f *manipulate.Filter) bson.M
CompileFilter compiles the given manipulate filter into a raw mongo filter.
func CreateCollection ¶
func CreateCollection(manipulator manipulate.Manipulator, identity elemental.Identity, info *mgo.CollectionInfo) error
CreateCollection creates a collection using the given mgo.CollectionInfo.
func CreateIndex ¶
func CreateIndex(manipulator manipulate.Manipulator, identity elemental.Identity, indexes ...mgo.Index) error
CreateIndex creates multiple mgo.Index for the collection storing info for the given identity using the given manipulator.
func DeleteIndex ¶
func DeleteIndex(manipulator manipulate.Manipulator, identity elemental.Identity, indexes ...string) error
DeleteIndex deletes multiple mgo.Index for the collection.
func DoesDatabaseExist ¶
func DoesDatabaseExist(manipulator manipulate.Manipulator) (bool, error)
DoesDatabaseExist checks if the database used by the given manipulator exists.
func DropDatabase ¶
func DropDatabase(manipulator manipulate.Manipulator) error
DropDatabase drops the entire database used by the given manipulator.
func GetDatabase ¶
func GetDatabase(manipulator manipulate.Manipulator) (*mgo.Database, func(), error)
GetDatabase returns a ready to use mgo.Database. Use at your own risks. You are responsible for closing the session by calling the returner close function
func New ¶
func New(url string, db string, options ...Option) (manipulate.TransactionalManipulator, error)
New returns a new manipulator backed by MongoDB.
func NewMongoManipulator ¶
func NewMongoManipulator(connectionString string, dbName string, user string, password string, authsource string, poolLimit int, CAPool *x509.CertPool, clientCerts []tls.Certificate) manipulate.TransactionalManipulator
NewMongoManipulator returns a new TransactionalManipulator backed by MongoDB
func SetConsistencyMode ¶
func SetConsistencyMode(manipulator manipulate.Manipulator, mode mgo.Mode, refresh bool)
SetConsistencyMode sets the mongo consistency mode of the mongo session.
Types ¶
type Option ¶
type Option func(*config)
An Option represents a maniphttp.Manipulator option.
func OptionConnectionPoolLimit ¶
OptionConnectionPoolLimit sets maximum size of the connection pool.
func OptionConnectionTimeout ¶
OptionConnectionTimeout sets the connection timeout.
func OptionCredentials ¶
OptionCredentials sets the username and password to use for authentication.
func OptionDefaultReadConsistencyMode ¶
func OptionDefaultReadConsistencyMode(consistency manipulate.ReadConsistency) Option
OptionDefaultReadConsistencyMode sets the default read consistency mode.
func OptionDefaultWriteConsistencyMode ¶
func OptionDefaultWriteConsistencyMode(consistency manipulate.WriteConsistency) Option
OptionDefaultWriteConsistencyMode sets the default write consistency mode.
func OptionSocketTimeout ¶
OptionSocketTimeout sets the socket timeout.
type Sharder ¶
type Sharder interface { // Shard will be call when the shard key needs to be set to // the given elemental.Identifiable. Shard(elemental.Identifiable) // FilterOne returns the filter bit as bson.M that must be // used to perform an efficient localized query for a single object. // // You can return nil which will trigger a broadcast. FilterOne(elemental.Identifiable) bson.M // FilterMany returns the filter bit as bson.M that must be // used to perform an efficient localized query for multiple objects. // // You can return nil which will trigger a broadcast. FilterMany(elemental.Identity) bson.M }
A Sharder is the interface of an object that can be use to manage sharding of resources.