-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: Remove feature flag
single-term-leader
In OpenRaft, whether a term supports multiple or single leaders is determined by the ordering implementation of `LeaderId`. This behavior is independent of compilation and can be configured at the application level, removing the need for a compilation flag `single-term-leader`. ### Changes: - The `single-term-leader` feature flag is removed. - Leader mode (multi-leader or single-leader per term) is now controlled by the `LeaderId` associated type in the application configuration. ### Configuration Guide: To enable **standard Raft mode (single leader per term)**: - Set `LeaderId` to `openraft::impls::leader_id_std::LeaderId` in the `declare_raft_types!` statement, or within the `RaftTypeConfig` implementation. Example: ```rust openraft::declare_raft_types!( pub TypeConfig: D = String, LeaderId = openraft::impls::leader_id_std::LeaderId<TypeConfig>, ); ``` To use the **default multi-leader per term mode**, leave `LeaderId` unset or explicitly set it to `openraft::impls::leader_id_adv::LeaderId`. Example: ```rust openraft::declare_raft_types!( pub TypeConfig: D = String, ); // Or: openraft::declare_raft_types!( pub TypeConfig: D = String, LeaderId = openraft::impls::leader_id_adv::LeaderId<TypeConfig>, ); ``` Upgrade tip: If the `single-term-leader` flag was previously used, remove it and configure `LeaderId` as follows: ```rust openraft::declare_raft_types!( pub TypeConfig: LeaderId = openraft::impls::leader_id_std::LeaderId<TypeConfig>, ); ```
- Loading branch information
1 parent
d1bd8a2
commit d1b41ef
Showing
38 changed files
with
196 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,29 +63,20 @@ jobs: | |
args: --features bench nothing-to-run --manifest-path openraft/Cargo.toml | ||
|
||
|
||
# Run openraft unit test `openraft/` and integration test `tests/`. | ||
openraft-test: | ||
# Run openraft unit test `openraft/` | ||
test-crate-openraft: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- toolchain: "stable" | ||
send_delay: "0" | ||
features: "" | ||
|
||
# With network delay | ||
- toolchain: "nightly" | ||
send_delay: "30" | ||
features: "" | ||
|
||
# Feature-flag: Standard raft term | ||
- toolchain: "nightly" | ||
send_delay: "0" | ||
features: "single-term-leader" | ||
|
||
|
||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v4 | ||
|
@@ -98,19 +89,57 @@ jobs: | |
override: true | ||
|
||
|
||
# - A store with defensive checks returns error when unexpected accesses are sent to RaftStore. | ||
# - Raft should not depend on defensive error to work correctly. | ||
- name: Test crate `openraft/` | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --features "${{ matrix.features }}" --manifest-path openraft/Cargo.toml | ||
env: | ||
# Parallel tests block each other and result in timeout. | ||
RUST_TEST_THREADS: 2 | ||
RUST_LOG: debug | ||
RUST_BACKTRACE: full | ||
OPENRAFT_NETWORK_SEND_DELAY: ${{ matrix.send_delay }} | ||
|
||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: "ut-openraft-${{ matrix.toolchain }}-${{ matrix.features }}" | ||
path: | | ||
openraft/_log/ | ||
# Run integration test `tests/`. | ||
test-crate-tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- toolchain: "stable" | ||
send_delay: "0" | ||
features: "" | ||
|
||
# With network delay | ||
- toolchain: "nightly" | ||
send_delay: "30" | ||
features: "" | ||
|
||
# Feature-flag: Standard raft term | ||
- toolchain: "nightly" | ||
send_delay: "0" | ||
features: "single-term-leader" | ||
|
||
|
||
steps: | ||
- name: Setup | Checkout | ||
uses: actions/checkout@v4 | ||
|
||
|
||
- name: Setup | Toolchain | ||
uses: actions-rs/[email protected] | ||
with: | ||
toolchain: "${{ matrix.toolchain }}" | ||
override: true | ||
|
||
|
||
- name: Test crate `tests/` | ||
|
@@ -130,9 +159,8 @@ jobs: | |
uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: "ut-${{ matrix.toolchain }}-${{ matrix.features }}-${{ matrix.send_delay }}" | ||
name: "ut-tests-${{ matrix.toolchain }}-${{ matrix.features }}-${{ matrix.send_delay }}" | ||
path: | | ||
openraft/_log/ | ||
tests/_log/ | ||
|
@@ -252,16 +280,8 @@ jobs: | |
- toolchain: "nightly" | ||
features: "serde" | ||
|
||
# Some test requires feature single-term-leader on and serde off. | ||
# This can only be tested without building another crate that enables | ||
# `serde`. | ||
# Move this test to unit-test when the snapshot API is upgraded to | ||
# non-serde-dependent. | ||
- toolchain: "nightly" | ||
features: "single-term-leader" | ||
|
||
- toolchain: "nightly" | ||
features: "single-term-leader,serde,singlethreaded" | ||
features: "serde,singlethreaded" | ||
|
||
|
||
steps: | ||
|
@@ -364,7 +384,7 @@ jobs: | |
shell: bash | ||
run: | | ||
cargo clippy --no-deps --workspace --all-targets -- -D warnings | ||
cargo clippy --no-deps --workspace --all-targets --features "bt,serde,bench,single-term-leader,compat" -- -D warnings | ||
cargo clippy --no-deps --workspace --all-targets --features "bt,serde,bench,compat" -- -D warnings | ||
- name: Build-doc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.