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


Golang BatchTx.UnsafeRange方法代碼示例

本文整理匯總了Golang中github.com/coreos/etcd/mvcc/backend.BatchTx.UnsafeRange方法的典型用法代碼示例。如果您正苦於以下問題:Golang BatchTx.UnsafeRange方法的具體用法?Golang BatchTx.UnsafeRange怎麽用?Golang BatchTx.UnsafeRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/coreos/etcd/mvcc/backend.BatchTx的用法示例。


在下文中一共展示了BatchTx.UnsafeRange方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getRevision

func getRevision(tx backend.BatchTx) uint64 {
	_, vs := tx.UnsafeRange(authBucketName, []byte(revisionKey), nil, 0)
	if len(vs) != 1 {
		plog.Panicf("failed to get the key of auth store revision")
	}

	return binary.BigEndian.Uint64(vs[0])
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:8,代碼來源:store.go

示例2: getRole

func getRole(tx backend.BatchTx, rolename string) *authpb.Role {
	_, vs := tx.UnsafeRange(authRolesBucketName, []byte(rolename), nil, 0)
	if len(vs) == 0 {
		return nil
	}

	role := &authpb.Role{}
	err := role.Unmarshal(vs[0])
	if err != nil {
		plog.Panicf("failed to unmarshal role struct (name: %s): %s", rolename, err)
	}
	return role
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:13,代碼來源:store.go

示例3: getUser

func getUser(tx backend.BatchTx, username string) *authpb.User {
	_, vs := tx.UnsafeRange(authUsersBucketName, []byte(username), nil, 0)
	if len(vs) == 0 {
		return nil
	}

	user := &authpb.User{}
	err := user.Unmarshal(vs[0])
	if err != nil {
		plog.Panicf("failed to unmarshal user struct (name: %s): %s", username, err)
	}
	return user
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:13,代碼來源:store.go

示例4: getAllRoles

func getAllRoles(tx backend.BatchTx) []*authpb.Role {
	_, vs := tx.UnsafeRange(authRolesBucketName, []byte{0}, []byte{0xff}, -1)
	if len(vs) == 0 {
		return nil
	}

	var roles []*authpb.Role

	for _, v := range vs {
		role := &authpb.Role{}
		err := role.Unmarshal(v)
		if err != nil {
			plog.Panicf("failed to unmarshal role struct: %s", err)
		}

		roles = append(roles, role)
	}

	return roles
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:20,代碼來源:store.go

示例5: getAllUsers

func getAllUsers(tx backend.BatchTx) []*authpb.User {
	_, vs := tx.UnsafeRange(authUsersBucketName, []byte{0}, []byte{0xff}, -1)
	if len(vs) == 0 {
		return nil
	}

	var users []*authpb.User

	for _, v := range vs {
		user := &authpb.User{}
		err := user.Unmarshal(v)
		if err != nil {
			plog.Panicf("failed to unmarshal user struct: %s", err)
		}

		users = append(users, user)
	}

	return users
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:20,代碼來源:store.go


注:本文中的github.com/coreos/etcd/mvcc/backend.BatchTx.UnsafeRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。