feat(replication): Use a ring buffer with messages to serve replication. (#1835)

* feat(replication): Use a ring buffer with messages to serve replication.

* Fix libraries dep graph

* Address PR feedback

* nits

* add a comment

* Lower the default log length
This commit is contained in:
Roy Jacobson 2023-09-18 13:59:41 +03:00 committed by GitHub
parent 1e61ec8114
commit db21b735f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 127 additions and 65 deletions

View file

@ -10,12 +10,12 @@ using namespace util;
void JournalStreamer::Start(io::Sink* dest) {
using namespace journal;
write_fb_ = fb2::Fiber("journal_stream", &JournalStreamer::WriterFb, this, dest);
journal_cb_id_ = journal_->RegisterOnChange([this](const Entry& entry, bool allow_await) {
if (entry.opcode == Op::NOOP) {
// No recode to write, just await if data was written so consumer will read the data.
journal_cb_id_ = journal_->RegisterOnChange([this](const JournalItem& item, bool allow_await) {
if (item.opcode == Op::NOOP) {
// No record to write, just await if data was written so consumer will read the data.
return AwaitIfWritten();
}
writer_.Write(entry);
Write(io::Buffer(item.data));
NotifyWritten(allow_await);
});
}