summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 135992e)
raw | patch | inline | side by side (parent: 135992e)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 1 Jul 2014 19:59:29 +0000 (21:59 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 1 Jul 2014 19:59:29 +0000 (21:59 +0200) |
src/core/store.c | patch | blob | history | |
t/unit/core/store_test.c | patch | blob | history |
diff --git a/src/core/store.c b/src/core/store.c
index 125009cd574b355625960a53f4eeb995ad7575dc..d185431f976de168213aa769ceee8bd2a7f16482 100644 (file)
--- a/src/core/store.c
+++ b/src/core/store.c
{
char time_str[64];
char interval_str[64];
+ size_t i;
if (! sdb_strftime(time_str, sizeof(time_str),
"%F %T %z", obj->last_update))
interval_str[sizeof(interval_str) - 1] = '\0';
sdb_strbuf_append(buf, "\"last_update\": \"%s\", "
- "\"update_interval\": \"%s\"", time_str, interval_str);
+ "\"update_interval\": \"%s\", \"backends\": [",
+ time_str, interval_str);
+
+ for (i = 0; i < obj->backends_num; ++i) {
+ sdb_strbuf_append(buf, "\"%s\"", obj->backends[i]);
+ if (i < obj->backends_num - 1)
+ sdb_strbuf_append(buf, ",");
+ }
+ sdb_strbuf_append(buf, "]");
} /* store_common_tojson */
/*
index cca3968c4674df076a948d641a71d211c1257e3d..4e40743d85ce60b28dcb965ac770b72935285927 100644 (file)
--- a/t/unit/core/store_test.c
+++ b/t/unit/core/store_test.c
} golden_data[] = {
{ 0, "{\"hosts\":["
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"{\"name\": \"k1\", \"value\": \"v1\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": \"v2\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": \"v3\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"}"
+ "\"update_interval\": \"0s\", \"backends\": []}"
"], "
"\"services\": []},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": [], "
"\"services\": ["
"{\"name\": \"s1\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"s2\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"}"
+ "\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}" },
{ SDB_SKIP_SERVICES,
"{\"hosts\":["
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"{\"name\": \"k1\", \"value\": \"v1\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": \"v2\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": \"v3\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"}"
+ "\"update_interval\": \"0s\", \"backends\": []}"
"]},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": []}"
"]}" },
{ SDB_SKIP_ATTRIBUTES,
"{\"hosts\":["
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": []},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s1\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"s2\", "
"\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"}"
+ "\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}" },
{ SDB_SKIP_SERVICES | SDB_SKIP_ATTRIBUTES,
"{\"hosts\":["
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"},"
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\"}"
+ "\"update_interval\": \"0s\", \"backends\": []}"
"]}" },
};