new(userspace/falco): handle subscribe events as streams based on keepalive

Co-Authored-By: Leonardo Di Donato <leodidonato@gmail.com>
Signed-off-by: Lorenzo Fontana <lo@linux.com>
This commit is contained in:
Lorenzo Fontana 2019-09-05 13:43:25 +02:00 committed by Leo Di Donato
parent fcc7fad0e7
commit 5abb26e764

View File

@ -117,14 +117,16 @@ void falco_grpc_server_impl::subscribe(const stream_context& ctx, const falco_ou
{
// Start (or continue) streaming
// ctx.m_status == stream_context::STREAMING
// todo > do we want batching?
dequeue:
if(!m_event_queue.try_pop(res))
if(m_event_queue.try_pop(res) && !req.keepalive())
{
// TODO: backoff mechanism that does has more false
goto dequeue;
ctx.m_has_more = true;
return;
}
ctx.m_has_more = true;
while(!m_event_queue.try_pop(res) && req.keepalive())
{
}
ctx.m_has_more = req.keepalive();
}
}