Documentation
¶
Index ¶
- Constants
- func Entry(cluster, table string) bool
- func NewMongo(dbtype, dbname, user, passwd string, addrs []string, timeout time.Duration) (*dbMongo, error)
- type Breaker
- type BreakerManager
- type Config
- type Configer
- type DB
- func (db *DB) ExecWrapper(tables []interface{}, query string, args ...interface{}) (sql.Result, error)
- func (db *DB) GetWrapper(tables []interface{}, dest interface{}, query string, args ...interface{}) error
- func (db *DB) NamedExecWrapper(tables []interface{}, query string, arg interface{}) (sql.Result, error)
- func (db *DB) NamedQueryWrapper(tables []interface{}, query string, arg interface{}) (*sqlx.Rows, error)
- func (db *DB) QueryRowxWrapper(tables []interface{}, query string, args ...interface{}) *sqlx.Row
- func (db *DB) QueryxWrapper(tables []interface{}, query string, args ...interface{}) (*sqlx.Rows, error)
- func (db *DB) SelectWrapper(tables []interface{}, dest interface{}, query string, args ...interface{}) error
- type EtcdConfig
- func (m *EtcdConfig) GetConfig(ctx context.Context, instance string) *Config
- func (m *EtcdConfig) GetConfigByGroup(ctx context.Context, instance, group string) *Config
- func (m *EtcdConfig) GetGroups(ctx context.Context) []string
- func (m *EtcdConfig) GetInstance(ctx context.Context, cluster, table string) (instance string)
- type FactoryFunc
- type GormDB
- type InstanceManager
- type Instancer
- type Parser
- type Router
- func (m *Router) MongoExecEventual(ctx context.Context, cluster, table string, query func(*mgo.Collection) error) error
- func (m *Router) MongoExecMonotonic(ctx context.Context, cluster, table string, query func(*mgo.Collection) error) error
- func (m *Router) MongoExecStrong(ctx context.Context, cluster, table string, query func(*mgo.Collection) error) error
- func (m *Router) OrmExec(ctx context.Context, cluster string, query func(*GormDB, []interface{}) error, ...) error
- func (m *Router) SqlExec(ctx context.Context, cluster string, query func(*DB, []interface{}) error, ...) error
- func (m *Router) StatInfo() []*stat.QueryStat
- type SimpleConfig
- func (m *SimpleConfig) GetConfig(ctx context.Context, instance string) *Config
- func (m *SimpleConfig) GetConfigByGroup(ctx context.Context, instance, group string) *Config
- func (m *SimpleConfig) GetGroups(ctx context.Context) []string
- func (m *SimpleConfig) GetInstance(ctx context.Context, cluster, table string) (instance string)
- type Sql
Constants ¶
View Source
const ( DB_TYPE_MONGO = "mongo" DB_TYPE_MYSQL = "mysql" DB_TYPE_POSTGRES = "postgres" )
View Source
const ( CONFIG_TYPE_SIMPLE = iota CONFIG_TYPE_ETCD )
View Source
const ( DefaultGroup = "" TestGroup = "test" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BreakerManager ¶
type BreakerManager struct { Breakers map[string]*Breaker // contains filtered or unexported fields }
TOOD 简单计数法实现熔断操作,后续改为滑动窗口或三方组件的方式
type Configer ¶
type Configer interface { GetConfig(ctx context.Context, instance string) *Config GetInstance(ctx context.Context, cluster, table string) (instance string) GetConfigByGroup(ctx context.Context, instance, group string) *Config GetGroups(ctx context.Context) []string }
func NewConfiger ¶
func NewEtcdConfiger ¶
func NewSimpleConfiger ¶
type DB ¶
func (*DB) ExecWrapper ¶
func (*DB) GetWrapper ¶
func (*DB) NamedExecWrapper ¶
func (*DB) NamedQueryWrapper ¶
func (*DB) QueryRowxWrapper ¶
func (*DB) QueryxWrapper ¶
func (*DB) SelectWrapper ¶
type EtcdConfig ¶
type EtcdConfig struct {
// contains filtered or unexported fields
}
func (*EtcdConfig) GetConfig ¶
func (m *EtcdConfig) GetConfig(ctx context.Context, instance string) *Config
func (*EtcdConfig) GetConfigByGroup ¶
func (m *EtcdConfig) GetConfigByGroup(ctx context.Context, instance, group string) *Config
func (*EtcdConfig) GetInstance ¶
func (m *EtcdConfig) GetInstance(ctx context.Context, cluster, table string) (instance string)
type FactoryFunc ¶
type InstanceManager ¶
type InstanceManager struct {
// contains filtered or unexported fields
}
func NewInstanceManager ¶
func NewInstanceManager(factory FactoryFunc, dbChangeChan chan dbConfigChange, groups []string) *InstanceManager
func (*InstanceManager) Close ¶
func (m *InstanceManager) Close()
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) GetInstance ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) MongoExecEventual ¶
func (*Router) MongoExecMonotonic ¶
func (*Router) MongoExecStrong ¶
type SimpleConfig ¶
type SimpleConfig struct {
// contains filtered or unexported fields
}
func (*SimpleConfig) GetConfig ¶
func (m *SimpleConfig) GetConfig(ctx context.Context, instance string) *Config
func (*SimpleConfig) GetConfigByGroup ¶
func (m *SimpleConfig) GetConfigByGroup(ctx context.Context, instance, group string) *Config
func (*SimpleConfig) GetInstance ¶
func (m *SimpleConfig) GetInstance(ctx context.Context, cluster, table string) (instance string)
Click to show internal directories.
Click to hide internal directories.