MCPcopy Create free account
hub / github.com/PuerkitoBio/fetchbot / Close

Method Close

fetch.go:134–151  ·  view source on GitHub ↗

Close closes the Queue so that no more Commands can be sent. It blocks until the Fetcher drains all pending commands. After the call, the Fetcher is stopped. Attempts to enqueue new URLs after Close has been called will always result in a ErrQueueClosed error.

()

Source from the content-addressed store, hash-verified

132// Attempts to enqueue new URLs after Close has been called will always result in
133// a ErrQueueClosed error.
134func (q *Queue) Close() error {
135 // Make sure it is not already closed, as this is a run-time panic
136 select {
137 case <-q.closed:
138 // Already closed, no-op
139 return nil
140 default:
141 // Close the signal-channel
142 close(q.closed)
143 // Send a nil Command to make sure the processQueue method sees the close signal.
144 q.ch <- nil
145 // Wait for the Fetcher to drain.
146 q.wg.Wait()
147 // Unblock any callers waiting on q.Block
148 close(q.done)
149 return nil
150 }
151}
152
153// Block blocks the current goroutine until the Queue is closed and all pending
154// commands are drained.

Callers 15

CancelMethod · 0.95
TestQueueClosedFunction · 0.80
TestBlockFunction · 0.80
TestSendVariadicFunction · 0.80
TestUserAgentFunction · 0.80
TestSendStringFunction · 0.80
TestFetchDisallowedFunction · 0.80
TestCrawlDelayFunction · 0.80
TestManyCrawlDelaysFunction · 0.80
TestCustomCommandFunction · 0.80
TestFreeIdleHostFunction · 0.80
TestRemoveHostsFunction · 0.80

Calls

no outgoing calls

Tested by 15

TestQueueClosedFunction · 0.64
TestBlockFunction · 0.64
TestSendVariadicFunction · 0.64
TestUserAgentFunction · 0.64
TestSendStringFunction · 0.64
TestFetchDisallowedFunction · 0.64
TestCrawlDelayFunction · 0.64
TestManyCrawlDelaysFunction · 0.64
TestCustomCommandFunction · 0.64
TestFreeIdleHostFunction · 0.64
TestRemoveHostsFunction · 0.64
TestRestartFunction · 0.64