本文整理匯總了Golang中qpid/apache/org/proton.Event.Injecter方法的典型用法代碼示例。如果您正苦於以下問題:Golang Event.Injecter方法的具體用法?Golang Event.Injecter怎麽用?Golang Event.Injecter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qpid/apache/org/proton.Event
的用法示例。
在下文中一共展示了Event.Injecter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleMessagingEvent
// HandleMessagingEvent handles an event, called in the handler goroutine.
func (h *handler) HandleMessagingEvent(t proton.MessagingEvent, e proton.Event) {
switch t {
case proton.MStart:
h.injecter = e.Injecter()
case proton.MLinkOpening:
if e.Link().IsReceiver() {
h.startReceiver(e)
} else {
h.startSender(e)
}
case proton.MLinkClosed:
h.linkClosed(e.Link(), e.Link().RemoteCondition().Error())
case proton.MSendable:
if s, ok := h.senders[e.Link()]; ok {
s.sendable() // Signal the send goroutine that we have credit.
} else {
proton.CloseError(e.Link(), amqp.Errorf(amqp.NotFound, "link %s sender not found", e.Link()))
}
case proton.MMessage:
m, err := e.Delivery().Message() // Message() must be called while handling the MMessage event.
if err != nil {
proton.CloseError(e.Link(), err)
break
}
r, ok := h.receivers[e.Link()]
if !ok {
proton.CloseError(e.Link(), amqp.Errorf(amqp.NotFound, "link %s receiver not found", e.Link()))
break
}
// This will not block as AMQP credit is set to the buffer capacity.
r.buffer <- receivedMessage{e.Delivery(), m}
util.Debugf("link %s received %s", e.Link(), util.FormatMessage(m))
case proton.MConnectionClosed, proton.MDisconnected:
for l, _ := range h.receivers {
h.linkClosed(l, nil)
}
for l, _ := range h.senders {
h.linkClosed(l, nil)
}
}
}