|
@@ -17,6 +17,9 @@ type Client interface {
|
|
|
// altered after it has been created.
|
|
// altered after it has been created.
|
|
|
Config() *Config
|
|
Config() *Config
|
|
|
|
|
|
|
|
|
|
+ // Brokers returns the current set of active brokers as retrieved from cluster metadata.
|
|
|
|
|
+ Brokers() []*Broker
|
|
|
|
|
+
|
|
|
// Topics returns the set of available topics as retrieved from cluster metadata.
|
|
// Topics returns the set of available topics as retrieved from cluster metadata.
|
|
|
Topics() ([]string, error)
|
|
Topics() ([]string, error)
|
|
|
|
|
|
|
@@ -157,6 +160,16 @@ func (client *client) Config() *Config {
|
|
|
return client.conf
|
|
return client.conf
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (client *client) Brokers() []*Broker {
|
|
|
|
|
+ client.lock.RLock()
|
|
|
|
|
+ defer client.lock.RUnlock()
|
|
|
|
|
+ brokers := make([]*Broker, 0)
|
|
|
|
|
+ for _, broker := range client.brokers {
|
|
|
|
|
+ brokers = append(brokers, broker)
|
|
|
|
|
+ }
|
|
|
|
|
+ return brokers
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (client *client) Close() error {
|
|
func (client *client) Close() error {
|
|
|
if client.Closed() {
|
|
if client.Closed() {
|
|
|
// Chances are this is being called from a defer() and the error will go unobserved
|
|
// Chances are this is being called from a defer() and the error will go unobserved
|