From 4c2311f2c3484ac25262556f9679c6c19e641eaf Mon Sep 17 00:00:00 2001
From: Sergey V <sv@picodata.io>
Date: Wed, 13 Apr 2022 15:00:48 +0300
Subject: [PATCH] chore: use tarantool::proc macro inside
 main::declare_stored_c_funcs macro

---
 src/main.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 96d0e8880f..7967c716e2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -203,7 +203,7 @@ macro_rules! declare_stored_c_funcs {
         // This is needed to tell the compiler that the functions are really used.
         // Otherwise the functions get optimized out and disappear from the binary
         // and we may get this error: dlsym(RTLD_DEFAULT, some_fn): symbol not found
-        fn used(_: extern "C" fn(FunctionCtx, FunctionArgs) -> c_int) {}
+        fn used(_: unsafe extern "C" fn(FunctionCtx, FunctionArgs) -> c_int) {}
 
         $(used($func_name);
             crate::tarantool::eval(concat!(
@@ -219,6 +219,7 @@ macro_rules! declare_stored_c_funcs {
 fn init_handlers() {
     declare_stored_c_funcs!(
         //
+        raft_interact,
         discover,
     );
 }
@@ -400,11 +401,12 @@ fn tarantool(args: args::Tarantool) -> Result<(), String> {
     tarantool_main!(args.tt_args()?)
 }
 
-#[no_mangle]
-pub extern "C" fn discover(ctx: FunctionCtx, args: FunctionArgs) -> c_int {
-    let (request, addr): (discovery::Request, discovery::Address) = args.as_struct().unwrap();
-    ctx.return_mp(&discovery::handle_request(request, &addr))
-        .unwrap()
+#[proc]
+fn discover(
+    request: discovery::Request,
+    address: discovery::Address,
+) -> proc::ReturnMsgpack<discovery::Response> {
+    proc::ReturnMsgpack(discovery::handle_request(request, &address))
 }
 
 fn test(args: args::Test) -> Result<(), String> {
-- 
GitLab