mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
27 lines
581 B
Go
27 lines
581 B
Go
package hook_message_work
|
|
|
|
import (
|
|
"pandax/iothub/netbase"
|
|
"pandax/pkg/global"
|
|
"sync"
|
|
)
|
|
|
|
type HookService struct {
|
|
Cache sync.Map
|
|
Wg sync.WaitGroup // 优雅关闭
|
|
Ch chan struct{} // 并发限制
|
|
MessageCh chan *netbase.DeviceEventInfo
|
|
}
|
|
|
|
func NewHookService() *HookService {
|
|
hs := &HookService{
|
|
Cache: sync.Map{},
|
|
MessageCh: make(chan *netbase.DeviceEventInfo),
|
|
}
|
|
// 并发限制,代表服务器处理能力
|
|
if global.Conf.Queue.Enable && global.Conf.Queue.Num > 0 {
|
|
hs.Ch = make(chan struct{}, global.Conf.Queue.Num)
|
|
}
|
|
return hs
|
|
}
|