Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract log Entry #1304

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Jan 25, 2025

Changelog

There is a lot changes and this PR will be split into several smaller ones


This change is Reviewable

@drmingdrmer drmingdrmer marked this pull request as draft January 25, 2025 09:54
@drmingdrmer drmingdrmer changed the title M examples/raft-kv-memstore-grpc/proto/internal_service.proto Abstract log Entry Jan 25, 2025
@drmingdrmer drmingdrmer force-pushed the 179-log-id-list branch 22 times, most recently from 666e0c7 to f0fd058 Compare February 1, 2025 02:32
- Remove trait `FromAppData` that is used to create log `Entry` from
  application data. Add `RaftEntry::new()`. Application should implement
  this method.

- Change: trait `RaftLogId`: before this commit, it is used to defined a
  `LogId` container, requiring methods `get_log_id()` and `set_log_id()`.
  In this commit, `RaftLogId` defines the behavior of `LogId` itself,
  requiring methods `new()`, `committed_leader_id()` and `index()`.

- The `RaftEntry` trait removed requirement of `RaftLogId`, due to the
  `RaftLogId` behavior change, and requires application to implements
  methods:
  - `new()` to create a log `Entry`,
  - `log_id_parts()`: to return references to the components of this
    entry's log ID: the committed leader ID and index,
  - `set_log_id()`: to update the log entry id.

  And `RaftEntry` provides several default implemented methods:
  - `new_blank()`, `new_normal()`, `new_membership()` to create
    different kind of log `Entry`.
  - `log_id()` returns an owned `LogId` instance,
  - `index()` returns the log id index.

- Refactor: Introduce `RefLogId` as a reference to a log ID

  Existing `LogIdOf<C>` provides a minimal storage implementation for
  a log ID with essential properties. In contrast, `RefLogId` which
  references a storage `LogIdOf<C>`, offers the same information as
  `LogIdOf<C>` while adding additional system-defined properties.

  For example, `LogIdOf<C>` defined by the application will not need
  to implement `Ord`. However, `RefLogId`, used internally, will
  provide a system-defined `Ord` implementation.

  This change updates internal components to return `RefLogId` or
  accept it as an argument where possible, enabling more flexibility
  and consistency in handling log IDs.

- Update example `raft-kv-memstore-grpc`: implement log `Entry` and
  other types with protobuf, such as state machine and RPC message
  types; Implement snapshot streaming transmission; Remove `serde` from
  this example.

- Part of databendlabs#1278

Upgrade tips:

1. **For applications using a custom `RaftEntry` implementation** (e.g.,
   declared with `declare_raft_types!(MyTypes: Entry = MyEntry)`),
   Update the `RaftEntry` implementation:
   - Remove implementation of `FromAppData`;
   - Add implementation of `new()`, `log_id_parts()` and
     `set_log_id()` method.

2. **For applications using the default `Entry` provided by OpenRaft**:
   - No changes are required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant