storage

package
v1.0.0-alpha02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2022 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncode = coderr.NewCodeError(coderr.Internal, "storage encode")
	ErrDecode = coderr.NewCodeError(coderr.Internal, "storage decode")

	ErrCreateSchemaAgain         = coderr.NewCodeError(coderr.Internal, "storage create schemas")
	ErrCreateClusterAgain        = coderr.NewCodeError(coderr.Internal, "storage create cluster")
	ErrCreateClusterViewAgain    = coderr.NewCodeError(coderr.Internal, "storage create cluster view")
	ErrUpdateClusterViewConflict = coderr.NewCodeError(coderr.Internal, "storage update cluster view")
	ErrCreateTableAgain          = coderr.NewCodeError(coderr.Internal, "storage create tables")
	ErrDeleteTableAgain          = coderr.NewCodeError(coderr.Internal, "storage delete table")
	ErrCreateShardViewAgain      = coderr.NewCodeError(coderr.Internal, "storage create shard view")
	ErrUpdateShardViewConflict   = coderr.NewCodeError(coderr.Internal, "storage update shard view")
)

Functions

func ConvertShardRoleToPB added in v1.0.0

func ConvertShardRoleToPB(role ShardRole) clusterpb.ShardRole

Types

type Cluster added in v1.0.0

type Cluster struct {
	ID                ClusterID
	Name              string
	MinNodeCount      uint32
	ReplicationFactor uint32
	ShardTotal        uint32
	CreatedAt         uint64
}

type ClusterID added in v1.0.0

type ClusterID uint32

type ClusterState added in v1.0.0

type ClusterState int
const (
	ClusterStateEmpty ClusterState = iota + 1
	ClusterStateStable
)

type ClusterView added in v1.0.0

type ClusterView struct {
	ClusterID  ClusterID
	Version    uint64
	State      ClusterState
	ShardNodes []ShardNode
	CreatedAt  uint64
}

type CreateClusterRequest added in v1.0.0

type CreateClusterRequest struct {
	Cluster Cluster
}

type CreateClusterViewRequest added in v1.0.0

type CreateClusterViewRequest struct {
	ClusterView ClusterView
}

type CreateOrUpdateNodeRequest added in v1.0.0

type CreateOrUpdateNodeRequest struct {
	ClusterID ClusterID
	Node      Node
}

type CreateSchemaRequest added in v1.0.0

type CreateSchemaRequest struct {
	ClusterID ClusterID
	Schema    Schema
}

type CreateShardViewsRequest added in v1.0.0

type CreateShardViewsRequest struct {
	ClusterID  ClusterID
	ShardViews []ShardView
}

type CreateTableRequest added in v1.0.0

type CreateTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
	Table     Table
}

type DeleteTableRequest added in v1.0.0

type DeleteTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
	TableName string
}

type GetClusterViewRequest added in v1.0.0

type GetClusterViewRequest struct {
	ClusterID ClusterID
}

type GetClusterViewResult added in v1.0.0

type GetClusterViewResult struct {
	ClusterView ClusterView
}

type GetTableRequest added in v1.0.0

type GetTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
	TableName string
}

type GetTableResult added in v1.0.0

type GetTableResult struct {
	Table  Table
	Exists bool
}

type ListClustersResult added in v1.0.0

type ListClustersResult struct {
	Clusters []Cluster
}

type ListNodesRequest added in v1.0.0

type ListNodesRequest struct {
	ClusterID ClusterID
}

type ListNodesResult added in v1.0.0

type ListNodesResult struct {
	Nodes []Node
}

type ListSchemasRequest added in v1.0.0

type ListSchemasRequest struct {
	ClusterID ClusterID
}

type ListSchemasResult added in v1.0.0

type ListSchemasResult struct {
	Schemas []Schema
}

type ListShardViewsRequest added in v1.0.0

type ListShardViewsRequest struct {
	ClusterID ClusterID
	ShardIDs  []ShardID
}

type ListShardViewsResult added in v1.0.0

type ListShardViewsResult struct {
	ShardViews []ShardView
}

type ListTableRequest added in v1.0.0

type ListTableRequest struct {
	ClusterID ClusterID
	SchemaID  SchemaID
}

type ListTablesResult added in v1.0.0

type ListTablesResult struct {
	Tables []Table
}

type Node added in v1.0.0

type Node struct {
	Name          string
	NodeStats     NodeStats
	LastTouchTime uint64
	State         NodeState
}

type NodeState added in v1.0.0

type NodeState int
const (
	NodeStateOnline NodeState = iota + 1
	NodeStateOffline
)

type NodeStats added in v1.0.0

type NodeStats struct {
	Lease       uint32
	Zone        string
	NodeVersion string
}

type Options

type Options struct {
	// MaxScanLimit is the max limit of the number of keys in a scan.
	MaxScanLimit int
	// MinScanLimit is the min limit of the number of keys in a scan.
	MinScanLimit int
}

type Schema added in v1.0.0

type Schema struct {
	ID        SchemaID
	ClusterID ClusterID
	Name      string
	CreatedAt uint64
}

type SchemaID added in v1.0.0

type SchemaID uint32

type ShardID added in v1.0.0

type ShardID uint32

type ShardNode added in v1.0.0

type ShardNode struct {
	ID        ShardID
	ShardRole ShardRole
	NodeName  string
}

type ShardRole added in v1.0.0

type ShardRole int
const (
	ShardRoleLeader ShardRole = iota + 1
	ShardRoleFollower
)

func ConvertShardRolePB added in v1.0.0

func ConvertShardRolePB(role clusterpb.ShardRole) ShardRole

type ShardView added in v1.0.0

type ShardView struct {
	ShardID   ShardID
	Version   uint64
	TableIDs  []TableID
	CreatedAt uint64
}

type Storage

type Storage interface {
	// ListClusters list all clusters.
	ListClusters(ctx context.Context) (ListClustersResult, error)
	// CreateCluster create new cluster, return error if cluster already exists.
	CreateCluster(ctx context.Context, req CreateClusterRequest) error

	// CreateClusterView create cluster view.
	CreateClusterView(ctx context.Context, req CreateClusterViewRequest) error
	// GetClusterView get cluster view by cluster id.
	GetClusterView(ctx context.Context, req GetClusterViewRequest) (GetClusterViewResult, error)
	// UpdateClusterView update cluster view.
	UpdateClusterView(ctx context.Context, req UpdateClusterViewRequest) error

	// ListSchemas list all schemas in specified cluster.
	ListSchemas(ctx context.Context, req ListSchemasRequest) (ListSchemasResult, error)
	// CreateSchema create schema in specified cluster.
	CreateSchema(ctx context.Context, req CreateSchemaRequest) error

	// CreateTable create new table in specified cluster and schema, return error if table already exists.
	CreateTable(ctx context.Context, req CreateTableRequest) error
	// GetTable get table by table name in specified cluster and schema.
	GetTable(ctx context.Context, req GetTableRequest) (GetTableResult, error)
	// ListTables list all tables in specified cluster and schema.
	ListTables(ctx context.Context, req ListTableRequest) (ListTablesResult, error)
	// DeleteTable delete table by table name in specified cluster and schema.
	DeleteTable(ctx context.Context, req DeleteTableRequest) error

	// CreateShardViews create shard views in specified cluster.
	CreateShardViews(ctx context.Context, req CreateShardViewsRequest) error
	// ListShardViews list all shard views in specified cluster.
	ListShardViews(ctx context.Context, req ListShardViewsRequest) (ListShardViewsResult, error)
	// UpdateShardView update shard views in specified cluster.
	UpdateShardView(ctx context.Context, req UpdateShardViewRequest) error

	// ListNodes list all nodes in specified cluster.
	ListNodes(ctx context.Context, req ListNodesRequest) (ListNodesResult, error)
	// CreateOrUpdateNode create or update node in specified cluster.
	CreateOrUpdateNode(ctx context.Context, req CreateOrUpdateNodeRequest) error
}

Storage defines the storage operations on the ceresdb cluster meta info.

func NewStorageWithEtcdBackend

func NewStorageWithEtcdBackend(client *clientv3.Client, rootPath string, opts Options) Storage

NewStorageWithEtcdBackend creates a new storage with etcd backend.

type Table added in v1.0.0

type Table struct {
	ID          TableID
	Name        string
	SchemaID    SchemaID
	CreatedAt   uint64
	Partitioned bool
}

type TableID added in v1.0.0

type TableID uint64

type UpdateClusterViewRequest added in v1.0.0

type UpdateClusterViewRequest struct {
	ClusterID     ClusterID
	ClusterView   ClusterView
	LatestVersion uint64
}

type UpdateShardViewRequest added in v1.0.0

type UpdateShardViewRequest struct {
	ClusterID     ClusterID
	ShardView     ShardView
	LatestVersion uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL