From cdab0dc825d798c6e042642b3c82d9b566c0ccad Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 16 Mar 2020 11:26:54 +0100 Subject: [PATCH] Rename messages channels to outgoing --- downstream.go | 8 ++++---- upstream.go | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/downstream.go b/downstream.go index e2d656a..4d28ab6 100644 --- a/downstream.go +++ b/downstream.go @@ -57,7 +57,7 @@ type downstreamConn struct { irc *irc.Conn srv *Server logger Logger - messages chan *irc.Message + outgoing chan *irc.Message consumptions chan consumption closed chan struct{} @@ -77,7 +77,7 @@ func newDownstreamConn(srv *Server, netConn net.Conn) *downstreamConn { irc: irc.NewConn(netConn), srv: srv, logger: &prefixLogger{srv.Logger, fmt.Sprintf("downstream %q: ", netConn.RemoteAddr())}, - messages: make(chan *irc.Message, 64), + outgoing: make(chan *irc.Message, 64), consumptions: make(chan consumption), closed: make(chan struct{}), } @@ -227,7 +227,7 @@ func (dc *downstreamConn) writeMessages() error { var err error var closed bool select { - case msg := <-dc.messages: + case msg := <-dc.outgoing: if dc.srv.Debug { dc.logger.Printf("sent: %v", msg) } @@ -290,7 +290,7 @@ func (dc *downstreamConn) Close() error { } func (dc *downstreamConn) SendMessage(msg *irc.Message) { - dc.messages <- msg + dc.outgoing <- msg } func (dc *downstreamConn) handleMessage(msg *irc.Message) error { diff --git a/upstream.go b/upstream.go index 0c07a99..2cc6ba8 100644 --- a/upstream.go +++ b/upstream.go @@ -33,7 +33,7 @@ type upstreamConn struct { irc *irc.Conn srv *Server user *user - messages chan<- *irc.Message + outgoing chan<- *irc.Message ring *Ring serverName string @@ -71,7 +71,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) { setKeepAlive(netConn) - msgs := make(chan *irc.Message, 64) + outgoing := make(chan *irc.Message, 64) uc := &upstreamConn{ network: network, logger: logger, @@ -79,7 +79,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) { irc: irc.NewConn(netConn), srv: network.user.srv, user: network.user, - messages: msgs, + outgoing: outgoing, ring: NewRing(network.user.srv.RingCap), channels: make(map[string]*upstreamChannel), history: make(map[string]uint64), @@ -87,7 +87,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) { } go func() { - for msg := range msgs { + for msg := range outgoing { if uc.srv.Debug { uc.logger.Printf("sent: %v", msg) } @@ -109,7 +109,7 @@ func (uc *upstreamConn) Close() error { if uc.closed { return fmt.Errorf("upstream connection already closed") } - close(uc.messages) + close(uc.outgoing) uc.closed = true return nil } @@ -681,5 +681,5 @@ func (uc *upstreamConn) readMessages() error { } func (uc *upstreamConn) SendMessage(msg *irc.Message) { - uc.messages <- msg + uc.outgoing <- msg }