driver

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MongoURIEnv             = "MONGO_URI"
	MongoReadPreferenceEnv  = "MONGO_READ_PREFERENCE"
	MongoAuthSourceEnv      = "MONGO_AUTH_SOURCE"
	MongoAuthMechanismEnv   = "MONGO_AUTH_MECHANISM"
	MongoReplicaSetEnv      = "MONGO_REPLICA_SET"
	MongoRetryWritesEnv     = "MONGO_RETRY_WRITES"
	MongoSSLVerifyEnv       = "MONGO_SSL_VERIFY_CERTIFICATE"
	MongoMinPoolSizeEnv     = "MONGO_MIN_POOL_SIZE"
	MongoMaxPoolSizeEnv     = "MONGO_MAX_POOL_SIZE"
	MongoConnectTimeoutEnv  = "MONGO_CONNECT_TIMEOUT"
	MongoQueryTimeoutEnv    = "MONGO_QUERY_TIMEOUT"
	MongoUsernameEnv        = "MONGO_USERNAME"
	MongoPasswordEnv        = "MONGO_PASSWORD"
	MongoClusterEndpointEnv = "MONGO_CLUSTER_ENDPOINT"
	MongoCertPathEnv        = "MONGO_CERT_PATH"
	MongoDBNameEnv          = "MONGO_DB_NAME"
	MongoLogLevelEnv        = "MONGO_LOG_LEVEL"

	MongoURIDefault             = ""
	MongoReadPreferenceDefault  = "primary"
	MongoAuthSourceDefault      = ""
	MongoAuthMechanismDefault   = ""
	MongoReplicaSetDefault      = ""
	MongoRetryWritesDefault     = "false"
	MongoSSLVerifyDefault       = false
	MongoMinPoolSizeDefault     = 1
	MongoMaxPoolSizeDefault     = 10
	MongoConnectTimeoutDefault  = 5
	MongoQueryTimeoutDefault    = 30
	MongoUsernameDefault        = ""
	MongoPasswordDefault        = ""
	MongoClusterEndpointDefault = ""
	MongoCertPathDefault        = ""
	MongoDBNameDefault          = ""
	MongoLogLevelDefault        = logger.LevelNone
)

Variables

View Source
var (
	ErrEmptyClient = errors.New("mgorepo-driver: client is nil")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	SSLVerifyCertificate bool
	ConnectTimeout       int
	QueryTimeout         int
	MinPoolSize          int
	MaxPoolSize          int
	URI                  string
	ReadPreference       string
	RetryWrites          string
	AuthSource           string
	AuthMechanism        string
	ReplicaSet           string
	Username             string
	Password             string
	ClusterEndpoint      string
	CertPath             string
	DBName               string
}

Config is the configuration for the driver.

func DefaultConfig

func DefaultConfig() Config

type Driver

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

func New

func New(ctx context.Context) (*Driver, error)

func NewWithConfig

func NewWithConfig(ctx context.Context, config Config) (*Driver, error)

func NewWithOptions added in v0.2.0

func NewWithOptions(options ...Option) (*Driver, error)

func (*Driver) Client

func (d *Driver) Client() *mongo.Client

func (*Driver) Close

func (d *Driver) Close() error

func (*Driver) DbName

func (d *Driver) DbName() string

type Option added in v0.2.0

type Option func(d *Driver)

func WithClient added in v0.2.0

func WithClient(client *mongo.Client) Option

func WithDbName added in v0.2.0

func WithDbName(dbName string) Option

type TestDriver

type TestDriver struct {
	Driver
	// contains filtered or unexported fields
}

func NewTest

func NewTest(t *testing.T) (*TestDriver, error)

func (*TestDriver) Close

func (gm *TestDriver) Close() error

Jump to

Keyboard shortcuts

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