runtime

package
v1.5.3-rc.4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 12 Imported by: 15

Documentation

Index

Constants

View Source
const DefaultTenant = "default"

DefaultTenant 默认租户标识符

Variables

This section is empty.

Functions

func NewCache added in v1.3.6

func NewCache(prefix string, store storage.AdapterCache, wxTokenStoreKey string) storage.AdapterCache

NewCache 创建对应上下文缓存

func NewQueue added in v1.3.6

func NewQueue(prefix string, queue storage.AdapterQueue) storage.AdapterQueue

NewQueue 创建对应上下文队列

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Application

NewConfig 默认值

func (*Application) GetAllCasbin

func (e *Application) GetAllCasbin() map[string]*casbin.SyncedEnforcer

GetAllCasbin 获取所有租户的casbin (原GetCasbin改名)

func (*Application) GetAllCrontab

func (e *Application) GetAllCrontab() map[string]*cron.Cron

GetAllCrontab 获取所有租户的定时任务 (原GetCrontab改名)

func (*Application) GetAllDb

func (e *Application) GetAllDb() map[string]*gorm.DB

GetAllDb 获取所有租户的数据库 (原GetDb改名)

func (*Application) GetAllHandler

func (e *Application) GetAllHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

func (*Application) GetAllMiddleware

func (e *Application) GetAllMiddleware() map[string]interface{}

GetAllMiddleware 获取所有中间件

func (*Application) GetApp added in v1.5.2

func (e *Application) GetApp() map[string]interface{}

GetApp 获取所有map里的app数据

func (*Application) GetAppByTenant

func (e *Application) GetAppByTenant(tenant string) interface{}

GetAppByTenant 根据key获取app

func (*Application) GetAppRouters added in v1.4.0

func (e *Application) GetAppRouters() []func()

GetAppRouters 获取app的路由

func (*Application) GetBefore added in v1.5.2

func (e *Application) GetBefore() []func()

func (*Application) GetCacheAdapter added in v1.3.6

func (e *Application) GetCacheAdapter() storage.AdapterCache

GetCacheAdapter 获取缓存

func (*Application) GetCacheAdapterPrefix

func (e *Application) GetCacheAdapterPrefix(prefix string) storage.AdapterCache

GetCacheAdapterPrefix 获取prefix标记的cache

func (*Application) GetCasbin

func (e *Application) GetCasbin() *casbin.SyncedEnforcer

GetCasbin 获取默认租户的casbin (新增单租户快捷方法)

func (*Application) GetCasbinByTenant

func (e *Application) GetCasbinByTenant(tenant string) *casbin.SyncedEnforcer

GetCasbinByTenant 根据租户获取casbin

func (*Application) GetCasbinExclude added in v1.5.2

func (e *Application) GetCasbinExclude() map[string]interface{}

GetCasbinExclude 获取所有map里的Exclude数据

func (*Application) GetCasbinExcludeByTenant

func (e *Application) GetCasbinExcludeByTenant(tenant string) interface{}

GetCasbinExcludeByTenant 根据租户获取Exclude

func (*Application) GetConfig added in v1.4.0

func (e *Application) GetConfig() map[string]interface{}

GetConfig 获取默认租户的config

func (*Application) GetConfigByTenant added in v1.5.2

func (e *Application) GetConfigByTenant(tenant string) map[string]interface{}

GetConfigByTenant 获取对应租户的config

func (*Application) GetConfigValue

func (e *Application) GetConfigValue(key string) interface{}

GetConfigValue 获取默认租户的配置值

func (*Application) GetConfigValueByTenant

func (e *Application) GetConfigValueByTenant(tenant, key string) interface{}

GetConfigValueByTenant 获取对应租户的config

func (*Application) GetCrontab

func (e *Application) GetCrontab() *cron.Cron

GetCrontab 获取默认租户的定时任务 (新增单租户快捷方法)

func (*Application) GetCrontabByTenant

func (e *Application) GetCrontabByTenant(tenant string) *cron.Cron

GetCrontabByTenant 根据租户获取crontab

func (*Application) GetDb

func (e *Application) GetDb() *gorm.DB

GetDb 获取默认租户的数据库 (新增单租户快捷方法)

func (*Application) GetDbByTenant

func (e *Application) GetDbByTenant(tenant string) *gorm.DB

GetDbByTenant 根据租户获取db

func (*Application) GetDefaultTenant

func (e *Application) GetDefaultTenant() string

GetDefaultTenant 获取默认租户

func (*Application) GetEngine

func (e *Application) GetEngine() http.Handler

GetEngine 获取路由引擎

func (*Application) GetHandler added in v1.3.6

func (e *Application) GetHandler() []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

func (*Application) GetHandlerByTenant

func (e *Application) GetHandlerByTenant(tenant string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

func (*Application) GetLogger

func (e *Application) GetLogger() logger.Logger

GetLogger 获取日志组件

func (*Application) GetMemoryQueue added in v1.3.6

func (e *Application) GetMemoryQueue(prefix string) storage.AdapterQueue

func (*Application) GetMiddleware

func (e *Application) GetMiddleware(key string) interface{}

GetMiddleware 获取对应的中间件

func (*Application) GetQueue

func (e *Application) GetQueue() storage.AdapterQueue

GetQueue 获取默认租户的队列

func (*Application) GetQueueAdapter added in v1.3.6

func (e *Application) GetQueueAdapter() storage.AdapterQueue

GetQueueAdapter 获取队列适配器

func (*Application) GetQueuePrefix added in v1.3.6

func (e *Application) GetQueuePrefix(key string) storage.AdapterQueue

GetQueuePrefix 获取标记的queue

func (*Application) GetRouter added in v1.3.6

func (e *Application) GetRouter() []Router

GetRouter 获取路由表

func (*Application) GetStreamMessage added in v1.3.6

func (e *Application) GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error)

GetStreamMessage 获取队列需要用的message

func (*Application) SetApp added in v1.5.2

func (e *Application) SetApp(app interface{})

SetApp 设置默认租户的app

func (*Application) SetAppByTenant

func (e *Application) SetAppByTenant(key string, app interface{})

SetAppByTenant 设置对应租户的app

func (*Application) SetAppRouters added in v1.4.0

func (e *Application) SetAppRouters(appRouters func())

SetAppRouters 设置app的路由

func (*Application) SetBefore added in v1.5.2

func (e *Application) SetBefore(f func())

func (*Application) SetCacheAdapter added in v1.3.6

func (e *Application) SetCacheAdapter(c storage.AdapterCache)

SetCacheAdapter 设置缓存

func (*Application) SetCasbin

func (e *Application) SetCasbin(enforcer *casbin.SyncedEnforcer)

SetCasbin 设置默认租户的casbin

func (*Application) SetCasbinByTenant

func (e *Application) SetCasbinByTenant(tenant string, enforcer *casbin.SyncedEnforcer)

func (*Application) SetCasbinExclude added in v1.5.2

func (e *Application) SetCasbinExclude(list interface{})

SetCasbinExclude 设置默认租户的Exclude

func (*Application) SetCasbinExcludeByTenant

func (e *Application) SetCasbinExcludeByTenant(tenant string, list interface{})

SetCasbinExcludeByTenant 设置对应租户的Exclude

func (*Application) SetConfigByTenant added in v1.5.2

func (e *Application) SetConfigByTenant(tenant string, value map[string]interface{})

SetConfigByTenant 设置对应租户的config

func (*Application) SetConfigValue

func (e *Application) SetConfigValue(key string, value interface{})

SetConfigValue 设置默认租户的配置值

func (*Application) SetConfigValueByTenant

func (e *Application) SetConfigValueByTenant(tenant, key string, value interface{})

SetConfigValueByTenant 设置对应租户的key的config

func (*Application) SetCrontab

func (e *Application) SetCrontab(crontab *cron.Cron)

SetCrontab 设置默认租户的crontab

func (*Application) SetCrontabByTenant

func (e *Application) SetCrontabByTenant(key string, crontab *cron.Cron)

SetCrontabByTenant 设置对应租户的crontab

func (*Application) SetDb

func (e *Application) SetDb(db *gorm.DB)

SetDb 设置默认租户的db

func (*Application) SetDbByTenant

func (e *Application) SetDbByTenant(tenant string, db *gorm.DB)

SetDbByTenant 设置对应租户的db

func (*Application) SetDefaultTenant

func (e *Application) SetDefaultTenant(tenant string)

SetDefaultTenant 设置默认租户

func (*Application) SetEngine

func (e *Application) SetEngine(engine http.Handler)

SetEngine 设置路由引擎

func (*Application) SetHandler added in v1.3.6

func (e *Application) SetHandler(routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))

func (*Application) SetHandlerByTenant

func (e *Application) SetHandlerByTenant(tenant string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))

func (*Application) SetLockerAdapter added in v1.3.6

func (e *Application) SetLockerAdapter(c storage.AdapterLocker)

SetLockerAdapter 设置分布式锁

func (*Application) SetLogger

func (e *Application) SetLogger(l logger.Logger)

SetLogger 设置日志组件

func (*Application) SetMiddleware

func (e *Application) SetMiddleware(key string, middleware interface{})

SetMiddleware 设置租户中间件

func (*Application) SetQueueAdapter added in v1.3.6

func (e *Application) SetQueueAdapter(c storage.AdapterQueue)

SetQueueAdapter 设置队列适配器

type Cache added in v1.3.6

type Cache struct {
	// contains filtered or unexported fields
}

func (Cache) Connect added in v1.3.6

func (e Cache) Connect() error

Connect 初始化

func (Cache) Decrease added in v1.3.6

func (e Cache) Decrease(key string) error

func (Cache) Del added in v1.3.6

func (e Cache) Del(key string) error

Del delete key in cache

func (Cache) Expire added in v1.3.6

func (e Cache) Expire(key string, dur time.Duration) error

func (Cache) Get added in v1.3.6

func (e Cache) Get(key string) (string, error)

Get val in cache

func (Cache) HashDel added in v1.3.6

func (e Cache) HashDel(hk, key string) error

HashDel delete one key:value pair in hashtable cache

func (Cache) HashGet added in v1.3.6

func (e Cache) HashGet(hk, key string) (string, error)

HashGet get val in hashtable cache

func (Cache) Increase added in v1.3.6

func (e Cache) Increase(key string) error

Increase value

func (Cache) PutToken added in v1.3.6

func (e Cache) PutToken(token *oauth2.Token) error

PutToken 设置微信oauth2 token

func (Cache) Set added in v1.3.6

func (e Cache) Set(key string, val interface{}, expire int) error

Set val in cache

func (*Cache) SetPrefix added in v1.3.6

func (e *Cache) SetPrefix(prefix string)

SetPrefix 设置前缀

func (*Cache) String added in v1.3.6

func (e *Cache) String() string

String string输出

func (Cache) Token added in v1.3.6

func (e Cache) Token() (token *oauth2.Token, err error)

Token 获取微信oauth2 token

type Config

type Config map[string]interface{}

type Queue added in v1.3.6

type Queue struct {
	// contains filtered or unexported fields
}

func (*Queue) Append added in v1.3.6

func (e *Queue) Append(message storage.Messager) error

Append 增加数据到生产者

func (*Queue) Register added in v1.3.6

func (e *Queue) Register(name string, f storage.ConsumerFunc)

Register 注册消费者

func (*Queue) Run added in v1.3.6

func (e *Queue) Run()

Run 运行

func (*Queue) Shutdown added in v1.3.6

func (e *Queue) Shutdown()

Shutdown 停止

func (*Queue) String added in v1.3.6

func (e *Queue) String() string

type Router added in v1.3.6

type Router struct {
	HttpMethod, RelativePath, Handler string
}

type Routers added in v1.3.6

type Routers struct {
	List []Router
}

type Runtime

type Runtime interface {
	// SetDbByTenant 设置租户数据库
	SetDbByTenant(tenant string, db *gorm.DB)
	// SetDb 设置默认租户数据库
	SetDb(db *gorm.DB)
	GetDbByTenant(tenant string) *gorm.DB
	GetDb() *gorm.DB
	GetAllDb() map[string]*gorm.DB

	SetBefore(f func())
	GetBefore() []func()

	SetAppByTenant(tenant string, app interface{})
	SetApp(app interface{})
	GetApp() map[string]interface{}
	GetAppByTenant(tenant string) interface{}

	SetCasbinExcludeByTenant(tenant string, list interface{})
	SetCasbinExclude(list interface{})
	GetCasbinExclude() map[string]interface{}
	GetCasbinExcludeByTenant(tenant string) interface{}

	SetCasbinByTenant(tenant string, enforcer *casbin.SyncedEnforcer)
	SetCasbin(enforcer *casbin.SyncedEnforcer)
	GetAllCasbin() map[string]*casbin.SyncedEnforcer
	GetCasbin() *casbin.SyncedEnforcer
	GetCasbinByTenant(tenant string) *casbin.SyncedEnforcer

	// SetEngine 使用的路由
	SetEngine(engine http.Handler)
	GetEngine() http.Handler

	GetRouter() []Router

	// SetLogger 使用go-admin定义的logger,参考来源go-micro
	SetLogger(logger logger.Logger)
	GetLogger() logger.Logger

	SetDefaultTenant(tenant string)
	GetDefaultTenant() string

	// SetCrontabByTenant crontab
	SetCrontabByTenant(tenant string, crontab *cron.Cron)
	SetCrontab(crontab *cron.Cron)
	GetCrontab() *cron.Cron
	GetAllCrontab() map[string]*cron.Cron
	GetCrontabByTenant(tenant string) *cron.Cron

	// SetMiddleware middleware
	SetMiddleware(string, interface{})
	GetAllMiddleware() map[string]interface{}
	GetMiddleware(string) interface{}

	// SetCacheAdapter cache
	SetCacheAdapter(storage.AdapterCache)
	GetCacheAdapter() storage.AdapterCache
	GetCacheAdapterPrefix(string) storage.AdapterCache

	GetMemoryQueue(string) storage.AdapterQueue
	SetQueueAdapter(storage.AdapterQueue)
	GetQueueAdapter() storage.AdapterQueue
	GetQueuePrefix(string) storage.AdapterQueue

	SetHandler(routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))
	SetHandlerByTenant(tenant string, routerGroup func(r *gin.RouterGroup, hand ...*gin.HandlerFunc))
	GetAllHandler() map[string][]func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
	GetHandler() []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)
	GetHandlerByTenant(tenant string) []func(r *gin.RouterGroup, hand ...*gin.HandlerFunc)

	GetStreamMessage(id, stream string, value map[string]interface{}) (storage.Messager, error)

	// SetConfigByTenant 设置对应租户的config
	SetConfigByTenant(tenant string, value map[string]interface{})
	// SetConfigValueByTenant 设置对应租户的key对应的value
	SetConfigValueByTenant(tenant, key string, value interface{})
	SetConfigValue(key string, value interface{})
	GetConfigValueByTenant(tenant, key string) interface{}
	GetConfigByTenant(tenant string) map[string]interface{}
	GetConfig() map[string]interface{}
	GetConfigValue(key string) interface{}

	// SetAppRouters set AppRouter
	SetAppRouters(appRouters func())
	GetAppRouters() []func()
}

Jump to

Keyboard shortcuts

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