本文整理汇总了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)
}
}
}