package service
|
|
import (
|
"context"
|
"fmt"
|
"time"
|
|
"github.com/muesli/cache2go"
|
)
|
|
var decoderMsgCache = cache2go.Cache("duanliu")
|
|
// 山东断流监控
|
func WatchDuanliu() {
|
url := "ipc:///tmp/shandong-decoder-duanliu-report.ipc"
|
|
sock := newPull(context.Background(), url, 6)
|
for {
|
if d, err := sock.Recv(); err == nil {
|
decoderMsgCache.Add(string(d), time.Duration(30)*time.Second, true)
|
fmt.Println("======>> Recv watchDuanliu:", string(d), "map size", decoderMsgCache.Count())
|
} else {
|
time.Sleep(10 * time.Second)
|
}
|
}
|
}
|
|
func GetDuanliuIds() []string {
|
var ids []string
|
|
decoderMsgCache.Foreach(func(key interface{}, item *cache2go.CacheItem) {
|
ids = append(ids, key.(string))
|
})
|
|
return ids
|
}
|