MCPcopy
hub / github.com/IBM/sarama / Close

Method Close

client.go:312–341  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

310}
311
312func (client *client) Close() error {
313 if client.Closed() {
314 // Chances are this is being called from a defer() and the error will go unobserved
315 // so we go ahead and log the event in this case.
316 Logger.Printf("Close() called on already closed client")
317 return ErrClosedClient
318 }
319
320 // shutdown and wait for the background thread before we take the lock, to avoid races
321 close(client.closer)
322 <-client.closed
323
324 client.lock.Lock()
325 defer client.lock.Unlock()
326 DebugLogger.Println("Closing Client")
327
328 for _, broker := range client.brokers {
329 safeAsyncClose(broker)
330 }
331
332 for _, broker := range client.seedBrokers {
333 safeAsyncClose(broker)
334 }
335
336 client.brokers = nil
337 client.metadata = nil
338 client.metadataTopics = nil
339
340 return nil
341}
342
343func (client *client) Closed() bool {
344 client.lock.RLock()

Callers 1

NewClientFunction · 0.95

Calls 4

ClosedMethod · 0.95
safeAsyncCloseFunction · 0.85
PrintfMethod · 0.65
PrintlnMethod · 0.65

Tested by

no test coverage detected