mongodb

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URI             string        `yaml:"uri" json:"uri"`
	Database        string        `yaml:"database" json:"database"`
	MaxPoolSize     uint64        `yaml:"maxPoolSize" json:"maxPoolSize"`
	MaxConnIdleTime time.Duration `yaml:"maxConnIdleTime" json:"maxConnIdleTime"`
	TLS             client.Config `yaml:"tls" json:"tls"`
}

func (*Config) Validate

func (c *Config) Validate() error

type OnClearFn

type OnClearFn = func(context.Context) error

type Store

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

Store implements an Store for MongoDB.

func NewStore

func NewStore(ctx context.Context, cfg Config, tls *tls.Config, tracerProvider trace.TracerProvider) (*Store, error)

NewStore creates a new Store.

func NewStoreWithCollection

func NewStoreWithCollection(ctx context.Context, cfg Config, tls *tls.Config, tracerProvider trace.TracerProvider, collection string, indexes ...bson.D) (*Store, error)

func (*Store) Clear

func (s *Store) Clear(ctx context.Context) error

Clear clears the event storage.

func (*Store) Client

func (s *Store) Client() *mongo.Client

Get mongodb client

func (*Store) Close

func (s *Store) Close(ctx context.Context) error

Close closes the database session.

func (*Store) Collection

func (s *Store) Collection(collection string) *mongo.Collection

Get collection with given name

func (*Store) DBName

func (s *Store) DBName() string

DBName returns db name

func (*Store) DropCollection

func (s *Store) DropCollection(ctx context.Context, collection string) error

Drops selected collection from database

func (*Store) DropDatabase

func (s *Store) DropDatabase(ctx context.Context) error

Drops the whole database

func (*Store) EnsureIndex

func (s *Store) EnsureIndex(ctx context.Context, collection string, indexes ...bson.D) error

func (*Store) SetOnClear

func (s *Store) SetOnClear(onClear OnClearFn)

Set the function called on Clear

Jump to

Keyboard shortcuts

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