MT#21751 recentcalls rename set_by_uuid to set_by_key

* rename set_by_uuid to set_by_key as key can be anything now
    * save uuid as an additional parameter inside the key entry

Change-Id: Ic63e11855d96931b2676b991d012197c35d8ca2f
changes/28/8728/1
Kirill Solomko 9 years ago
parent 7150ee8aa5
commit 2d34ec7969

@ -68,24 +68,27 @@ end
return client return client
end end
function NGCPRecentCalls:set_by_uuid(uuid, callid, start_time, function NGCPRecentCalls:set_by_key(key,
callid, uuid, start_time,
duration, caller, callee, duration, caller, callee,
source) source)
if not self._test_connection(self.central) then if not self._test_connection(self.central) then
self.central = self._connect(self.config.central) self.central = self._connect(self.config.central)
end end
local res = self.central:hmset(uuid, "callid", callid, local res = self.central:hmset(key,
"callid", callid,
"uuid", uuid,
"start_time", start_time, "start_time", start_time,
"duration", duration, "duration", duration,
"caller", caller, "caller", caller,
"callee", callee, "callee", callee,
"source", source) "source", source)
if res then if res then
self.central:expire(uuid, self.config.expire) self.central:expire(key, self.config.expire)
end end
sr.log("info", string.format("central:hset[%s]=>[%s] callid: %s start_time: %s duration: %d caller: %s callee: %s source: %s expire: %d\n", sr.log("info", string.format("central:hset[%s]=>[%s] callid: %s uuid: %s start_time: %s duration: %d caller: %s callee: %s source: %s expire: %d\n",
uuid, tostring(res), key, tostring(res),
callid, callid, uuid,
start_time, duration, start_time, duration,
caller, callee, caller, callee,
source, source,

@ -67,9 +67,10 @@ TestNGCPRecentCalls = {} --class
assertIs(prev, self.central) assertIs(prev, self.central)
end end
function TestNGCPRecentCalls:test_set_by_uuid() function TestNGCPRecentCalls:test_set_by_key()
local ttl = 7200 local ttl = 7200
local key = "431110001"
local uuid = "9bcb88b6-541a-43da-8fdc-816f5557ff93" local uuid = "9bcb88b6-541a-43da-8fdc-816f5557ff93"
local callid = "12345-67890" local callid = "12345-67890"
local start_time = "1439911398" local start_time = "1439911398"
@ -79,7 +80,8 @@ TestNGCPRecentCalls = {} --class
local source = "SIPWISE_1" local source = "SIPWISE_1"
self.central:ping() ;mc :returns(true) self.central:ping() ;mc :returns(true)
self.central:hmset(uuid, "callid", callid, self.central:hmset(key, "callid", callid,
"uuid", uuid,
"start_time", start_time, "start_time", start_time,
"duration", duration, "duration", duration,
"caller", caller, "caller", caller,
@ -88,7 +90,8 @@ TestNGCPRecentCalls = {} --class
self.central:expire(uuid, ttl) ;mc :returns(1) self.central:expire(uuid, ttl) ;mc :returns(1)
mc:replay() mc:replay()
local res = self.rcalls:set_by_uuid(uuid, callid, local res = self.rcalls:set_by_key(key,
callid, uuid,
start_time, duration, start_time, duration,
caller, callee, caller, callee,
source) source)

Loading…
Cancel
Save