Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/postgrex/type_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ defmodule Postgrex.TypeServer do

defstruct [:types, :connections, :lock, :waiting]

@timeout 60_000

@doc """
Starts a type server.
"""
Expand All @@ -24,8 +22,10 @@ defmodule Postgrex.TypeServer do
@spec fetch(pid) ::
{:lock, reference, Postgrex.Types.state()} | :noproc | :error
def fetch(server) do
timeout = Application.fetch_env!(:postgrex, :type_server_timeout)

try do
GenServer.call(server, :fetch, @timeout)
GenServer.call(server, :fetch, timeout)
catch
# module timed out, pretend it did not exist.
:exit, {:normal, _} -> :noproc
Expand All @@ -38,7 +38,8 @@ defmodule Postgrex.TypeServer do
"""
@spec update(pid, reference, [Postgrex.TypeInfo.t()]) :: :ok
def update(server, ref, [_ | _] = type_infos) do
GenServer.call(server, {:update, ref, type_infos}, @timeout)
timeout = Application.fetch_env!(:postgrex, :type_server_timeout)
GenServer.call(server, {:update, ref, type_infos}, timeout)
end

def update(server, ref, []) do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Postgrex.Mixfile do
[
extra_applications: [:logger, :crypto, :ssl],
mod: {Postgrex.App, []},
env: [type_server_reap_after: 3 * 60_000, json_library: Jason]
env: [type_server_reap_after: 3 * 60_000, type_server_timeout: 60_000, json_library: Jason]
]
end

Expand Down
Loading