kb

package module
v0.0.0-...-cc4b76c Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2017 License: MIT Imports: 4 Imported by: 3

README

kafka-brokers-go

GoDoc Build Status

Go library to access Kafka broker list in Zookeeper. It's useful when working with sarama.

Usage

package main

import (
	"fmt"

	"github.com/philipjkim/kafka-brokers-go"
)

func main() {
	zkServers := []string{"192.168.99.100:2181"}
	c, err := kb.NewConn(zkServers)
	if err != nil {
		panic(err)
	}

	defer c.Close()

	for {
		brokers, ch, err := c.GetW()
		if err != nil {
			panic(err)
		}
		fmt.Printf("%q\n", brokers)
		e := <-ch
		fmt.Printf("%v\n", e.Type)
	}
}

References

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn interacts with the Kafka metadata in Zookeeper.

func NewConn

func NewConn(servers []string) (*Conn, error)

NewConn creates a new connection instance.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection with the Zookeeper.

func (*Conn) GetW

func (c *Conn) GetW() ([]string, <-chan zk.Event, error)

GetW returns a list of all Kafka brokers, and a channel for watching changes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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