mongodb

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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