feat(common): 添加GlowFilter的Level字段

添加了GlowFilter结构体中的Level字段,用于表示等级信息,
对应JSON标签为"level,omitempty"

---

fix(utils): 修复concurrent_swiss_map中的panic处理

- 使用goroutine替代线程池来监听通道
- 添加panic恢复机制,当发生panic时记录错误日志
- 确保在异常情况下程序能够
This commit is contained in:
昔念
2026-01-25 23:17:46 +08:00
parent 4dd05726af
commit fa928c9a48
20 changed files with 156 additions and 210 deletions

View File

@@ -47,6 +47,7 @@ type GlowFilter struct {
// Knockout 是否挖空,默认 false
Knockout bool `json:"knockout,omitempty"`
ColorMatrixFilter [20]float32 `json:"matrix,omitempty"`
Level uint8 `json:"level,omitempty"` //等级
}
// ItemInfo

View File

@@ -277,14 +277,22 @@ func (m *CsMap[K, V]) produce(ctx context.Context, ch chan Tuple[K, V]) {
func (m *CsMap[K, V]) listen(f func(key K, value V) (stop bool), ch chan Tuple[K, V]) *sync.WaitGroup {
var wg sync.WaitGroup
wg.Add(1)
m.pool.Submit(func() {
go func() {
defer wg.Done()
defer func() {
if err := recover(); err != nil { // 恢复 panicerr 为 panic 错误值
// 1. 打印错误信息
cool.Logger.Error(context.TODO(), "panic 错误:", err)
}
}()
for t := range ch {
if stop := f(t.Key, t.Val); stop {
return
}
}
})
}()
return &wg
}