zookeeper

package
v2.4.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package zookeeper has a common interface and mock objects to implement and test Zookeeper connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBrokerConnectionInfo

func GetBrokerConnectionInfo(brokerID int, zkConn Connection) (scheme, brokerHost string, jmxPort int, brokerPort int, err error)

GetBrokerConnectionInfo Collects Broker connection info from Zookeeper

func GetBrokerIDs

func GetBrokerIDs(zkConn Connection) ([]string, error)

GetBrokerIDs retrieves the broker ids from Zookeeper

func Path

func Path(path string) string

Path takes a zookeeper path and prepends it with argument args.GlobalArgs

Types

type Connection

type Connection interface {
	Get(string) ([]byte, *zk.Stat, error)
	Children(string) ([]string, *zk.Stat, error)
	CreateClient() (connection.Client, error)
	CreateClusterAdmin() (sarama.ClusterAdmin, error)
}

Connection interface to allow easy mocking of a Zookeeper connection

func NewConnection

func NewConnection(kafkaArgs *args.KafkaArguments) (Connection, error)

NewConnection creates a new Connection with the given arguments. If not hosts are specified then a nil Connection and error will be returned

Waiting on issue https://github.com/samuel/go-zookeeper/issues/108 so we can change this function and allow us to mock out the zk.Connect function

type MockConnection

type MockConnection struct {
	mock.Mock
}

MockConnection implements Connection to facilitate testing.

func (MockConnection) Children

func (m MockConnection) Children(s string) ([]string, *zk.Stat, error)

Children mocks the Children method

func (MockConnection) CreateClient

func (m MockConnection) CreateClient() (connection.Client, error)

CreateClient mocks the CreateClient method

func (MockConnection) CreateClusterAdmin

func (m MockConnection) CreateClusterAdmin() (sarama.ClusterAdmin, error)

CreateClusterAdmin mocks the CreateClusterAdmin method

func (MockConnection) Get

func (m MockConnection) Get(s string) ([]byte, *zk.Stat, error)

Get mocks the Get method

Jump to

Keyboard shortcuts

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