zk

package
v0.0.0-...-6fba4f8 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseConnectionString

func ParseConnectionString(connectionString string) (nodes []string, chroot string)

ParseConnectionString parses a zookeeper connection string in the form of host1:2181,host2:2181/chroot and returns the list of servers, and the chroot.

Types

type Client

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

Client is a simple wrapper for zk.

func New

func New(servers []string, conf *Config) (*Client, error)

New creates a instance of Client.

func NewFromConnectionString

func NewFromConnectionString(connectionString string, dialTimeout, sessionTimeout time.Duration) (*Client, error)

NewFromConnectionString creates a new connection instance based on a zookeeer connection string that can include a chroot.

func NewWithConnection

func NewWithConnection(conn Conn, conf *Config) *Client

NewWithConnection creates a Client with an existing zookeeper connection.

func (*Client) Brokers

func (c *Client) Brokers() (map[int32]string, error)

Brokers returns a map of all the brokers that make part of the Kafka cluster that is registered in Zookeeper.

func (*Client) Close

func (c *Client) Close()

Close closes zookeeper client.

func (*Client) KafkaUrls

func (c *Client) KafkaUrls() (string, error)

KafkaUrls get the kafka urls from zookeeper

func (*Client) Partitions

func (c *Client) Partitions(topic string) ([]int32, error)

Partitions returns partitions of specific topic.

func (*Client) Topics

func (c *Client) Topics() ([]string, error)

Topics returns a list of all registered Kafka topics.

type Config

type Config struct {
	Chroot         string
	SessionTimeout time.Duration
	DialTimeout    time.Duration
}

Config for zookeeper client.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates a default config.

type Conn

type Conn interface {
	Close()
	Children(path string) ([]string, *zk.Stat, error)
	Get(path string) ([]byte, *zk.Stat, error)
}

Conn is an interface abstracting away the zookeeper connection.

The standard `*zk.Conn` type implements this interface.

Jump to

Keyboard shortcuts

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