當前位置: 首頁>>代碼示例>>Golang>>正文


Golang tribrpc.CreateUserReply類代碼示例

本文整理匯總了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;未經允許,請勿轉載。