Documentation ¶
Index ¶
- func FilterArgs(filter bson.M) *logutils.FieldArgs
- func PerformTransaction[T common.Storage](th TransactionHandler[T], transaction func(storage T) error) error
- type Adapter
- func (a *Adapter) DeleteConfig(id string) error
- func (a *Adapter) FindConfig(configType string, appID string, orgID string) (*common.Config, error)
- func (a *Adapter) FindConfigByID(id string) (*common.Config, error)
- func (a *Adapter) FindConfigs(configType *string) ([]common.Config, error)
- func (a *Adapter) InsertConfig(config common.Config) error
- func (a *Adapter) NewStorageListener() StorageListener
- func (a *Adapter) RegisterStorageListener(listener common.StorageListener)
- func (a *Adapter) Start(sl common.StorageListener) error
- func (a *Adapter) StartSession(opts ...*options.SessionOptions) (mongo.Session, error)
- func (a *Adapter) UpdateConfig(config common.Config) error
- func (a *Adapter) WithContext(context mongo.SessionContext) common.Storage
- type CollectionWrapper
- func (collWrapper *CollectionWrapper) AddIndex(ctx context.Context, keys interface{}, unique bool) error
- func (collWrapper *CollectionWrapper) AddIndexWithOptions(ctx context.Context, keys interface{}, opt *options.IndexOptions) error
- func (collWrapper *CollectionWrapper) Aggregate(ctx context.Context, pipeline interface{}, result interface{}, ...) error
- func (collWrapper *CollectionWrapper) CountDocuments(ctx context.Context, filter interface{}) (int64, error)
- func (collWrapper *CollectionWrapper) DeleteMany(ctx context.Context, filter interface{}, opts *options.DeleteOptions) (*mongo.DeleteResult, error)
- func (collWrapper *CollectionWrapper) DeleteOne(ctx context.Context, filter interface{}, opts *options.DeleteOptions) (*mongo.DeleteResult, error)
- func (collWrapper *CollectionWrapper) Drop(ctx context.Context) error
- func (collWrapper *CollectionWrapper) DropIndex(ctx context.Context, name string) error
- func (collWrapper *CollectionWrapper) Find(ctx context.Context, filter interface{}, result interface{}, ...) error
- func (collWrapper *CollectionWrapper) FindOne(ctx context.Context, filter interface{}, result interface{}, ...) error
- func (collWrapper *CollectionWrapper) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, ...) error
- func (collWrapper *CollectionWrapper) InsertMany(ctx context.Context, documents []interface{}, opts *options.InsertManyOptions) (*mongo.InsertManyResult, error)
- func (collWrapper *CollectionWrapper) InsertOne(ctx context.Context, data interface{}) (interface{}, error)
- func (collWrapper *CollectionWrapper) ListIndexes(ctx context.Context, l *logs.Logger) ([]bson.M, error)
- func (collWrapper *CollectionWrapper) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, ...) error
- func (collWrapper *CollectionWrapper) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (collWrapper *CollectionWrapper) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (collWrapper *CollectionWrapper) Watch(pipeline interface{}, l *logs.Logger)
- type Database
- type StorageListener
- type TransactionHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterArgs ¶
FilterArgs creates a log object from an unordered MongoDB filter document
func PerformTransaction ¶
func PerformTransaction[T common.Storage](th TransactionHandler[T], transaction func(storage T) error) error
PerformTransaction performs a transaction
Types ¶
type Adapter ¶
type Adapter struct { Context mongo.SessionContext // contains filtered or unexported fields }
Adapter implements the Storage interface
func NewStorageAdapter ¶
NewStorageAdapter creates a new storage adapter instance
func (*Adapter) DeleteConfig ¶
DeleteConfig deletes a configuration from storage
func (*Adapter) FindConfig ¶
FindConfig finds the config for the specified type, appID, and orgID
func (*Adapter) FindConfigByID ¶
FindConfigByID finds the config for the specified ID
func (*Adapter) FindConfigs ¶
FindConfigs finds all configs for the specified type
func (*Adapter) InsertConfig ¶
InsertConfig inserts a new config
func (*Adapter) NewStorageListener ¶
func (a *Adapter) NewStorageListener() StorageListener
NewStorageListener creates a new StorageListener
func (*Adapter) RegisterStorageListener ¶
func (a *Adapter) RegisterStorageListener(listener common.StorageListener)
RegisterStorageListener registers a data change listener with the storage adapter
func (*Adapter) Start ¶
func (a *Adapter) Start(sl common.StorageListener) error
Start starts the storage
func (*Adapter) StartSession ¶
StartSession starts a new session on the underlying MongoDB database
func (*Adapter) UpdateConfig ¶
UpdateConfig updates an existing config
func (*Adapter) WithContext ¶
func (a *Adapter) WithContext(context mongo.SessionContext) common.Storage
WithContext creates a new Adapter with provided context
type CollectionWrapper ¶
type CollectionWrapper struct { Database *Database Coll *mongo.Collection }
CollectionWrapper wraps a MongoDB collection with additional database settings
func (*CollectionWrapper) AddIndex ¶
func (collWrapper *CollectionWrapper) AddIndex(ctx context.Context, keys interface{}, unique bool) error
AddIndex performs an AddIndex operation on the underlying MongoDB collection
func (*CollectionWrapper) AddIndexWithOptions ¶
func (collWrapper *CollectionWrapper) AddIndexWithOptions(ctx context.Context, keys interface{}, opt *options.IndexOptions) error
AddIndexWithOptions performs an AddIndexWithOptions operation on the underlying MongoDB collection
func (*CollectionWrapper) Aggregate ¶
func (collWrapper *CollectionWrapper) Aggregate(ctx context.Context, pipeline interface{}, result interface{}, ops *options.AggregateOptions) error
Aggregate performs an Aggregate operation on the underlying MongoDB collection
func (*CollectionWrapper) CountDocuments ¶
func (collWrapper *CollectionWrapper) CountDocuments(ctx context.Context, filter interface{}) (int64, error)
CountDocuments performs a CountDocuments operation on the underlying MongoDB collection
func (*CollectionWrapper) DeleteMany ¶
func (collWrapper *CollectionWrapper) DeleteMany(ctx context.Context, filter interface{}, opts *options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany performs a Delete operation on the underlying MongoDB collection
func (*CollectionWrapper) DeleteOne ¶
func (collWrapper *CollectionWrapper) DeleteOne(ctx context.Context, filter interface{}, opts *options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOne performs a DeleteOne operation on the underlying MongoDB collection
func (*CollectionWrapper) Drop ¶
func (collWrapper *CollectionWrapper) Drop(ctx context.Context) error
Drop performs a Drop operation on the underlying MongoDB collection
func (*CollectionWrapper) DropIndex ¶
func (collWrapper *CollectionWrapper) DropIndex(ctx context.Context, name string) error
DropIndex performs a DropIndex operation on the underlying MongoDB collection
func (*CollectionWrapper) Find ¶
func (collWrapper *CollectionWrapper) Find(ctx context.Context, filter interface{}, result interface{}, findOptions *options.FindOptions) error
Find performs a Find operation on the underlying MongoDB collection
func (*CollectionWrapper) FindOne ¶
func (collWrapper *CollectionWrapper) FindOne(ctx context.Context, filter interface{}, result interface{}, findOptions *options.FindOneOptions) error
FindOne performs a FindOne operation on the underlying MongoDB collection
func (*CollectionWrapper) FindOneAndUpdate ¶
func (collWrapper *CollectionWrapper) FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, result interface{}, opts *options.FindOneAndUpdateOptions) error
FindOneAndUpdate performs a FindOneAndUpdate operation on the underlying MongoDB collection
func (*CollectionWrapper) InsertMany ¶
func (collWrapper *CollectionWrapper) InsertMany(ctx context.Context, documents []interface{}, opts *options.InsertManyOptions) (*mongo.InsertManyResult, error)
InsertMany performs an InsertMany operation on the underlying MongoDB collection
func (*CollectionWrapper) InsertOne ¶
func (collWrapper *CollectionWrapper) InsertOne(ctx context.Context, data interface{}) (interface{}, error)
InsertOne performs an InsertOne operation on the underlying MongoDB collection
func (*CollectionWrapper) ListIndexes ¶
func (collWrapper *CollectionWrapper) ListIndexes(ctx context.Context, l *logs.Logger) ([]bson.M, error)
ListIndexes performs a ListIndexes operation on the underlying MongoDB collection
func (*CollectionWrapper) ReplaceOne ¶
func (collWrapper *CollectionWrapper) ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, replaceOptions *options.ReplaceOptions) error
ReplaceOne performs a ReplaceOne operation on the underlying MongoDB collection
func (*CollectionWrapper) UpdateMany ¶
func (collWrapper *CollectionWrapper) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts *options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany performs an UpdateMany operation on the underlying MongoDB collection
func (*CollectionWrapper) UpdateOne ¶
func (collWrapper *CollectionWrapper) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts *options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOne performs an UpdateOne operation on the underlying MongoDB collection
func (*CollectionWrapper) Watch ¶
func (collWrapper *CollectionWrapper) Watch(pipeline interface{}, l *logs.Logger)
Watch performs a Watch operation on the underlying MongoDB collection
type Database ¶
type Database struct { MongoDBAuth string MongoDBName string MongoTimeout time.Duration Logger *logs.Logger OnDataChanged func(string) Listeners []common.StorageListener // contains filtered or unexported fields }
Database represents a wrapper for a connection to a MongoDB instance
func (*Database) Collection ¶
func (d *Database) Collection(name string, opts ...*options.CollectionOptions) *mongo.Collection
Collection gets a handle for a MongoDB collection with the given name configured with the given CollectionOptions
type StorageListener ¶
type StorageListener struct { common.DefaultStorageListener // contains filtered or unexported fields }
StorageListener handles responding to database changes
func (*StorageListener) OnConfigsUpdated ¶
func (s *StorageListener) OnConfigsUpdated()
OnConfigsUpdated handles database updates to configs
type TransactionHandler ¶
type TransactionHandler[T common.Storage] interface { WithContext(context mongo.SessionContext) T StartSession(opts ...*options.SessionOptions) (mongo.Session, error) }
TransactionHandler represents an entity that is able to handle a transaction on a MongoDB database