From 97743eaad51fc26b0849214ee992740fff491c7a Mon Sep 17 00:00:00 2001 From: boyska Date: Thu, 23 Aug 2018 01:14:08 +0200 Subject: [PATCH] Hub resists to Client failures --- hub.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hub.go b/hub.go index e9efd27..d68ef08 100644 --- a/hub.go +++ b/hub.go @@ -48,7 +48,12 @@ func (h *Hub) Run() { } h.circbuf.Do(func(x interface{}) { if x != nil { - cl.Messages <- x.(format.LogParts) + select { // send without blocking + case cl.Messages <- x.(format.LogParts): + break + default: + break + } } }) if cl.Nofollow { @@ -65,7 +70,12 @@ func (h *Hub) Run() { h.circbuf.Value = msg h.circbuf = h.circbuf.Next() for client := range h.clients { - client.Messages <- msg + select { // send without blocking + case client.Messages <- msg: + break + default: + break + } } } }