Documentation ¶
Overview ¶
zkcluster - A connector for a zookeeper assisted redis cluster. It reads cluster configurations and shard status from zookeeper servers. It has a checker implementation which could be run separately. Multiple checkers are also possible and they would automatically elect a leader and make quorum-like decisions.
Index ¶
Constants ¶
const ( ZK_ROOT = "/goreclusters" DEF_FLAGS = int32(0) EPH_SEQ_FLAGS = zk.FlagEphemeral | zk.FlagSequence )
Variables ¶
var (
DEF_ACL = zk.WorldACL(zk.PermAll)
)
Functions ¶
This section is empty.
Types ¶
type ZKChecker ¶
type ZKChecker struct {
// contains filtered or unexported fields
}
Healthchecker implementation of the zookeeper assisted redis cluster. It checks the status of redis instances and record them to the zookeeper. ZKCluster would watch that information and update its status. ZKChecker also supports quorum-like decisions with an automatic leader election. The leader gathers votes from all checkers to change status. Once the majority(even would be ignored) has an opposite state, a status change happens. Only the leader can gather votes, open the ballot box and update the status. If the leader lost a connection to the zookeeper, another one would take the leader automatically.
func NewZKChecker ¶
func NewZKChecker(options *ZKCheckerOptions) (*ZKChecker, error)
Return a new checker instance.
type ZKCheckerOptions ¶
type ZKCheckerOptions struct { ZKServers []string ZKTimeout time.Duration Clustername string Nworker int Interval time.Duration Threshold time.Duration }
Options for ZKChecker
type ZKCluster ¶
type ZKCluster struct {
// contains filtered or unexported fields
}
Connector implementation for the zookeeper assisted redis cluster. It reads cluster configurations and shard status from zookeeper servers. It also has roles of NodeReader, RingBuilder and HealthChecker which Cluster interface requires.
func NewZKCluster ¶
Return a new ZKCluster instance.
func (*ZKCluster) BuildRing ¶
func (c *ZKCluster) BuildRing(shards []Shard) *HashRing
ZK assisted RingBuilder implementation. The ring type or the parameters might be designated via the zookeeper.
func (*ZKCluster) ReadNodes ¶
func (c *ZKCluster) ReadNodes() []Shard
ZK assisted NodeReader implementation.
type ZKClusterInfo ¶
type ZKClusterInfo struct { Name string Version int64 Options ZKClusterOptions Shards []Shard }
Cluster information stored on the zookeeper.
type ZKClusterOptions ¶
Cluster options stored on the zookeeper.
type ZKConnector ¶
type ZKConnector struct {
// contains filtered or unexported fields
}
Connector interface to zookeeper servers.
func NewZKConnector ¶
func NewZKConnector(servers []string, timeout time.Duration) (*ZKConnector, error)
func (*ZKConnector) GetCluster ¶
func (zc *ZKConnector) GetCluster(name string) (*ZKClusterInfo, error)
func (*ZKConnector) GetClusters ¶
func (zc *ZKConnector) GetClusters() ([]*ZKClusterInfo, error)
func (*ZKConnector) Shutdown ¶
func (zc *ZKConnector) Shutdown()
type ZKManager ¶
type ZKManager struct {
// contains filtered or unexported fields
}
The manager of cluster information on the zookeeper.
func NewZKManager ¶
Return a new manager instance.
func (*ZKManager) CreateCluster ¶
func (zm *ZKManager) CreateCluster(cluster *ZKClusterInfo) error
Create a new cluster information with given option onto the zookeeper.
func (*ZKManager) DeleteCluster ¶
Delete the cluster.
func (*ZKManager) UpdateCluster ¶
func (zm *ZKManager) UpdateCluster(cluster *ZKClusterInfo) error
Update a cluster information.