mongodb

package
v1.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCollectionNotFound = errors.New("mongodb collection not found")

ErrCollectionNotFound signals that provided mongodb collection is not available

View Source
var ErrEmptyMongoDBName = errors.New("empty db name")

ErrEmptyMongoDBName signals that an empty db name has been provided

View Source
var ErrNilMongoDBClient = errors.New("nil mongodb client")

ErrNilMongoDBClient signals that a nil mongodb client has been provided

Functions

func NewClient

func NewClient(client *mongo.Client, dbName string, numUsersColls uint32, metricsHandler core.StatusMetricsHandler) (*mongodbClient, error)

NewClient will create a new mongodb client instance

Types

type CollectionID

type CollectionID string

CollectionID defines mongodb collection type

const (
	// UsersCollectionID specifies mongodb collection for users
	UsersCollectionID CollectionID = "users"
)

type MongoDBClient

type MongoDBClient interface {
	Put(coll CollectionID, key []byte, data []byte) error
	Get(coll CollectionID, key []byte) ([]byte, error)
	Has(coll CollectionID, key []byte) error
	Remove(coll CollectionID, key []byte) error
	GetIndex(collID CollectionID, key []byte) (uint32, error)
	PutIndexIfNotExists(collID CollectionID, key []byte, index uint32) error
	IncrementIndex(collID CollectionID, key []byte) (uint32, error)
	GetAllCollectionsIDs() []CollectionID
	Close() error
	IsInterfaceNil() bool
}

MongoDBClient defines what a mongodb client should do

func CreateMongoDBClient

func CreateMongoDBClient(cfg config.MongoDBConfig, metricsHandler core.StatusMetricsHandler) (MongoDBClient, error)

CreateMongoDBClient will create a new mongo db client instance

Jump to

Keyboard shortcuts

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