Skip to content

Commit

Permalink
UPDATE: default maximum retry to be zero
Browse files Browse the repository at this point in the history
  • Loading branch information
lovebes committed Oct 26, 2023
1 parent aa28c83 commit 01a31f5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ config :novu,
domain: "domain", # required: your domain
wait_min: 1000, # optional: the minimum time to retry a request is milliseconds (default: 1000)
wait_max: 10_000, # optional: the maximum time to retry a request is milliseconds (default: 10_000)
max_retries: 3, # optional: the amount of retries in case of responses 408/429/500/502/503/504 (default: 3)
max_retries: 3, # optional: the amount of retries in case of responses 408/429/500/502/503/504 (default: 0)
retry_log_level: :warning # optional: the log level to emit retry logs at. Can be set to false do disable logging (default: :warning)
```

Expand Down
4 changes: 3 additions & 1 deletion lib/novu/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defmodule Novu.Http do

@type response() :: {:ok, map()} | {:error, list() | :timeout | any()}

@max_retries 0

@doc """
Makes a `DELETE` request to Novu.
"""
Expand Down Expand Up @@ -81,7 +83,7 @@ defmodule Novu.Http do

defp wait_min, do: Application.get_env(:novu, :wait_min, 1000)
defp wait_max, do: Application.get_env(:novu, :wait_max, 10_000)
defp max_retries, do: Application.get_env(:novu, :max_retries, 3)
defp max_retries, do: Application.get_env(:novu, :max_retries, @max_retries)
defp retry_log_level, do: Application.get_env(:novu, :retry_log_level, :warning)

defp retry_delay_function(n) do
Expand Down
12 changes: 12 additions & 0 deletions test/novu/http_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ defmodule Novu.HttpTest do
end

describe "build_req/1" do
test "default maximum retry should be zero", %{bypass: bypass} do
wait_min = 100
Application.put_env(:novu, :wait_min, wait_min)
Application.delete_env(:novu, :max_retries)

Bypass.expect_once(bypass, "GET", "/", fn conn ->
novu_response(conn, 500, %{data: %{error: "Internal Server Error"}})
end)

Http.get("/")
end

test "creates a request with a minimum delay", %{bypass: bypass} do
wait_min = 100
Application.put_env(:novu, :wait_min, wait_min)
Expand Down

0 comments on commit 01a31f5

Please sign in to comment.