mongodb

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(conf *Config) (*mgo.Session, error)

Dial dial to target server with Monotonic mode

func HealthCheck

func HealthCheck(s *mgo.Session) health.CheckFunc

HealthCheck return a health check function.

Types

type Config

type Config struct {
	Addrs    []string      `envconfig:"MONGODB_ADDRS" default:"mongodb:27017"`
	Database string        `envconfig:"MONGODB_DATABASE" default:"goway"`
	Username string        `envconfig:"MONGODB_USERNAME"`
	Password string        `envconfig:"MONGODB_PASSWORD"`
	Timeout  time.Duration `envconfig:"MONGODB_TIMEOUT" default:"10s"`
	Mode     mgo.Mode      `envconfig:"MONGODB_MODE" default:"1"`
	Refesh   bool          `envconfig:"MONGODB_REFRESH" default:"true"`
}

Config hold MongoDB configuration information

func LoadConfigFromEnv

func LoadConfigFromEnv() *Config

LoadConfigFromEnv returns a Config object populated from environment variables.

func (*Config) DialInfo

func (conf *Config) DialInfo() *mgo.DialInfo

DialInfo return dial info from config

Jump to

Keyboard shortcuts

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