|
|
@ -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. |
|
|
*/ |
|
|
*/ |
|
|
|