Title
#fleet
k

Kun Nan

08/10/2021, 2:05 AM
Hi,I hava a question about fleet dealing with redis results,https://github.com/fleetdm/fleet/blob/main/server/pubsub/redis_query_results.go#L189
for {
// 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

Bacarus

08/10/2021, 7:52 AM
OT: here on slack you can use the block code with “ctrl + alt + shift + c” shortcut in order to have a prettier visualization of your code
zwass

zwass

08/10/2021, 7:30 PM
k

Kun Nan

08/11/2021, 5:57 AM
Thanks very much!