Documentation ¶
Index ¶
- func AddFromFiles(currentPath string) error
- func AddFromStructs(ms []Mariadb_t, rs []Redis_t, ps []Postgres_t) (err error)
- func AddOnlyMariadb(ms []Mariadb_t) (err error)
- func AddOnlyPostgres(ps []Postgres_t) (err error)
- func AddOnlyRedis(rs []Redis_t) (err error)
- func BGREWRITEAOF(conn *redis.Conn) error
- func CleanMariadb()
- func CleanPostgres()
- func CleanRedis()
- func DEL(conn *redis.Conn, keys ...interface{}) (err error)
- func DecryptConnectorFile(filename string) (string, error)
- func Diconnect(conn *redis.Conn) (err error)
- func EXISTS(conn *redis.Conn, key string) (ret bool, err error)
- func GET(conn *redis.Conn, key string) (string, error)
- func HDEL(conn *redis.Conn, params ...interface{}) (err error)
- func HGETALL(conn *redis.Conn, key string) (ret map[string]string, err error)
- func HMGET(conn *redis.Conn, params ...interface{}) (vals []string, err error)
- func HMSET(conn *redis.Conn, params ...interface{}) (err error)
- func KEYS(conn *redis.Conn, query string) (keys []string, err error)
- func SET(conn *redis.Conn, key, value string) (err error)
- type MariadbConnector
- type Mariadb_t
- type PostgresConnector
- type Postgres_t
- type RedisConnector
- type Redis_t
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFromStructs ¶
func AddFromStructs(ms []Mariadb_t, rs []Redis_t, ps []Postgres_t) (err error)
从连接配置结构体切片中进行添加,一般改函数用于第二步,从配置文件中读取后,进行添加,如果与之前的文件连接器key冲突,这里将覆盖之前的内容
func AddOnlyPostgres ¶ added in v1.0.10
func AddOnlyPostgres(ps []Postgres_t) (err error)
只增加Postgres连接
func BGREWRITEAOF ¶ added in v1.0.1
func DecryptConnectorFile ¶
解密一个指定的连接器文件,只还原字符串原型,不做进一步解析
Types ¶
type MariadbConnector ¶ added in v1.0.9
type MariadbConnector string
func (MariadbConnector) Connector ¶ added in v1.0.9
func (ctr MariadbConnector) Connector() *sqlx.DB
返回连接器,如果没有找到则连接器返回nil
func (MariadbConnector) Info ¶ added in v1.0.9
func (ctr MariadbConnector) Info() *Mariadb_t
返回连接信息,如果没有找到则连接器返回nil
type Mariadb_t ¶
type Mariadb_t struct { Key string `toml:"key" json:"key"` Server string `toml:"server" json:"server"` Port int `toml:"port" json:"port"` Uid string `toml:"uid" json:"uid"` Pwd string `toml:"pwd" json:"pwd"` DB string `toml:"db" json:"db"` Timeout string `toml:"timeout" json:"timeout"` // 字符串,携带单位如果忘记写默认s ReadTimeout string `toml:"readTimeout" json:"readTimeout"` // 字符串,携带单位如果忘记写默认s WriteTimeout string `toml:"writeTimeout" json:"writeTimeout"` // 字符串,携带单位如果忘记写默认s }
func (Mariadb_t) CreateConnector ¶
将连接信息按照规范写入流(加密后内容)
func (Mariadb_t) SaveConnectorFile ¶
提供文件名(不含后缀,模块自动添加),保存生成连接器文件
type PostgresConnector ¶ added in v1.0.9
type PostgresConnector string
func (PostgresConnector) Connector ¶ added in v1.0.9
func (ctr PostgresConnector) Connector() *sqlx.DB
返回连接器,如果没有找到则连接器返回nil
func (PostgresConnector) Info ¶ added in v1.0.9
func (ctr PostgresConnector) Info() *Postgres_t
返回连接信息,如果没有找到则连接器返回nil
type Postgres_t ¶ added in v1.0.9
type Postgres_t struct { Key string `toml:"key" json:"key"` Server string `toml:"server" json:"server"` Port int `toml:"port" json:"port"` Username string `toml:"user" json:"user"` Pwd string `toml:"pwd" json:"pwd"` DB string `toml:"db" json:"db"` Timeout int `toml:"timeout" json:"timeout"` }
func (Postgres_t) CreateConnector ¶ added in v1.0.9
func (t Postgres_t) CreateConnector(output io.Writer) error
将连接信息按照规范写入流(加密后内容)
func (Postgres_t) SaveConnectorFile ¶ added in v1.0.9
func (t Postgres_t) SaveConnectorFile(onlyMainFilename string) error
提供文件名(不含后缀,模块自动添加),保存生成连接器文件
type RedisConnector ¶ added in v1.0.9
type RedisConnector string
func (RedisConnector) Connect ¶ added in v1.0.9
func (r RedisConnector) Connect() (*redis.Conn, error)
从连连接池获取一个连接. 获得一个有效连接后,可以使用封装的常用命令,也可以直接使用 conn.Do原生函数执行任何命令
func (RedisConnector) Info ¶ added in v1.0.9
func (ctr RedisConnector) Info() *Redis_t
返回连接信息,如果没有找到则连接器返回nil
type Redis_t ¶
type Redis_t struct { Key string `toml:"key" json:"key"` Server string `toml:"server"` Port int `toml:"port"` Pwd string `toml:"pwd"` DB int `toml:"db"` PoolMaxActive int `toml:"poolMaxActive"` // 0无限制 }
func (Redis_t) CreateConnector ¶
将连接信息按照规范写入流(加密后内容)
func (Redis_t) SaveConnectorFile ¶
提供文件名(不含后缀,模块自动添加),保存生成连接器文件
Click to show internal directories.
Click to hide internal directories.