runtime

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(prefix string, store storage.AdapterCache, tokenStoreKey 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 Application

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

func NewConfig

func NewConfig() *Application

NewConfig 默认值

func (*Application) Config

func (e *Application) Config(ctx context.Context, pattern string) *gvar.Var

func (*Application) Cron

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

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

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

GetCasbinKey 根据key获取casBin

func (*Application) GetConfig

func (e *Application) GetConfig() *gcfg.Config

func (*Application) GetJwt

func (e *Application) GetJwt() map[string]*jwt.GfJWTMiddleware

func (*Application) GetJwtKey

func (e *Application) GetJwtKey(moduleKey string) *jwt.GfJWTMiddleware

GetJwtKey 根据key获取Jwt

func (*Application) GetLang

func (e *Application) GetLang() *gi18n.Manager

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

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

GetQueueAdapter 获取队列适配器

func (*Application) GetQueueMessage

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

GetQueueMessage 获取队列需要用的message

func (*Application) GetQueuePrefix

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

GetQueuePrefix 获取带租户标记的queue

func (*Application) GetRabbitQueue

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

func (*Application) GetRocketQueue

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

func (*Application) GetWebSocket

func (e *Application) GetWebSocket() *ws.Instance

func (*Application) Lang

func (e *Application) Lang(ctx context.Context, langKey string) string

Lang 多语言翻译

func (*Application) MemoryTask added in v0.1.5

func (e *Application) MemoryTask() task.MemoryService

func (*Application) RabbitTask added in v0.1.4

func (e *Application) RabbitTask() task.RabbitMqService

func (*Application) RocketMqTask added in v0.1.5

func (e *Application) RocketMqTask() task.RocketMqService

func (*Application) Server

func (e *Application) Server() *ghttp.Server

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

func (e *Application) SetConfig(c *gcfg.Config)

func (*Application) SetCron

func (e *Application) SetCron(srv cron.Adapter)

func (*Application) SetJwt

func (e *Application) SetJwt(key string, jwtIns *jwt.GfJWTMiddleware)

func (*Application) SetLang

func (e *Application) SetLang(lang *gi18n.Manager)

func (*Application) SetLockerAdapter

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

SetLockerAdapter 设置分布式锁

func (*Application) SetMemoryTask added in v0.1.5

func (e *Application) SetMemoryTask(srv task.MemoryService)

func (*Application) SetQueueAdapter

func (e *Application) SetQueueAdapter(key string, c storage.AdapterQueue)

SetQueueAdapter 设置队列适配器

func (*Application) SetRabbitTask added in v0.1.4

func (e *Application) SetRabbitTask(srv task.RabbitMqService)

func (*Application) SetRocketMqTask added in v0.1.5

func (e *Application) SetRocketMqTask(srv task.RocketMqService)

func (*Application) SetServer

func (e *Application) SetServer(srv *ghttp.Server)

func (*Application) SetSettings added in v0.2.3

func (e *Application) SetSettings(c *config.Settings)

func (*Application) SetTask added in v0.1.6

func (e *Application) SetTask(srv task.TasksService)

func (*Application) SetWebSocket

func (e *Application) SetWebSocket(s *ws.Instance)

func (*Application) Settings added in v0.2.3

func (e *Application) Settings() *config.Settings

func (*Application) Task added in v0.1.6

func (e *Application) Task() task.TasksService

func (*Application) WebSocket

func (e *Application) WebSocket() *ws.Instance

type Cache

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

func (Cache) Connect

func (e Cache) Connect() error

Connect 初始化

func (Cache) Decrease

func (e Cache) Decrease(ctx context.Context, key string) error

func (Cache) Del

func (e Cache) Del(ctx context.Context, key string) error

Del delete key in cache

func (Cache) Expire

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

func (Cache) Get

func (e Cache) Get(ctx context.Context, key string) (*gvar.Var, error)

Get val in cache

func (Cache) HashDel

func (e Cache) HashDel(ctx context.Context, hk, key string) error

HashDel delete one key:value pair in hashtable cache

func (Cache) HashGet

func (e Cache) HashGet(ctx context.Context, hk, key string) (*gvar.Var, error)

HashGet get val in hashtable cache

func (Cache) Increase

func (e Cache) Increase(ctx context.Context, key string) error

Increase value

func (Cache) Set

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

Set val in cache

func (*Cache) SetPrefix

func (e *Cache) SetPrefix(prefix string)

SetPrefix 设置前缀

func (*Cache) String

func (e *Cache) String() string

String string输出

type Locker

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

func (*Locker) Lock

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

Lock 返回分布式锁对象

func (*Locker) String

func (e *Locker) String() string

type Queue

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

func (*Queue) Consumer

func (e *Queue) Consumer(ctx context.Context, name string, f storage.ConsumerFunc, optionFuncs ...func(*storage.ConsumeOptions))

Consumer 注册消费者

func (*Queue) Publish

func (e *Queue) Publish(ctx context.Context, message storage.Messager, optionFuncs ...func(*storage.PublishOptions)) error

Publish 数据生产者

func (*Queue) Run

func (e *Queue) Run(ctx context.Context)

Run 运行

func (*Queue) Shutdown

func (e *Queue) Shutdown(ctx context.Context)

Shutdown 停止

func (*Queue) String

func (e *Queue) String() string

type Runtime

type Runtime interface {
	// SetServer Http Server
	SetServer(srv *ghttp.Server)
	Server() *ghttp.Server

	// SetCasbin casbin module
	SetCasbin(key string, enforcer *casbin.SyncedEnforcer)
	GetCasbin() map[string]*casbin.SyncedEnforcer
	GetCasbinKey(key string) *casbin.SyncedEnforcer
	// SetJwt jwt module
	SetJwt(key string, jwtIns *jwt.GfJWTMiddleware)
	GetJwt() map[string]*jwt.GfJWTMiddleware
	GetJwtKey(moduleKey string) *jwt.GfJWTMiddleware
	// SetLang gi18n
	SetLang(lang *gi18n.Manager)
	GetLang() *gi18n.Manager
	Lang(ctx context.Context, langKey string) string
	// SetConfig config
	SetConfig(c *gcfg.Config)
	GetConfig() *gcfg.Config
	Config(ctx context.Context, pattern string) *gvar.Var
	SetSettings(c *config.Settings)
	Settings() *config.Settings
	// SetCacheAdapter cache
	SetCacheAdapter(storage.AdapterCache)
	GetCacheAdapter() storage.AdapterCache
	GetCachePrefix(string) storage.AdapterCache
	// SetWebSocket websocket
	SetWebSocket(s *ws.Instance)
	WebSocket() *ws.Instance
	GetWebSocket() *ws.Instance

	GetMemoryQueue(prefix string) storage.AdapterQueue
	GetRabbitQueue(prefix string) storage.AdapterQueue
	GetRocketQueue(prefix string) storage.AdapterQueue

	SetQueueAdapter(string, storage.AdapterQueue)
	GetQueueAdapter(key string) storage.AdapterQueue
	GetQueuePrefix(key string) storage.AdapterQueue
	GetQueueMessage(id, routingKey string, value map[string]interface{}) (storage.Messager, error)

	SetLockerAdapter(storage.AdapterLocker)
	GetLockerAdapter() storage.AdapterLocker
	GetLockerPrefix(string) storage.AdapterLocker

	SetCron(srv cron.Adapter)
	Cron() cron.Adapter

	SetTask(srv task.TasksService)
	Task() task.TasksService
	SetRabbitTask(srv task.RabbitMqService)
	RabbitTask() task.RabbitMqService
	SetRocketMqTask(srv task.RocketMqService)
	RocketMqTask() task.RocketMqService
	SetMemoryTask(srv task.MemoryService)
	MemoryTask() task.MemoryService
}

Jump to

Keyboard shortcuts

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