runtime

package
v1.3.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(prefix string, store cache.Adapter, wxTokenStoreKey string) cache.Adapter

NewCache 创建对应上下文缓存

Types

type Application

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

func NewConfig

func NewConfig() *Application

NewConfig 默认值

func (*Application) GetCacheAdapter

func (e *Application) GetCacheAdapter() cache.Adapter

GetCacheAdapter 获取缓存

func (*Application) GetCachePrefix

func (e *Application) GetCachePrefix(key string) cache.Adapter

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

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

GetLogger 获取日志组件

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

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

GetStreamMessage 获取队列需要用的message

func (*Application) SetCacheAdapter

func (e *Application) SetCacheAdapter(c cache.Adapter)

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

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

SetLogger 设置日志组件

func (*Application) SetMiddleware

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

SetMiddleware 设置中间件

type Cache

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

func (Cache) Append

func (e Cache) Append(message cache.Message) error

Append 增加数据到生产者

func (Cache) Connect

func (e Cache) Connect() error

Connect 初始化

func (Cache) Decrease

func (e Cache) Decrease(key string) error

func (Cache) Del

func (e Cache) Del(key string) error

Del delete key in cache

func (Cache) Expire

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

func (Cache) Get

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

Get val in cache

func (Cache) HashDel

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

HashDel delete one key:value pair in hashtable cache

func (Cache) HashGet

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

HashGet get val in hashtable cache

func (Cache) Increase

func (e Cache) Increase(key string) error

Increase value

func (Cache) Lock

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

Lock 返回分布式锁对象

func (Cache) PutToken

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

PutToken 设置微信oauth2 token

func (Cache) Register

func (e Cache) Register(name string, f cache.ConsumerFunc)

Register 注册消费者

func (Cache) Run

func (e Cache) Run()

Run 运行

func (Cache) Set

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

Set val in cache

func (*Cache) SetPrefix

func (e *Cache) SetPrefix(prefix string)

SetPrefix 设置前缀

func (Cache) Shutdown

func (e Cache) Shutdown()

Shutdown 停止

func (*Cache) String added in v1.3.2

func (e *Cache) String() string

String string输出

func (Cache) Token

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

Token 获取微信oauth2 token

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(cache.Adapter)
	GetCacheAdapter() cache.Adapter
	GetCachePrefix(string) cache.Adapter
	GetStreamMessage(id, stream string, value map[string]interface{}) (cache.Message, error)
}

Jump to

Keyboard shortcuts

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