Documentation
¶
Index ¶
- Variables
- func WithRUStats(op *GetResourceGroupOp)
- type APIContext
- type APIVersion
- type Client
- func NewClient(callerComponent caller.Component, svrAddrs []string, security SecurityOption, ...) (Client, error)
- func NewClientWithAPIContext(ctx context.Context, apiCtx APIContext, callerComponent caller.Component, ...) (Client, error)
- func NewClientWithContext(ctx context.Context, callerComponent caller.Component, svrAddrs []string, ...) (Client, error)
- func NewClientWithKeyspace(ctx context.Context, callerComponent caller.Component, keyspaceID uint32, ...) (Client, error)
- type GCClient
- type GetResourceGroupOp
- type GetResourceGroupOption
- type GlobalConfigItem
- type KeyspaceClient
- type RPCClient
- type ResourceManagerClient
- type SecurityOption
Constants ¶
This section is empty.
Variables ¶
var ControllerConfigPathPrefixBytes = []byte(controllerConfigPathPrefix)
ControllerConfigPathPrefixBytes is used to watch or get controller config.
var GroupSettingsPathPrefixBytes = []byte(groupSettingsPathPrefix)
GroupSettingsPathPrefixBytes is used to watch or get resource groups.
Functions ¶
func WithRUStats ¶
func WithRUStats(op *GetResourceGroupOp)
WithRUStats specifies to return resource group with ru statistics data.
Types ¶
type APIContext ¶
type APIContext interface { GetAPIVersion() (apiVersion APIVersion) GetKeyspaceName() (keyspaceName string) }
APIContext is the context for API version.
func NewAPIContextV1 ¶
func NewAPIContextV1() APIContext
NewAPIContextV1 creates a API context for V1.
func NewAPIContextV2 ¶
func NewAPIContextV2(keyspaceName string) APIContext
NewAPIContextV2 creates a API context with the specified keyspace name for V2.
type APIVersion ¶
type APIVersion int
APIVersion is the API version the server and the client is using. See more details in https://github.com/tikv/rfcs/blob/master/text/0069-api-v2.md#kvproto
const ( V1 APIVersion = iota V2 )
The API versions the client supports. As for V1TTL, client won't use it and we just remove it.
type Client ¶
type Client interface { RPCClient // GetClusterID gets the cluster ID from PD. GetClusterID(ctx context.Context) uint64 // GetLeaderURL returns current leader's URL. It returns "" before // syncing leader from server. GetLeaderURL() string // GetServiceDiscovery returns ServiceDiscovery GetServiceDiscovery() sd.ServiceDiscovery // UpdateOption updates the client option. UpdateOption(option opt.DynamicOption, value any) error // WithCallerComponent returns a new Client with the specified caller // component. Caller component refers to the specific part or module within // the process. You can set the component in two ways: // * Define it manually, like `caller.Component("DDL")`. // * Use the provided helper function, `caller.GetComponent(upperLayer)`. // The upperLayer parameter specifies the depth of the caller stack, // where 0 means the current function. Adjust the upperLayer value based // on your needs. WithCallerComponent(callerComponent caller.Component) Client // Close closes the client. Close() }
Client is a PD (Placement Driver) RPC client. It should not be used after calling Close().
func NewClient ¶
func NewClient( callerComponent caller.Component, svrAddrs []string, security SecurityOption, opts ...opt.ClientOption, ) (Client, error)
NewClient creates a PD client.
func NewClientWithAPIContext ¶
func NewClientWithAPIContext( ctx context.Context, apiCtx APIContext, callerComponent caller.Component, svrAddrs []string, security SecurityOption, opts ...opt.ClientOption, ) (Client, error)
NewClientWithAPIContext creates a client according to the API context.
func NewClientWithContext ¶
func NewClientWithContext( ctx context.Context, callerComponent caller.Component, svrAddrs []string, security SecurityOption, opts ...opt.ClientOption, ) (Client, error)
NewClientWithContext creates a PD client with context. This API uses the default keyspace id 0.
func NewClientWithKeyspace ¶
func NewClientWithKeyspace( ctx context.Context, callerComponent caller.Component, keyspaceID uint32, svrAddrs []string, security SecurityOption, opts ...opt.ClientOption, ) (Client, error)
NewClientWithKeyspace creates a client with context and the specified keyspace id. And now, it's only for test purpose.
type GCClient ¶
type GCClient interface { UpdateGCSafePointV2(ctx context.Context, keyspaceID uint32, safePoint uint64) (uint64, error) UpdateServiceSafePointV2(ctx context.Context, keyspaceID uint32, serviceID string, ttl int64, safePoint uint64) (uint64, error) WatchGCSafePointV2(ctx context.Context, revision int64) (chan []*pdpb.SafePointEvent, error) }
GCClient is a client for doing GC
type GetResourceGroupOp ¶
type GetResourceGroupOp struct {
// contains filtered or unexported fields
}
GetResourceGroupOp represents available options when getting resource group.
type GetResourceGroupOption ¶
type GetResourceGroupOption func(*GetResourceGroupOp)
GetResourceGroupOption configures GetResourceGroupOp.
type GlobalConfigItem ¶
GlobalConfigItem standard format of KV pair in GlobalConfig client
type KeyspaceClient ¶
type KeyspaceClient interface { // LoadKeyspace load and return target keyspace's metadata. LoadKeyspace(ctx context.Context, name string) (*keyspacepb.KeyspaceMeta, error) // UpdateKeyspaceState updates target keyspace's state. UpdateKeyspaceState(ctx context.Context, id uint32, state keyspacepb.KeyspaceState) (*keyspacepb.KeyspaceMeta, error) // WatchKeyspaces watches keyspace meta changes. WatchKeyspaces(ctx context.Context) (chan []*keyspacepb.KeyspaceMeta, error) // GetAllKeyspaces get all keyspace's metadata. GetAllKeyspaces(ctx context.Context, startID uint32, limit uint32) ([]*keyspacepb.KeyspaceMeta, error) }
KeyspaceClient manages keyspace metadata.
type RPCClient ¶
type RPCClient interface { // GetAllMembers gets the members Info from PD GetAllMembers(ctx context.Context) ([]*pdpb.Member, error) // GetStore gets a store from PD by store id. // The store may expire later. Caller is responsible for caching and taking care // of store change. GetStore(ctx context.Context, storeID uint64) (*metapb.Store, error) // GetAllStores gets all stores from pd. // The store may expire later. Caller is responsible for caching and taking care // of store change. GetAllStores(ctx context.Context, opts ...opt.GetStoreOption) ([]*metapb.Store, error) // UpdateGCSafePoint TiKV will check it and do GC themselves if necessary. // If the given safePoint is less than the current one, it will not be updated. // Returns the new safePoint after updating. UpdateGCSafePoint(ctx context.Context, safePoint uint64) (uint64, error) // UpdateServiceGCSafePoint updates the safepoint for specific service and // returns the minimum safepoint across all services, this value is used to // determine the safepoint for multiple services, it does not trigger a GC // job. Use UpdateGCSafePoint to trigger the GC job if needed. UpdateServiceGCSafePoint(ctx context.Context, serviceID string, ttl int64, safePoint uint64) (uint64, error) // ScatterRegion scatters the specified region. Should use it for a batch of regions, // and the distribution of these regions will be dispersed. // NOTICE: This method is the old version of ScatterRegions, you should use the later one as your first choice. ScatterRegion(ctx context.Context, regionID uint64) error // ScatterRegions scatters the specified regions. Should use it for a batch of regions, // and the distribution of these regions will be dispersed. ScatterRegions(ctx context.Context, regionsID []uint64, opts ...opt.RegionsOption) (*pdpb.ScatterRegionResponse, error) // SplitRegions split regions by given split keys SplitRegions(ctx context.Context, splitKeys [][]byte, opts ...opt.RegionsOption) (*pdpb.SplitRegionsResponse, error) // SplitAndScatterRegions split regions by given split keys and scatter new regions SplitAndScatterRegions(ctx context.Context, splitKeys [][]byte, opts ...opt.RegionsOption) (*pdpb.SplitAndScatterRegionsResponse, error) // GetOperator gets the status of operator of the specified region. GetOperator(ctx context.Context, regionID uint64) (*pdpb.GetOperatorResponse, error) // LoadGlobalConfig gets the global config from etcd LoadGlobalConfig(ctx context.Context, names []string, configPath string) ([]GlobalConfigItem, int64, error) // StoreGlobalConfig set the config from etcd StoreGlobalConfig(ctx context.Context, configPath string, items []GlobalConfigItem) error // WatchGlobalConfig returns a stream with all global config and updates WatchGlobalConfig(ctx context.Context, configPath string, revision int64) (chan []GlobalConfigItem, error) // GetExternalTimestamp returns external timestamp GetExternalTimestamp(ctx context.Context) (uint64, error) // SetExternalTimestamp sets external timestamp SetExternalTimestamp(ctx context.Context, timestamp uint64) error router.Client tso.Client metastorage.Client // KeyspaceClient manages keyspace metadata. KeyspaceClient // GCClient manages gcSafePointV2 and serviceSafePointV2 GCClient // ResourceManagerClient manages resource group metadata and token assignment. ResourceManagerClient }
RPCClient is a PD (Placement Driver) RPC and related mcs client which can only call RPC.
type ResourceManagerClient ¶
type ResourceManagerClient interface { ListResourceGroups(ctx context.Context, opts ...GetResourceGroupOption) ([]*rmpb.ResourceGroup, error) GetResourceGroup(ctx context.Context, resourceGroupName string, opts ...GetResourceGroupOption) (*rmpb.ResourceGroup, error) AddResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceGroup) (string, error) ModifyResourceGroup(ctx context.Context, metaGroup *rmpb.ResourceGroup) (string, error) DeleteResourceGroup(ctx context.Context, resourceGroupName string) (string, error) LoadResourceGroups(ctx context.Context) ([]*rmpb.ResourceGroup, int64, error) AcquireTokenBuckets(ctx context.Context, request *rmpb.TokenBucketsRequest) ([]*rmpb.TokenBucketResponse, error) Watch(ctx context.Context, key []byte, opts ...opt.MetaStorageOption) (chan []*meta_storagepb.Event, error) }
ResourceManagerClient manages resource group info and token request.