Browse Source

Merge pull request #111 from wshops/main

close publisher properly to prevent resource leaks
pull/110/head
Lane Wagner 3 years ago
committed by GitHub
parent
commit
748d47f1e9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      publish.go

+ 6
- 0
publish.go View File

@ -269,6 +269,12 @@ func (publisher *Publisher) PublishWithDeferredConfirmWithContext(
// The publisher should be discarded as it's not safe for re-use
// Only call Close() once
func (publisher *Publisher) Close() {
// close the channel so that rabbitmq server knows that the
// publisher has been stopped.
err := publisher.chanManager.Close()
if err != nil {
publisher.options.Logger.Warnf("error while closing the channel: %v", err)
}
publisher.options.Logger.Infof("closing publisher...")
go func() {
publisher.closeConnectionToManagerCh <- struct{}{}


Loading…
Cancel
Save