close is used internally to stop the DCP client. Sends any fatal errors to the client's done channel, and closes that channel.
()
| 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. |
| 293 | func (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 |
| 319 | func (dc *DCPClient) getAgentConfig(spec BucketSpec) (*gocbcore.DCPAgentConfig, error) { |
no test coverage detected