summaryrefslogtreecommitdiffstats
path: root/nserver/src/protocol.c
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2019-11-02 11:59:56 -0400
committerrsiddharth <s@ricketyspace.net>2020-04-17 20:56:34 -0400
commita485240c332beba45ee67454432fcc55ef9669b9 (patch)
tree6cbeedfd0cf8cb5df7165b1447db78c5adabee9d /nserver/src/protocol.c
parent1edf1d1f7f86301f5c37857cd2c521e0e1522e6e (diff)
nserver: protocol: Define ssdump.
* nserver/src/protocol.c (ssdump): New function. * nserver/tests/protocol_tests.c (test_ssdump): New test. (all_tests): Add test_ssdump.
Diffstat (limited to 'nserver/src/protocol.c')
-rw-r--r--nserver/src/protocol.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c
index adcfc21..bb23b92 100644
--- a/nserver/src/protocol.c
+++ b/nserver/src/protocol.c
@@ -103,3 +103,22 @@ double ssmean(char *key)
return -1;
}
+char *ssdump(char *key)
+{
+ check(hash != NULL, "hash not initialized");
+
+ // 1. create bstring from 'key'.
+ bstring k = bfromcstr(key);
+
+ // 2. try to get Stats for key.
+ Stats *st = (Stats *) Hashmap_get(hash, k);
+ check(st != NULL, "stats not found for key");
+
+ // 3. get dump.
+ char *dstr = Stats_dump(st);
+ check(dstr != NULL, "dump failed for key");
+
+ return dstr;
+ error:
+ return NULL;
+}