mongoclient

package
v0.64.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CollectionBlobs         = "blobs"
	CollectionResellers     = "resellers"
	CollectionUsers         = "users"
	CollectionSubscriptions = "bb_subscriptions"
	CollectionSites         = "projects"
)

Variables

This section is empty.

Functions

func Connect

func Connect(log logrus.FieldLogger, config *Config) (*mongo.Client, error)

Connect connects to MongoDB

func ConnectWithOptions added in v0.40.0

func ConnectWithOptions(log logrus.FieldLogger, replSet string, servers []string, opts ...Option) (*mongo.Client, error)

func LoadCAFromFiles added in v0.64.0

func LoadCAFromFiles(cafiles []string) (*x509.CertPool, error)

func LoadCAFromValue added in v0.64.0

func LoadCAFromValue(ca string) (*x509.CertPool, error)

func LoadCertFromFiles added in v0.64.0

func LoadCertFromFiles(certFile, keyFile string) (tls.Certificate, error)

func LoadCertFromValues added in v0.64.0

func LoadCertFromValues(certPEM, keyPEM string) (tls.Certificate, error)

Types

type Auth

type Auth struct {
	Username string
	Password string
	Source   string
}

type Config

type Config struct {
	AppName            string
	TLS                *TLSConfig
	Servers            []string
	ReplSetName        string
	ConnTimeout        time.Duration
	Auth               *Auth
	SecondaryPreferred bool
}

type Option added in v0.40.0

type Option func(opt *options.ClientOptions) error

func AppName added in v0.40.0

func AppName(name string) Option

func AuthOption added in v0.40.0

func AuthOption(config Auth) Option

func ConnectionTimeout added in v0.40.0

func ConnectionTimeout(dur time.Duration) Option

func SecondaryPreferred added in v0.40.0

func SecondaryPreferred() Option

func TLSOption added in v0.40.0

func TLSOption(log logrus.FieldLogger, config TLSConfig) Option

type TLSConfig added in v0.64.0

type TLSConfig struct {
	CAFiles  []string `mapstructure:"ca_files" envconfig:"ca_files" json:"ca_files" yaml:"ca_files"`
	KeyFile  string   `mapstructure:"key_file" split_words:"true" json:"key_file" yaml:"key_file"`
	CertFile string   `mapstructure:"cert_file" split_words:"true" json:"cert_file" yaml:"cert_file"`

	Cert string `mapstructure:"cert"`
	Key  string `mapstructure:"key"`
	CA   string `mapstructure:"ca"`

	Insecure bool `default:"false"`
	Enabled  bool `default:"false"`
}

func (TLSConfig) TLSConfig added in v0.64.0

func (cfg TLSConfig) TLSConfig() (*tls.Config, error)

Jump to

Keyboard shortcuts

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