本文整理汇总了Golang中github.com/cmu440/tribbler/rpc/tribrpc.GetSubscriptionsReply.UserIDs方法的典型用法代码示例。如果您正苦于以下问题:Golang GetSubscriptionsReply.UserIDs方法的具体用法?Golang GetSubscriptionsReply.UserIDs怎么用?Golang GetSubscriptionsReply.UserIDs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cmu440/tribbler/rpc/tribrpc.GetSubscriptionsReply
的用法示例。
在下文中一共展示了GetSubscriptionsReply.UserIDs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
if ts.userExist(args.UserID) == false {
reply.Status = tribrpc.NoSuchUser
return nil
}
UserIDs, err := ts.ls.GetList(util.FormatSubListKey(args.UserID))
if err == nil {
reply.Status = tribrpc.OK
reply.UserIDs = UserIDs
} else {
reply.Status = tribrpc.OK
reply.UserIDs = make([]string, 0)
}
return nil
}
示例2: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
user := args.UserID
_, err := ts.Libstore.Get(user)
switch err {
case nil: // expected case, do nothing
case libstore.ErrorKeyNotFound:
reply.Status = tribrpc.NoSuchUser
return nil
default:
return err
}
subscListKey := makeSubscListKey(user)
userIDs, err := ts.Libstore.GetList(subscListKey)
switch err {
case nil:
case libstore.ErrorKeyNotFound:
userIDs = make([]string, 0)
default:
return err
}
reply.UserIDs = userIDs
reply.Status = tribrpc.OK
return nil
}
示例3: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
UserKey := GenerateUserKey(args.UserID)
_, err := ts.lib.Get(UserKey)
if err != nil {
reply.Status = tribrpc.NoSuchUser
reply.UserIDs = nil
return nil
}
SubsKey := GenerateSubsKey(args.UserID)
SubsList, err := ts.lib.GetList(SubsKey)
if err != nil {
reply.Status = tribrpc.OK
reply.UserIDs = nil
return nil
}
reply.Status = tribrpc.OK
reply.UserIDs = SubsList
return nil
}
示例4: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
subkey := util.FormatSubListKey(args.UserID)
userkey := util.FormatUserKey(args.UserID)
_, userErr := ts.libstore.Get(userkey)
if userErr != nil {
reply.Status = tribrpc.NoSuchUser
} else {
list, _ := ts.libstore.GetList(subkey)
reply.Status = tribrpc.OK
reply.UserIDs = list
}
return nil
}
示例5: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
LOGE.Printf("GetSubscriptions:: args=%s\n", string(marshal(*args)))
userIDKey := GetUserKey(args.UserID)
_, err := ts.lib.Get(userIDKey)
if err != nil {
reply.Status = tribrpc.NoSuchUser
reply.UserIDs = nil
return nil
}
userSubsKey := GetsSubsKey(args.UserID)
userSubsList, err := ts.lib.GetList(userSubsKey)
if err != nil {
reply.Status = tribrpc.OK
reply.UserIDs = nil
return nil
}
reply.Status = tribrpc.OK
reply.UserIDs = userSubsList
LOGE.Printf("GetSubscriptions:: reply=%s\n", string(marshal(reply)))
return nil
}
示例6: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
userkey := util.FormatUserKey(args.UserID)
usersubs := util.FormatSubListKey(args.UserID)
// Make sure user exists
if _, eu := ts.ls.Get(userkey); eu != nil {
reply.Status = tribrpc.NoSuchUser
return nil
}
if lst, err := ts.ls.GetList(usersubs); err == nil {
reply.Status = tribrpc.OK
reply.UserIDs = lst
return nil
} else {
// The user has no subscriptions yet
reply.Status = tribrpc.OK
reply.UserIDs = make([]string, 0)
return nil
}
}
示例7: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
key := util.FormatUserKey(args.UserID)
if ts.checkIfKnown(key) {
sublist_key := util.FormatSubListKey(args.UserID)
sub_ids, err := ts.storage.GetList(sublist_key)
if err != nil {
sub_ids = []string{}
}
reply.UserIDs = sub_ids
reply.Status = tribrpc.OK
} else {
reply.Status = tribrpc.NoSuchUser
}
return nil
}
示例8: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
userid := args.UserID
useridkey := util.FormatUserKey(userid)
_, userExists := ts.ls.Get(useridkey)
if userExists != nil {
reply.Status = tribrpc.NoSuchUser
return nil
}
userSubListKey := util.FormatSubListKey(userid)
nodes, err := ts.ls.GetList(userSubListKey)
if err != nil {
reply.Status = tribrpc.OK
reply.UserIDs = nil
return nil
}
reply.Status = tribrpc.OK
reply.UserIDs = nodes
return nil
}
示例9: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
user_id := util.FormatUserKey(args.UserID)
// If the user_id doesn't exist
// Reture NoSuchUser
_, err := ts.lib_store.Get(user_id)
if err != nil {
fmt.Println("===========", err, "============")
reply.Status = tribrpc.NoSuchUser
return nil
}
user_id_list := util.FormatSubListKey(args.UserID)
user_list, err := ts.lib_store.GetList(user_id_list)
//if err != nil {
// reply.Status = tribrpc.NoSuchUser
// return nil
// }
reply.UserIDs = user_list
reply.Status = tribrpc.OK
return nil
}
示例10: GetSubscriptions
func (ts *tribServer) GetSubscriptions(args *tribrpc.GetSubscriptionsArgs, reply *tribrpc.GetSubscriptionsReply) error {
if DBG {
fmt.Println("-----> GetSubscriptions")
}
/*
formatsublistkey
*/
var thisUsrId string = args.UserID
//check if user present in server
_, err := ts.libStore.Get(util.FormatUserKey(thisUsrId))
if err != nil {
switch err.Error() {
case KEY_NOT_FOUND:
reply.Status = tribrpc.NoSuchUser
return nil
case WRONG_SERVER:
fmt.Println("ERROR: WRONG SERVER in tribserver")
return errors.New("Wrong server contacted!")
default:
fmt.Println("ERROR in tribserver: wrong error message received")
return errors.New("WRONG error message")
}
//user not found
reply.Status = tribrpc.NoSuchUser
//return err
return nil
}
subscrList, err := ts.libStore.GetList(util.FormatSubListKey(thisUsrId))
if err == nil {
reply.Status = tribrpc.OK
reply.UserIDs = subscrList
return nil
}
//error not nil
switch err.Error() {
case KEY_NOT_FOUND:
//User present, no subscriptions
reply.Status = tribrpc.OK
//Empty list of user IDs
reply.UserIDs = make([]string, 0)
return nil
break
case WRONG_SERVER:
fmt.Println("ERROR: WRONG SERVER in tribserver")
return nil
break
default:
fmt.Println("ERROR in tribserver: wrong error message received")
}
return nil
}