members

package
v0.0.0-...-d2438c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config func(*config)

Config defines a option for generating a filesystem config

func WithAdvertiseAddrPort

func WithAdvertiseAddrPort(addr string, port int) Config

WithAdvertiseAddrPort adds a AdvertiseAddr and AdvertisePort to the configuration

func WithBindAddrPort

func WithBindAddrPort(addr string, port int) Config

WithBindAddrPort adds a BindAddr and BindPort to the configuration

func WithBroadcastTimeout

func WithBroadcastTimeout(d time.Duration) Config

WithBroadcastTimeout adds a BroadcastTimeout to the configuration

func WithClientAddrPort

func WithClientAddrPort(addr string, port int) Config

WithClientAddrPort adds a ClientAddr and ClientPort to the configuration

func WithDaemon

func WithDaemon(address, nonce string) Config

WithDaemon adds a DaemonAddress, DaemonNonce to the configuration

func WithLogOutput

func WithLogOutput(logOutput io.Writer) Config

WithLogOutput adds a LogOutput to the configuration

func WithNodeName

func WithNodeName(nodeName string) Config

WithNodeName adds a NodeName to the configuration

func WithPeerType

func WithPeerType(peerType PeerType) Config

WithPeerType adds a PeerType to the configuration

type ErrorEvent

type ErrorEvent struct {
	Error error
}

ErrorEvent is an event that represents when an error comes from the cluster

func (ErrorEvent) Type

func (ErrorEvent) Type() EventType

Type returns the EventType of the Event

type Event

type Event interface {
	// Type is one of the EventType
	Type() EventType
}

Event is the member event to be acted upon

func NewErrorEvent

func NewErrorEvent(err error) Event

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

func NewQueryEvent(name string, payload []byte, query *serf.Query) Event

NewQueryEvent creates a new QueryEvent with the correct dependencies

func NewUserEvent

func NewUserEvent(name string, payload []byte) Event

NewUserEvent creates a new UserEvent with the correct dependencies

type EventHandler

type EventHandler struct {
	// contains filtered or unexported fields
}

EventHandler defines a handler for dealing with events coming from the underlying serf agent

func (*EventHandler) HandleEvent

func (h *EventHandler) HandleEvent(event serf.Event)

HandleEvent handles any events from the underlying serf agent.

type EventType

type EventType int

EventType is the potential event type for member event

const (
	// EventMember was received from the cluster
	EventMember EventType = iota

	// EventQuery was received from the cluster
	EventQuery

	// EventUser was received from the cluster
	EventUser

	// EventError was received from the cluster
	EventError
)

type Handler

type Handler interface {
	HandleEvent(Event)
}

Handler handles any events coming from the underlying serf agent

type Member

type Member struct {
	// contains filtered or unexported fields
}

Member represents a node in the cluster.

func (Member) Address

func (r Member) Address() string

Address returns the host:port of the member

func (Member) Name

func (r Member) Name() string

Name returns the name of the member

func (Member) PeerInfo

func (r Member) PeerInfo() (PeerInfo, error)

PeerInfo returns the meta data associated with a node

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 struct {
	// contains filtered or unexported fields
}

MemberList represents a way to manage members with in a cluster

func (*MemberList) LocalNode

func (m *MemberList) LocalNode() Member

LocalNode is used to return the local Member

func (*MemberList) Members

func (m *MemberList) Members() []Member

Members returns a point-in-time snapshot of the members of this cluster.

func (*MemberList) NumMembers

func (m *MemberList) NumMembers() int

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.

type Members

type Members struct {
	// contains filtered or unexported fields
}

Members represents a way of joining a members cluster

func NewMembers

func NewMembers(options ...Option) *Members

NewMembers creates a new members list to join.

func (*Members) AddHandler

func (m *Members) AddHandler(handler Handler)

AddHandler attaches an event listener to all the members events and broadcasts the event to the handler.

func (*Members) DispatchEvent

func (m *Members) DispatchEvent(e Event) error

DispatchEvent dispatches an event to all the members in the cluster.

func (*Members) Init

func (m *Members) Init(config ...Config) error

Init will initialise the members with the config to start the agent.

func (*Members) Join

func (m *Members) Join() (int, error)

Join joins an existing Serf cluster. Returns the number of nodes successfully contacted.

func (*Members) Leave

func (m *Members) Leave() error

Leave gracefully exits the cluster. It is safe to call this multiple times.

func (*Members) MemberList

func (m *Members) MemberList() *MemberList

MemberList is used to get access to the underlying Memberlist instance

func (*Members) RemoveHandler

func (m *Members) RemoveHandler(handler Handler)

RemoveHandler removes the event listener.

func (*Members) Shutdown

func (m *Members) Shutdown() error

Shutdown will leave the cluster gracefully, before shutting it down.

func (*Members) Walk

func (m *Members) Walk(fn func(PeerInfo) error) error

Walk over the list of members to gain access to each peer information

type Option

type Option func(*options)

Option defines a option for generating a filesystem options

func WithExisting

func WithExisting(existing []string) Option

WithExisting adds a Existing to the configuration

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger on the option

type PeerInfo

type PeerInfo struct {
	Name          string   `json:"name"`
	Type          PeerType `json:"type"`
	DaemonAddress string   `json:"daemon_address"`
	DaemonNonce   string   `json:"daemon_nonce"`
}

PeerInfo describes what each peer is, along with the addr and port of each

type PeerType

type PeerType string

PeerType describes the type of peer with in the cluster.

func (PeerType) String

func (p PeerType) String() string

type QueryEvent

type QueryEvent struct {
	Name    string
	Payload []byte
	// contains filtered or unexported fields
}

QueryEvent is an event that represents when a query from the cluster that needs to be answered.

func (QueryEvent) Type

func (QueryEvent) Type() EventType

Type returns the EventType of the Event

type UserEvent

type UserEvent struct {
	Name    string
	Payload []byte
}

UserEvent is an event that represents when a user sends a message to the cluster

func (UserEvent) Type

func (UserEvent) Type() EventType

Type returns the EventType of the Event

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL