db

package
v0.0.0-...-8db1920 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultMongoDBHost            = "localhost"
	DefaultMongoDBPort            = "27017"
	DefaultMongoDBAuthDB          = "admin"
	DefaultMongoDBTimeout         = "5s"
	DefaultMongoDBTimeoutDuration = time.Duration(5) * time.Second
)
View Source
var (
	ErrMsgAuthFailedStr string = "server returned error on SASL authentication step: Authentication failed."
	ErrSessionTimeout          = errors.New("timed out waiting for mongodb connection")
	ErrPrimaryTimeout          = errors.New("timed out waiting for host to become primary")
)

Functions

func GetSession

func GetSession(cnf *Config) (*mgo.Session, error)

func LastSSLError

func LastSSLError() error

LastSSLError returns the last error related to the DB connection SSL handshake

func WaitForPrimary

func WaitForPrimary(session *mgo.Session, maxRetries uint, sleepDuration time.Duration) error

func WaitForSession

func WaitForSession(cnf *Config, maxRetries uint, sleepDuration time.Duration) (*mgo.Session, error)

Types

type Config

type Config struct {
	DialInfo *mgo.DialInfo
	SSL      *SSLConfig
}

func NewConfig

func NewConfig(app *kingpin.Application, envUser string, envPassword string) *Config

func (*Config) Uri

func (cnf *Config) Uri() string

type SSLConfig

type SSLConfig struct {
	Enabled    bool
	PEMKeyFile string
	CAFile     string
	Insecure   bool
}

func NewSSLConfig

func NewSSLConfig(app *kingpin.Application) *SSLConfig

Jump to

Keyboard shortcuts

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