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


Golang backend.BatchTx類代碼示例

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


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

示例1: putUser

func putUser(tx backend.BatchTx, user *authpb.User) {
	b, err := user.Marshal()
	if err != nil {
		plog.Panicf("failed to marshal user struct (name: %s): %s", user.Name, err)
	}
	tx.UnsafePut(authUsersBucketName, user.Name, b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:7,代碼來源:store.go

示例2: 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

示例3: putRole

func putRole(tx backend.BatchTx, role *authpb.Role) {
	b, err := role.Marshal()
	if err != nil {
		plog.Panicf("failed to marshal role struct (name: %s): %s", role.Name, err)
	}

	tx.UnsafePut(authRolesBucketName, []byte(role.Name), b)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:8,代碼來源:store.go

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: commitRevision

func (as *authStore) commitRevision(tx backend.BatchTx) {
	as.revision++
	revBytes := make([]byte, revBytesLen)
	binary.BigEndian.PutUint64(revBytes, as.revision)
	tx.UnsafePut(authBucketName, revisionKey, revBytes)
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:6,代碼來源:store.go

示例9: delRole

func delRole(tx backend.BatchTx, rolename string) {
	tx.UnsafeDelete(authRolesBucketName, []byte(rolename))
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:3,代碼來源:store.go

示例10: delUser

func delUser(tx backend.BatchTx, username string) {
	tx.UnsafeDelete(authUsersBucketName, []byte(username))
}
開發者ID:luizbafilho,項目名稱:fusis,代碼行數:3,代碼來源:store.go


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