Documentation
¶
Index ¶
- Variables
- func ConfigLoader(name string, config interface{}, sql string, lifeSpan time.Duration, ...) (*gokits.CacheItem, error)
- func Handle(mux *http.ServeMux) *http.ServeMux
- func InitSqlxDB()
- func Load()
- func LoadConfig(configFile string, config interface{})
- func PublishToClusterNodes(consumer func(address string))
- func RegisterHandler(handler Handler)
- func RegisterLoader(loader Loader)
- func ServerAddr() string
- func TokenLoader(name string, queryDest UpdatedRecord, querySql string, ...) (*gokits.CacheItem, error)
- func TokenLoaderStrict(name string, queryDest ExpireTimeRecord, querySql string, ...) (*gokits.CacheItem, error)
- func TrimPrefixPath(request *http.Request, subPath string) string
- type Config
- type ExpireTimeRecord
- type Handler
- type HandlerRegistry
- type Loader
- type LoaderRegistry
- type UpdatedRecord
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *sqlx.DB
View Source
var Post = gokits.ServePost
Functions ¶
func ConfigLoader ¶
func InitSqlxDB ¶
func InitSqlxDB()
func LoadConfig ¶
func LoadConfig(configFile string, config interface{})
func PublishToClusterNodes ¶
func PublishToClusterNodes(consumer func(address string))
func RegisterHandler ¶
func RegisterHandler(handler Handler)
func RegisterLoader ¶
func RegisterLoader(loader Loader)
func ServerAddr ¶
func ServerAddr() string
func TokenLoader ¶
func TokenLoader( name string, queryDest UpdatedRecord, querySql string, queryTokenBuilder func(queryDest UpdatedRecord) interface{}, createSql string, updateSql string, requestor func(key interface{}) (map[string]string, error), uncompleteSql string, completeSql string, completeArg func(response map[string]string, lifeSpan time.Duration) map[string]interface{}, requestTokenBuilder func(response map[string]string) interface{}, lifeSpan time.Duration, lifeSpanTemp time.Duration, key interface{}, args ...interface{}) (*gokits.CacheItem, error)
针对具有刷新过渡期的token 在旧的token即将过期时, 请求获取新的token 在此过程中新旧token同时可用 所以在某一集群节点更新token时 其他节点可临时缓存旧的token保证平滑过渡
func TokenLoaderStrict ¶
func TokenLoaderStrict( name string, queryDest ExpireTimeRecord, querySql string, queryTokenBuilder func(queryDest ExpireTimeRecord) interface{}, requestor func(key interface{}) (map[string]string, error), createSql string, updateSql string, createUpdateArg func(response map[string]string) map[string]interface{}, expireCriticalSpan time.Duration, requestTokenBuilder func(response map[string]string) interface{}, maxLifeSpan time.Duration, key interface{}, args ...interface{}) (*gokits.CacheItem, error)
针对没有刷新过渡期的token 旧的token固定过期时间, 在有效期内无法获取新的token 超出有效期后, 可请求获取新的token 所以在旧的token即将过期前的一小段时间内, 停止缓存token并请求更新 在某一集群节点更新token后, 其他节点触发入库失败并查询已更新的token进行缓存 由于有效期内token不会更新, 所以重复请求不会覆盖token
Types ¶
type ExpireTimeRecord ¶
type ExpireTimeRecord interface {
GetExpireTime() int64
}
type HandlerRegistry ¶
func NewHandlerRegistry ¶
func NewHandlerRegistry() *HandlerRegistry
func (*HandlerRegistry) Register ¶
func (r *HandlerRegistry) Register(handler Handler)
type LoaderRegistry ¶
func NewLoaderRegistry ¶
func NewLoaderRegistry() *LoaderRegistry
func (*LoaderRegistry) Register ¶
func (r *LoaderRegistry) Register(loader Loader)
type UpdatedRecord ¶
type UpdatedRecord interface { ExpireTimeRecord GetUpdated() string }
Click to show internal directories.
Click to hide internal directories.