Kun Nan
08/10/2021, 2:05 AMfor {
// Loop reading messages from conn.Receive() (via
// msgChannel) until the context is cancelled.
select {
case msg, ok := <-msgChannel:
if !ok {
return
}
switch msg := msg.(type) {
case redis.Message:
var res fleet.DistributedQueryResult
err := json.Unmarshal(msg.Data, &res)
if err != nil {
outChannel <- err
}
outChannel <- res
case error:
outChannel <- errors.Wrap(msg, "reading from redis")
}
case <-ctx.Done():
conn.Unsubscribe()
}
}
the ctx here is a empty context,so ctx.Done()
only get nil .
Does this select case will not be executed forevere?
If so,what's the purpose here?Bacarus
08/10/2021, 7:52 AMzwass
08/10/2021, 7:30 PMKun Nan
08/11/2021, 5:57 AM