1.0.0 • Published 5 months ago

pollicy v1.0.0

Weekly downloads
-
License
(Apache-2.0 AND M...
Repository
github
Last release
5 months ago

Pollicy

Library for defining Polling policy for tasks to be retried.

Name is not a typo it intentional collision of Poll with Policy.

API

import { constant, exponential } from "pollicy"

// poll every 10ms. Give if failed 32 attempts or if had been trying
// for more 7000ms.
constant(10)
  .limitAttempts(32)
  .limitDuration(7000)
  .poll(() => fetch(url))

// or use exponential back-off strategy increasing intervals from 10ms
// to 100ms. Give up if after 32 failed attempts or after trying for 7000ms.
exponential(10, 100)
  .limitAttempts(32)
  .limitDuration(7000)
  .poll(() => fetch(url))

Prior Art

Library is essentially JS port of the excellent elm-retry

1.0.0

5 months ago