本文整理匯總了Golang中github.com/Wikia/influxdb/protocol.Request.GetDescription方法的典型用法代碼示例。如果您正苦於以下問題:Golang Request.GetDescription方法的具體用法?Golang Request.GetDescription怎麽用?Golang Request.GetDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/Wikia/influxdb/protocol.Request
的用法示例。
在下文中一共展示了Request.GetDescription方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: forwardRequest
func (self *ShardData) forwardRequest(request *p.Request) ([]<-chan *p.Response, []uint32, error) {
ids := []uint32{}
responses := []<-chan *p.Response{}
for _, server := range self.clusterServers {
responseChan := make(chan *p.Response, 1)
// do this so that a new id will get assigned
request.Id = nil
log.Debug("Forwarding request %s to %d", request.GetDescription(), server.Id)
server.MakeRequest(request, responseChan)
responses = append(responses, responseChan)
ids = append(ids, server.Id)
}
return responses, ids, nil
}
示例2: HandleDestructiveQuery
func (self *ShardData) HandleDestructiveQuery(querySpec *parser.QuerySpec, request *p.Request, response chan<- *p.Response, runLocalOnly bool) {
if !self.IsLocal && runLocalOnly {
panic("WTF islocal is false and runLocalOnly is true")
}
responseChannels := []<-chan *p.Response{}
serverIds := []uint32{}
if self.IsLocal {
err := self.deleteDataLocally(querySpec)
if err != nil {
msg := err.Error()
log.Error(msg)
response <- &p.Response{
Type: p.Response_ERROR.Enum(),
ErrorMessage: &msg,
}
return
}
}
log.Debug("request %s, runLocalOnly: %v", request.GetDescription(), runLocalOnly)
if !runLocalOnly {
responses, ids, _ := self.forwardRequest(request)
serverIds = append(serverIds, ids...)
responseChannels = append(responseChannels, responses...)
}
var errorResponse *p.Response
for idx, channel := range responseChannels {
serverId := serverIds[idx]
log.Debug("Waiting for response to %s from %d", request.GetDescription(), serverId)
for {
res := <-channel
log.Debug("Received %s response from %d for %s", res.GetType(), serverId, request.GetDescription())
if res.GetType() == p.Response_END_STREAM {
break
}
// don't send the access denied response until the end so the readers don't close out before the other responses.
// See https://github.com/Wikia/influxdb/issues/316 for more info.
if res.GetType() != p.Response_ERROR {
response <- res
} else if errorResponse == nil {
errorResponse = res
}
}
}
if errorResponse != nil {
response <- errorResponse
return
}
response <- &p.Response{Type: p.Response_END_STREAM.Enum()}
}