mongo

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

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 IsCollectionsExist(err error) bool

func IsDuplicateKey

func IsDuplicateKey(err error) bool

func IsNoneDocErr

func IsNoneDocErr(err error) bool

func NewDatasource

func NewDatasource(c *config.Config) error

func NewMongoClient

func NewMongoClient(config *config.Config)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func GetClient

func GetClient() *Client

func (*Client) Close

func (mc *Client) Close()

func (*Client) CreateIndexes

func (mc *Client) CreateIndexes(ctx context.Context, Table string, indexes []mongo.IndexModel) error

func (*Client) Err

func (mc *Client) Err() <-chan error

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) GetDB

func (mc *Client) GetDB() *mongo.Database

func (*Client) HealthCheck

func (mc *Client) HealthCheck(ctx context.Context)

func (*Client) Initialize

func (mc *Client) Initialize(config *config.Config) error

func (*Client) Ready

func (mc *Client) Ready() <-chan struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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