Version: v1.9.0 Latest Latest

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

Go to latest
Published: Jun 28, 2021 License: Apache-2.0 Imports: 17 Imported by: 0




This section is empty.


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")


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)


type Config

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

func NewConfig

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

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL