Skip to content

Commit

Permalink
ISSUE-94: loadCommandEventsList add commitindex pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
DongbinCheng committed Oct 11, 2023
1 parent 5277c85 commit 3227604
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/infra/es/ReadonlyCommandEventStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ class ReadonlyCommandEventStore {
const EventDecoder &eventDecoder,
Id commandId,
uint64_t size,
CommandEventsList *bundles) = 0;
CommandEventsList *bundles,
uint64_t *pCommitIndex = nullptr) = 0;

/**
* wait till leader is ready for expected term or step down,
Expand Down
3 changes: 2 additions & 1 deletion src/infra/es/store/ReadonlyDefaultCommandEventStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class ReadonlyDefaultCommandEventStore : public ReadonlyCommandEventStore {
const EventDecoder &,
Id,
uint64_t,
CommandEventsList *) override {
CommandEventsList *,
uint64_t *pCommitIndex) override {
SPDLOG_WARN("dummy method, always return empty. Please use other store.");
return 0;
}
Expand Down
6 changes: 5 additions & 1 deletion src/infra/es/store/ReadonlyRaftCommandEventStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ ReadonlyRaftCommandEventStore::loadCommandEventsList(const CommandDecoder &,
const EventDecoder &,
Id commandId,
uint64_t size,
CommandEventsList *bundles) {
CommandEventsList *bundles,
uint64_t *pCommitIndex) {
auto commitIndex = mRaftImpl->getCommitIndex();
if (pCommitIndex != nullptr) {
*pCommitIndex = commitIndex;
}

if (commandId <= 0 || commandId > commitIndex) {
return 0;
Expand Down
3 changes: 2 additions & 1 deletion src/infra/es/store/ReadonlyRaftCommandEventStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ class ReadonlyRaftCommandEventStore final : public ReadonlyCommandEventStore {
const EventDecoder &,
Id,
uint64_t,
CommandEventsList *) override;
CommandEventsList *,
uint64_t *pCommitIndex = nullptr) override;

/**
* wait until leader is ready for expected term or step down.
Expand Down
3 changes: 2 additions & 1 deletion src/infra/es/store/ReadonlySQLiteCommandEventStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ ReadonlySQLiteCommandEventStore::loadNextCommandEvents(const CommandDecoder &com
uint64_t
ReadonlySQLiteCommandEventStore::loadCommandEventsList(const gringofts::CommandDecoder &,
const gringofts::EventDecoder &,
Id, uint64_t, CommandEventsList *) {
Id, uint64_t, CommandEventsList *,
uint64_t *pCommitIndex) {
throw std::runtime_error("SQLite does not support loadCommandEventsList()");
}

Expand Down
3 changes: 2 additions & 1 deletion src/infra/es/store/ReadonlySQLiteCommandEventStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class ReadonlySQLiteCommandEventStore : public ReadonlyCommandEventStore {
const EventDecoder &,
Id,
uint64_t,
CommandEventsList *) override;
CommandEventsList *,
uint64_t *pCommitIndex = nullptr) override;

uint64_t getCurrentOffset() const override {
return mCurrentLoadedCommandOffset;
Expand Down

0 comments on commit 3227604

Please sign in to comment.