clustering

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package clustering provides an interface to register and list members in a cluster.

Index

Constants

View Source
const ClusterMemberPath = "/members"
View Source
const DefaultACLPerms = zk.PermAll

Variables

This section is empty.

Functions

func CleanPath

func CleanPath(path string) string

func CreateParentPath

func CreateParentPath(conn *zk.Conn, path string, acl []zk.ACL) error

func CreatePath added in v0.7.0

func CreatePath(conn *zk.Conn, path string, acl []zk.ACL) error

Types

type ClusterMember

type ClusterMember interface {
	// MemberID returns the unique identifier for this cluster member.
	MemberID() MemberID
	// MemberList returns a current list of the cluster members. Returns an error
	// if the list was unable to be retrieved.
	MemberList() ([]MemberID, error)
	// MemberListCallback will call the callback function once for every member
	// currently in the tree and then again for each future addition and removal.
	// Subsequent calls to MemberListCallback will cancel previous callbacks.
	MemberListCallback(callback MemberListCallbackFunc) error
	// Register will register this member with the cluster. Once a cluster member is
	// registered it should stay registered as long as the cluster member is alive.
	// If registration was unsuccessful an error is returned.
	Register() error
	// Unregister will unregister this member with the cluster. Unregister may not be
	// called so arrangements should be made for the cluster to unregister a
	// member if it dies unexpectedly.
	Unregister() error
}

ClusterMember is one member of a cluster.

type MemberID

type MemberID string

MemberID is a string identifier that is unique for each cluster member.

type MemberListCallbackFunc

type MemberListCallbackFunc func(add MemberID, remove MemberID)

MemberListCallbackFunc is a function that will be called once for every member added or removed from the cluster.

type ZookeeperClusterMember

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

func NewZookeeperClusterMember

func NewZookeeperClusterMember(config *configuration.GatewayConfig, conn *zk.Conn, member string) *ZookeeperClusterMember

func (*ZookeeperClusterMember) MemberID

func (z *ZookeeperClusterMember) MemberID() MemberID

func (*ZookeeperClusterMember) MemberList

func (z *ZookeeperClusterMember) MemberList() ([]MemberID, error)

func (*ZookeeperClusterMember) MemberListCallback

func (z *ZookeeperClusterMember) MemberListCallback(callback MemberListCallbackFunc) error

func (*ZookeeperClusterMember) Register

func (z *ZookeeperClusterMember) Register() error

Register will create an ephemeral Zookeeper node in a cluster member tree. The node will be removed automatically by Zookeeper if the session disconnects.

func (*ZookeeperClusterMember) Unregister

func (z *ZookeeperClusterMember) Unregister() error

Jump to

Keyboard shortcuts

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