drmingdrmer / openraft

An implementation of the Raft distributed consensus protocol using the Tokio framework.
https://datafuselabs.github.io/openraft/
Apache License 2.0
1 stars 1 forks source link

Add call to redirect request from the learners to the leader. #22

Closed ppamorim closed 2 years ago

ppamorim commented 2 years ago

Checklist

ppamorim commented 2 years ago

@drmingdrmer I think I messed up the git history here, do you know what I need to do to sort that out? I tried to rebase and apply a fix up but idk.

drmingdrmer commented 2 years ago

Here it is a snippet to rebuild a commit with the same content but do not depend on rebase.

# Rebuild a commit with the content in branch `src` and set the parent commit to `base`
# Then set `new_branch` to the new commit.

rebuild()
{
    local src=$1
    local base=$2
    local new_branch=$3

    tree=$(git rev-parse "$src^{tree}")
    new_commit=$(echo "rebuild commit" | git commit-tree $tree -p $base)
    git update-ref refs/heads/$new_branch $new_commit
}

rebuild example origin/example cleanup

Before:

*   71739d0 (HEAD -> example) Merge branch 'example' into example
|\
| * 17d16a1 (origin/example) Fixup: Improve example
| * 42748fe Fixup: exclude example-raft-kv from workspace
| * 0721656 Doc: add example raft-kv
| *   b45aa32 (ups/main) Merge pull request #159 from drmingdrmer/fix-candi
| |\
| | * 4015cc3 Fix: a Candidate should revert to Follower at once when a higher vote is seen
| |/
* | 4ad16aa Add redirect
* | 74f9f26 Improve example
* | 86bc6e2 Fixup: exclude example-raft-kv from workspace
* | 96967e9 Doc: add example raft-kv
|/
*   950d23b Merge pull request #150 from drmingdrmer/vv

After:

* 42c6f9f (cleanup) rebuild commit
| *   71739d0 (HEAD -> example) Merge branch 'example' into example
| |\
| |/
|/|
* | 17d16a1 (origin/example) Fixup: Improve example
* | 42748fe Fixup: exclude example-raft-kv from workspace
* | 0721656 Doc: add example raft-kv
* |   b45aa32 (ups/main) Merge pull request #159 from drmingdrmer/fix-candi
|\ \
| * | 4015cc3 Fix: a Candidate should revert to Follower at once when a higher vote is seen
|/ /
| * 4ad16aa Add redirect
| * 74f9f26 Improve example
| * 86bc6e2 Fixup: exclude example-raft-kv from workspace
| * 96967e9 Doc: add example raft-kv
|/
*   950d23b Merge pull request #150 from drmingdrmer/vv
drmingdrmer commented 2 years ago

BTW this repo is my personal developing repo. : | Let's open PRs on https://github.com/datafuselabs/openraft Then other people would know what's going on :DD

GitHub
GitHub - datafuselabs/openraft: rust raft with improvements
rust raft with improvements. Contribute to datafuselabs/openraft development by creating an account on GitHub.
ppamorim commented 2 years ago

@drmingdrmer Thank you for the lovely explanation! I will use that script for my life now!

Btw, this PR was opened there because your example PR was not merged yet, so I could not work on that.

drmingdrmer commented 2 years ago

Btw, this PR was opened there because your example PR was not merged yet, so I could not work on that.

Right. I merged the example PR. :D Now we can continue on working on https://github.com/datafuselabs/openraft

GitHub
GitHub - datafuselabs/openraft: rust raft with improvements
rust raft with improvements. Contribute to datafuselabs/openraft development by creating an account on GitHub.