(msg *Message, timeout time.Duration)
| 268 | } |
| 269 | |
| 270 | func (q *queue) sendLowTimeout(msg *Message, timeout time.Duration) error { |
| 271 | if q.isClosed() { |
| 272 | return types.ErrChannelClosed |
| 273 | } |
| 274 | sub := q.chanSub(msg.Topic) |
| 275 | if sub.isClose == 1 { |
| 276 | return types.ErrChannelClosed |
| 277 | } |
| 278 | if timeout == -1 { |
| 279 | sub.low <- msg |
| 280 | return nil |
| 281 | } |
| 282 | if timeout == 0 { |
| 283 | return q.sendAsyn(msg) |
| 284 | } |
| 285 | t := time.NewTimer(timeout) |
| 286 | defer t.Stop() |
| 287 | select { |
| 288 | case sub.low <- msg: |
| 289 | return nil |
| 290 | case <-t.C: |
| 291 | qlog.Error("send asyn timeout", "msg", msg) |
| 292 | return ErrQueueTimeout |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // Client new client |
| 297 | func (q *queue) Client() Client { |
no test coverage detected