X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgrpc.cc;h=19917ec6fafd716920d387981d5dba33a6f1df9d;hb=c7c89cc9618ef25cc9b0861ac2782cb1a5d6782d;hp=8b76954d6748090a795d2eaf09fcfe7a8110f7c0;hpb=3d74a63ae43c1786eb9b966e2209c24c5643dae8;p=collectd.git diff --git a/src/grpc.cc b/src/grpc.cc index 8b76954d..19917ec6 100644 --- a/src/grpc.cc +++ b/src/grpc.cc @@ -1,6 +1,7 @@ /** * collectd - src/grpc.cc * Copyright (C) 2015-2016 Sebastian Harl + * Copyright (C) 2016 Florian octo Forster * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,6 +23,7 @@ * * Authors: * Sebastian Harl + * Florian octo Forster **/ #include @@ -47,8 +49,8 @@ extern "C" { using collectd::Collectd; -using collectd::DispatchValuesRequest; -using collectd::DispatchValuesResponse; +using collectd::PutValuesRequest; +using collectd::PutValuesResponse; using collectd::QueryValuesRequest; using collectd::QueryValuesResponse; @@ -283,13 +285,13 @@ public: return status; } - grpc::Status DispatchValues(grpc::ServerContext *ctx, - grpc::ServerReader *reader, - DispatchValuesResponse *res) override { - DispatchValuesRequest req; + grpc::Status PutValues(grpc::ServerContext *ctx, + grpc::ServerReader *reader, + PutValuesResponse *res) override { + PutValuesRequest req; while (reader->Read(&req)) { - value_list_t vl = VALUE_LIST_INIT; + value_list_t vl = {0}; auto status = unmarshal_value_list(req.value_list(), &vl); if (!status.ok()) return status; @@ -426,18 +428,18 @@ public: CollectdClient(std::shared_ptr channel) : stub_(Collectd::NewStub(channel)) { } - int DispatchValues(value_list_t const *vl) { + int PutValues(value_list_t const *vl) { grpc::ClientContext ctx; - DispatchValuesRequest req; + PutValuesRequest req; auto status = marshal_value_list(vl, req.mutable_value_list()); if (!status.ok()) { ERROR("grpc: Marshalling value_list_t failed."); return -1; } - DispatchValuesResponse res; - auto stream = stub_->DispatchValues(&ctx, &res); + PutValuesResponse res; + auto stream = stub_->PutValues(&ctx, &res); if (!stream->Write(req)) { NOTICE("grpc: Broken stream."); /* intentionally not returning. */ @@ -451,7 +453,7 @@ public: } return 0; - } /* int DispatchValues */ + } /* int PutValues */ private: std::unique_ptr stub_; @@ -471,7 +473,7 @@ extern "C" { value_list_t const *vl, user_data_t *ud) { CollectdClient *c = (CollectdClient *) ud->data; - return c->DispatchValues(vl); + return c->PutValues(vl); } static int c_grpc_config_listen(oconfig_item_t *ci) @@ -674,5 +676,3 @@ extern "C" { plugin_register_shutdown("grpc", c_grpc_shutdown); } /* module_register() */ } /* extern "C" */ - -/* vim: set sw=4 ts=4 tw=78 noexpandtab : */