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 irc *irc.Conn
srv *Server srv *Server
logger Logger logger Logger
messages chan *irc.Message outgoing chan *irc.Message
consumptions chan consumption consumptions chan consumption
closed chan struct{} closed chan struct{}
@ -77,7 +77,7 @@ func newDownstreamConn(srv *Server, netConn net.Conn) *downstreamConn {
irc: irc.NewConn(netConn), irc: irc.NewConn(netConn),
srv: srv, srv: srv,
logger: &prefixLogger{srv.Logger, fmt.Sprintf("downstream %q: ", netConn.RemoteAddr())}, 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), consumptions: make(chan consumption),
closed: make(chan struct{}), closed: make(chan struct{}),
} }
@ -227,7 +227,7 @@ func (dc *downstreamConn) writeMessages() error {
var err error var err error
var closed bool var closed bool
select { select {
case msg := <-dc.messages: case msg := <-dc.outgoing:
if dc.srv.Debug { if dc.srv.Debug {
dc.logger.Printf("sent: %v", msg) dc.logger.Printf("sent: %v", msg)
} }
@ -290,7 +290,7 @@ func (dc *downstreamConn) Close() error {
} }
func (dc *downstreamConn) SendMessage(msg *irc.Message) { func (dc *downstreamConn) SendMessage(msg *irc.Message) {
dc.messages <- msg dc.outgoing <- msg
} }
func (dc *downstreamConn) handleMessage(msg *irc.Message) error { func (dc *downstreamConn) handleMessage(msg *irc.Message) error {

View File

@ -33,7 +33,7 @@ type upstreamConn struct {
irc *irc.Conn irc *irc.Conn
srv *Server srv *Server
user *user user *user
messages chan<- *irc.Message outgoing chan<- *irc.Message
ring *Ring ring *Ring
serverName string serverName string
@ -71,7 +71,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
setKeepAlive(netConn) setKeepAlive(netConn)
msgs := make(chan *irc.Message, 64) outgoing := make(chan *irc.Message, 64)
uc := &upstreamConn{ uc := &upstreamConn{
network: network, network: network,
logger: logger, logger: logger,
@ -79,7 +79,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
irc: irc.NewConn(netConn), irc: irc.NewConn(netConn),
srv: network.user.srv, srv: network.user.srv,
user: network.user, user: network.user,
messages: msgs, outgoing: outgoing,
ring: NewRing(network.user.srv.RingCap), ring: NewRing(network.user.srv.RingCap),
channels: make(map[string]*upstreamChannel), channels: make(map[string]*upstreamChannel),
history: make(map[string]uint64), history: make(map[string]uint64),
@ -87,7 +87,7 @@ func connectToUpstream(network *network) (*upstreamConn, error) {
} }
go func() { go func() {
for msg := range msgs { for msg := range outgoing {
if uc.srv.Debug { if uc.srv.Debug {
uc.logger.Printf("sent: %v", msg) uc.logger.Printf("sent: %v", msg)
} }
@ -109,7 +109,7 @@ func (uc *upstreamConn) Close() error {
if uc.closed { if uc.closed {
return fmt.Errorf("upstream connection already closed") return fmt.Errorf("upstream connection already closed")
} }
close(uc.messages) close(uc.outgoing)
uc.closed = true uc.closed = true
return nil return nil
} }
@ -681,5 +681,5 @@ func (uc *upstreamConn) readMessages() error {
} }
func (uc *upstreamConn) SendMessage(msg *irc.Message) { func (uc *upstreamConn) SendMessage(msg *irc.Message) {
uc.messages <- msg uc.outgoing <- msg
} }