本文整理汇总了Golang中github.com/zond/god/common.Remote.Go方法的典型用法代码示例。如果您正苦于以下问题:Golang Remote.Go方法的具体用法?Golang Remote.Go怎么用?Golang Remote.Go使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zond/god/common.Remote
的用法示例。
在下文中一共展示了Remote.Go方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findRecent
func (self *Conn) findRecent(operation string, data common.Item) (result *common.Item) {
currentRedundancy := self.ring.Redundancy()
futures := make([]*rpc.Call, currentRedundancy)
results := make([]*common.Item, currentRedundancy)
nodes := make(common.Remotes, currentRedundancy)
nextKey := data.Key
var nextSuccessor *common.Remote
for i := 0; i < currentRedundancy; i++ {
_, _, nextSuccessor = self.ring.Remotes(nextKey)
thisResult := &common.Item{}
nodes[i] = *nextSuccessor
results[i] = thisResult
futures[i] = nextSuccessor.Go(operation, data, thisResult)
nextKey = nextSuccessor.Pos
}
for index, future := range futures {
<-future.Done
if future.Error != nil {
self.removeNode(nodes[index])
return self.findRecent(operation, data)
}
if result == nil || result.Timestamp < results[index].Timestamp {
result = results[index]
}
}
return
}
示例2: mergeRecent
func (self *Conn) mergeRecent(operation string, r common.Range, up bool) (result []common.Item) {
currentRedundancy := self.ring.Redundancy()
futures := make([]*rpc.Call, currentRedundancy)
results := make([]*[]common.Item, currentRedundancy)
nodes := make(common.Remotes, currentRedundancy)
nextKey := r.Key
var nextSuccessor *common.Remote
for i := 0; i < currentRedundancy; i++ {
_, _, nextSuccessor = self.ring.Remotes(nextKey)
var thisResult []common.Item
nodes[i] = *nextSuccessor
results[i] = &thisResult
futures[i] = nextSuccessor.Go(operation, r, &thisResult)
nextKey = nextSuccessor.Pos
}
for index, future := range futures {
<-future.Done
if future.Error != nil {
self.removeNode(nodes[index])
return self.mergeRecent(operation, r, up)
}
}
result = common.MergeItems(results, up)
return
}