MCPcopy Create free account
hub / github.com/33cn/chain33 / sendLowTimeout

Method sendLowTimeout

queue/queue.go:270–294  ·  view source on GitHub ↗
(msg *Message, timeout time.Duration)

Source from the content-addressed store, hash-verified

268}
269
270func (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
297func (q *queue) Client() Client {

Callers 1

SendTimeoutMethod · 0.80

Calls 4

isClosedMethod · 0.95
chanSubMethod · 0.95
sendAsynMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected