this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove dead backoff

garrison 96e51b91 0ab7ee03

-18
-18
lib/utils.ex
··· 405 405 Integer.pow(2, attempt) 406 406 end 407 407 408 - @spec backoff(term, ({:cont, term, term} | {:halt, term} -> term), non_neg_integer, non_neg_integer) :: term 409 - def backoff(acc \\ nil, fun, count \\ 6, attempt \\ 0, last_error \\ nil) 410 - 411 - def backoff(_acc, _fun, count, attempt, last_error) when attempt == count do 412 - last_error 413 - end 414 - 415 - def backoff(acc, fun, count, attempt, _last_error) when is_function(fun, 1) and is_integer(count) and is_integer(attempt) do 416 - case fun.(acc) do 417 - {:cont, acc, error} -> 418 - delay = Integer.pow(2, attempt + 1) 419 - SimProcess.sleep(delay) 420 - backoff(acc, fun, count, attempt + 1, error) 421 - {:halt, acc} -> 422 - acc 423 - end 424 - end 425 - 426 408 @spec inc_stat(map, term, number) :: map 427 409 def inc_stat(stats, key, amount \\ 1) when is_map(stats) do 428 410 Map.update(stats, key, amount, &(&1 + amount))