Skip to content
Open
Changes from 1 commit
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
28 changes: 19 additions & 9 deletions lib/flame/pool.ex
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ defmodule FLAME.Pool do
{:noreply, handle_runner_async_up(state, pid, ref)}
end

def handle_info({ref, {:error, reason}}, %Pool{} = state) when is_reference(ref) do
{:stop, reason, state}
end

def handle_info(:async_boot_continue, %Pool{} = state) do
{:noreply, async_boot_runner(%Pool{state | async_boot_timer: nil})}
end
Expand Down Expand Up @@ -652,7 +656,10 @@ defmodule FLAME.Pool do
{_runner, new_acc} = put_runner(acc, pid)
new_acc

{:exit, reason}, _acc ->
{:ok, {:error, reason}}, _acc ->
raise "failed to boot runner: #{inspect(reason)}"

{:ok, {:exit, reason}}, _acc ->
raise "failed to boot runner: #{inspect(reason)}"
end)
else
Expand Down Expand Up @@ -693,16 +700,19 @@ defmodule FLAME.Pool do
restart: :temporary
}

{:ok, pid} = DynamicSupervisor.start_child(state.runner_sup, spec)
with {:start, {:ok, pid}} <- {:start, DynamicSupervisor.start_child(state.runner_sup, spec)},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use nested cases if you want to distinguish on the output type. Thank you.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, updated.

{:remote_boot, :ok} <- {:remote_boot, Runner.remote_boot(pid, state.base_sync_stream)} do
{:ok, pid}
else
{:start, {:error, reason}} ->
{:error, {:start_error, reason}}

try do
case Runner.remote_boot(pid, state.base_sync_stream) do
:ok -> {:ok, pid}
{:error, reason} -> {:error, reason}
end
catch
{:exit, reason} -> {:error, {:exit, reason}}
{:remote_boot, {:error, reason}} ->
{:error, {:remote_boot_error, reason}}
end
catch
:exit, reason ->
{:error, {:exit, reason}}
end

defp put_runner(%Pool{} = state, pid) when is_pid(pid) do
Expand Down