Rename messages channels to outgoing

This commit is contained in:
Simon Ser 2020-03-16 11:26:54 +01:00
parent 7fe0986859
commit cdab0dc825
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 10 additions and 10 deletions

View File

@ -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 {

View File

@ -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
}