本文整理匯總了Golang中github.com/netflix/rend/client/common.Prot.GetWithOpaque方法的典型用法代碼示例。如果您正苦於以下問題:Golang Prot.GetWithOpaque方法的具體用法?Golang Prot.GetWithOpaque怎麽用?Golang Prot.GetWithOpaque使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/netflix/rend/client/common.Prot
的用法示例。
在下文中一共展示了Prot.GetWithOpaque方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: worker
func worker(prot common.Prot, rw *bufio.ReadWriter, keys chan []byte, wg *sync.WaitGroup) {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for key := range keys {
curOpCount := atomic.AddUint64(opCount, 1)
if curOpCount%10000 == 0 {
log.Println(curOpCount)
}
valLen := r.Intn(9*1024) + 1024
value := common.RandData(nil, valLen, true)
// continue on even if there's errors here
if err := prot.Set(rw, key, value); err != nil {
log.Println("Error during set:", err.Error())
if err == io.EOF {
log.Println("End of file. Aborting!")
wg.Done()
return
}
}
opaque := r.Int()
// pass the test if the data matches
ret, err := prot.GetWithOpaque(rw, key, opaque)
if err != nil {
log.Println("Error getting data for key", string(key), ":", err.Error())
if err == io.EOF {
log.Println("End of file. Aborting!")
wg.Done()
return
}
continue
}
if !bytes.Equal(value, ret) {
log.Println("Data returned from server does not match!",
"\nData len sent:", len(value),
"\nData len recv:", len(ret))
//log.Println("sent:", string(value))
//log.Println("got:", string(ret))
}
}
wg.Done()
}