Only send an error if there is a receiver

This commit is contained in:
Kevin Cotugno 2017-11-18 22:18:40 -08:00 committed by Kevin Cotugno
parent 81ec3c1eb8
commit f324ba576c

View File

@ -30,7 +30,11 @@ func (r *Registrar) record() {
_, err := r.Database.TradeService().CreateTrade(trade)
if err != nil {
r.Logger.Info("Error inserting trade: %v", err)
r.err <- err
select {
case r.err <- err:
default:
}
}
}(t)
}
@ -40,7 +44,11 @@ func (r *Registrar) record() {
go func() {
for err := range r.Listener.Error() {
r.Logger.Info("Registrar received error: %v", err)
r.err <- err
select {
case r.err <- err:
default:
}
}
r.Logger.Info("Error goroutine done")