Skip to content
Snippets Groups Projects

Resolve "Error handling in event publishing via entity services could be improved"

8 files
+ 99
146
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -23,7 +23,8 @@ type EventService struct {
}
const (
rePublishAttempts = 5
// Max number of tries to republish a failed message
rePublishAttempts = 10
)
// NewEventService creates a new connection to the broker and opens a channel for later usage.
@@ -88,7 +89,7 @@ func (e *EventService) PublishEvent(topic string, event event.Event) error {
// RetryPublish is used to retry publishing an event after a failed attempt.
func (e *EventService) RetryPublish(topic string, event event.Event) error {
ctx := context.Background()
backOff := retry.NewConstant(2 * time.Second)
backOff := retry.NewFibonacci(time.Second)
if err := retry.Do(ctx, retry.WithMaxRetries(rePublishAttempts, backOff), func(ctx context.Context) error {
if pubErr := e.PublishEvent(topic, event); pubErr != nil {
Loading