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 handle BecomeXXXX? #14

Open
billlin0904 opened this issue Jun 1, 2018 · 3 comments
Open

How to handle BecomeXXXX? #14

billlin0904 opened this issue Jun 1, 2018 · 3 comments

Comments

@billlin0904
Copy link

This is great library ever : )

I need to handle the node state and send my state to server,
but I can't find class , that be adapt the node state (ex: handler) ?

@billlin0904 billlin0904 changed the title How to handle BecomXXXX state? How to handle BecomeXXXX state? Jun 1, 2018
@billlin0904 billlin0904 changed the title How to handle BecomeXXXX state? How to handle BecomeXXXX? Jun 1, 2018
@TomPallister
Copy link
Member

@billlin0904 thanks for the compliment!

Can you explain more? I don’t understand what you want to do?

@billlin0904
Copy link
Author

I want use default implement class Node and notify my node state to server.

public class MyNode : Node
{
private WebSocket _client;

    public void BecomeLeader(CurrentState state)
    {
             _client.Send("I am a leader");
    }

}

But Node class can't to override BecomeLeader. QQ

@unclshura
Copy link

unclshura commented Oct 24, 2019

Partial solution is to intercept handling of AppendEntries and RequestVote requests. In this handler check if Node.State.CurrentState.LeaderId changed and react on it. However this is just a partial solution because if this Node is a leader from the beginning there is no way to detect follower->candidate->leader change.

Ideally Node should expose an even or have a virtual method or accept a delegate which called on state change.

This is kind of a big issue because event if the algo itself works, I see no way to actually use it in real app which relies on leader/follower state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants