diff options
author | kballou <kballou@devnulllabs.io> | 2014-10-21 18:09:01 -0600 |
---|---|---|
committer | kballou <kballou@devnulllabs.io> | 2014-10-21 18:11:55 -0600 |
commit | 7b08fdedc3a6bae0b9c7f45a4d2ec6fca3371ea0 (patch) | |
tree | 682ef78bb77ffabb497ae71adefb4555a634d9e6 | |
parent | 76bf4cd450826b2f581a839889588ceeb2dd417d (diff) | |
download | poolparty-7b08fdedc3a6bae0b9c7f45a4d2ec6fca3371ea0.tar.gz poolparty-7b08fdedc3a6bae0b9c7f45a4d2ec6fca3371ea0.tar.xz |
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)
-rw-r--r-- | lib/poolparty/scheduler.ex | 10 |
1 files changed, 9 insertions, 1 deletions
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 |