mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-17 21:57:17 +00:00
update(userspace/falco/grpc): bidirectional sub implementation
Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com> Signed-off-by: Lorenzo Fontana <lo@linux.com>
This commit is contained in:
parent
0d194f2b40
commit
b9e6d65e69
@ -31,53 +31,37 @@ bool falco::grpc::server_impl::is_running()
|
|||||||
|
|
||||||
void falco::grpc::server_impl::get(const stream_context& ctx, const output::request& req, output::response& res)
|
void falco::grpc::server_impl::get(const stream_context& ctx, const output::request& req, output::response& res)
|
||||||
{
|
{
|
||||||
falco_logger::log(LOG_INFO, "get\n");
|
|
||||||
if(ctx.m_status == stream_context::SUCCESS || ctx.m_status == stream_context::ERROR)
|
if(ctx.m_status == stream_context::SUCCESS || ctx.m_status == stream_context::ERROR)
|
||||||
{
|
{
|
||||||
// todo(leodido) > log "status=ctx->m_status, stream=ctx->m_stream"
|
// todo(leodido) > log "status=ctx->m_status, stream=ctx->m_stream"
|
||||||
ctx.m_stream = nullptr;
|
ctx.m_stream = nullptr;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Start or continue streaming
|
|
||||||
// m_status == stream_context::STREAMING?
|
|
||||||
// todo(leodido) > set m_stream
|
|
||||||
falco_logger::log(LOG_INFO, "get - else\n");
|
|
||||||
|
|
||||||
ctx.m_has_more = output::queue::get().unsafe_size() > 1;
|
ctx.m_is_running = is_running();
|
||||||
output::queue::get().try_pop(res);
|
|
||||||
}
|
// Start or continue streaming
|
||||||
|
// m_status == stream_context::STREAMING?
|
||||||
|
// todo(leodido) > set m_stream
|
||||||
|
|
||||||
|
ctx.m_has_more = output::queue::get().try_pop(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
void falco::grpc::server_impl::sub(const bidi_context& ctx, const output::request& req, output::response& res)
|
void falco::grpc::server_impl::sub(const bidi_context& ctx, const output::request& req, output::response& res)
|
||||||
{
|
{
|
||||||
if(ctx.m_status == stream_context::SUCCESS || ctx.m_status == stream_context::ERROR)
|
if(ctx.m_status == stream_context::SUCCESS || ctx.m_status == stream_context::ERROR)
|
||||||
{
|
{
|
||||||
|
ctx.m_stream = nullptr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
falco_logger::log(LOG_INFO, "SUB\n");
|
ctx.m_is_running = is_running();
|
||||||
ctx.m_has_more = output::queue::get().unsafe_size() > 0;
|
|
||||||
|
|
||||||
if(ctx.m_has_more)
|
// Start or continue streaming
|
||||||
{
|
// m_status == stream_context::STREAMING?
|
||||||
falco_logger::log(LOG_INFO, "SUB - HAS MORE? TRUE\n");
|
// todo(leodido) > set m_stream
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
falco_logger::log(LOG_INFO, "SUB - HAS MORE? FALSE\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(output::queue::get().try_pop(res))
|
ctx.m_has_more = output::queue::get().try_pop(res);
|
||||||
{
|
|
||||||
falco_logger::log(LOG_INFO, "SUB - WAIT WRITE DONE: TRUE\n");
|
|
||||||
ctx.m_wait_write_done = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
falco_logger::log(LOG_INFO, "SUB - WAIT WRITE DONE: FALSE\n");
|
|
||||||
ctx.m_wait_write_done = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void falco::grpc::server_impl::version(const context& ctx, const version::request&, version::response& res)
|
void falco::grpc::server_impl::version(const context& ctx, const version::request&, version::response& res)
|
||||||
|
Loading…
Reference in New Issue
Block a user