qixiaoning
2025-07-25 94f3085afd10d76fa6e0640b5eed1d615b11ecea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
}