calions-app/jsonapi-http-retry/2.0.0

Renamed to FabienHenon/jsonapi-http-retry. It is published under that name, and new versions come out there.

Versions published as calions-app/jsonapi-http-retry still install under that name. 2 versions of 2 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/FabienHenon/jsonapi-http-retry.

What we checked: The repo moved to github.com/FabienHenon/jsonapi-http-retry. Rebuilt with git archive from commit e6c3bc1260f8 of https://github.com/FabienHenon/jsonapi-http-retry (zip prefix calions-app-jsonapi-http-retry-e6c3bc1/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 13e53041cbea94520506e88de268624f601601f1.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/calions-app/jsonapi-http-retry/zipball/2.0.0/

jsonapi-http-retry

Retry failed jsonapi requests with retry policies.

It is greatly inspired by the Retry package but aims to handle http requests from the jsonapi-http package.

With this package you can add retry policies to jsonapi-http requests errors. You can choose specific errors that will trigger a retry: unauthenticated error, network error, etc...

You can also send Cmds between 2 failures with the Http.CmdRetry module.

Getting Started

Here is an example retrying requests 5 times maximum with a constant interval between retries, only for unauthenticated and unauthorized errors:

import Http.Request
import Http.Retry
import Json.Encode
import JsonApi.Decode

request : Cmd Msg
request =
    Request.request
        { url = "http://endpoint"
        , headers = []
        , body = Json.Encode.object []
        , documentDecoder = JsonApi.Decode.resources "resource-type" entityDecoder
        }
        |> Http.Retry.with
            [ Http.Retry.maxRetries 5
            , Http.Retry.exponentialBackoff { interval = 500, maxInterval = 3000 }
            ]
            [ Http.Retry.onUnauthenticatedStatus
            , Http.Retry.onUnauthorizedStatus
            ]
        |> Task.perform OnTaskCompleted