Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureCollection(col string, validator interface{}, indexes []mongo.IndexModel)
- func IsCollectionsExist(err error) bool
- func IsDuplicateKey(err error) bool
- func IsNoneDocErr(err error) bool
- func NewDatasource(c *config.Config) error
- func NewMongoClient(config *config.Config)
- type Client
- func (mc *Client) Close()
- func (mc *Client) CreateIndexes(ctx context.Context, Table string, indexes []mongo.IndexModel) error
- func (mc *Client) Err() <-chan error
- func (mc *Client) ExecTxn(ctx context.Context, cmd func(sessionContext mongo.SessionContext) error) error
- func (mc *Client) GetDB() *mongo.Database
- func (mc *Client) HealthCheck(ctx context.Context)
- func (mc *Client) Initialize(config *config.Config) error
- func (mc *Client) Ready() <-chan struct{}
Constants ¶
View Source
const ( DuplicateKey = "E11000" CollectionsExists = 48 )
View Source
const ( MongoCheckDelay = 2 * time.Second HeathChekRetryTimes = 3 DefaultDBName = "servicecomb" )
Variables ¶
View Source
var ( ErrOpenDbFailed = errors.New("open db failed") ErrRootCAMissing = errors.New("rootCAFile is empty in config file") ErrURIIsEmpty = errors.New("uri is empty") )
View Source
var ErrNoDocuments = errors.New("no doc found")
Functions ¶
func EnsureCollection ¶
func EnsureCollection(col string, validator interface{}, indexes []mongo.IndexModel)
func IsCollectionsExist ¶
func IsDuplicateKey ¶
func IsNoneDocErr ¶
func NewDatasource ¶
func NewMongoClient ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateIndexes ¶
func (*Client) ExecTxn ¶
func (mc *Client) ExecTxn(ctx context.Context, cmd func(sessionContext mongo.SessionContext) error) error
ExecTxn execute a transaction command want to abort transaction, return error in cmd fn impl, otherwise it will commit transaction
func (*Client) HealthCheck ¶
Click to show internal directories.
Click to hide internal directories.