MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / close

Method close

base/dcp_client.go:293–316  ·  view source on GitHub ↗

close is used internally to stop the DCP client. Sends any fatal errors to the client's done channel, and closes that channel.

()

Source from the content-addressed store, hash-verified

291// close is used internally to stop the DCP client. Sends any fatal errors to the client's done channel, and
292// closes that channel.
293func (dc *DCPClient) close() {
294
295 // set dc.closing to true, avoid re-triggering close if it's already in progress
296 if !dc.closing.CompareAndSwap(false, true) {
297 InfofCtx(dc.ctx, KeyDCP, "DCP Client close called - client is already closing")
298 return
299 }
300
301 // Stop workers
302 close(dc.terminator)
303 if dc.agent != nil {
304 agentErr := dc.agent.Close()
305 if agentErr != nil {
306 WarnfCtx(dc.ctx, "Error closing DCP agent in client close: %v", agentErr)
307 }
308 }
309
310 // Wait for all workers to finish before closing doneChannel
311 go func() {
312 dc.workersWg.Wait()
313 dc.doneChannel <- dc.getCloseError()
314 close(dc.doneChannel)
315 }()
316}
317
318// getAgentConfig returns a gocbcore.DCPAgentConfig for the given BucketSpec
319func (dc *DCPClient) getAgentConfig(spec BucketSpec) (*gocbcore.DCPAgentConfig, error) {

Callers 7

CloseMethod · 0.95
deactivateVbucketMethod · 0.95
fatalErrorMethod · 0.95
executeMethod · 0.45
close_all_filesMethod · 0.45
__make_zipMethod · 0.45
CloseMethod · 0.45

Calls 6

getCloseErrorMethod · 0.95
WarnfCtxFunction · 0.85
CompareAndSwapMethod · 0.80
InfofCtxFunction · 0.70
CloseMethod · 0.65
WaitMethod · 0.45

Tested by

no test coverage detected