cluster

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 8 Imported by: 0

README

Cluster

Golang Package for System Clustering.


Documentation

Usage

To create a cluster

import (
    "fmt"
    "github.com/clivern/cluster"
)


clus := &cluster.Cluster{}

// Generate a unique name
nodeName := clus.GetNodeName()

// Get a default configs
config := clus.GetConfig()
config.Name = nodeName
config.BindPort = 0 // assign a free port
config.Events = &cluster.NodeEvents{}

// Override configs
clus.SetConfig(config)

clus.AddLocalNode([]string{}) // or []string{"x.x.x.x:port"} in case of the second, third ... node

fmt.Println(clus.GetLocalNode())

// 2020/10/18 20:44:19 [DEBUG] memberlist: Using dynamic bind port 52053
// A node has joined: Clivern-2.local--c5553465-2bc9-4ef1-8a83-384e5a0c4097
// Clivern-2.local--c5553465-2bc9-4ef1-8a83-384e5a0c4097

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, Cluster is maintained under the Semantic Versioning guidelines and release process is predictable and business-friendly.

See the Releases section of our GitHub project for changelogs for each release version of Cluster. It contains summaries of the most noteworthy changes made in each release.

Bug tracker

If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/cluster/issues

Security Issues

If you discover a security vulnerability within Cluster, please send an email to hello@clivern.com

Contributing

We are an open source, community-driven project so please feel free to join us. see the contributing guidelines for more details.

License

© 2020, Clivern. Released under MIT License.

Cluster is authored and maintained by @clivern.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expect

func Expect(t *testing.T, got, want interface{})

Expect compare two values for testing

func GenerateUUID4

func GenerateUUID4() string

GenerateUUID4 create a UUID

func InArray

func InArray(val interface{}, array interface{}) bool

InArray check if value is on array

func Unset

func Unset(a []string, i int) []string

Unset remove element at position i

Types

type Broadcast

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

Broadcast struct

func (*Broadcast) Finished added in v0.0.8

func (b *Broadcast) Finished()

Finished ..

func (*Broadcast) Invalidates added in v0.0.8

func (b *Broadcast) Invalidates(other memberlist.Broadcast) bool

Invalidates ..

func (*Broadcast) Message added in v0.0.8

func (b *Broadcast) Message() []byte

Message ..

type Cluster

Cluster struct

func (*Cluster) AddLocalNode

func (c *Cluster) AddLocalNode(members []string) (int, error)

AddLocalNode

func (*Cluster) GetConfig

func (c *Cluster) GetConfig() *memberlist.Config

GetConfig

func (*Cluster) GetLocalNode

func (c *Cluster) GetLocalNode() *memberlist.Node

GetLocalNode

func (*Cluster) GetNodeName

func (c *Cluster) GetNodeName() string

GetNodeName

func (*Cluster) SetConfig

func (c *Cluster) SetConfig(config *memberlist.Config)

SetConfig

type Delegate added in v0.0.8

type Delegate struct {
	State      []byte
	Broadcasts *memberlist.TransmitLimitedQueue
	Cluster    *Cluster
}

Delegate struct

func (*Delegate) GetBroadcasts added in v0.0.8

func (d *Delegate) GetBroadcasts(overhead, limit int) [][]byte

GetBroadcasts ..

func (*Delegate) LocalState added in v0.0.8

func (d *Delegate) LocalState(join bool) []byte

LocalState ..

func (*Delegate) MergeRemoteState added in v0.0.8

func (d *Delegate) MergeRemoteState(buf []byte, join bool)

MergeRemoteState ..

func (*Delegate) NodeMeta added in v0.0.8

func (d *Delegate) NodeMeta(limit int) []byte

NodeMeta ..

func (*Delegate) NotifyMsg added in v0.0.8

func (d *Delegate) NotifyMsg(msg []byte)

NotifyMsg ..

func (*Delegate) SetCluster added in v0.0.8

func (d *Delegate) SetCluster(cluster *Cluster)

SetCluster ..

func (*Delegate) UpdateState added in v0.0.8

func (d *Delegate) UpdateState(data []byte)

UpdateState ..

type Message added in v0.0.8

type Message struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Message struct

func (*Message) Bytes added in v0.0.8

func (m *Message) Bytes() []byte

Bytes ..

func (*Message) Load added in v0.0.8

func (m *Message) Load(data []byte) error

Load ..

type NodeEvents

type NodeEvents struct{}

NodeEvents struct implements https://github.com/hashicorp/memberlist/blob/master/event_delegate.go#L7

func (*NodeEvents) NotifyJoin

func (n *NodeEvents) NotifyJoin(node *memberlist.Node)

NotifyJoin

func (*NodeEvents) NotifyLeave

func (n *NodeEvents) NotifyLeave(node *memberlist.Node)

NotifyLeave

func (*NodeEvents) NotifyUpdate

func (n *NodeEvents) NotifyUpdate(node *memberlist.Node)

NotifyUpdate

type RoundRobinBalancer added in v0.1.1

type RoundRobinBalancer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RoundRobinBalancer ...

func NewRoundRobinBalancer added in v0.1.1

func NewRoundRobinBalancer(clus *Cluster) *RoundRobinBalancer

NewRoundRobinBalancer ...

func (*RoundRobinBalancer) Get added in v0.1.1

Get ...

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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