Documentation ¶
Index ¶
- Constants
- Variables
- type AppMeta
- type Cluster
- func (C *Cluster) AmLeader() bool
- func (C *Cluster) ClusterData() map[string][]byte
- func (C *Cluster) ClusterStatusHandler(w http.ResponseWriter, r *http.Request)
- func (C *Cluster) Connect(peers ...string) error
- func (C *Cluster) Disconnect() error
- func (C *Cluster) GetData() []byte
- func (C *Cluster) Leader() (name, address string)
- func (C *Cluster) Notifications() <-chan []byte
- func (C *Cluster) Notify(member *memberlist.Node, msg []byte) error
- func (C *Cluster) NotifyAll(msg []byte) error
- func (C *Cluster) OtherMembers() map[*memberlist.Node][]byte
- func (C *Cluster) RegisterTasks(tasks ...Task)
- func (C *Cluster) RunOnDemand()
- func (C *Cluster) RunTask(onDemand Task) error
- func (C *Cluster) SetData(appdata []byte)
- func (C *Cluster) WithDirLock(dirPath string)
- func (C *Cluster) WithNotificationChannel(notificationChannel chan []byte)
- type ClusterFunc
- type DefaultEncoderDecoder
- type Delegate
- type EncoderDecoder
- type ExecutionStage
- type Node
- type NodeConfig
- type NodeMeta
- type StatusResponse
- type Task
Constants ¶
View Source
const (
ProtocolVersion = 4
)
Variables ¶
View Source
var MetaMaxSize = memberlist.MetaMaxSize
Functions ¶
This section is empty.
Types ¶
type AppMeta ¶
type AppMeta struct {
// contains filtered or unexported fields
}
func CreateAppMeta ¶
type Cluster ¶
type Cluster struct { *memberlist.Memberlist Tasks []Task // contains filtered or unexported fields }
func NewCluster ¶
func (*Cluster) ClusterData ¶
ClusterData return a mapping snapshot of all AppData, for each node in the cluster. The AppData returned is only a Copy.
func (*Cluster) ClusterStatusHandler ¶
func (C *Cluster) ClusterStatusHandler(w http.ResponseWriter, r *http.Request)
func (*Cluster) Disconnect ¶
func (*Cluster) Notifications ¶
func (*Cluster) OtherMembers ¶
func (C *Cluster) OtherMembers() map[*memberlist.Node][]byte
OtherMembers returns a mapping of all other known live nodes along with that node's AppData.
func (*Cluster) RegisterTasks ¶
RegisterTasks registers the given Tasks to the Cluster.
func (*Cluster) RunOnDemand ¶
func (C *Cluster) RunOnDemand()
RunOnDemand runs all registered Tasks with the OnDemand ExecutionTask parameter.
func (*Cluster) RunTask ¶
RunTask runs the given Task with with the OnDemand ExecutionTask parameter.
func (*Cluster) WithDirLock ¶
func (*Cluster) WithNotificationChannel ¶
type ClusterFunc ¶
type ClusterFunc interface { Leader() (name, address string) AmLeader() bool OtherMembers() map[*memberlist.Node][]byte Notifications() <-chan []byte Notify(*memberlist.Node, []byte) error NotifyAll([]byte) error SetData([]byte) GetData() []byte ClusterData() map[string][]byte }
ClusterFuncs are functions available for Tasks.
type DefaultEncoderDecoder ¶
type DefaultEncoderDecoder struct{}
func (*DefaultEncoderDecoder) Decode ¶
func (d *DefaultEncoderDecoder) Decode(data []byte) NodeMeta
func (*DefaultEncoderDecoder) Encode ¶
func (d *DefaultEncoderDecoder) Encode(m *NodeMeta) []byte
type Delegate ¶
type Delegate interface { memberlist.Delegate EncoderDecoder WithNotificationChannel(chan []byte) }
type EncoderDecoder ¶
type ExecutionStage ¶
type ExecutionStage int
const ( Bootstrap ExecutionStage = iota // On initial 1 node cluster start OnDemand // OnDemand Tasks, envoked via RunOnDemand or RunTask LeaderOnJoin // Newly elected Leader Tasks during an election LeaderOnLeave // Current Leader Tasks when leaving the cluster FollowerOnPromotion // During an election, Follower Tasks when promoted to Leader before running LeaderOnJoin Tasks FollowerOnLeaderLeave // During an election, Follower Tasks when not promoted to Leader befere running FollowerOnNewLeader Tasks FollowerOnNewLeader // During an election, Follower Tasks when a new Leader has been elected FollowerOnJoin // Follower Tasks when joining the cluster FollowerOnLeave // Follower Tasks when leaving the cluster )
type Node ¶
type Node struct { Config *memberlist.Config DirLockPath string L *log.Logger }
func CreateNode ¶
func CreateNode(config *NodeConfig) *Node
type NodeConfig ¶
type NodeConfig struct { Name string BindAddr string AdvertiseAddr string DirLockPath string BindPort int AdvertisePort int Peers []string Logger *log.Logger }
func (*NodeConfig) CreateNode ¶
func (C *NodeConfig) CreateNode() *Node
func (*NodeConfig) SetDefaults ¶
func (C *NodeConfig) SetDefaults()
type StatusResponse ¶
type Task ¶
type Task func(ExecutionStage, ClusterFunc) error
Click to show internal directories.
Click to hide internal directories.