Documentation ¶
Overview ¶
Package mgox Created by xuzhuoxi on 2019-06-15. @author xuzhuoxi
Package mgox Created by xuzhuoxi on 2019-06-16. @author xuzhuoxi
Package mgox Created by xuzhuoxi on 2019-06-16. @author xuzhuoxi
Package mgox Created by xuzhuoxi on 2019-06-13. @author xuzhuoxi
Package mgox Created by xuzhuoxi on 2019-06-14. @author xuzhuoxi
Package mgox Created by xuzhuoxi on 2019-06-15. @author xuzhuoxi
Index ¶
- Variables
- func NewOptions(uri string) *options.ClientOptions
- type IContextGetter
- type IContextSetter
- type IMongoClient
- type IMongoDatabase
- type IMongoDriver
- type MongoClient
- func (c *MongoClient) Client() *mongo.Client
- func (c *MongoClient) Connect() error
- func (c *MongoClient) Connecting() bool
- func (c *MongoClient) Disconnect() error
- func (c *MongoClient) GetDatabaseNames() []string
- func (c *MongoClient) LocateDatabase(dbName string, newContext context.Context) (db IMongoDatabase, change bool)
- func (c *MongoClient) LocatedDatabase() IMongoDatabase
- func (c *MongoClient) Name() string
- func (c *MongoClient) Reconnect() error
- type MongoDatabase
- func (db *MongoDatabase) Connect() error
- func (db *MongoDatabase) Database() *mongo.Database
- func (db *MongoDatabase) DatabaseName() string
- func (db *MongoDatabase) Disconnect() error
- func (db *MongoDatabase) GetCollection(cName string) (c *mongo.Collection, ok bool)
- func (db *MongoDatabase) GetCollectionNames() []string
- func (db *MongoDatabase) LocateCollection(cName string) (c *mongo.Collection, change bool)
- func (db *MongoDatabase) LocatedCollection() *mongo.Collection
- type MongoDriver
- func (d *MongoDriver) Close() error
- func (d *MongoDriver) CloseClient(name string) error
- func (d *MongoDriver) GetClient(name string) (client IMongoClient, ok bool)
- func (d *MongoDriver) MasterClient() IMongoClient
- func (d *MongoDriver) NumClient() int
- func (d *MongoDriver) OpenClient(name string, options *options.ClientOptions, context context.Context) (client IMongoClient, err error)
- func (d *MongoDriver) SetMasterClient(name string) (client IMongoClient, change bool)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultContext = context.Background() ClientContext = context.Background() DBReaderContext = context.Background() DBWriterContext = context.Background() CollectionReaderContext = context.Background() CollectionWriterContext = context.Background() )
Functions ¶
func NewOptions ¶
func NewOptions(uri string) *options.ClientOptions
Types ¶
type IContextGetter ¶
type IContextSetter ¶
type IMongoClient ¶
type IMongoClient interface { Name() string Connect() error Disconnect() error Connecting() bool Reconnect() error Client() *mongo.Client GetDatabaseNames() []string LocateDatabase(dbName string, newContext context.Context) (db IMongoDatabase, change bool) LocatedDatabase() IMongoDatabase }
func NewIMongoClient ¶
func NewIMongoClient(clientName string, options *options.ClientOptions, context context.Context) IMongoClient
type IMongoDatabase ¶
type IMongoDatabase interface { Connect() error Disconnect() error DatabaseName() string Database() *mongo.Database GetCollectionNames() []string GetCollection(cName string) (c *mongo.Collection, ok bool) LocateCollection(cName string) (c *mongo.Collection, change bool) LocatedCollection() *mongo.Collection }
func NewIMongoDatabase ¶
func NewIMongoDatabase(db *mongo.Database, context context.Context) IMongoDatabase
type IMongoDriver ¶
type IMongoDriver interface { io.Closer OpenClient(name string, options *options.ClientOptions, context context.Context) (client IMongoClient, err error) CloseClient(name string) error NumClient() int GetClient(name string) (client IMongoClient, ok bool) SetMasterClient(name string) (client IMongoClient, change bool) MasterClient() IMongoClient }
func NewMongoDriver ¶
func NewMongoDriver(maxClient int) IMongoDriver
type MongoClient ¶
type MongoClient struct { Options *options.ClientOptions CliContext context.Context Cli *mongo.Client ConnectMutex sync.RWMutex DatabaseNames []string Database IMongoDatabase DBName string // contains filtered or unexported fields }
func NewMongoClient ¶
func NewMongoClient(clientName string, options *options.ClientOptions, context context.Context) *MongoClient
func (*MongoClient) Client ¶
func (c *MongoClient) Client() *mongo.Client
func (*MongoClient) Connect ¶
func (c *MongoClient) Connect() error
func (*MongoClient) Connecting ¶
func (c *MongoClient) Connecting() bool
func (*MongoClient) Disconnect ¶
func (c *MongoClient) Disconnect() error
func (*MongoClient) GetDatabaseNames ¶
func (c *MongoClient) GetDatabaseNames() []string
func (*MongoClient) LocateDatabase ¶
func (c *MongoClient) LocateDatabase(dbName string, newContext context.Context) (db IMongoDatabase, change bool)
func (*MongoClient) LocatedDatabase ¶
func (c *MongoClient) LocatedDatabase() IMongoDatabase
func (*MongoClient) Name ¶
func (c *MongoClient) Name() string
func (*MongoClient) Reconnect ¶
func (c *MongoClient) Reconnect() error
type MongoDatabase ¶
type MongoDatabase struct { DB *mongo.Database DBContext context.Context CollectionNames []string Collections map[string]*mongo.Collection Collection *mongo.Collection CName string }
func NewMongoDatabase ¶
func NewMongoDatabase(db *mongo.Database, context context.Context) *MongoDatabase
func (*MongoDatabase) Connect ¶
func (db *MongoDatabase) Connect() error
func (*MongoDatabase) Database ¶
func (db *MongoDatabase) Database() *mongo.Database
func (*MongoDatabase) DatabaseName ¶
func (db *MongoDatabase) DatabaseName() string
func (*MongoDatabase) Disconnect ¶
func (db *MongoDatabase) Disconnect() error
func (*MongoDatabase) GetCollection ¶
func (db *MongoDatabase) GetCollection(cName string) (c *mongo.Collection, ok bool)
func (*MongoDatabase) GetCollectionNames ¶
func (db *MongoDatabase) GetCollectionNames() []string
func (*MongoDatabase) LocateCollection ¶
func (db *MongoDatabase) LocateCollection(cName string) (c *mongo.Collection, change bool)
func (*MongoDatabase) LocatedCollection ¶
func (db *MongoDatabase) LocatedCollection() *mongo.Collection
type MongoDriver ¶
type MongoDriver struct { Clients []IMongoClient MasterIndex int ChanLimit lang.IChannelLimit Lock sync.RWMutex }
func (*MongoDriver) Close ¶
func (d *MongoDriver) Close() error
func (*MongoDriver) CloseClient ¶
func (d *MongoDriver) CloseClient(name string) error
func (*MongoDriver) GetClient ¶
func (d *MongoDriver) GetClient(name string) (client IMongoClient, ok bool)
func (*MongoDriver) MasterClient ¶
func (d *MongoDriver) MasterClient() IMongoClient
func (*MongoDriver) NumClient ¶
func (d *MongoDriver) NumClient() int
func (*MongoDriver) OpenClient ¶
func (d *MongoDriver) OpenClient(name string, options *options.ClientOptions, context context.Context) (client IMongoClient, err error)
func (*MongoDriver) SetMasterClient ¶
func (d *MongoDriver) SetMasterClient(name string) (client IMongoClient, change bool)
Click to show internal directories.
Click to hide internal directories.