zk

package
v0.2.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (

	// misoconfig-prop: enable zk client | false
	PropZkEnabled = "zk.enabled"

	// misoconfig-prop: zk server host (slice of string) | localhost
	PropZkHost = "zk.hosts"

	// misoconfig-prop: zk server session timeout (seconds) | 5
	PropZkSessionTimeout = "zk.session-timeout"
)

misoconfig-section: Zookeeper Configuration

Variables

This section is empty.

Functions

func Conn

func Conn() *zk.Conn

func CreateEphNode

func CreateEphNode(p string, dat []byte) error

func CreatePerNode

func CreatePerNode(p string, dat []byte) error

func Get

func Get(p string) ([]byte, error)

func Watch

func Watch(p string) (<-chan zk.Event, error)

Types

type LeaderElection

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

func NewLeaderElection

func NewLeaderElection(rootPath string) *LeaderElection

Create LeaderElection.

For the same rootPath, only one *LeaderElection should be created and used.

func (*LeaderElection) Elect

func (l *LeaderElection) Elect(rail miso.Rail, leaderDo func()) (bool, error)

Elect leader.

If current node becomes the leader, leaderDo is called exactly one time.

If current node fails to become the leader, it blocks indefinitively until it becomes the leader.

You can cancel the election, using Rail.WithCancel() or Rail.WithTimeout().

Jump to

Keyboard shortcuts

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