2015-06-04 04:51:16 -07:00
|
|
|
package hostdiscovery
|
|
|
|
|
2015-09-18 12:54:08 -07:00
|
|
|
import "net"
|
2015-06-04 04:51:16 -07:00
|
|
|
|
|
|
|
// JoinCallback provides a callback event for new node joining the cluster
|
|
|
|
type JoinCallback func(entries []net.IP)
|
|
|
|
|
2015-10-21 21:31:43 -07:00
|
|
|
// ActiveCallback provides a callback event for active discovery event
|
|
|
|
type ActiveCallback func()
|
|
|
|
|
2015-06-04 04:51:16 -07:00
|
|
|
// LeaveCallback provides a callback event for node leaving the cluster
|
|
|
|
type LeaveCallback func(entries []net.IP)
|
|
|
|
|
|
|
|
// HostDiscovery primary interface
|
|
|
|
type HostDiscovery interface {
|
2015-09-18 12:54:08 -07:00
|
|
|
//Watch Node join and leave cluster events
|
2015-10-21 21:31:43 -07:00
|
|
|
Watch(activeCallback ActiveCallback, joinCallback JoinCallback, leaveCallback LeaveCallback) error
|
2016-06-22 14:20:30 +08:00
|
|
|
// StopDiscovery stops the discovery process
|
2015-06-04 04:51:16 -07:00
|
|
|
StopDiscovery() error
|
|
|
|
// Fetch returns a list of host IPs that are currently discovered
|
2015-09-18 12:54:08 -07:00
|
|
|
Fetch() []net.IP
|
2015-06-04 04:51:16 -07:00
|
|
|
}
|