Msgs returns an iter.Seq2[*Msg, error] that can be used to iterate over messages. It can only be used with a subscription that has been created with SubscribeSync or QueueSubscribeSync, otherwise it will return an error on the first iteration. The iterator will block until a message is available. T
()
| 29 | // The iterator will block until a message is available. The |
| 30 | // subscription will not be closed when the iterator is done. |
| 31 | func (sub *Subscription) Msgs() iter.Seq2[*Msg, error] { |
| 32 | return func(yield func(*Msg, error) bool) { |
| 33 | for { |
| 34 | msg, err := sub.nextMsgNoTimeout() |
| 35 | if err != nil { |
| 36 | yield(nil, err) |
| 37 | return |
| 38 | } |
| 39 | if !yield(msg, nil) { |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | // MsgsTimeout returns an iter.Seq2[*Msg, error] that can be used to iterate |
| 48 | // over messages. It can only be used with a subscription that has been created |