Send enqueues a Command into the Fetcher. If the Queue has been closed, it returns ErrQueueClosed. The Command's URL must have a Host.
(c Command)
| 181 | // Send enqueues a Command into the Fetcher. If the Queue has been closed, it |
| 182 | // returns ErrQueueClosed. The Command's URL must have a Host. |
| 183 | func (q *Queue) Send(c Command) error { |
| 184 | if c == nil { |
| 185 | return ErrEmptyHost |
| 186 | } |
| 187 | if u := c.URL(); u == nil || u.Host == "" { |
| 188 | return ErrEmptyHost |
| 189 | } |
| 190 | select { |
| 191 | case <-q.closed: |
| 192 | return ErrQueueClosed |
| 193 | default: |
| 194 | q.ch <- c |
| 195 | } |
| 196 | return nil |
| 197 | } |
| 198 | |
| 199 | // SendString enqueues a method and some URL strings into the Fetcher. It returns an error |
| 200 | // if the URL string cannot be parsed, or if the Queue has been closed. |