update timeout and buffer size

This commit is contained in:
poiuty 2023-07-03 22:50:23 +03:00
parent fbbe4921c9
commit 926814260d
2 changed files with 7 additions and 4 deletions

View file

@ -28,10 +28,10 @@ var (
json = jsoniter.ConfigCompatibleWithStandardLibrary json = jsoniter.ConfigCompatibleWithStandardLibrary
socketServer = make(chan []byte, 100) socketServer = make(chan []byte, 1)
save = make(chan saveData, 100) save = make(chan saveData, 1)
slog = make(chan saveLog, 100) slog = make(chan saveLog, 32)
rooms = &Rooms{ rooms = &Rooms{
Count: make(chan int), Count: make(chan int),
@ -99,8 +99,10 @@ func socketHandler() {
select { select {
case b := <-socketServer: case b := <-socketServer:
//fmt.Println("socketServer", len(socketServer), cap(socketServer))
if conn == nil || conn.RemoteAddr() == nil { if conn == nil || conn.RemoteAddr() == nil {
conn, err = net.DialTimeout("unix", "/tmp/echo.sock", time.Second*5) conn, err = net.DialTimeout("unix", "/tmp/echo.sock", time.Millisecond*10)
if err != nil { if err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
continue continue

View file

@ -204,6 +204,7 @@ func saveLogs() {
bulk = nil bulk = nil
} }
case m := <-slog: case m := <-slog:
//fmt.Println("slog", len(slog), cap(slog))
if len(m.Mes) > 0 { if len(m.Mes) > 0 {
bulk = append(bulk, m) bulk = append(bulk, m)
} }