本文整理汇总了Golang中github.com/cmu440/tribbler/rpc/storagerpc.PutArgs.Key方法的典型用法代码示例。如果您正苦于以下问题:Golang PutArgs.Key方法的具体用法?Golang PutArgs.Key怎么用?Golang PutArgs.Key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cmu440/tribbler/rpc/storagerpc.PutArgs
的用法示例。
在下文中一共展示了PutArgs.Key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AppendToList
func (ls *libstore) AppendToList(key, newItem string) error {
var args storagerpc.PutArgs
var reply storagerpc.PutReply
args.Key = key
args.Value = newItem
// pick the right server
cli, err := ls.GetServer(key)
if err != nil {
return err
}
// call rpc to storage server
err = cli.Call("StorageServer.AppendToList", &args, &reply)
if err != nil {
return err
}
// check the reply status
if reply.Status != storagerpc.OK {
err = GetErrorType(reply.Status)
return err
}
return nil
}
示例2: Put
func (ls *libstore) Put(key, value string) error {
// Get the right server
cli, err := ls.GetServer(key)
if err != nil {
return err
}
var args storagerpc.PutArgs
var reply storagerpc.PutReply
args.Key = key
args.Value = value
// call rpc put to storage server
err = cli.Call("StorageServer.Put", &args, &reply)
if err != nil {
return err
}
if reply.Status != storagerpc.OK {
err = GetErrorType(reply.Status)
return err
}
return nil
}
示例3: AppendToList
func (ls *libstore) AppendToList(key, newItem string) error {
var args storagerpc.PutArgs
var reply storagerpc.PutReply
args.Key = key
args.Value = newItem
target_server := ls.GetServerIndex(key)
ls.rpc_connection[target_server].Call("StorageServer.AppendToList", args, &reply)
if reply.Status != storagerpc.OK {
return errors.New("Error in AppendToList")
}
return nil
}
示例4: Put
func (ls *libstore) Put(key, value string) error {
var args storagerpc.PutArgs
var reply storagerpc.PutReply
args.Key = key
args.Value = value
target_server := ls.GetServerIndex(key)
ls.rpc_connection[target_server].Call("StorageServer.Put", args, &reply)
if reply.Status != storagerpc.OK {
return errors.New("Error in put operation")
}
return nil
}
示例5: RemoveFromList
func (ls *libstore) RemoveFromList(key, removeItem string) error {
var args storagerpc.PutArgs
var reply storagerpc.PutReply
args.Key = key
args.Value = removeItem
target_server := ls.GetServerIndex(key)
ls.rpc_connection[target_server].Call("StorageServer.RemoveFromList", args, &reply)
if reply.Status != storagerpc.OK {
return errors.New("Error in RemoveFromList")
} else {
return nil
}
}
示例6: RemoveFromList
func (ls *libstore) RemoveFromList(key, removeItem string) error {
var args storagerpc.PutArgs
var reply storagerpc.PutReply
args.Key = key
args.Value = removeItem
cli, err := ls.GetServer(key)
if err != nil {
return err
}
err = cli.Call("StorageServer.RemoveFromList", &args, &reply)
if err != nil {
return err
}
if reply.Status != storagerpc.OK {
err = GetErrorType(reply.Status)
return err
}
return nil
}