db

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBConfigFile = "db.conf"

	DBTypeMongo    = "mongo"
	DBTypeMySQL    = "mysql"
	DBTypePostgres = "postgres"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConfig

type DBConfig struct {
	Type DBType `yaml:"type" json:"type"`
}

数据库配置

func SharedDBConfig

func SharedDBConfig() *DBConfig

取得共享的配置

func (*DBConfig) Save

func (this *DBConfig) Save() error

保存

type DBType

type DBType = string

数据库配置

type MongoAccessLogConfig

type MongoAccessLogConfig struct {
	CleanHour int `yaml:"cleanHour" json:"cleanHour"` // 清理时间,0-23
	KeepDays  int `yaml:"keepDays" json:"keepDays"`   // 保留挺熟
}

type MongoConfig

type MongoConfig struct {
	URI       string                `yaml:"uri" json:"uri"`
	AccessLog *MongoAccessLogConfig `yaml:"accessLog" json:"accessLog"`
}

MongoDB配置

func LoadMongoConfig

func LoadMongoConfig() (*MongoConfig, error)

加载MongoDB配置

func NewMongoConfig

func NewMongoConfig() *MongoConfig

获取新对象

func (*MongoConfig) Save

func (this *MongoConfig) Save() error

保存

type MongoConnectionConfig

type MongoConnectionConfig struct {
	Scheme                  string             `json:"scheme"`
	Username                string             `json:"username"`
	Password                string             `json:"password"`
	Host                    string             `json:"host"`
	Port                    uint               `json:"port"`
	AuthMechanism           string             `json:"authMechanism"`
	AuthMechanismProperties []*shared.Variable `json:"authMechanismProperties"`
	RequestURI              string             `json:"requestURI"` // @TODO 未来版本需要实现
}

MongoDB连接配置

func SharedMongoConfig

func SharedMongoConfig() *MongoConnectionConfig

取得全局的MongoDB配置

func (*MongoConnectionConfig) AuthMechanismPropertiesMap

func (this *MongoConnectionConfig) AuthMechanismPropertiesMap() map[string]string

取得Map形式的认证属性

func (*MongoConnectionConfig) AuthMechanismPropertiesString

func (this *MongoConnectionConfig) AuthMechanismPropertiesString() string

取得字符串形式的认证属性

func (*MongoConnectionConfig) Save

func (this *MongoConnectionConfig) Save() error

保存修改后的MongoDB配置

func (*MongoConnectionConfig) URI

func (this *MongoConnectionConfig) URI() string

组合后的URI

func (*MongoConnectionConfig) URIMask

func (this *MongoConnectionConfig) URIMask() string

组合后的URI,但是对URI进行掩码

Jump to

Keyboard shortcuts

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