jfischoff / postgresql-queue

A PostgreSQL backed queue
BSD 3-Clause "New" or "Revised" License
16 stars 3 forks source link

Retry with exponential backoff #9

Open charles-cooper opened 6 years ago

charles-cooper commented 6 years ago

Reading the implementation for withPayloadDB, https://github.com/jfischoff/postgresql-queue/blob/6a9c22055ae81e8dcaf5cfd60bcb640a4c512206/src/Database/PostgreSQL/Simple/Queue.hs#L227-L229, it looks like there is no strategy for backoff. Would it be better to implement some sort of backoff strategy within postgresql-simple-queue or do have a client-side implementation? E.g.

forever $ do
  withPayloadDB "public" 5 $ \payload -> do
    tryProcessPayload
  sleep 10 -- or something more complicated based on `pModifiedAt` and `pAttempts`
jfischoff commented 6 years ago

Just saw this. Yeah retry with exponential backoff sounds like a improvement.