| "github.com/Shopify/sarama" |
| var errClientInUse = errors.New("cluster: client is already used by another consumer") |
| // Client is a group client |
| // NewClient creates a new client instance |
| func NewClient(addrs []string, config *Config) (*Client, error) { |
| if err := config.Validate(); err != nil { |
| client, err := sarama.NewClient(addrs, &config.Config) |
| return &Client{Client: client, config: *config}, nil |
| // ClusterConfig returns the cluster configuration. |
| func (c *Client) ClusterConfig() *Config { |
| func (c *Client) claim() bool { |
| return atomic.CompareAndSwapUint32(&c.inUse, 0, 1) |
| func (c *Client) release() { |
| atomic.CompareAndSwapUint32(&c.inUse, 1, 0) |