runtime

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 21 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) 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) Bot added in v1.0.5

func (e *Application) Bot() *telebot.Bot

func (*Application) BotHook added in v1.0.7

func (e *Application) BotHook() telebot.Hook

func (*Application) Cache added in v0.3.3

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

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) 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) Monitor added in v0.4.3

func (e *Application) Monitor() *metrics.Monitor

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) SetBot added in v1.0.5

func (e *Application) SetBot(b *telebot.Bot)

func (*Application) SetBotHook added in v1.0.7

func (e *Application) SetBotHook(b telebot.Hook)

func (*Application) SetCache added in v0.3.3

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

SetCache 设置缓存

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) SetMetrics added in v0.4.3

func (e *Application) SetMetrics(m *metrics.Monitor)

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) SetTus added in v0.3.8

func (e *Application) SetTus(t *tus.Uploader)

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) Tus added in v0.3.8

func (e *Application) Tus() *tus.Uploader

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
	// SetCache cache
	SetCache(storage.AdapterCache)
	Cache() 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
	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

	SetTus(c *tus.Uploader)
	Tus() *tus.Uploader
	SetMetrics(m *metrics.Monitor)
	Monitor() *metrics.Monitor

	SetBotHook(b telebot.Hook)
	BotHook() telebot.Hook
	SetBot(b *telebot.Bot)
	Bot() *telebot.Bot
}

Jump to

Keyboard shortcuts

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