in client.go [339:357]
func (c *Connection) send(streamClosed, streamSendLock chan struct{}, stream acpb.AgentCommunication_StreamAgentMessagesClient) {
defer func() {
// Lock the stream sends so we can close the stream.
streamSendLock <- struct{}{}
stream.CloseSend()
}()
for {
select {
case req := <-c.sends:
if err := c.streamSend(req, streamClosed, streamSendLock, stream); err != nil {
return
}
case <-c.closed:
return
case <-streamClosed:
return
}
}
}