Documentation ¶
Index ¶
- type Config
- type ErrorEvent
- type Event
- type EventBus
- type EventHandler
- type EventType
- type Member
- type MemberEvent
- type MemberEventType
- type MemberList
- type Members
- type Option
- func WithAPIAddrPort(addr string, port int) Option
- func WithAdvertiseAddrPort(addr string, port int) Option
- func WithBindAddrPort(addr string, port int) Option
- func WithBroadcastTimeout(d time.Duration) Option
- func WithClientAddrPort(addr string, port int) Option
- func WithExisting(existing []string) Option
- func WithLogOutput(logOutput io.Writer) Option
- func WithNodeName(nodeName string) Option
- func WithPeerType(peerType PeerType) Option
- type PeerInfo
- type PeerType
- type QueryEvent
- type UserEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config defines a configuration setup for creating a list to manage the members cluster
type ErrorEvent ¶
type ErrorEvent struct {
Error error
}
ErrorEvent is an event that represents when an error comes from the cluster
type Event ¶
type Event interface { // Type is one of the EventType Type() EventType }
Event is the member event to be acted upon
func NewErrorEvent ¶
NewErrorEvent creates a new ErrorEvent with the correct dependencies
func NewMemberEvent ¶
func NewMemberEvent(eventType MemberEventType, members []Member) Event
NewMemberEvent creates a new MemberEvent with the correct dependencies
func NewQueryEvent ¶
NewQueryEvent creates a new QueryEvent with the correct dependencies
func NewUserEvent ¶
NewUserEvent creates a new UserEvent with the correct dependencies
type EventBus ¶
type EventBus interface { // RegisterEventHandler attaches a event listener to all the members events // and broadcasts the event to the handler. RegisterEventHandler(EventHandler) error // DeregisterEventHandler removes the event listener. DeregisterEventHandler(EventHandler) error // DispatchEvent dispatches an event to all the members in the cluster. DispatchEvent(Event) error }
EventBus allows the distributing and receiving of events over the cluster
type EventHandler ¶
EventHandler is an alias for the event dispatcher
type Member ¶
type Member interface { // Name returns the name of the member Name() string // Address returns the host:port of the member Address() string }
Member represents a node in the cluster.
type MemberEvent ¶
type MemberEvent struct { EventType MemberEventType Members []Member }
MemberEvent is an event that represents when a member has changed in the cluster
func (MemberEvent) Type ¶
func (MemberEvent) Type() EventType
Type returns the EventType of the Event
type MemberEventType ¶
type MemberEventType int
MemberEventType is the potential event type for member event
const ( // EventMemberJoined notified from a cluster when a member has joined EventMemberJoined MemberEventType = iota // EventMemberLeft notified from a cluster when a member has left EventMemberLeft // EventMemberFailed notified from a cluster when a member has failed EventMemberFailed // EventMemberUpdated notified from a cluster when a member has updated EventMemberUpdated )
type MemberList ¶
type MemberList interface { // NumMembers returns the number of alive nodes currently known. Between // the time of calling this and calling Members, the number of alive nodes // may have changed, so this shouldn't be used to determine how many // members will be returned by Members. NumMembers() int // LocalNode is used to return the local Member LocalNode() Member // Members returns a point-in-time snapshot of the members of this cluster. Members() []Member }
MemberList represents a way to manage members with in a cluster
type Members ¶
type Members interface { EventBus // Join joins an existing members cluster. Returns the number of nodes // successfully contacted. The returned error will be non-nil only in the // case that no nodes could be contacted. Join() (int, error) // Leave gracefully exits the cluster. It is safe to call this multiple // times. Leave() error // Memberlist is used to get access to the underlying Memberlist instance MemberList() MemberList // Walk over a set of alive members Walk(func(PeerInfo) error) error // Close the current members cluster Close() error }
Members represents a way of joining a members cluster
type Option ¶
Option defines a option for generating a filesystem Config
func WithAPIAddrPort ¶
WithAPIAddrPort adds a APIAddr and APIPort to the configuration
func WithAdvertiseAddrPort ¶
WithAdvertiseAddrPort adds a AdvertiseAddr and AdvertisePort to the configuration
func WithBindAddrPort ¶
WithBindAddrPort adds a BindAddr and BindPort to the configuration
func WithBroadcastTimeout ¶
WithBroadcastTimeout adds a BroadcastTimeout to the configuration
func WithClientAddrPort ¶
WithClientAddrPort adds a ClientAddr and ClientPort to the configuration
func WithExisting ¶
WithExisting adds a Existing to the configuration
func WithLogOutput ¶
WithLogOutput adds a LogOutput to the configuration
func WithNodeName ¶
WithNodeName adds a NodeName to the configuration
func WithPeerType ¶
WithPeerType adds a PeerType to the configuration
type QueryEvent ¶
QueryEvent is an event that represents when a query from the cluster that needs to be answered.