mirror of
https://github.com/falcosecurity/falco.git
synced 2025-08-16 13:17:04 +00:00
new(userspace/falco): macro to REGISTER_BIDI gRPC services
Co-authored-by: Lorenzo Fontana <lo@linux.com> Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
parent
58adc5b60c
commit
a72f27c028
@ -44,6 +44,15 @@ limitations under the License.
|
|||||||
c.start(this); \
|
c.start(this); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define REGISTER_BIDI(req, res, svc, rpc, impl, num) \
|
||||||
|
std::vector<request_bidi_context<svc, req, res>> rpc##_contexts(num); \
|
||||||
|
for(request_bidi_context<svc, req, res> & c : rpc##_contexts) \
|
||||||
|
{ \
|
||||||
|
c.m_process_func = &server::impl; \
|
||||||
|
c.m_request_func = &svc::AsyncService::Request##rpc; \
|
||||||
|
c.start(this); \
|
||||||
|
}
|
||||||
|
|
||||||
static void gpr_log_dispatcher_func(gpr_log_func_args* args)
|
static void gpr_log_dispatcher_func(gpr_log_func_args* args)
|
||||||
{
|
{
|
||||||
int priority;
|
int priority;
|
||||||
@ -199,7 +208,8 @@ void falco::grpc::server::run()
|
|||||||
// todo(leodido) > take a look at thread_stress_test.cc into grpc repository
|
// todo(leodido) > take a look at thread_stress_test.cc into grpc repository
|
||||||
|
|
||||||
REGISTER_UNARY(version::request, version::response, version::service, version, version, context_num)
|
REGISTER_UNARY(version::request, version::response, version::service, version, version, context_num)
|
||||||
REGISTER_STREAM(output::request, output::response, output::service, subscribe, subscribe, context_num)
|
REGISTER_STREAM(output::request, output::response, output::service, get, get, context_num)
|
||||||
|
REGISTER_BIDI(output::request, output::response, output::service, sub, sub, context_num)
|
||||||
|
|
||||||
m_threads.resize(m_threadiness);
|
m_threads.resize(m_threadiness);
|
||||||
int thread_idx = 0;
|
int thread_idx = 0;
|
||||||
@ -211,7 +221,7 @@ void falco::grpc::server::run()
|
|||||||
|
|
||||||
while(server_impl::is_running())
|
while(server_impl::is_running())
|
||||||
{
|
{
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
}
|
}
|
||||||
// todo(leodido) > log "stopping gRPC server"
|
// todo(leodido) > log "stopping gRPC server"
|
||||||
stop();
|
stop();
|
||||||
|
Loading…
Reference in New Issue
Block a user