zookeeper

package
v0.0.0-...-baf2d7e Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : config.go # Created : 2019-05-07 19:33 # Last Modified : 2019-05-07 19:33 # Describe : # # ====================================================

====================================================

# Copyright (C)2019 All rights reserved. # # Author : domchan # Email : 814172254@qq.com # File Name : zookeeper.go # Created : 2019-05-07 19:28 # Last Modified : 2019-05-07 19:28 # Describe : # # ====================================================

Index

Constants

View Source
const (
	// SOH control character
	SOH = "\x01"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config is the config use to connection zk

type Election

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

func New

func New(addrs []string, cfg *Config) (*Election, error)

New init a election based on zk addrs => host:port

func (*Election) Close

func (s *Election) Close() error

Close shutdown the connection

func (*Election) Delete

func (s *Election) Delete(ctx context.Context, key string) error

func (*Election) HeartBeat

func (s *Election) HeartBeat() error

HeartBeat check the connection weather is active

func (*Election) SetNx

func (s *Election) SetNx(ctx context.Context, key string, value []byte, opt *election.WriteOptions) error

SetNx set the key if key is not exist because zk is special, you cannot set TTL for non-persistent nodes

func (*Election) Watch

func (s *Election) Watch(ctx context.Context, key string, stopCh <-chan struct{}) (<-chan *election.WatchRes, error)

Watch watch the key

Jump to

Keyboard shortcuts

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