func (client *Client) Close() error {
	client.lock.Lock()
	defer client.lock.Unlock()
	Logger.Println("Closing Client")
	for _, broker := range client.brokers {
		myBroker := broker  
		go withRecover(func() { myBroker.Close() })
	}
	client.brokers = nil
	client.leaders = nil
	if client.extraBroker != nil {
		go withRecover(func() { client.extraBroker.Close() })
	}
	return nil
}
Close shuts down all broker connections managed by this client. It is required to call this function before
a client object passes out of scope, as it will otherwise leak memory. You must close any Producers or Consumers
using a client before you close the client.
package sarama
import (
	"sort"
	"sync"
	"time"
)
type ClientConfig struct {
	MetadataRetries      int            
	WaitForElection      time.Duration  
	ConcurrencyPerBroker int            
}
type Client struct {
	id     string
	config ClientConfig
	extraBrokerAddrs []string
	extraBroker      *Broker
	deadBrokerAddrs  []string
	brokers map[int32]*Broker           
	leaders map[string]map[int32]int32  
	lock    sync.RWMutex                
}
func NewClient(id string, addrs []string, config *ClientConfig) (*Client, error) {
	Logger.Println("Initializing new client")
	if config == nil {
		config = new(ClientConfig)
	}
	if config.MetadataRetries <= 0 {
		return nil, ConfigurationError("Invalid MetadataRetries. Try 10")
	}
	if config.WaitForElection <= time.Duration(0) {
		return nil, ConfigurationError("Invalid WaitForElection. Try 250*time.Millisecond")
	}
	if config.ConcurrencyPerBroker < 0 {
		return nil, ConfigurationError("Invalid ConcurrencyPerBroker")
	}
	if len(addrs) < 1 {
		return nil, ConfigurationError("You must provide at least one broker address")
	}
	client := &Client{
		id:               id,
		config:           *config,
		extraBrokerAddrs: addrs,
		extraBroker:      NewBroker(addrs[0]),
		brokers:          make(map[int32]*Broker),
		leaders:          make(map[string]map[int32]int32),
	}
	client.extraBroker.Open(config.ConcurrencyPerBroker)
	err := client.RefreshAllMetadata()
	if err != nil {
		client.Close()  
		return nil, err
	}
	Logger.Println("Successfully initialized new client")
	return client, nil
}