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 Detect leader changed? #300

Closed
xiatianqiuyu opened this issue Apr 27, 2023 · 4 comments
Closed

how to Detect leader changed? #300

xiatianqiuyu opened this issue Apr 27, 2023 · 4 comments

Comments

@xiatianqiuyu
Copy link

How to check whether the leader has changed? How to register an observer and perform certain operations when the leader sends a change

@kevburnsjr
Copy link
Contributor

kevburnsjr commented Apr 27, 2023

config.NodeHostConfig.RaftEventListener
https://pkg.go.dev/github.com/lni/dragonboat/v4@v4.0.0-20230202152124-023bafb8e648/config#NodeHostConfig

// RaftEventListener is the listener for Raft events, such as Raft leadership
// change, exposed to user space. NodeHost uses a single dedicated goroutine
// to invoke all RaftEventListener methods one by one, CPU intensive or IO
// related procedures that can cause long delays should be offloaded to worker
// goroutines managed by users. See the raftio.IRaftEventListener definition
// for more details.
RaftEventListener raftio.IRaftEventListener
type IRaftEventListener interface {
	LeaderUpdated(info LeaderInfo)
}
type LeaderInfo struct {
	ShardID   uint64
	ReplicaID uint64
	Term      uint64
	LeaderID  uint64
}

@xiatianqiuyu
Copy link
Author

this method is very good。How to check whether the raft node Breakdowns? How to register an observer and perform certain operations when the node Breakdowns

@lni
Copy link
Owner

lni commented May 3, 2023

your new question is being addressed in #301.

@lni lni closed this as completed May 3, 2023
@paulm17
Copy link

paulm17 commented Mar 16, 2024

I've got a use case where I have a scheduler. It only needs to be run on one node. However I'm using dragonboat to provide HA.

What would be the best mechanism to only ensure the scheduler runs in 1 node only?

Thanks

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

No branches or pull requests

4 participants