本文整理匯總了Golang中github.com/cmu440/tribbler/rpc/tribrpc.GetSubscriptionsReply類的典型用法代碼示例。如果您正苦於以下問題:Golang GetSubscriptionsReply類的具體用法?Golang GetSubscriptionsReply怎麽用?Golang GetSubscriptionsReply使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GetSubscriptionsReply類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
}
示例6: 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
}
示例7: 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
}
示例8: 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
}
示例9: 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
}
示例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
}