From 7b08fdedc3a6bae0b9c7f45a4d2ec6fca3371ea0 Mon Sep 17 00:00:00 2001 From: kballou Date: Tue, 21 Oct 2014 18:09:01 -0600 Subject: Add extra handling for worker departure * Remove worker form worker list _and_ processing list * If there was pending work in the processing list, send the waiting client a message about the failure (later improvement to send _more_ information about the failure) --- lib/poolparty/scheduler.ex | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/poolparty/scheduler.ex b/lib/poolparty/scheduler.ex index dc4d731..988ee50 100644 --- a/lib/poolparty/scheduler.ex +++ b/lib/poolparty/scheduler.ex @@ -68,7 +68,15 @@ defmodule PoolParty.Scheduler do def handle_cast({:leave, pid}, state) do Logger.debug("[#{__MODULE__}]: Worker left pool") GenEvent.notify(state.events, {:worker_leaving, pid}) - {:noreply, %{state| workers: state.workers -- [pid]}} + processing = case HashDict.pop(state.processing, pid) do + {nil, processing} -> + processing + {client, processing} -> + send(client, {:result, :failed}) + processing + end + {:noreply, %{state| workers: state.workers -- [pid], + processing: processing}} end def handle_cast({:ready, result, pid}, state) do -- cgit v1.2.1