36 InEC(sys::fs::openFileForRead(InboundName, Inbound)) {
39 int max_retries = 30, attempts = 0;
40 double wait_seconds = 0.2, backoff_exp = 1.2;
42 while (attempts < max_retries) {
46 std::cout <<
"Cannot open inbound file retrying! attempt: " << attempts
48 std::this_thread::sleep_for(
49 std::chrono::duration<double>(wait_seconds));
50 wait_seconds *= backoff_exp;
56 auto message =
"Cannot open inbound file: " +
InEC.message();
58 this->Ctx->emitError(message);
60 std::cerr << message << std::endl;
67 auto message =
"Cannot open outbound file: " +
OutEC.message();
69 this->Ctx->emitError(message);
71 std::cerr << message << std::endl;
86 std::string OutputBuffer(N,
'\0');
87 char *Buff = OutputBuffer.data();
89 const size_t Limit = N;
90 while (InsPoint < Limit) {
91 auto ReadOrErr = ::sys::fs::readNativeFile(
92 sys::fs::convertFDToNativeFile(
Inbound),
93 {Buff + InsPoint, OutputBuffer.size() - InsPoint});
94 if (ReadOrErr.takeError()) {
96 this->
Ctx->emitError(
"Failed reading from inbound file");
98 std::cerr <<
"Failed reading from inbound file" << std::endl;
101 InsPoint += *ReadOrErr;