(ctx context.Context)
| 591 | } |
| 592 | |
| 593 | func (s *Server) writeLoop(ctx context.Context) error { |
| 594 | for { |
| 595 | msg, err := s.outgoingQueue.Get(ctx) |
| 596 | if err != nil { |
| 597 | return err |
| 598 | } |
| 599 | if err := s.w.Write(msg); err != nil { |
| 600 | return fmt.Errorf("failed to write message: %w", err) |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | // WARNING: this should only be called in the async portion of a request handler, |
| 606 | // otherwise a deadlock can occur. |