runtime

package
v1.3.5-rc.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: Apache-2.0 Imports: 12 Imported by: 10

Documentation

Index

Constants

This section is empty.

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 NewLocker added in v1.3.6

func NewLocker(prefix string, locker storage.AdapterLocker) storage.AdapterLocker

NewLocker 创建对应上下文分布式锁

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) GetCacheAdapter added in v1.3.6

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

GetCacheAdapter 获取缓存

func (*Application) GetCachePrefix added in v1.3.6

func (e *Application) GetCachePrefix(key string) storage.AdapterCache

GetCachePrefix 获取带租户标记的cache

func (*Application) GetCasbin

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

func (*Application) GetCasbinKey

func (e *Application) GetCasbinKey(key string) *casbin.SyncedEnforcer

GetCasbinKey 根据key获取casbin

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) GetDb

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

GetDb 获取所有map里的db数据

func (*Application) GetDbByKey

func (e *Application) GetDbByKey(key string) *gorm.DB

GetDbByKey 根据key获取db

func (*Application) GetEngine

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

GetEngine 获取路由引擎

func (*Application) GetLockerAdapter added in v1.3.6

func (e *Application) GetLockerAdapter() storage.AdapterLocker

GetLockerAdapter 获取分布式锁

func (*Application) GetLockerPrefix added in v1.3.6

func (e *Application) GetLockerPrefix(key string) storage.AdapterLocker

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() map[string]interface{}

GetMiddleware 获取所有中间件

func (*Application) GetMiddlewareKey

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

GetMiddlewareKey 获取对应key的中间件

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) GetStreamMessage added in v1.3.6

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

GetStreamMessage 获取队列需要用的message

func (*Application) SetCacheAdapter added in v1.3.6

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

SetCacheAdapter 设置缓存

func (*Application) SetCasbin

func (e *Application) SetCasbin(key string, enforcer *casbin.SyncedEnforcer)

func (*Application) SetCrontab

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

SetCrontab 设置对应key的crontab

func (*Application) SetDb

func (e *Application) SetDb(key string, db *gorm.DB)

SetDb 设置对应key的db

func (*Application) SetEngine

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

SetEngine 设置路由引擎

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 Locker added in v1.3.6

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

func (*Locker) Lock added in v1.3.6

func (e *Locker) Lock(key string, ttl int64, options *redislock.Options) (*redislock.Lock, error)

Lock 返回分布式锁对象

func (*Locker) String added in v1.3.6

func (e *Locker) String() string

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 Runtime

type Runtime interface {
	//多db设置,⚠️SetDbs不允许并发,可以根据自己的业务,例如app分库、host分库
	SetDb(key string, db *gorm.DB)
	GetDb() map[string]*gorm.DB
	GetDbByKey(key string) *gorm.DB

	SetCasbin(key string, enforcer *casbin.SyncedEnforcer)
	GetCasbin() map[string]*casbin.SyncedEnforcer
	GetCasbinKey(key string) *casbin.SyncedEnforcer

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

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

	//crontab
	SetCrontab(key string, crontab *cron.Cron)
	GetCrontab() map[string]*cron.Cron
	GetCrontabKey(key string) *cron.Cron

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

	//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

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

Jump to

Keyboard shortcuts

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