Packages

Pluggable resolve throttling for Absinthe GraphQL.

Current section

Files

Jump to
absinthe_throttle lib adapter poolboy.ex
Raw

lib/adapter/poolboy.ex

defmodule AbsintheThrottle.Adapter.Poolboy do
require Logger
def transaction(res, args \\ []) do
pool = Keyword.fetch!(args, :pool)
timeout = Keyword.get(args, :timeout, 1_000)
error = Keyword.get(args, :error, {:error, :timeout})
try do
:poolboy.transaction(pool, fn _worker ->
{:ok, res}
end, timeout)
catch
:exit, {:timeout, _} ->
Logger.error("Failed to checkout resolve worker")
error
end
end
end