Documentation ¶
Overview ¶
Package rkmongo is an implementation of rkentry.Entry which could be used mongo client instance.
Index ¶
- Constants
- func GetMongoDB(entryName, dbName string) *mongo.Database
- func RegisterMongoEntryYAML(raw []byte) map[string]rkentry.Entry
- func ToClientOptions(config *BootMongoE) *mongoOpt.ClientOptions
- type BootMongo
- type BootMongoE
- type MongoEntry
- func (entry *MongoEntry) Bootstrap(ctx context.Context)
- func (entry *MongoEntry) GetDefaultMongoDB() *mongo.Database
- func (entry *MongoEntry) GetDescription() string
- func (entry *MongoEntry) GetMongoClient() *mongo.Client
- func (entry *MongoEntry) GetMongoClientOptions() *mongoOpt.ClientOptions
- func (entry *MongoEntry) GetMongoDB(dbName string) *mongo.Database
- func (entry *MongoEntry) GetName() string
- func (entry *MongoEntry) GetType() string
- func (entry *MongoEntry) Interrupt(ctx context.Context)
- func (entry *MongoEntry) String() string
- type Option
- func WithCertEntry(in *rkentry.CertEntry) Option
- func WithClientOptions(opt *mongoOpt.ClientOptions) Option
- func WithDatabase(dbName string, dbOpts ...*mongoOpt.DatabaseOptions) Option
- func WithDescription(description string) Option
- func WithInsecureSkipVerify(skip bool) Option
- func WithLoggerEntry(entry *rkentry.LoggerEntry) Option
- func WithName(name string) Option
- func WithPingTimeoutMs(tout int) Option
Constants ¶
const MongoEntryType = "MongoEntry"
Variables ¶
This section is empty.
Functions ¶
func GetMongoDB ¶
GetMongoDB returns mongo.Database
func RegisterMongoEntryYAML ¶ added in v1.0.0
RegisterMongoEntryYAML register MongoEntry based on config file into rkentry.GlobalAppCtx
func ToClientOptions ¶
func ToClientOptions(config *BootMongoE) *mongoOpt.ClientOptions
ToClientOptions convert BootConfigMongo to options.ClientOptions
Types ¶
type BootMongo ¶ added in v1.0.1
type BootMongo struct {
Mongo []*BootMongoE `yaml:"mongo" json:"mongo"`
}
BootMongo MongoEntry boot config which reflects to YAML config
type BootMongoE ¶ added in v1.0.1
type BootMongoE struct { Name string `yaml:"name" json:"name"` Enabled bool `yaml:"enabled" json:"enabled"` Description string `yaml:"description" json:"description"` Domain string `yaml:"domain" json:"domain"` SimpleURI string `yaml:"simpleURI" json:"simpleURI"` PingTimeoutMs int `yaml:"pingTimeoutMs" json:"pingTimeoutMs"` Database []struct { Name string `yaml:"name" json:"name"` } LoggerEntry string `yaml:"loggerEntry" json:"loggerEntry"` CertEntry string `yaml:"certEntry" json:"certEntry"` InsecureSkipVerify bool `yaml:"insecureSkipVerify" json:"insecureSkipVerify"` AppName *string `yaml:"appName" json:"appName"` Auth *struct { Mechanism string `yaml:"mechanism" json:"mechanism"` MechanismProperties map[string]string `yaml:"mechanismProperties" json:"mechanismProperties"` Source string `yaml:"source" json:"source"` Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` PasswordSet bool `yaml:"passwordSet" json:"passwordSet"` } `yaml:"auth" json:"auth"` ConnectTimeoutMs *int64 `yaml:"connectTimeoutMs" json:"connectTimeoutMs"` Compressors []string `yaml:"compressors" json:"compressors"` Direct *bool `yaml:"direct" json:"direct"` DisableOCSPEndpointCheck *bool `yaml:"disableOCSPEndpointCheck" json:"disableOCSPEndpointCheck"` HeartbeatIntervalMs *int64 `yaml:"heartbeatIntervalMs" json:"heartbeatIntervalMs"` Hosts []string `yaml:"hosts" json:"hosts"` LoadBalanced *bool `yaml:"loadBalanced" json:"loadBalanced"` LocalThresholdMs *int64 `yaml:"localThresholdMs" json:"localThresholdMs"` MaxConnIdleTimeMs *int64 `yaml:"maxConnIdleTimeMs" json:"maxConnIdleTimeMs"` MaxPoolSize *uint64 `yaml:"maxPoolSize" json:"maxPoolSize"` MinPoolSize *uint64 `yaml:"minPoolSize" json:"minPoolSize"` MaxConnecting *uint64 `yaml:"maxConnecting" json:"maxConnecting"` ReplicaSet *string `yaml:"replicaSet" json:"replicaSet"` RetryReads *bool `yaml:"retryReads" json:"retryReads"` RetryWrites *bool `yaml:"retryWrites" json:"retryWrites"` ServerApiOptions *struct { Version string `yaml:"version" json:"version"` Strict *bool `yaml:"strict" json:"strict"` DeprecationErrors *bool `yaml:"deprecationErrors" json:"deprecationErrors"` } `yaml:"serverApiOptions" json:"serverApiOptions"` ServerSelectionTimeoutMs *int `yaml:"serverSelectionTimeoutMs" json:"serverSelectionTimeoutMs"` SocketTimeoutMs *int `yaml:"socketTimeoutMs" json:"socketTimeoutMs"` SRVMaxHosts *int `yaml:"srvMaxHosts" json:"srvMaxHosts"` SRVServiceName *string `yaml:"srvServiceName" json:"srvServiceName"` ZlibLevel *int `yaml:"zlibLevel" json:"zlibLevel"` ZstdLevel *int `yaml:"zstdLevel" json:"zstdLevel"` }
BootMongoE sub struct for BootConfig
type MongoEntry ¶
type MongoEntry struct { Opts *mongoOpt.ClientOptions `yaml:"-" json:"-"` Client *mongo.Client `yaml:"-" json:"-"` // contains filtered or unexported fields }
MongoEntry will init mongo.Client with provided arguments
func GetMongoEntry ¶
func GetMongoEntry(entryName string) *MongoEntry
GetMongoEntry returns MongoEntry
func RegisterMongoEntry ¶
func RegisterMongoEntry(opts ...Option) *MongoEntry
RegisterMongoEntry will register Entry into GlobalAppCtx
func (*MongoEntry) Bootstrap ¶
func (entry *MongoEntry) Bootstrap(ctx context.Context)
Bootstrap MongoEntry
func (*MongoEntry) GetDefaultMongoDB ¶ added in v1.1.3
func (entry *MongoEntry) GetDefaultMongoDB() *mongo.Database
GetDefaultMongoDB returns first mongo.Database
func (*MongoEntry) GetDescription ¶
func (entry *MongoEntry) GetDescription() string
GetDescription returns entry description
func (*MongoEntry) GetMongoClient ¶
func (entry *MongoEntry) GetMongoClient() *mongo.Client
GetMongoClient returns mongo.Client
func (*MongoEntry) GetMongoClientOptions ¶
func (entry *MongoEntry) GetMongoClientOptions() *mongoOpt.ClientOptions
GetMongoClientOptions returns options.ClientOptions
func (*MongoEntry) GetMongoDB ¶
func (entry *MongoEntry) GetMongoDB(dbName string) *mongo.Database
GetMongoDB returns mongo.Database
func (*MongoEntry) Interrupt ¶
func (entry *MongoEntry) Interrupt(ctx context.Context)
Interrupt MongoEntry
func (*MongoEntry) String ¶
func (entry *MongoEntry) String() string
String returns json marshalled string
type Option ¶
type Option func(entry *MongoEntry)
Option for MongoEntry
func WithCertEntry ¶
func WithCertEntry(in *rkentry.CertEntry) Option
WithCertEntry provide CertEntry
func WithClientOptions ¶
func WithClientOptions(opt *mongoOpt.ClientOptions) Option
WithClientOptions provide options.ClientOptions
func WithDatabase ¶
func WithDatabase(dbName string, dbOpts ...*mongoOpt.DatabaseOptions) Option
func WithDescription ¶
WithDescription provide name.
func WithInsecureSkipVerify ¶ added in v1.1.4
func WithLoggerEntry ¶ added in v1.0.0
func WithLoggerEntry(entry *rkentry.LoggerEntry) Option
WithLoggerEntry provide rkentry.LoggerEntry entry name