func (t *rabbitTransport) handleRspDelivery(delivery amqp.Delivery) { logId := t.logId(delivery) enc := delivery.Headers["Content-Encoding"].(string) switch enc { case "response": rsp := message.NewResponse() t.deliveryToMessage(delivery, rsp) t.inflightReqsM.Lock() rspChan, ok := t.inflightReqs[rsp.Id()] delete(t.inflightReqs, rsp.Id()) t.inflightReqsM.Unlock() if !ok { log.Warnf("[Typhon:RabbitTransport] Could not match response %s to channel", logId) return } timeout := time.NewTimer(chanSendTimeout) defer timeout.Stop() select { case rspChan <- rsp: case <-timeout.C: log.Errorf("[Typhon:RabbitTransport] Could not deliver response %s after %s: receiving channel is full", logId, chanSendTimeout.String()) } default: log.Errorf("[Typhon:RabbitTransport] Cannot handle Content-Encoding \"%s\" as response for %s", enc, logId) } }
func NewResponse() Response { return FromTyphonResponse(tmsg.NewResponse()) }