mongo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultAppName

func SetDefaultAppName(val string)

func SetDefaultAuthMechanism

func SetDefaultAuthMechanism(val string)

func SetDefaultAuthMechanismProperties

func SetDefaultAuthMechanismProperties(val map[string]string)

func SetDefaultAuthPassword

func SetDefaultAuthPassword(val string)

func SetDefaultAuthPasswordSet

func SetDefaultAuthPasswordSet(val bool)

func SetDefaultAuthSource

func SetDefaultAuthSource(val string)

func SetDefaultAuthUsername

func SetDefaultAuthUsername(val string)

func SetDefaultCollection

func SetDefaultCollection(val string)

func SetDefaultCompressors

func SetDefaultCompressors(val []string)

func SetDefaultConnectionTimeout

func SetDefaultConnectionTimeout(val time.Duration)

func SetDefaultCredentialFlagsPrefix

func SetDefaultCredentialFlagsPrefix(val string)

func SetDefaultDatabase

func SetDefaultDatabase(val string)

func SetDefaultDirect

func SetDefaultDirect(val bool)

func SetDefaultDisableOCSPEndpointCheck

func SetDefaultDisableOCSPEndpointCheck(val bool)

func SetDefaultHeartbeatInterval

func SetDefaultHeartbeatInterval(val time.Duration)

func SetDefaultHosts

func SetDefaultHosts(val []string)

func SetDefaultLocalThreshold

func SetDefaultLocalThreshold(val time.Duration)

func SetDefaultMaxConnIdleTime

func SetDefaultMaxConnIdleTime(val time.Duration)

func SetDefaultMaxPoolSize

func SetDefaultMaxPoolSize(val uint64)

func SetDefaultMinPoolSize

func SetDefaultMinPoolSize(val uint64)

func SetDefaultMongoFlagsPrefix

func SetDefaultMongoFlagsPrefix(val string)

func SetDefaultReadConcernFlagsPrefix

func SetDefaultReadConcernFlagsPrefix(val string)

func SetDefaultReadConcernLevel

func SetDefaultReadConcernLevel(val string)

func SetDefaultReadPrefFlagsPrefix

func SetDefaultReadPrefFlagsPrefix(val string)

func SetDefaultReadPrefHedgeEnabled

func SetDefaultReadPrefHedgeEnabled(val bool)

func SetDefaultReadPrefMaxStaleness

func SetDefaultReadPrefMaxStaleness(val time.Duration)

func SetDefaultReadPrefMode

func SetDefaultReadPrefMode(val readpref.Mode)

func SetDefaultReadPrefTagSets

func SetDefaultReadPrefTagSets(val []tag.Set)

func SetDefaultReplicaSet

func SetDefaultReplicaSet(val string)

func SetDefaultRetryReads

func SetDefaultRetryReads(val bool)

func SetDefaultRetryWrites

func SetDefaultRetryWrites(val bool)

func SetDefaultSeverSelectTimeout

func SetDefaultSeverSelectTimeout(val time.Duration)

func SetDefaultSocketTimeout

func SetDefaultSocketTimeout(val time.Duration)

func SetDefaultURI

func SetDefaultURI(val string)

func SetDefaultZlibLevel

func SetDefaultZlibLevel(val int)

func SetDefaultZstdLevel

func SetDefaultZstdLevel(val int)

Types

type ClientOptions

type ClientOptions struct {
	AppName string     `json:"app-name" yaml:"app-name"`
	Auth    Credential `json:"auth" yaml:"auth"`

	ConnectTimeout           time.Duration `json:"connect-timeout" yaml:"connect-timeout"`
	Compressors              []string      `json:"compressors" yaml:"compressors"`
	Collection               string        `json:"collection" yaml:"collection"`
	DB                       string        `json:"database" yaml:"database"`
	Direct                   bool          `json:"direct" yaml:"direct"`
	DisableOCSPEndpointCheck bool          `json:"disable-ocsp-endpoint-check" yaml:"disable-ocsp-endpoint-check"`
	HeartbeatInterval        time.Duration `json:"heartbeat-interval" yaml:"heartbeat-interval"`
	Hosts                    []string      `json:"hosts" yaml:"hosts"`
	LocalThreshold           time.Duration `json:"local-threshold" yaml:"local-threshold"`
	MaxConnIdleTime          time.Duration `json:"max-conn-idle-time" yaml:"max-conn-idle-time"`
	MaxPoolSize              uint64        `json:"max-pool-size" yaml:"max-pool-size"`
	MinPoolSize              uint64        `json:"min-pool-size" yaml:"min-pool-size"`

	// ReadConcern for replica sets and replica set shards determines which data to return from a query.
	ReadConcern ReadConcern `json:"read-concern" yaml:"read-concern"`

	// ReadPreference determines which servers are considered suitable for read operations.
	ReadPreference ReadPref `json:"read-preference" yaml:"read-preference"`

	ReplicaSet string `json:"replica-set" yaml:"replica-set"`

	RetryReads bool `json:"retry-reads" yaml:"retry-reads"`

	RetryWrites bool `json:"retry-writes" yaml:"retry-writes"`

	ServerSelectionTimeout time.Duration `json:"server-selection-timeout" yaml:"server-selection-timeout"`

	SocketTimeout time.Duration `json:"socket-timeout" yaml:"socket-timeout"`

	URI string `json:"uri" yaml:"uri"`

	ZlibLevel int `json:"zlib-level" yaml:"zlib-yaml"`

	ZstdLevel int `json:"zstd-level" yaml:"zstd-yaml"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

func (*ClientOptions) BindFlags

func (m *ClientOptions) BindFlags(fs *bootflag.FlagSet)

func (*ClientOptions) Parse

func (m *ClientOptions) Parse() (err error)

func (*ClientOptions) Standardize

func (m *ClientOptions) Standardize() (opts *options.ClientOptions, err error)

type Credential

type Credential struct {
	AuthMechanism           string            `json:"mechanism" yaml:"mechanism"`
	AuthMechanismProperties map[string]string `json:"mechanism-properties" yaml:"mechanism-properties"`
	AuthSource              string            `json:"source" yaml:"source"`
	Username                string            `json:"username" yaml:"username"`
	Password                string            `json:"password" yaml:"password"`
	PasswordSet             bool              `json:"password-set" yaml:"password-set"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

Credential can be used to provide authentication options when configuring a Client.

See official go-mongo-driver doc https://godoc.org/go.mongodb.org/mongo-driver/mongo/options#Credential for details.

func (*Credential) BindFlags

func (c *Credential) BindFlags(fs *bootflag.FlagSet)

func (*Credential) Parse

func (c *Credential) Parse() (err error)

type ReadConcern

type ReadConcern struct {
	Level string `json:"level" yaml:"level"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

ReadConcern for replica sets and replica set shards determines which data to return from a query.

func (*ReadConcern) BindFlags

func (rc *ReadConcern) BindFlags(fs *bootflag.FlagSet)

func (*ReadConcern) Parse

func (rc *ReadConcern) Parse() (err error)

type ReadPref

type ReadPref struct {
	MaxStaleness time.Duration `json:"max-staleness" yaml:"max-staleness"`
	Mode         readpref.Mode `json:"mode" yaml:"mode"`
	TagSets      []tag.Set     `json:"tag-sets" yaml:"tag-sets"`
	HedgeEnabled bool          `json:"hedge-enabled" yaml:"hedge-enabled"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
	// contains filtered or unexported fields
}

ReadPref determines which servers are considered suitable for read operations.

func (*ReadPref) BindFlags

func (rp *ReadPref) BindFlags(fs *bootflag.FlagSet)

func (*ReadPref) Get

func (rp *ReadPref) Get() (srp *readpref.ReadPref, err error)

func (*ReadPref) Parse

func (rp *ReadPref) Parse() (err error)

func (*ReadPref) Standardize

func (rp *ReadPref) Standardize() (srp *readpref.ReadPref, err error)

Jump to

Keyboard shortcuts

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