this repo has no description
2
fork

Configure Feed

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

Remove dead code

garrison db388f6e 708daeac

-35
-6
lib/transaction.ex
··· 311 311 end 312 312 end 313 313 314 - # Calls CommitBuffer.get_shards but retries if :read_version_too_new 315 - @doc false 316 - def get_shards_backoff(commit_buffer_pid, key_or_range) do 317 - too_new_backoff(fn -> CommitBuffer.get_shards(commit_buffer_pid, key_or_range) end) 318 - end 319 - 320 314 defp random_commit_buffer(%Cluster{} = cluster) do 321 315 commit_buffers = get_servers(cluster, Hobbes.Servers.CommitBuffer) 322 316 i = Enum.random(0..(length(commit_buffers) - 1))
-29
lib/utils.ex
··· 376 376 |> Enum.sort() 377 377 end 378 378 379 - @doc """ 380 - Attempts to run `fun`, but backs off and retries 381 - if `{:error, :read_version_too_new}` is received. 382 - 383 - ## Examples 384 - 385 - iex> too_new_backoff(fn -> Storage.read(...) end) 386 - {:ok, ...} 387 - 388 - iex> too_new_backoff(fn -> Storage.read(...) end) 389 - {:error, :too_many_retries} 390 - 391 - """ 392 - @spec too_new_backoff(function, non_neg_integer) :: term | {:error, :too_many_retries} 393 - def too_new_backoff(fun, attempt \\ 0) 394 - 395 - def too_new_backoff(_fun, 10), do: {:error, :too_many_retries} 396 - 397 - def too_new_backoff(fun, attempt) when is_integer(attempt) do 398 - case fun.() do 399 - {:error, :read_version_too_new} -> 400 - delay = floor(Float.pow(1.6, attempt + 1)) 401 - SimProcess.sleep(delay) 402 - too_new_backoff(fun, attempt + 1) 403 - result -> 404 - result 405 - end 406 - end 407 - 408 379 @spec backoff(term, ({:cont, term, term} | {:halt, term} -> term), non_neg_integer, non_neg_integer) :: term 409 380 def backoff(acc \\ nil, fun, count \\ 6, attempt \\ 0, last_error \\ nil) 410 381