mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: timeouts @ the engine, not the parent process
This commit is contained in:
parent
24d9948ddb
commit
20a9f76c8d
1 changed files with 26 additions and 23 deletions
|
@ -68,29 +68,6 @@ defmodule Ash.Engine do
|
||||||
authorize? = opts[:authorize?]
|
authorize? = opts[:authorize?]
|
||||||
actor = opts[:actor]
|
actor = opts[:actor]
|
||||||
|
|
||||||
if opts[:timeout] && is_integer(opts[:timeout]) do
|
|
||||||
parent = self()
|
|
||||||
|
|
||||||
Task.start_link(fn ->
|
|
||||||
ref = Process.monitor(parent)
|
|
||||||
timeout = opts[:timeout]
|
|
||||||
|
|
||||||
receive do
|
|
||||||
{:DOWN, ^ref, _, ^parent, _} ->
|
|
||||||
:ok
|
|
||||||
after
|
|
||||||
timeout ->
|
|
||||||
Logger.error("""
|
|
||||||
Engine timed out processing requests.
|
|
||||||
|
|
||||||
#{Enum.map_join(requests, "\n", &summarize(&1))}
|
|
||||||
""")
|
|
||||||
|
|
||||||
exit(:timeout)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
opts = Keyword.put(opts, :callers, [self() | Process.get(:"$callers", [])])
|
opts = Keyword.put(opts, :callers, [self() | Process.get(:"$callers", [])])
|
||||||
|
|
||||||
# If the requests are invalid, this is a framework level error
|
# If the requests are invalid, this is a framework level error
|
||||||
|
@ -249,6 +226,32 @@ defmodule Ash.Engine do
|
||||||
def init(opts) do
|
def init(opts) do
|
||||||
Process.put(:"$callers", opts[:callers])
|
Process.put(:"$callers", opts[:callers])
|
||||||
|
|
||||||
|
if opts[:timeout] && is_integer(opts[:timeout]) do
|
||||||
|
parent = self()
|
||||||
|
|
||||||
|
Task.start_link(fn ->
|
||||||
|
ref = Process.monitor(parent)
|
||||||
|
timeout = opts[:timeout]
|
||||||
|
|
||||||
|
receive do
|
||||||
|
{:DOWN, ^ref, _, ^parent, _} ->
|
||||||
|
:ok
|
||||||
|
|
||||||
|
other ->
|
||||||
|
IO.inspect(other, label: "GOT THING")
|
||||||
|
after
|
||||||
|
timeout ->
|
||||||
|
Logger.error("""
|
||||||
|
Engine timed out processing requests.
|
||||||
|
|
||||||
|
#{Enum.map_join(opts[:requests], "\n", &summarize(&1))}
|
||||||
|
""")
|
||||||
|
|
||||||
|
exit(:timeout)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
state =
|
state =
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
requests: opts[:requests],
|
requests: opts[:requests],
|
||||||
|
|
Loading…
Reference in a new issue