diff --git a/server/router.go b/server/router.go index b068da4..8be5ce3 100644 --- a/server/router.go +++ b/server/router.go @@ -59,7 +59,7 @@ func (r *RedisRouter) Route(msg *meowlib.ToServerMessage) (*meowlib.FromServerMe } if msg.Timeout > 0 { // set timeout for the lookup - r.subscribe(msg) + r.subscribe(msg, int(msg.Timeout)) } } // manage Matriochka @@ -196,7 +196,7 @@ func goSubscribeAndListen(client *redis.Client, key string, messages chan<- stri } } -func (r *RedisRouter) subscribe(msg *meowlib.ToServerMessage) (*meowlib.FromServerMessage, error) { +func (r *RedisRouter) subscribe(msg *meowlib.ToServerMessage, timeout int) (*meowlib.FromServerMessage, error) { var from_server meowlib.FromServerMessage // update messages counter err := r.Client.Incr("statistics:messages:messagessubscription").Err() @@ -217,7 +217,7 @@ func (r *RedisRouter) subscribe(msg *meowlib.ToServerMessage) (*meowlib.FromServ case <-messages: close(done) return r.checkForMessage(msg) - case <-time.After(10 * time.Second): // 10 seconds timeout + case <-time.After(time.Duration(timeout) * time.Second): // 10 seconds timeout close(done) } wg.Wait()