Documentation
¶
Overview ¶
Package keyspace provides utilities for keyspace for nextgen TiDB.
Keyspace are used to isolate data and operations, allowing for multi-tenancy in next generation TiDB. Each keyspace represents a logical cluster on top of the underlying physical cluster.
There are two types of keyspace: user keyspace and reserved internal keyspace, currently, only SYSTEM keyspace is reserved for internal use.
SYSTEM keyspace is reserved for system-level services and data, currently, only the DXF service uses this keyspace. As user keyspace depends on SYSTEM keyspace, we need to make sure SYSTEM keyspace exist before user keyspace start serving any user traffic. So for the deployment of nextgen cluster, we need to:
- Deploy PD/TiKV and other components, wait them to be ready to serve TiDB access.
- Deploy SYSTEM keyspace, wait it fully bootstrapped.
- Deploy other user keyspace, they can be deployed concurrently.
During upgrade, we also need to follow above order, i.e. We need to upgrade the SYSTEM keyspace first, then user keyspace.
Note: serverless also use keyspace, and have the special NULL and DEFAULT keyspace, while nextgen hasn't.
Index ¶
- Constants
- Variables
- func BuildAPIContext(keyspaceName string) pd.APIContext
- func GetKeyspaceNameBySettings() (keyspaceName string)
- func GetKeyspaceNameBytesBySettings() []byte
- func IsKeyspaceNameEmpty(keyspaceName string) bool
- func MakeKeyspaceEtcdNamespace(c tikv.Codec) string
- func MakeKeyspaceEtcdNamespaceSlash(c tikv.Codec) string
- func WrapZapcoreWithKeyspace() zap.Option
- type UsernamePolicy
Constants ¶
const ( // System is the keyspace name for SYSTEM keyspace. // see doc.go for more detail. System = "SYSTEM" )
Variables ¶
var CodecV1 = tikv.NewCodecV1(tikv.ModeTxn)
CodecV1 represents api v1 codec.
Functions ¶
func BuildAPIContext ¶
func BuildAPIContext(keyspaceName string) pd.APIContext
BuildAPIContext returns a V1 API context for the default keyspace and a V2 API context scoped to keyspaceName otherwise.
func GetKeyspaceNameBySettings ¶
func GetKeyspaceNameBySettings() (keyspaceName string)
GetKeyspaceNameBySettings is used to get Keyspace name setting.
func GetKeyspaceNameBytesBySettings ¶
func GetKeyspaceNameBytesBySettings() []byte
GetKeyspaceNameBytesBySettings is used to get keyspace name setting as a byte slice.
func IsKeyspaceNameEmpty ¶
IsKeyspaceNameEmpty is used to determine whether keyspaceName is set.
func MakeKeyspaceEtcdNamespace ¶
MakeKeyspaceEtcdNamespace return the keyspace prefix path for etcd namespace
func MakeKeyspaceEtcdNamespaceSlash ¶
MakeKeyspaceEtcdNamespaceSlash return the keyspace prefix path for etcd namespace, and end with a slash.
func WrapZapcoreWithKeyspace ¶
WrapZapcoreWithKeyspace is used to wrap zapcore.Core.
Types ¶
type UsernamePolicy ¶
type UsernamePolicy interface {
// ValidateUsername checks if the username is valid.
ValidateUsername(username string) error
// ValidateUsernameFormat checks if the username is in the expected format.
ValidateUsernameFormat(username string) bool
// GetUsernameVariants returns possible username variants for the given username.
GetUsernameVariants(username string) []string
// GetOriginalUsername returns the username with the current policy prefix removed.
// It returns an empty string when the current policy does not transform the input.
GetOriginalUsername(username string) string
}
UsernamePolicy is the interface for username policy.
func GetUsernamePolicy ¶
func GetUsernamePolicy() UsernamePolicy
GetUsernamePolicy returns the username policy for the current deployment mode.