Page MenuHomePhabricator

[services] Backup - Rust lib - Add terminate
ClosedPublic

Authored by karol on Aug 18 2022, 4:31 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Jun 18, 5:45 PM
Unknown Object (File)
Thu, Jun 13, 4:42 PM
Unknown Object (File)
Sun, May 26, 7:53 PM
Unknown Object (File)
Sun, May 26, 7:53 PM
Unknown Object (File)
Sun, May 26, 7:53 PM
Unknown Object (File)
Sun, May 26, 7:52 PM
Unknown Object (File)
Sun, May 26, 7:49 PM
Unknown Object (File)
May 4 2024, 8:49 PM

Details

Summary

Depends on D4869

Adding terminating function in rust to be called from the c++.

The goal here is to:

  • spawn a thread in rust that will listen on a thread-safe queue (initialize)
  • schedule some data on this queue (process)
  • gracefully exit the thread and release all resources (terminate)

Later on, in the spawned thread, we will connect to the blob service through the gRPC, but first things first.

I'm probably going to remove all logging before landing, I'm leaving it as is for now.

Test Plan

In the c++ code:

#include "rust_lib/src/lib.rs.h"
// ...
extern "C" {
void rust_initialize();
void rust_process(const char *data);
void rust_terminate();
}
// ...
std::cout << "CALLING RUST CODE" << std::endl;
rust_initialize();
rust_process("aaa");
rust_process("bbbbb");
rust_process("cccccccccc");
rust_terminate();
std::cout << "CALLED RUST CODE" << std::endl;

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Aug 18 2022, 4:33 AM
Harbormaster failed remote builds in B11438: Diff 15733!
karol edited the test plan for this revision. (Show Details)
karol added reviewers: tomek, varun, max.
karol edited the summary of this revision. (Show Details)

Requesting review for the same reason as in https://phab.comm.dev/D4861#140658

tomek added 1 blocking reviewer(s): varun.
This revision is now accepted and ready to land.Aug 25 2022, 5:05 AM

We should plan to remove the unwrap and expect's as a later improvement to this library. An extern "Rust" function returning a Result turns into a throw in C++ if the Rust side produces an error.

@karol, I wish you would've created a task as requested... ended up falling on me. I went ahead and created a task: https://linear.app/comm/issue/ENG-1806/get-rid-of-unwrap-calls-in-servicesbackupblob-client