summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9d6e008)
raw | patch | inline | side by side (parent: 9d6e008)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 6 May 2016 22:09:45 +0000 (00:09 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 30 May 2016 21:44:19 +0000 (23:44 +0200) |
proto/types.proto | patch | blob | history | |
src/grpc.cc | patch | blob | history |
diff --git a/proto/types.proto b/proto/types.proto
index 7f3d329d4f63404d3c28cd0a0043a82253006708..6e6714b6ce8aec1dd1a7c29ab81607b0841322a6 100644 (file)
--- a/proto/types.proto
+++ b/proto/types.proto
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
+message Identifier {
+ string host = 1;
+ string plugin = 2;
+ string plugin_instance = 3;
+ string type = 4;
+ string type_instance = 5;
+}
+
message Value {
oneof value {
uint64 counter = 1;
google.protobuf.Timestamp time = 2;
google.protobuf.Duration interval = 3;
- string host = 4;
- string plugin = 5;
- string plugin_instance = 6;
- string type = 7;
- string type_instance = 8;
+ Identifier identifier = 4;
}
diff --git a/src/grpc.cc b/src/grpc.cc
index a82c1ec462e219c0ac67259d7f5838687bdf1b6b..45fb02902ad0434a1c4487741fe3d7f3e766208d 100644 (file)
--- a/src/grpc.cc
+++ b/src/grpc.cc
* proto conversion
*/
-static grpc::Status unmarshal_value_list(const collectd::types::ValueList &msg, value_list_t *vl)
+static grpc::Status unmarshal_ident(const collectd::types::Identifier &msg, value_list_t *vl)
{
- vl->time = NS_TO_CDTIME_T(TimeUtil::TimestampToNanoseconds(msg.time()));
- vl->interval = NS_TO_CDTIME_T(TimeUtil::DurationToNanoseconds(msg.interval()));
-
std::string s;
s = msg.host();
s = msg.type_instance();
sstrncpy(vl->type_instance, s.c_str(), sizeof(vl->type_instance));
+ return grpc::Status::OK;
+} /* unmarshal_ident() */
+
+static grpc::Status unmarshal_value_list(const collectd::types::ValueList &msg, value_list_t *vl)
+{
+ vl->time = NS_TO_CDTIME_T(TimeUtil::TimestampToNanoseconds(msg.time()));
+ vl->interval = NS_TO_CDTIME_T(TimeUtil::DurationToNanoseconds(msg.interval()));
+
+ auto status = unmarshal_ident(msg.identifier(), vl);
+ if (!status.ok())
+ return status;
+
value_t *values = NULL;
size_t values_len = 0;
- auto status = grpc::Status::OK;
+ status = grpc::Status::OK;
for (auto v : msg.value()) {
value_t *val = (value_t *)realloc(values, (values_len + 1) * sizeof(*values));