Hoverbear / old-raft-rs

[Incomplete] A Raft implementation in Rust
https://hoverbear.github.io/raft-rs/raft/
MIT License
266 stars 41 forks source link

How to Handle Client Requests #5

Closed Hoverbear closed 9 years ago

Hoverbear commented 9 years ago

I'm currently struggling with how to properly handle the requests the "client" application makes to the library. Code here

How does a Follower of Raft handle this request? The Raft paper suggest a redirect, but I think this could be handled better.

Manishearth commented 9 years ago

Another way to do this is to internally forward the request to the leader, however this makes a more brittle connection. Returning an error; ERR_REDIRECT or something, with a host/port seems better to me.

Hoverbear commented 9 years ago

@Manishearth Currently I'm looking to transparently forward a request from a Follower to it's Leader, what do you mean by 'brittle'?

Manishearth commented 9 years ago

If the follower goes down, it will break :)

Hoverbear commented 9 years ago

@Manishearth If the follower goes down then the node won't be making requests anyways. :)

Manishearth commented 9 years ago

@Hoverbear Not if the follower tells the node the IP of the leader beforehand :)

Hoverbear commented 9 years ago

@Manishearth Right, but if the follower goes down the consuming application on that node will have crashed too, yes?

Manishearth commented 9 years ago

What do you mean by a node here?

Hoverbear commented 9 years ago

@Manishearth The library/application pair. Hmm.. I need to think about this.

Hoverbear commented 9 years ago

We talked about this on IRC today for a bit and come up with these thoughts:

<hoverbear> So we agree that raft should act as an event emitter to the client (Our state machine)?
<dcb> yes
<hoverbear> And we're undetermined on if client requests should go over network, but yes we think that might be the right idea since that's how the raft paper describes it?
<dcb> yep, I'm quite sure it has to touch the network in at least some cases, if not most
<hoverbear> dcb: Yes, I think so too. So it might be best for the leader to just express interest in a second socket through mio or something. We can discuss this more.
Hoverbear commented 9 years ago

It was determined that we'd do something along the lines of

consuming application <-> Raft <-> RaftNode <-> {State & StateMachine}