mongo

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: MulanPSL-2.0 Imports: 12 Imported by: 0

README

gsf-mongo

db config json

component

{
  "max_rep_time" : 3,
  "max_idle_time" : 3,
  "selection_time" : 3,
  "slow_threshold" : 200
}

client

{
  "host": "127.0.0.1:9800",
  "user": "root",
  "pwd": "root",
  "db": "test",
  "options": "",
  "min_pool_size" : 2,
  "max_pool_size" : 10
}

命令行参数

--mongo-req-timeout value        mongo request timeout (default: 0)
--mongo-idle-timeout value       mongo idle connect timeout (default: 0)
--mongo-select-timeout value     mongo selection timeout (default: 0)
--mongo-slow-threshold value     mongo slow sql threshold (default: 0)
--mongo-{{key}}-pool-min value   mongo({{key}}) min pool size (default: 0)
--mongo-{{key}}-pool-max value   mongo({{key}}) max pool size (default: 0)
--mongo-{{key}}-dsn value        mongo({{key}}) DSN (format: mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]])

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateClient = defaultNewClient

Functions

This section is empty.

Types

type Client added in v0.3.0

type Client struct {
	Client *mongo.Database
	Cfg    ClientConfig
}

func (*Client) CliFlags added in v0.3.0

func (c *Client) CliFlags(name string) []cli.Flag

func (*Client) Load added in v0.3.0

func (c *Client) Load(name string, cfg *ComponentConfig) (err error)

type ClientConfig added in v0.3.0

type ClientConfig struct {
	Host        string `json:"host"          yaml:"host"`
	User        string `json:"user"          yaml:"user"`
	Pwd         string `json:"pwd"           yaml:"pwd"`
	DB          string `json:"db"            yaml:"db"`
	Options     string `json:"options"       yaml:"options"`
	MinPoolSize int    `json:"min_pool_size" yaml:"min_pool_size"`
	MaxPoolSize int    `json:"max_pool_size" yaml:"max_pool_size"`
}

type Component

type Component struct {
	DSNPrint bool
	Cfg      ComponentConfig
	Clts     map[string]*Client
}

func (*Component) CliFlags

func (c *Component) CliFlags() []cli.Flag

func (*Component) Close

func (c *Component) Close() error

func (*Component) Init

func (c *Component) Init(l logger.Interface, cfg *gsf.AppConfig, ctx *cli.Context) error

func (*Component) LoadOne added in v0.3.0

func (c *Component) LoadOne(name string) (err error)

func (*Component) Run

func (c *Component) Run() error

type ComponentConfig added in v0.3.0

type ComponentConfig struct {
	ReqMaxTime    int `json:"rep_max_time"    yaml:"rep_max_time"`
	MaxIdleTime   int `json:"max_idle_time"   yaml:"max_idle_time"`
	SelectionTime int `json:"selection_time"  yaml:"selection_time"`
	SlowThreshold int `json:"slow_threshold"  yaml:"slow_threshold"`
}

Jump to

Keyboard shortcuts

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