{_key, callees} ->
Logger.info("Got Callees: #{inspect(callees)}")
- {_key, [callee_index]} = ClusterKV.get(db, realm, "#{procedure}:callee_index")
+ callee_index = get_index(db, realm, procedure)
Logger.info("Got Index: #{callee_index}")
{callees, callee_index}
end
end
+ def get_index(db, realm, proc) do
+ case ClusterKV.get(db, realm, "#{proc}:callee_index") do
+ {_key, [callee_index]} ->
+ callee_index
+
+ {_key, [_ | t]} ->
+ Logger.info("Got list of indexes... #{inspect(t)}")
+ get_last_index(t)
+ end
+ end
+
+ def get_last_index([i]), do: i
+ def get_last_index([_ | t]), do: get_last_index(t)
+
def round_robin(db, realm, procedure, len) do
ClusterKV.update(db, realm, "#{procedure}:callee_index", len, &update_round_robin/2)
end