retryer

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Retryer

type Retryer struct {
	// contains filtered or unexported fields
}

Retryer defines the service in charge of finding failed deliveries and trying them again.

func New

New creates a Retryer instance.

func (*Retryer) DeliverMessage

func (r *Retryer) DeliverMessage(message *resource.Message) error

DeliverMessage queues the message to be delivered.

func (*Retryer) RetrieveFailedMessages

func (r *Retryer) RetrieveFailedMessages() ([]*resource.Message, error)

retrieveFailedMessageIDs retrieves from the database all failed messages that were created in the last two hours, then calculates whether each one is due to be retried.

Failed messages are retried on an exponential backoff schedule, waiting 4^i seconds with each retry. Messages that have been tried six times will be considered as permanently failed.

The following table lists the wait time of each retry:

 deliveries |    wait time    | cumul. wait time
-------------------------------------------------
          0 |    1s,       1s |               1s
          1 |    4s,       4s |               5s
          2 |   16s,      16s |              21s
          3 |   64s,    1m04s |             1m25
          4 |  256s,    4m16s |             5m41
          5 | 1024s,   17m04s |            22m45
          6 | 4096s, 1h08m16s |          1h31m01

Notes:

  • It should not happen for a failed message to have no deliveries. In this case, the message will still be added to the list of messages to deliver.
  • The cumulative wait time column is an approximation. The Scheduler service is run periodically, and the exact wait time cannot be calculated beforehand.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL