当前位置: 首页>>代码示例>>Golang>>正文


Golang common.Remote类代码示例

本文整理汇总了Golang中github.com/zond/god/common.Remote的典型用法代码示例。如果您正苦于以下问题:Golang Remote类的具体用法?Golang Remote怎么用?Golang Remote使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Remote类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:baeeq,项目名称:god,代码行数:25,代码来源:client.go

示例2: 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
}
开发者ID:baeeq,项目名称:god,代码行数:27,代码来源:client.go

示例3: putVia

func (self *Conn) putVia(succ *common.Remote, key, value []byte, sync bool) {
	data := common.Item{
		Key:   key,
		Value: value,
		Sync:  sync,
	}
	var x int
	if err := succ.Call("DHash.Put", data, &x); err != nil {
		self.removeNode(*succ)
		_, _, newSuccessor := self.ring.Remotes(key)
		*succ = *newSuccessor
		self.putVia(succ, key, value, sync)
	}
}
开发者ID:baeeq,项目名称:god,代码行数:14,代码来源:client.go


注:本文中的github.com/zond/god/common.Remote类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。