Files
taskq/plugin.go
hupeh 326f2a371c feat: 优化监控仪表盘 UI
- 添加 appbar 导航栏,支持 Chart/Queues 视图切换
- appbar 切换使用 history API,支持浏览器前进/后退
- 图表视图占满整个可视区域
- queue-modal 共享 appbar 样式
- 修复 queue tab count 字段名大小写问题
- tooltip 跟随鼠标显示在右下方,移除箭头
- 图表 canvas 鼠标样式改为准星
- pause/resume 队列后刷新列表
- example 添加 flag 配置参数
2025-12-10 00:53:30 +08:00

42 lines
985 B
Go

package taskq
import (
"context"
"github.com/redis/go-redis/v9"
)
// Context 插件上下文,提供对 Servlet 资源的访问
type Context struct {
context.Context
servlet *Servlet
}
// Redis 返回 Redis 客户端
func (ctx *Context) Redis() redis.UniversalClient {
return ctx.servlet.redisClient
}
// Queues 返回队列优先级配置
func (ctx *Context) Queues() map[string]int {
return ctx.servlet.Queues()
}
// Plugin 定义插件接口,用于扩展 Servlet 的生命周期
type Plugin interface {
// Name 返回插件名称,用于日志和调试
Name() string
// Init 初始化插件,在 Servlet.Start 之前调用
// ctx 提供对 Servlet 资源的访问
Init(ctx *Context) error
// Start 启动插件,在 Servlet.Start 时调用
// ctx 提供对 Servlet 资源的访问,内嵌的 context.Context 会在 Stop 时取消
Start(ctx *Context) error
// Stop 停止插件,在 Servlet.Stop 时调用
// 按注册的逆序调用
Stop() error
}