new(userspace/falco): gRPC unary version service impl

Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
Leonardo Di Donato 2019-10-04 10:26:01 +00:00 committed by poiana
parent 550ee0d8fc
commit 714a6619ad
3 changed files with 15 additions and 0 deletions

View File

@ -62,5 +62,6 @@ public:
mutable void* m_stream = nullptr; // todo(fntlnz, leodido) > useful in the future
mutable bool m_has_more = false;
};
} // namespace grpc
} // namespace falco

View File

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#include "config_falco.h"
#include "grpc_server_impl.h"
#include "falco_output_queue.h"
#include "banned.h"
@ -49,6 +50,16 @@ void falco::grpc::server_impl::subscribe(const stream_context& ctx, const output
}
}
void falco::grpc::server_impl::version(const context& ctx, const version::request&, version::response& res)
{
res.set_version(FALCO_VERSION);
res.set_major(std::stoi(FALCO_VERSION_MAJOR));
res.set_minor(std::stoi(FALCO_VERSION_MINOR));
res.set_patch(std::stoi(FALCO_VERSION_PATCH));
res.set_prerelease(FALCO_VERSION_PRERELEASE);
res.set_build(FALCO_VERSION_BUILD);
}
void falco::grpc::server_impl::shutdown()
{
m_stop = true;

View File

@ -18,6 +18,7 @@ limitations under the License.
#include <atomic>
#include "output.grpc.pb.h"
#include "version.grpc.pb.h"
#include "grpc_context.h"
namespace falco
@ -37,6 +38,8 @@ protected:
void subscribe(const stream_context& ctx, const output::request& req, output::response& res);
void version(const context& ctx, const version::request& req, version::response& res);
private:
std::atomic<bool> m_stop{false};
};