glo

package
v0.0.0-...-0b50f6a Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Config Params
	Config GlobalConfig
	// ConfigFile FileName
	ConfigFile string
)
View Source
var (
	Db *gorm.DB
)

Functions

func DbConnect

func DbConnect()

DbConnect 连接数据库

func DbDisconnect

func DbDisconnect()

DbDisconnect 断开数据库

func Deserialization

func Deserialization(byt []byte, ptr interface{}) (err error)

Deserialization 反序列化

func NewRedisPool

func NewRedisPool()

NewRedisPool func redis pool

func ParseConfig

func ParseConfig(file string) (err error)

ParseConfig Function

func RdsDisConnect

func RdsDisConnect()

RdsDisConnect DisConnect Redis Pool

func Serialization

func Serialization(value interface{}) ([]byte, error)

Serialization 序列化

Types

type AlertCfg

type AlertCfg struct {
	AlertChan int64 `yaml:"alert_chan"`
}

type Cache

type Cache struct {
	Pool              *redis.Pool
	DefaultExpiration time.Duration
}
var (
	RedisCache Cache
)

func (*Cache) Del

func (cache *Cache) Del(name string) (err error)

Del 删除Key

func (*Cache) Exist

func (cache *Cache) Exist(name string) (bool, error)

判断所在的 key 是否存在

func (*Cache) HExists

func (cache *Cache) HExists(name, field string) (bool, error)

查看hash 中指定是否存在

func (*Cache) HGet

func (cache *Cache) HGet(name, field string) (v interface{}, ok bool, err error)

获取单个hash 中的值

func (*Cache) HGetAll

func (cache *Cache) HGetAll(name string) (data map[string]string, err error)

HIncrby hash key 自增

func (*Cache) HGetString

func (cache *Cache) HGetString(name, field string) (v interface{}, ok bool, err error)

HGetString 获取单个hash中的值string

func (*Cache) HIncrby

func (cache *Cache) HIncrby(name, field string) (ok bool, err error)

HIncrby hash key 自增

func (*Cache) HMSet

func (cache *Cache) HMSet(name string, kv map[string]interface{}) (err error)

HMSet 设置单个值, value 还可以是一个 map slice 等

func (*Cache) HSet

func (cache *Cache) HSet(name string, key string, value interface{}) (err error)

设置单个值, value 还可以是一个 map slice 等

func (*Cache) Hdel

func (cache *Cache) Hdel(name, key string) (bool, error)

////////////////// hash /////////// 删除指定的 hash 键

func (*Cache) StringGet

func (cache *Cache) StringGet(name string) (v interface{}, err error)

StringGet 获取字符串类型的值

func (*Cache) StringSet

func (cache *Cache) StringSet(name string, v interface{}) error

StringSet string 类型 添加, v 可以是任意类型

type DatabaseConfig

type DatabaseConfig struct {
	Dialect     string `yaml:"dialect"`
	Addr        string `yaml:"addr"`
	AutoMigrate bool   `yaml:"automigrate"`
}

DatabaseConfig Struct

type DingDingConfig

type DingDingConfig struct {
	API string `yaml:"api"`
}

type GlobalConfig

type GlobalConfig struct {
	GopsAPI GopsAPICfg `yaml:"gops_api"`
}

GlobalConfig Struct

type GopsAPICfg

type GopsAPICfg struct {
	EncryptKey string         `yaml:"encrypt_key"`
	Enable     bool           `yaml:"enable"`
	MaxRequest string         `yaml:"max_request"`
	Deadline   int            `yaml:"deadline"`
	Database   DatabaseConfig `yaml:"database"`
	Redis      RedisConfig    `yaml:"redis"`
	ServerPort int            `yaml:"server_port"`
	Log        LogConfig      `yaml:"log"`
	Notify     NotifyConfig   `yaml:"notify"`
	Ticket     TicketConfig   `yaml:"ticket"`
	Modify     ModifyConfig   `yaml:"modify"`
	Alert      AlertCfg       `yaml:"alert"`
}

GopsAPICfg Struct

type LogConfig

type LogConfig struct {
	Mode string `yaml:"mode"`
	Path string `yaml:"path"`
}

type ModifyConfig

type ModifyConfig struct {
	Details            string `yaml:"details"`
	SLAProcessAlert    int    `yaml:"sla_process_alert"`
	CloudModifyDetails string `yaml:"cloud_modify_url"`
}

type NotifyConfig

type NotifyConfig struct {
	DingDing DingDingConfig `yaml:"dingding"`
}

type RedisConfig

type RedisConfig struct {
	MaxIdle        int    `yaml:"max_idle"`
	IdleTimeoutSec int    `yaml:"idle_timeout_sec"`
	DefaultExpried int    `yaml:"expried_sec"`
	Addr           string `yaml:"addr"`
	Password       string `yaml:"password"`
	LoopSec        int    `yaml:"loop_sec"`
	Expried        int    `yaml:"expried"`
}

RedisConfig Struct

type TicketConfig

type TicketConfig struct {
	Details            string `yaml:"details"`
	SLAProcessAlert    int    `yaml:"sla_process_alert"`
	CloudTicketDetails string `yaml:"cloud_ticket_url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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