• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang tribrpc.CreateUserReply类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cmu440/tribbler/rpc/tribrpc.CreateUserReply的典型用法代码示例。如果您正苦于以下问题:Golang CreateUserReply类的具体用法?Golang CreateUserReply怎么用?Golang CreateUserReply使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CreateUserReply类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	if DBG {
		fmt.Println("-----> CreateUser")
	}
	var usrID string = args.UserID

	_, err := ts.libStore.Get(util.FormatUserKey(usrID))

	if err == nil {
		//user not found
		reply.Status = tribrpc.Exists
		return nil
		//return err
	}

	err = ts.libStore.Put(util.FormatUserKey(usrID), "exists")

	if err != nil {

		return nil
	}

	//populate reply struct
	reply.Status = tribrpc.OK
	return nil
}
开发者ID:aditij1,项目名称:p2aditijakkamat,代码行数:26,代码来源:tribserver_impl.go


示例2: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	if ts.userExist(args.UserID) == true {
		reply.Status = tribrpc.Exists
		return nil
	}
	reply.Status = tribrpc.OK
	ts.ls.Put(util.FormatUserKey(args.UserID), util.FormatUserKey(args.UserID))
	return nil
}
开发者ID:thuhujin,项目名称:Tribbler,代码行数:9,代码来源:tribserver_impl.go


示例3: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {

	user := util.FormatUserKey(args.UserID)

	// Check that this user doesn't already exist
	if _, err := ts.ls.Get(user); err != nil {
		ts.ls.Put(user, user)
		reply.Status = tribrpc.OK
	} else {
		reply.Status = tribrpc.Exists
	}
	return nil
}
开发者ID:pyurky,项目名称:p2,代码行数:13,代码来源:tribserver_impl.go


示例4: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	key := util.FormatUserKey(args.UserID)
	if ts.checkIfKnown(key) {
		reply.Status = tribrpc.Exists
	} else {
		err := ts.storage.Put(key, args.UserID)
		if err != nil {
			return err
		}
		reply.Status = tribrpc.OK
	}
	return nil
}
开发者ID:jbuckman,项目名称:p2-440,代码行数:13,代码来源:tribserver_impl.go


示例5: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {

	key := util.FormatUserKey(args.UserID)
	_, err := ts.libstore.Get(key)

	if err == nil {
		reply.Status = tribrpc.Exists
	} else {
		err2 := ts.libstore.Put(key, key)
		if err2 != nil {
			return err2
		}
		reply.Status = tribrpc.OK
	}

	return nil
}
开发者ID:wentianqi7,项目名称:15640-distributed-systems,代码行数:17,代码来源:tribserver_impl.go


示例6: CreateUser

/*Creating users:
Before a user can either subscribe, add Tribbles, or be subscribed to,it must rst be created using the
CreateUser method. On success, it replies with tribrpc.OK. If the user already is in the system,
it replies with tribrpc.Exists.
There is no interface to delete users (once a user is created, it can never be deleted).*/
func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	LOGE.Printf("CreateUser:: args=%s\n", string(marshal(*args)))
	userIDKey := GetUserKey(args.UserID)
	_, err := ts.lib.Get(userIDKey)
	if err == nil {
		reply.Status = tribrpc.Exists
		return err
	}
	err = ts.lib.Put(userIDKey, args.UserID)
	if err != nil {
		reply.Status = tribrpc.Exists
		return nil
	}
	reply.Status = tribrpc.OK
	LOGE.Printf("CreateUser:: reply=%s\n", string(marshal(reply)))
	return nil
}
开发者ID:201101050424,项目名称:Tribbler,代码行数:22,代码来源:tribserver_impl.go


示例7: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	user_id := util.FormatUserKey(args.UserID)

	_, err := ts.lib_store.Get(user_id)
	if err == nil {
		reply.Status = tribrpc.Exists
		return nil
	}

	err = ts.lib_store.Put(user_id, args.UserID)
	if err != nil {
		reply.Status = tribrpc.Exists
		return err
	}
	reply.Status = tribrpc.OK
	return nil
}
开发者ID:mallocanswer,项目名称:Tribbler,代码行数:17,代码来源:tribserver_impl.go


示例8: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	userid := args.UserID
	useridkey := util.FormatUserKey(userid)
	_, err := ts.ls.Get(useridkey)

	if err == nil {
		reply.Status = tribrpc.Exists
		return nil
	}

	err2 := ts.ls.Put(useridkey, userid)
	if err2 != nil {
		reply.Status = tribrpc.Exists
		return err2
	}

	reply.Status = tribrpc.OK
	return nil
}
开发者ID:iedwardwangi,项目名称:Tribbler,代码行数:19,代码来源:tribserver_impl.go


示例9: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	_, err := ts.Libstore.Get(args.UserID)
	if err == nil {
		reply.Status = tribrpc.Exists
		return nil
	}
	switch err {
	case libstore.ErrorKeyNotFound: // expected error, do nothing
	default:
		return err
	}

	err = ts.Libstore.Put(args.UserID, "")
	if err != nil {
		return err
	}

	reply.Status = tribrpc.OK
	return nil
}
开发者ID:oldady,项目名称:ds_p2,代码行数:20,代码来源:tribserver_impl.go


示例10: CreateUser

func (ts *tribServer) CreateUser(args *tribrpc.CreateUserArgs, reply *tribrpc.CreateUserReply) error {
	// generate user key
	UserKey := GenerateUserKey(args.UserID)

	// check if same user exists
	_, err := ts.lib.Get(UserKey)
	if err == nil {
		reply.Status = tribrpc.Exists
		return nil
	}

	// put username in the storage
	err = ts.lib.Put(UserKey, args.UserID)
	if err != nil {
		reply.Status = tribrpc.Exists
		return nil
	}

	reply.Status = tribrpc.OK
	return nil
}
开发者ID:oldady,项目名称:Tribbler,代码行数:21,代码来源:tribserver_impl.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang tribrpc.DeleteTribbleReply类代码示例发布时间:2022-05-23
下一篇:
Golang storagerpc.RevokeLeaseReply类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap