Skip to content

Commit f20274a

Browse files
Th3-M4jorThe Major
andauthored
Make timeouts for TypeServer configurable (#755)
Co-authored-by: The Major <spartan364@gmai.com>
1 parent 0a0006d commit f20274a

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/postgrex/type_server.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ defmodule Postgrex.TypeServer do
55

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

8-
@timeout 60_000
9-
108
@doc """
119
Starts a type server.
1210
"""
@@ -24,8 +22,10 @@ defmodule Postgrex.TypeServer do
2422
@spec fetch(pid) ::
2523
{:lock, reference, Postgrex.Types.state()} | :noproc | :error
2624
def fetch(server) do
25+
timeout = Application.fetch_env!(:postgrex, :type_server_timeout)
26+
2727
try do
28-
GenServer.call(server, :fetch, @timeout)
28+
GenServer.call(server, :fetch, timeout)
2929
catch
3030
# module timed out, pretend it did not exist.
3131
:exit, {:normal, _} -> :noproc
@@ -38,7 +38,8 @@ defmodule Postgrex.TypeServer do
3838
"""
3939
@spec update(pid, reference, [Postgrex.TypeInfo.t()]) :: :ok
4040
def update(server, ref, [_ | _] = type_infos) do
41-
GenServer.call(server, {:update, ref, type_infos}, @timeout)
41+
timeout = Application.fetch_env!(:postgrex, :type_server_timeout)
42+
GenServer.call(server, {:update, ref, type_infos}, timeout)
4243
end
4344

4445
def update(server, ref, []) do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Postgrex.Mixfile do
2323
[
2424
extra_applications: [:logger, :crypto, :ssl],
2525
mod: {Postgrex.App, []},
26-
env: [type_server_reap_after: 3 * 60_000, json_library: Jason]
26+
env: [type_server_reap_after: 3 * 60_000, type_server_timeout: 60_000, json_library: Jason]
2727
]
2828
end
2929

0 commit comments

Comments
 (0)