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


Golang tribrpc.GetSubscriptionsReply类代码示例

本文整理汇总了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
}
开发者ID:oldady,项目名称:ds_p2,代码行数:25,代码来源:tribserver_impl.go

示例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
}
开发者ID:wentianqi7,项目名称:15640-distributed-systems,代码行数:13,代码来源:tribserver_impl.go

示例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
}
开发者ID:thuhujin,项目名称:Tribbler,代码行数:15,代码来源:tribserver_impl.go

示例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
}
开发者ID:jbuckman,项目名称:p2-440,代码行数:15,代码来源:tribserver_impl.go

示例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
	}
}
开发者ID:pyurky,项目名称:p2,代码行数:23,代码来源:tribserver_impl.go

示例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
}
开发者ID:mallocanswer,项目名称:Tribbler,代码行数:23,代码来源:tribserver_impl.go

示例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
}
开发者ID:iedwardwangi,项目名称:Tribbler,代码行数:24,代码来源:tribserver_impl.go

示例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
}
开发者ID:oldady,项目名称:Tribbler,代码行数:22,代码来源:tribserver_impl.go

示例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
}
开发者ID:201101050424,项目名称:Tribbler,代码行数:23,代码来源:tribserver_impl.go

示例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
}
开发者ID:aditij1,项目名称:p2aditijakkamat,代码行数:62,代码来源:tribserver_impl.go


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