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

How to use this lib? #402

Open
HichuYamichu opened this issue Oct 8, 2020 · 8 comments
Open

How to use this lib? #402

HichuYamichu opened this issue Oct 8, 2020 · 8 comments
Labels
Good First Issue A good issue for a new contributor. Help Wanted An issue with unsolved problems, looking for help. Question A question to be answered.

Comments

@HichuYamichu
Copy link

Or more specifically how does one build transport component?

I'm feeling kind of lost after reading docs, readme and examples as none of them (at least to my knowledge) shows/points to information about transport implementation. Readme mentions gRPC but I couldn't find any further information on the matter besides raft-rs/proto/, which isn't much on its own. TiKv is too big to be a valid reference for starters and etcd raftexample although helpful shows only http api and uses Go implementation.

I believe some information about transport layer should be present either in docs, examples or readme (as it is the case for log and state machine parts). If that's the case and I've simply missed it this can be closed right away.

@BusyJay BusyJay added Help Wanted An issue with unsolved problems, looking for help. Good First Issue A good issue for a new contributor. Question A question to be answered. labels Oct 9, 2020
@BusyJay
Copy link
Member

BusyJay commented Oct 9, 2020

Basically you need to see batch_raft RPC implement:

Receiver: https://github.com/tikv/tikv/blob/master/src/server/service/kv.rs#L628-L664
Sender: https://github.com/tikv/tikv/blob/master/src/server/raft_client.rs

And snapshot handling:

https://github.com/tikv/tikv/blob/master/src/server/snap.rs.

Providing a details and minimal example in raft-rs using gRPC and raft-rs would certainly help.

@chen-zhuohan
Copy link

chen-zhuohan commented Dec 29, 2020

The Example and docs don't show the border in this lib. For example, I spend much time learning how nodes connect to and know each other automatically(I thought the lib has default way to broadcast message, the only things I provided is IP or Host) , finnally I found I should implement broadcasting messages.

On the other hand, seriously, if I did not write the full program including basic raft and upper kv-db, I totally don't know what should do with the lib. "Server gets requests and wait another thread handles these requests message with raft-rs" is not intuitive. It needs docs apart from example.

The example may has somethings wrong. It's another issue: #412

@PsiACE
Copy link
Contributor

PsiACE commented May 16, 2021

You can check and use some frameworks built on top of raft-rs, such as ritedb/riteraft . This hides most of the work details and can help you get a good start. A simple Raft HashStore Service example is written in ~160 lines of code, you can try to run it.

In addition, async-raft has a brief document. Although its design is different from raft-rs, it is still a reference material worth reading.

@BusyJay
Copy link
Member

BusyJay commented May 17, 2021

@PsiACE If you can send a PR, we can list it as an item under "Projects using the Raft crate".

@Fomalhauthmj
Copy link
Contributor

I have written a simple example about how to use this lib, dkvrr which use real gRPC framework. My toy project is still under development and need helpful suggestions.

@sp1ff
Copy link

sp1ff commented Feb 18, 2022

I'd like to add to this: not only are @HichuYamichu 's comments reflective of my own experience trying to figure out how to use this crate, I'm not thrilled about being forced to use slog for logging & grpc for network communications. These (especially logging) should be left to the user behind interfaces, perhaps with pluggable implementations.

@BusyJay
Copy link
Member

BusyJay commented Feb 21, 2022

being forced to use slog for logging

@sp1ff You can opt out slog by configuring raft as raft = { version = "0.6", default-features = false, features = ["protobuf-codec"] }.

grpc for network communications.

raft-rs is designed and implemented as simple as possible, there is no RPC logics in the library at all. So you can use any RPC you like to build up network layers.

@jopemachine
Copy link
Contributor

jopemachine commented Jun 16, 2023

I have ported riteraft, which was originally created by @PsiACE, to riteraft-py.

I think riteraft-py's example code is written in Python instead of Rust, making it easier to read and understand for beginners.

However, the current version of riteraft contains several bugs from the original implementation.

As I am not a distributed system expert, I am facing difficulties in resolving these issues.

I would greatly appreciate it if someone could assist me with this problem by any chance.

1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue A good issue for a new contributor. Help Wanted An issue with unsolved problems, looking for help. Question A question to be answered.
Projects
None yet
Development

No branches or pull requests

7 participants