mgoutil

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package mgoutil provides utilities for working with mgo library.

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"`
	Refresh  bool          `envconfig:"MONGODB_REFRESH" default:"true"`
}

Config hold MongoDB common configuration.

func ReadConfigFromEnv added in v0.1.0

func ReadConfigFromEnv(opts ...config.ReadOption) *Config

ReadConfigFromEnv 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