Browse Source

improve logs

pull/117/head v0.12.3
wagslane 3 years ago
parent
commit
05646d6bbc
2 changed files with 16 additions and 15 deletions
  1. +3
    -1
      consume.go
  2. +13
    -14
      publish.go

+ 3
- 1
consume.go View File

@ -94,7 +94,9 @@ func NewConsumer(
*options, *options,
) )
if err != nil { if err != nil {
consumer.options.Logger.Errorf("error restarting consumer goroutines after cancel or close: %v", err)
consumer.options.Logger.Fatalf("error restarting consumer goroutines after cancel or close: %v", err)
consumer.options.Logger.Fatalf("consumer closing, unable to recover")
return
} }
} }
}() }()


+ 13
- 14
publish.go View File

@ -104,7 +104,19 @@ func NewPublisher(conn *Conn, optionFuncs ...func(*PublisherOptions)) (*Publishe
return nil, err return nil, err
} }
go publisher.handleRestarts()
go func() {
for err := range publisher.reconnectErrCh {
publisher.options.Logger.Infof("successful publisher recovery from: %v", err)
err := publisher.startup()
if err != nil {
publisher.options.Logger.Fatalf("error on startup for publisher after cancel or close: %v", err)
publisher.options.Logger.Fatalf("publisher closing, unable to recover")
return
}
go publisher.startReturnHandler()
go publisher.startPublishHandler()
}
}()
return publisher, nil return publisher, nil
} }
@ -119,19 +131,6 @@ func (publisher *Publisher) startup() error {
return nil return nil
} }
func (publisher *Publisher) handleRestarts() {
for err := range publisher.reconnectErrCh {
publisher.options.Logger.Infof("successful publisher recovery from: %v", err)
err := publisher.startup()
if err != nil {
publisher.options.Logger.Infof("failed to startup publisher: %v", err)
continue
}
go publisher.startReturnHandler()
go publisher.startPublishHandler()
}
}
/* /*
Publish publishes the provided data to the given routing keys over the connection. Publish publishes the provided data to the given routing keys over the connection.
*/ */


Loading…
Cancel
Save