Rename messages channels to outgoing
This commit is contained in:
parent
7fe0986859
commit
cdab0dc825
@ -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 {
|
||||
|
12
upstream.go
12
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user