Documentation ¶
Index ¶
- func NewCache(prefix string, store storage.AdapterCache, wxTokenStoreKey string) storage.AdapterCache
- func NewLocker(prefix string, locker storage.AdapterLocker) storage.AdapterLocker
- func NewQueue(prefix string, queue storage.AdapterQueue) storage.AdapterQueue
- type AppModule
- type Application
- func (e *Application) AddPlugin(plugin IPlugin) error
- func (e *Application) GetApp() []IAppModule
- func (e *Application) GetAppByKey(key string) IAppModule
- func (e *Application) GetAppRouters() []func()
- func (e *Application) GetAuth() jwtauth.IAuth
- func (e *Application) GetBefore() []func()
- func (e *Application) GetCacheAdapter() storage.AdapterCache
- func (e *Application) GetCachePrefix(key string) storage.AdapterCache
- func (e *Application) GetCasbin() map[string]*casbin.SyncedEnforcer
- func (e *Application) GetCasbinExclude() map[string]interface{}
- func (e *Application) GetCasbinExcludeByKey(key string) interface{}
- func (e *Application) GetCasbinKey(key string) *casbin.SyncedEnforcer
- func (e *Application) GetConfig() *config.Config
- func (e *Application) GetCrontab() map[string]*cron.Cron
- func (e *Application) GetCrontabKey(key string) *cron.Cron
- func (e *Application) GetDb() map[string]*gorm.DB
- func (e *Application) GetDbByKey(key string) *gorm.DB
- func (e *Application) GetEngine() http.Handler
- func (e *Application) GetHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
- func (e *Application) GetHandlerPrefix(key string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
- func (e *Application) GetLockerAdapter() storage.AdapterLocker
- func (e *Application) GetLockerPrefix(key string) storage.AdapterLocker
- func (e *Application) GetLogger() logger.Logger
- func (e *Application) GetMemoryQueue(prefix string) storage.AdapterQueue
- func (e *Application) GetMiddleware() map[string]interface{}
- func (e *Application) GetMiddlewareKey(key string) interface{}
- func (e *Application) GetPlugin(key string) (IPlugin, bool)
- func (e *Application) GetQueueAdapter() storage.AdapterQueue
- func (e *Application) GetQueuePrefix(key string) storage.AdapterQueue
- func (e *Application) GetRouter() []Router
- func (e *Application) GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error)
- func (e *Application) RemovePlugin(key string) error
- func (e *Application) SetApp(app IAppModule) error
- func (e *Application) SetAppRouters(appRouters func())
- func (e *Application) SetAuth(auth jwtauth.IAuth)
- func (e *Application) SetBefore(f func())
- func (e *Application) SetCacheAdapter(c storage.AdapterCache)
- func (e *Application) SetCasbin(key string, enforcer *casbin.SyncedEnforcer)
- func (e *Application) SetCasbinExclude(key string, list interface{})
- func (e *Application) SetConfig(conf *config.Config)
- func (e *Application) SetCrontab(key string, crontab *cron.Cron)
- func (e *Application) SetDb(key string, db *gorm.DB)
- func (e *Application) SetEngine(engine http.Handler)
- func (e *Application) SetHandler(key string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))
- func (e *Application) SetLockerAdapter(c storage.AdapterLocker)
- func (e *Application) SetLogger(l logger.Logger)
- func (e *Application) SetMiddleware(key string, middleware interface{})
- func (e *Application) SetQueueAdapter(c storage.AdapterQueue)
- func (e *Application) Start(ctx context.Context) error
- func (e *Application) Stop(ctx context.Context) error
- type Cache
- func (e Cache) AddList(key string, val ...interface{}) error
- func (e Cache) Append(key string, val ...interface{}) error
- func (e Cache) Connect() error
- func (e Cache) Decrease(key string) error
- func (e Cache) Del(key string) error
- func (e Cache) Expire(key string, dur time.Duration) error
- func (e Cache) Get(key string) (string, error)
- func (e Cache) GetList(key string) ([]string, error)
- func (e Cache) GetPrefix(key string, length ...int) ([]string, error)
- func (e Cache) HashDel(hk, key string) error
- func (e Cache) HashGet(hk, key string) (string, error)
- func (e Cache) HashGetAll(hk string) (map[string]string, error)
- func (e *Cache) HashSet(hk string, value interface{}, expire int) error
- func (e Cache) Increase(key string) error
- func (e Cache) PutToken(token *oauth2.Token) error
- func (e Cache) Set(key string, val interface{}, expire int) error
- func (e *Cache) SetPrefix(prefix string)
- func (e *Cache) String() string
- func (e Cache) Token() (token *oauth2.Token, err error)
- type IAppModule
- type IApplication
- type IPlugin
- type Locker
- type Queue
- type Router
- type Routers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCache ¶
func NewCache(prefix string, store storage.AdapterCache, wxTokenStoreKey string) storage.AdapterCache
NewCache 创建对应上下文缓存
func NewLocker ¶
func NewLocker(prefix string, locker storage.AdapterLocker) storage.AdapterLocker
NewLocker 创建对应上下文分布式锁
func NewQueue ¶
func NewQueue(prefix string, queue storage.AdapterQueue) storage.AdapterQueue
NewQueue 创建对应上下文队列
Types ¶
type AppModule ¶
type AppModule struct {
// contains filtered or unexported fields
}
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
func (*Application) AddPlugin ¶
func (e *Application) AddPlugin(plugin IPlugin) error
AddPlugin implements IApplication.
func (*Application) GetAppByKey ¶
func (e *Application) GetAppByKey(key string) IAppModule
GetAppByKey 根据key获取app
func (*Application) GetAppRouters ¶
func (e *Application) GetAppRouters() []func()
GetAppRouters 获取app的路由
func (*Application) GetAuth ¶
func (e *Application) GetAuth() jwtauth.IAuth
func (*Application) GetBefore ¶
func (e *Application) GetBefore() []func()
func (*Application) GetCacheAdapter ¶
func (e *Application) GetCacheAdapter() storage.AdapterCache
GetCacheAdapter 获取缓存
func (*Application) GetCachePrefix ¶
func (e *Application) GetCachePrefix(key string) storage.AdapterCache
GetCachePrefix 获取带租户标记的cache
func (*Application) GetCasbin ¶
func (e *Application) GetCasbin() map[string]*casbin.SyncedEnforcer
func (*Application) GetCasbinExclude ¶
func (e *Application) GetCasbinExclude() map[string]interface{}
GetCasbinExclude 获取所有map里的Exclude数据
func (*Application) GetCasbinExcludeByKey ¶
func (e *Application) GetCasbinExcludeByKey(key string) interface{}
GetCasbinExcludeByKey 根据key获取Exclude
func (*Application) GetCasbinKey ¶
func (e *Application) GetCasbinKey(key string) *casbin.SyncedEnforcer
GetCasbinKey 根据key获取casbin
func (*Application) GetConfig ¶
func (e *Application) GetConfig() *config.Config
GetConfig 获取对应key的config
func (*Application) GetCrontab ¶
func (e *Application) GetCrontab() map[string]*cron.Cron
GetCrontab 获取所有map里的crontab数据
func (*Application) GetCrontabKey ¶
func (e *Application) GetCrontabKey(key string) *cron.Cron
GetCrontabKey 根据key获取crontab
func (*Application) GetDbByKey ¶
func (e *Application) GetDbByKey(key string) *gorm.DB
GetDbByKey 根据key获取db
func (*Application) GetHandler ¶
func (e *Application) GetHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
func (*Application) GetHandlerPrefix ¶
func (e *Application) GetHandlerPrefix(key string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
func (*Application) GetLockerAdapter ¶
func (e *Application) GetLockerAdapter() storage.AdapterLocker
GetLockerAdapter 获取分布式锁
func (*Application) GetLockerPrefix ¶
func (e *Application) GetLockerPrefix(key string) storage.AdapterLocker
func (*Application) GetMemoryQueue ¶
func (e *Application) GetMemoryQueue(prefix string) storage.AdapterQueue
func (*Application) GetMiddleware ¶
func (e *Application) GetMiddleware() map[string]interface{}
GetMiddleware 获取所有中间件
func (*Application) GetMiddlewareKey ¶
func (e *Application) GetMiddlewareKey(key string) interface{}
GetMiddlewareKey 获取对应key的中间件
func (*Application) GetPlugin ¶
func (e *Application) GetPlugin(key string) (IPlugin, bool)
GetPlugin implements IApplication.
func (*Application) GetQueueAdapter ¶
func (e *Application) GetQueueAdapter() storage.AdapterQueue
GetQueueAdapter 获取队列适配器
func (*Application) GetQueuePrefix ¶
func (e *Application) GetQueuePrefix(key string) storage.AdapterQueue
GetQueuePrefix 获取带租户标记的queue
func (*Application) GetStreamMessage ¶
func (e *Application) GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error)
GetStreamMessage 获取队列需要用的message
func (*Application) RemovePlugin ¶
func (e *Application) RemovePlugin(key string) error
RemovePlugin implements IApplication.
func (*Application) SetAppRouters ¶
func (e *Application) SetAppRouters(appRouters func())
SetAppRouters 设置app的路由
func (*Application) SetAuth ¶
func (e *Application) SetAuth(auth jwtauth.IAuth)
func (*Application) SetBefore ¶
func (e *Application) SetBefore(f func())
func (*Application) SetCacheAdapter ¶
func (e *Application) SetCacheAdapter(c storage.AdapterCache)
SetCacheAdapter 设置缓存
func (*Application) SetCasbin ¶
func (e *Application) SetCasbin(key string, enforcer *casbin.SyncedEnforcer)
func (*Application) SetCasbinExclude ¶
func (e *Application) SetCasbinExclude(key string, list interface{})
SetCasbinExclude 设置对应key的Exclude
func (*Application) SetConfig ¶
func (e *Application) SetConfig(conf *config.Config)
// SetConfigByTenant 设置对应租户的config
func (e *Application) SetConfigByTenant(tenant string, value map[string]interface{}) { e.mux.Lock() defer e.mux.Unlock() e.configs[tenant] = value }
// GetConfigByTenant 获取对应租户的config
func (e *Application) GetConfigByTenant(tenant string) interface{} { e.mux.Lock() defer e.mux.Unlock() return e.configs[tenant] }
SetConfig 设置对应key的config
func (*Application) SetCrontab ¶
func (e *Application) SetCrontab(key string, crontab *cron.Cron)
SetCrontab 设置对应key的crontab
func (*Application) SetEngine ¶
func (e *Application) SetEngine(engine http.Handler)
SetEngine 设置路由引擎
func (*Application) SetHandler ¶
func (e *Application) SetHandler(key string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))
func (*Application) SetLockerAdapter ¶
func (e *Application) SetLockerAdapter(c storage.AdapterLocker)
SetLockerAdapter 设置分布式锁
func (*Application) SetMiddleware ¶
func (e *Application) SetMiddleware(key string, middleware interface{})
SetMiddleware 设置中间件
func (*Application) SetQueueAdapter ¶
func (e *Application) SetQueueAdapter(c storage.AdapterQueue)
SetQueueAdapter 设置队列适配器
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
type IAppModule ¶
type IAppModule interface { ModuleName() string Install(core IApplication) error InitRouter(core IApplication) error Migrate(core IApplication) error Start(context.Context) error Stop(context.Context) error AddServer(key string, server transport.Server) error GetServer(key string) (transport.Server, error) }
type IApplication ¶
type IApplication interface { // SetDb 多db设置,⚠️SetDbs不允许并发,可以根据自己的业务,例如app分库、host分库 SetDb(key string, db *gorm.DB) GetDb() map[string]*gorm.DB GetDbByKey(key string) *gorm.DB SetApp(IAppModule) error GetApp() []IAppModule GetAppByKey(key string) IAppModule SetBefore(f func()) GetBefore() []func() SetCasbinExclude(key string, list interface{}) GetCasbinExclude() map[string]interface{} GetCasbinExcludeByKey(key string) interface{} SetCasbin(key string, enforcer *casbin.SyncedEnforcer) GetCasbin() map[string]*casbin.SyncedEnforcer GetCasbinKey(key string) *casbin.SyncedEnforcer // SetEngine 使用的路由 SetEngine(engine http.Handler) GetEngine() http.Handler GetRouter() []Router SetAuth(auth jwtauth.IAuth) GetAuth() jwtauth.IAuth AddPlugin(plugin IPlugin) error // 添加插件 GetPlugin(key string) (IPlugin, bool) // 获取插件 RemovePlugin(key string) error // 移除插件 // SetLogger 使用go-admin定义的logger,参考来源go-micro SetLogger(logger logger.Logger) GetLogger() logger.Logger // SetCrontab crontab SetCrontab(key string, crontab *cron.Cron) GetCrontab() map[string]*cron.Cron GetCrontabKey(key string) *cron.Cron // SetMiddleware middleware SetMiddleware(string, interface{}) GetMiddleware() map[string]interface{} GetMiddlewareKey(key string) interface{} // SetCacheAdapter cache SetCacheAdapter(storage.AdapterCache) GetCacheAdapter() storage.AdapterCache GetCachePrefix(string) storage.AdapterCache GetMemoryQueue(string) storage.AdapterQueue SetQueueAdapter(storage.AdapterQueue) GetQueueAdapter() storage.AdapterQueue GetQueuePrefix(string) storage.AdapterQueue SetLockerAdapter(storage.AdapterLocker) GetLockerAdapter() storage.AdapterLocker GetLockerPrefix(string) storage.AdapterLocker SetHandler(key string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)) GetHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc) GetHandlerPrefix(key string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc) GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error) // GetConfigByTenant(tenant string) interface{} GetConfig() *config.Config // SetConfigByTenant(tenant string, value map[string]interface{}) SetConfig(*config.Config) // SetAppRouters set AppRouter SetAppRouters(appRouters func()) GetAppRouters() []func() Start(context.Context) error Stop(context.Context) error }
type IPlugin ¶
type IPlugin interface { Key() string Install(context.Context, IApplication) error // 安装插件 Uninstall(IApplication) error // 卸载插件 }
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}