From af1071509d31f75ddb7633e169260bc1ce2794b6 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 16 Apr 2020 11:37:40 -0500 Subject: [PATCH] handle callee index somehow getting turned into multiple items in list --- lib/router/realms/session.ex | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/router/realms/session.ex b/lib/router/realms/session.ex index f2ecda0..22636bf 100644 --- a/lib/router/realms/session.ex +++ b/lib/router/realms/session.ex @@ -25,12 +25,26 @@ defmodule Wampex.Router.Realms.Session do {_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 -- 2.45.3