[{"name":"Http.CmdRetry","comment":" Tries to perform a `Task` and retry it upon failure, allowing you to execute other `Cmd`s between each failure.\n\nThe following example executes a request with a retry policy when the request fails and\nexecutes a port before each new retry:\n\n    type Msg\n        = OnRetry (Http.CmdRetry.RetryContext Msg Entity)\n        | OnEntityRetrieved (RemoteData.RemoteData Http.Error.RequestError Entity)\n\n    type alias Model =\n        { entity : RemoteData.RemoteData Http.Error.RequestError Entity }\n\n    init : ( Model, Cmd Msg )\n    init =\n        ( { entity = RemoteData.Loading }\n        , getEntity\n            |> Http.CmdRetry.with\n                [ Http.Retry.maxDuration 7000\n                , Http.Retry.exponentialBackoff { interval = 500, maxInterval = 3000 }\n                ]\n                [ Http.Retry.onUnauthenticatedStatus ]\n                OnRetry\n        )\n\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg model =\n        case msg of\n            OnRetry retryContext ->\n                ( model\n                , Http.CmdRetry.newAttempt\n                    executePort\n                    OnEntityRetrieved\n                    retryContext\n                )\n\n            OnEntityRetrieved entity ->\n                ( { model | entity = entity }, Cmd.none )\n\n    getEntity : Task Never (RemoteData.RemoteData Http.Error.RequestError Entity)\n    getEntity =\n        Request.request\n            { url = \"<http://endpoint\">\n            , headers = []\n            , body = Json.Encode.object []\n            , documentDecoder = JsonApi.Decode.resources \"resource-type\" entityDecoder\n            }\n\n\n# Retry\n\n@docs with, newAttempt\n\n\n# Types\n\n@docs RetryContext\n\n","unions":[{"name":"RetryContext","comment":" Type used by the module to keep the context of the retry process.\nYou will never handle it directly\n\n`msg` is your `Msg` type and `data` is the data you you to receive from your request.\n\n","args":["msg","data"],"cases":[]}],"aliases":[],"values":[{"name":"newAttempt","comment":" Attempt a new retry from your update function with the `RetryContext` you received.\nThe first parameter allows you to execute a `Cmd` just before the next retry.\nThe second parameter is the message you want to send when the request finally succeeded or failed (after all configured retries)\n\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg model =\n        case msg of\n            OnRetry retryContext ->\n                ( model\n                , Http.CmdRetry.newAttempt\n                    (\\lastError ->\n                        doSomethingWithLastError lastError\n                    )\n                    OnRequestDone\n                    retryContext\n                )\n\n","type":"(Http.Error.RequestError -> Platform.Cmd.Cmd msg) -> (RemoteData.RemoteData Http.Error.RequestError data -> msg) -> Http.CmdRetry.RetryContext msg data -> Platform.Cmd.Cmd msg"},{"name":"with","comment":" Tries to execute the given task. You will receive a message with the retry context.\nFrom there you will call `newAttempt` which will handle your request retry, allowing you\nto execute a `Cmd` before the next retry.\n\n    originalTask\n        |> Http.CmdRetry.with\n            [ Http.Retry.maxDuration 7000\n            , Http.Retry.exponentialBackoff { interval = 500, maxInterval = 3000 }\n            ]\n            [ Http.Retry.onUnauthenticatedStatus ]\n            OnRetry\n\n","type":"List.List (Http.Internal.Policy Http.Error.RequestError) -> List.List Http.Internal.FailureCondition -> (Http.CmdRetry.RetryContext msg data -> msg) -> Task.Task Basics.Never (RemoteData.RemoteData Http.Error.RequestError data) -> Platform.Cmd.Cmd msg"}],"binops":[]},{"name":"Http.Retry","comment":" Add retries to a jsonapi http task, based on a list of retry policies, until any one of\nthe policies fail too.\n\n@docs with\n\n\n# Policies\n\n@docs Policy, maxRetries, maxDuration, constantInterval, exponentialBackoff\n\n\n# Failure conditions\n\n@docs FailureCondition, onStatus, onUnauthenticatedStatus, onUnauthorizedStatus, onNetworkError, onTimeout, onAllFailures\n\n","unions":[],"aliases":[{"name":"FailureCondition","comment":" FailureCondition contains a function that filter request errors\n","args":[],"type":"Http.Internal.FailureCondition"},{"name":"Policy","comment":" A [`Policy`](#Policy) is attached with a function that will return another\n[`Policy`](#Policy) as a [`Task`](https://package.elm-lang.org/packages/elm/core/latest/Task#Task) value.\nThe arguments of the function are\n\n  - `Int` timestamp of when we first started `originalTask`, in milliseconds\n  - `Policy x` the current policy; destructure to obtain the function to call\n  - `x` last error from attempting `originalTask`\n    Refer to [`maxRetries`](#maxRetries) source code for a simple example.\n\n","args":["x"],"type":"Http.Internal.Policy x"}],"values":[{"name":"constantInterval","comment":" Sleep for the same number of milliseconds before every retry.\n\n    Retry.with [ Retry.constantInterval 1000 ] [] originalTask\n        |> Task.attempt DidOriginalTask\n\nNOTE: The code above will keep retrying `originalTask`; best to combine with\n[`maxRetries`](#maxRetries) or [`maxDuration`](#maxDuration)\n\n","type":"Basics.Float -> Http.Retry.Policy x"},{"name":"exponentialBackoff","comment":" Sleep for an increasing number of milliseconds before every retry. Backoff\nalgorithim is based off [https://github.com/cenkalti/backoff](https://github.com/cenkalti/backoff/blob/4b4cebaf850ec58f1bb1fec5bdebdf8501c2bc3f/exponential.go#L144-L153)\n\n    Retry.with [ Retry.exponentialBackoff { interval = 500, maxInterval = 3000 } ] [] originalTask\n        |> Task.attempt DidOriginalTask\n\nNOTE: The code above will keep retrying `originalTask`; best to combine with\n[`maxRetries`](#maxRetries) or [`maxDuration`](#maxDuration)\n\n","type":"{ interval : Basics.Float, maxInterval : Basics.Float } -> Http.Retry.Policy x"},{"name":"maxDuration","comment":" Stop retrying `originalTask` after some number of milliseconds.\n\n    Retry.with [ Retry.maxDuration 7000 ] [] originalTask\n        |> Task.attempt DidOriginalTask\n\nNOTE: The code above does NOT sleep between retries; best to combine with\n[`constantInterval`](#constantInterval) or [`exponentialBackoff`](#exponentialBackoff)\n\n","type":"Basics.Int -> Http.Retry.Policy x"},{"name":"maxRetries","comment":" Stop retrying `originalTask` after a number of retries.\n\n    Retry.with [ Retry.maxRetries 20 ] [] originalTask\n        |> Task.attempt DidOriginalTask\n\nNOTE: The code above does NOT sleep between retries; best to combine with\n[`constantInterval`](#constantInterval) or [`exponentialBackoff`](#exponentialBackoff)\n\n","type":"Basics.Int -> Http.Retry.Policy x"},{"name":"onAllFailures","comment":" To use with `with` function. Filters errors to be retried by retrying all errors\n","type":"Http.Retry.FailureCondition"},{"name":"onNetworkError","comment":" To use with `with` function. Filters errors to be retried by retrying all network errors\n","type":"Http.Retry.FailureCondition"},{"name":"onStatus","comment":" To use with `with` function. Filters errors to be retried by retrying errors based on the status code\n","type":"Basics.Int -> Http.Retry.FailureCondition"},{"name":"onTimeout","comment":" To use with `with` function. Filters errors to be retried by retrying all timeout errors\n","type":"Http.Retry.FailureCondition"},{"name":"onUnauthenticatedStatus","comment":" To use with `with` function. Filters errors to be retried by retrying errors base on the 401 status code\n","type":"Http.Retry.FailureCondition"},{"name":"onUnauthorizedStatus","comment":" To use with `with` function. Filters errors to be retried by retrying errors base on the 403 status code\n","type":"Http.Retry.FailureCondition"},{"name":"with","comment":" Given a list of error handling `Policy` we can make our `originalTask`\nretry on failure until any one of the `Policy` fails or the request succeeds.\n\n    originalTask\n        |> Http.Retry.with\n            [ Http.Retry.maxDuration 7000\n            , Http.Retry.exponentialBackoff { interval = 500, maxInterval = 3000 }\n            ]\n            [ Http.Retry.onUnauthenticatedStatus ]\n        |> Task.perform DidOriginalTask\n\n","type":"List.List (Http.Retry.Policy Http.Error.RequestError) -> List.List Http.Retry.FailureCondition -> Task.Task Basics.Never (RemoteData.RemoteData Http.Error.RequestError data) -> Task.Task Basics.Never (RemoteData.RemoteData Http.Error.RequestError data)"}],"binops":[]}]