Documentation
¶
Index ¶
- Constants
- Variables
- func ConvertNodeToPB(node *RegisteredNode) *clusterpb.Node
- func ConvertShardsInfoToPB(shard *ShardInfo) *metaservicepb.ShardInfo
- func ConvertTableInfoToPB(table *TableInfo) *metaservicepb.TableInfo
- type Cluster
- func (c *Cluster) AllocShardID(ctx context.Context) (uint32, error)
- func (c *Cluster) CreateShardTopologies(ctx context.Context, state clusterpb.ClusterTopology_ClusterState, ...) error
- func (c *Cluster) CreateTable(ctx context.Context, nodeName string, schemaName string, tableName string) (*CreateTableResult, error)
- func (c *Cluster) DropTable(ctx context.Context, schemaName, tableName string) (*DropTableResult, error)
- func (c *Cluster) GetClusterID() uint32
- func (c *Cluster) GetClusterMinNodeCount() uint32
- func (c *Cluster) GetClusterShardView() ([]*clusterpb.Shard, error)
- func (c *Cluster) GetClusterState() clusterpb.ClusterTopology_ClusterState
- func (c *Cluster) GetClusterVersion() uint64
- func (c *Cluster) GetNodeShards(_ context.Context) (*GetNodeShardsResult, error)
- func (c *Cluster) GetOrCreateSchema(ctx context.Context, schemaName string) (*Schema, bool, error)
- func (c *Cluster) GetRegisteredNode(nodeName string) (*RegisteredNode, bool)
- func (c *Cluster) GetRegisteredNodes() []*RegisteredNode
- func (c *Cluster) GetShardByID(id uint32) (*Shard, error)
- func (c *Cluster) GetShardIDsByNode(nodeName string) ([]uint32, error)
- func (c *Cluster) GetTable(ctx context.Context, schemaName, tableName string) (*Table, bool, error)
- func (c *Cluster) GetTables(_ context.Context, shardIDs []uint32, nodeName string) (map[uint32]*ShardTablesWithRole, error)
- func (c *Cluster) GetTotalShardNum() uint32
- func (c *Cluster) Load(ctx context.Context) error
- func (c *Cluster) Name() string
- func (c *Cluster) RegisterNode(ctx context.Context, nodeInfo *metaservicepb.NodeInfo) error
- func (c *Cluster) RouteTables(_ context.Context, schemaName string, tableNames []string) (*RouteTablesResult, error)
- type CreateTableResult
- type DropTableResult
- type GetNodeShardsResult
- type Manager
- type NodeShard
- type RegisteredNode
- type RouteEntry
- type RouteTablesResult
- type Schema
- type Shard
- type ShardInfo
- type ShardTables
- type ShardTablesWithRole
- type ShardVersionUpdate
- type ShardsOfNode
- type Table
- type TableInfo
Constants ¶
View Source
const ( AllocClusterIDPrefix = "ClusterID" AllocSchemaIDPrefix = "SchemaID" AllocTableIDPrefix = "TableID" )
View Source
const (
MinShardID = 0
)
Variables ¶
View Source
var ( ErrCreateCluster = coderr.NewCodeError(coderr.BadRequest, "create cluster") ErrClusterAlreadyExists = coderr.NewCodeError(coderr.ClusterAlreadyExists, "cluster already exists") ErrClusterStateInvalid = coderr.NewCodeError(coderr.Internal, "cluster state invalid") ErrClusterNotFound = coderr.NewCodeError(coderr.NotFound, "cluster not found") ErrClusterTopologyNotFound = coderr.NewCodeError(coderr.NotFound, "cluster topology not found") ErrSchemaNotFound = coderr.NewCodeError(coderr.NotFound, "schema not found") ErrTableNotFound = coderr.NewCodeError(coderr.NotFound, "Table not found") ErrShardNotFound = coderr.NewCodeError(coderr.NotFound, "shard not found") ErrNodeNotFound = coderr.NewCodeError(coderr.NotFound, "node not found") ErrNodeIsEmpty = coderr.NewCodeError(coderr.NotFound, "cluster nodes list is empty") ErrShardListIsEmpty = coderr.NewCodeError(coderr.NotFound, "cluster shard list is empty") ErrNodeShardsIsEmpty = coderr.NewCodeError(coderr.Internal, "node's shard list is empty") ErrGetShardTopology = coderr.NewCodeError(coderr.Internal, "get shard topology") ErrTableAlreadyExists = coderr.NewCodeError(coderr.Internal, "table already exists") ErrShardTopologyVersionNotMatch = coderr.NewCodeError(coderr.Internal, "shard topology version not match") )
Functions ¶
func ConvertNodeToPB ¶ added in v0.4.0
func ConvertNodeToPB(node *RegisteredNode) *clusterpb.Node
func ConvertShardsInfoToPB ¶ added in v0.4.0
func ConvertShardsInfoToPB(shard *ShardInfo) *metaservicepb.ShardInfo
func ConvertTableInfoToPB ¶ added in v0.4.0
func ConvertTableInfoToPB(table *TableInfo) *metaservicepb.TableInfo
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func NewCluster ¶
func (*Cluster) AllocShardID ¶ added in v0.4.0
func (*Cluster) CreateShardTopologies ¶ added in v0.4.0
func (c *Cluster) CreateShardTopologies(ctx context.Context, state clusterpb.ClusterTopology_ClusterState, shardTopologies []*clusterpb.ShardTopology, shardView []*clusterpb.Shard) error
func (*Cluster) CreateTable ¶ added in v0.4.0
func (*Cluster) GetClusterID ¶ added in v0.4.0
func (*Cluster) GetClusterMinNodeCount ¶ added in v0.4.0
func (*Cluster) GetClusterShardView ¶ added in v0.4.0
func (*Cluster) GetClusterState ¶ added in v0.4.0
func (c *Cluster) GetClusterState() clusterpb.ClusterTopology_ClusterState
func (*Cluster) GetClusterVersion ¶ added in v0.4.0
func (*Cluster) GetNodeShards ¶ added in v0.4.0
func (c *Cluster) GetNodeShards(_ context.Context) (*GetNodeShardsResult, error)
func (*Cluster) GetOrCreateSchema ¶
GetOrCreateSchema the second output parameter bool: Returns true if the schema was newly created.
func (*Cluster) GetRegisteredNode ¶ added in v0.4.0
func (c *Cluster) GetRegisteredNode(nodeName string) (*RegisteredNode, bool)
func (*Cluster) GetRegisteredNodes ¶ added in v0.4.0
func (c *Cluster) GetRegisteredNodes() []*RegisteredNode
func (*Cluster) GetShardByID ¶ added in v0.4.0
GetShardByID return immutable `Shard`.
func (*Cluster) GetShardIDsByNode ¶ added in v0.4.0
func (*Cluster) GetTotalShardNum ¶ added in v0.4.0
func (*Cluster) RegisterNode ¶
func (*Cluster) RouteTables ¶
type CreateTableResult ¶ added in v0.4.0
type CreateTableResult struct {
Table *Table
ShardVersionUpdate *ShardVersionUpdate
}
type DropTableResult ¶ added in v0.4.0
type DropTableResult struct {
ShardVersionUpdate *ShardVersionUpdate
}
type GetNodeShardsResult ¶ added in v0.4.0
type Manager ¶
type Manager interface {
// Start must be called before manager is used.
Start(ctx context.Context) error
// Stop must be called before manager is dropped.
Stop(ctx context.Context) error
ListClusters(ctx context.Context) ([]*Cluster, error)
CreateCluster(ctx context.Context, clusterName string, nodeCount, replicationFactor, shardTotal uint32) (*Cluster, error)
GetCluster(ctx context.Context, clusterName string) (*Cluster, error)
// AllocSchemaID means get or create schema.
// The second output parameter bool: Returns true if the table was newly created.
AllocSchemaID(ctx context.Context, clusterName, schemaName string) (uint32, bool, error)
// AllocTableID means get or create table.
// The second output parameter bool: Returns true if the table was newly created.
AllocTableID(ctx context.Context, clusterName, schemaName, tableName, nodeName string) (*Table, bool, error)
GetTables(ctx context.Context, clusterName, nodeName string, shardIDs []uint32) (map[uint32]*ShardTables, error)
DropTable(ctx context.Context, clusterName, schemaName, tableName string) error
GetShardIDs(ctx context.Context, clusterName, nodeName string) ([]uint32, error)
RouteTables(ctx context.Context, clusterName, schemaName string, tableNames []string) (*RouteTablesResult, error)
GetNodeShards(ctx context.Context, clusterName string) (*GetNodeShardsResult, error)
RegisterNode(ctx context.Context, clusterName string, nodeInfo *metaservicepb.NodeInfo) error
GetRegisteredNode(ctx context.Context, clusterName string, node string) (*metaservicepb.NodeInfo, error)
}
type RegisteredNode ¶ added in v0.4.0
type RegisteredNode struct {
// contains filtered or unexported fields
}
func NewRegisteredNode ¶ added in v0.4.0
func NewRegisteredNode(meta *clusterpb.Node, shardInfos []*ShardInfo) *RegisteredNode
func (*RegisteredNode) GetMeta ¶ added in v0.4.0
func (n *RegisteredNode) GetMeta() *clusterpb.Node
func (*RegisteredNode) GetShardInfos ¶ added in v0.4.0
func (n *RegisteredNode) GetShardInfos() []*ShardInfo
func (RegisteredNode) IsExpired ¶ added in v0.4.0
func (n RegisteredNode) IsExpired(now uint64, aliveThreshold uint64) bool
func (*RegisteredNode) IsOnline ¶ added in v0.4.0
func (n *RegisteredNode) IsOnline() bool
type RouteEntry ¶
type RouteTablesResult ¶
type RouteTablesResult struct {
Version uint64
RouteEntries map[string]*RouteEntry
}
type Shard ¶
type Shard struct {
// contains filtered or unexported fields
}
func (*Shard) FindShardByNode ¶ added in v0.4.0
FIXME: avoid returning *clusterpb.Shard.
func (*Shard) GetVersion ¶ added in v0.4.0
type ShardTables ¶
type ShardTablesWithRole ¶
type ShardTablesWithRole struct {
// contains filtered or unexported fields
}
type ShardVersionUpdate ¶ added in v0.4.0
type ShardsOfNode ¶ added in v0.4.0
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) GetSchemaID ¶
func (*Table) GetSchemaName ¶
func (*Table) GetShardID ¶
Click to show internal directories.
Click to hide internal directories.