本文整理匯總了Golang中proto-ascent/msg.Header.GetResponse方法的典型用法代碼示例。如果您正苦於以下問題:Golang Header.GetResponse方法的具體用法?Golang Header.GetResponse怎麽用?Golang Header.GetResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類proto-ascent/msg.Header
的用法示例。
在下文中一共展示了Header.GetResponse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: DispatchResponse
// DispatchResponse enqueues an incoming response into the response channel for
// the corresponding request.
//
// header: Message header for the response.
//
// data: User data in the response message.
//
// Returns nil on success.
func (this *Messenger) DispatchResponse(header *msgpb.Header,
data []byte) error {
lock, errLock := this.ctlr.Lock("this.requestMap")
if errLock != nil {
return errLock
}
defer lock.Unlock()
response := header.GetResponse()
requestID := response.GetRequestId()
responseCh, found := this.requestMap[requestID]
if !found {
this.Errorf("could not find request %d to dispatch response %s",
requestID, header)
return errs.ErrNotExist
}
// Close the lock early to release the resources.
lock.Unlock()
entry := &Entry{header: header, data: data}
select {
case responseCh <- entry:
return nil
default:
this.Errorf("could not queue response %s to request %d", header,
requestID)
return errs.ErrOverflow
}
}