storage

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEncodeCluster         = coderr.NewCodeError(coderr.Internal, "meta storage unmarshal cluster")
	ErrDecodeCluster         = coderr.NewCodeError(coderr.Internal, "meta storage marshal cluster")
	ErrEncodeClusterTopology = coderr.NewCodeError(coderr.Internal, "meta storage unmarshal cluster topology")
	ErrDecodeClusterTopology = coderr.NewCodeError(coderr.Internal, "meta storage marshal cluster topology")
	ErrEncodeShardTopology   = coderr.NewCodeError(coderr.Internal, "meta storage unmarshal shard topology")
	ErrDecodeShardTopology   = coderr.NewCodeError(coderr.Internal, "meta storage marshal shard topology")
	ErrEncodeSchema          = coderr.NewCodeError(coderr.Internal, "meta storage unmarshal schema")
	ErrDecodeSchema          = coderr.NewCodeError(coderr.Internal, "meta storage marshal schema")
	ErrEncodeTable           = coderr.NewCodeError(coderr.Internal, "meta storage unmarshal table")
	ErrDecodeTable           = coderr.NewCodeError(coderr.Internal, "meta storage marshal table")
	ErrEncodeNode            = coderr.NewCodeError(coderr.Internal, "meta storage unmarshal node")
	ErrDecodeNode            = coderr.NewCodeError(coderr.Internal, "meta storage marshal node")

	ErrCreateSchemaAgain          = coderr.NewCodeError(coderr.Internal, "meta storage create schemas")
	ErrCreateClusterAgain         = coderr.NewCodeError(coderr.Internal, "meta storage create cluster")
	ErrCreateClusterTopologyAgain = coderr.NewCodeError(coderr.Internal, "meta storage create cluster topology")
	ErrPutClusterTopologyConflict = coderr.NewCodeError(coderr.Internal, "meta storage put cluster topology")
	ErrCreateTableAgain           = coderr.NewCodeError(coderr.Internal, "meta storage create tables")
	ErrTableIDNotFound            = coderr.NewCodeError(coderr.NotFound, "table id not found")
	ErrDeleteTableAgain           = coderr.NewCodeError(coderr.Internal, "meta storage delete table")
	ErrCreateShardTopologyAgain   = coderr.NewCodeError(coderr.Internal, "meta storage create shard topology")
	ErrPutShardTopologyConflict   = coderr.NewCodeError(coderr.Internal, "meta storage put shard topology")
	ErrCreateOrUpdateNode         = coderr.NewCodeError(coderr.Internal, "meta storage create or update nodes")
)

Functions

This section is empty.

Types

type KV

type KV interface {
	Get(ctx context.Context, key string) (string, error)
	Scan(ctx context.Context, key, endKey string, limit int) (keys []string, values []string, err error)
	Put(ctx context.Context, key, value string) error
	Delete(ctx context.Context, key string) error

	Txn(ctx context.Context) clientv3.Txn
}

KV is an abstract interface for kv storage

func NewEtcdKV

func NewEtcdKV(client *clientv3.Client, rootPath string) KV

NewEtcdKV creates a new etcd kv. nolint

type MetaStorage

type MetaStorage interface {
	ListClusters(ctx context.Context) ([]*clusterpb.Cluster, error)
	CreateCluster(ctx context.Context, cluster *clusterpb.Cluster) (*clusterpb.Cluster, error)
	GetCluster(ctx context.Context, clusterID uint32) (*clusterpb.Cluster, error)
	PutCluster(ctx context.Context, clusterID uint32, cluster *clusterpb.Cluster) error

	CreateClusterTopology(ctx context.Context, clusterTopology *clusterpb.ClusterTopology) (*clusterpb.ClusterTopology, error)
	GetClusterTopology(ctx context.Context, clusterID uint32) (*clusterpb.ClusterTopology, error)
	PutClusterTopology(ctx context.Context, clusterID uint32, latestVersion uint64, clusterTopology *clusterpb.ClusterTopology) error

	ListSchemas(ctx context.Context, clusterID uint32) ([]*clusterpb.Schema, error)
	CreateSchema(ctx context.Context, clusterID uint32, schema *clusterpb.Schema) (*clusterpb.Schema, error)
	PutSchemas(ctx context.Context, clusterID uint32, schemas []*clusterpb.Schema) error

	CreateTable(ctx context.Context, clusterID uint32, schemaID uint32, table *clusterpb.Table) (*clusterpb.Table, error)
	GetTable(ctx context.Context, clusterID uint32, schemaID uint32, tableName string) (*clusterpb.Table, bool, error)
	ListTables(ctx context.Context, clusterID uint32, schemaID uint32) ([]*clusterpb.Table, error)
	PutTables(ctx context.Context, clusterID uint32, schemaID uint32, tables []*clusterpb.Table) error
	DeleteTable(ctx context.Context, clusterID uint32, schemaID uint32, tableName string) error

	CreateShardTopologies(ctx context.Context, clusterID uint32, shardTopologies []*clusterpb.ShardTopology) ([]*clusterpb.ShardTopology, error)
	ListShardTopologies(ctx context.Context, clusterID uint32, shardID []uint32) ([]*clusterpb.ShardTopology, error)
	PutShardTopologies(ctx context.Context, clusterID uint32, shardIDs []uint32, latestVersion uint64, shardTopologies []*clusterpb.ShardTopology) error

	ListNodes(ctx context.Context, clusterID uint32) ([]*clusterpb.Node, error)
	CreateOrUpdateNode(ctx context.Context, clusterID uint32, node *clusterpb.Node) (*clusterpb.Node, error)
}

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

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 Storage

type Storage interface {
	KV
	MetaStorage
}

Storage is the interface for the backend storage of the ceresmeta.

func NewMetaStorageImpl

func NewMetaStorageImpl(
	kv KV,
	opts Options,
	rootPath string,
) Storage

NewMetaStorageImpl creates a new base storage endpoint with the given KV and encryption key manager. It should be embedded insIDe a storage backend.

func NewStorageWithEtcdBackend

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

NewStorageWithEtcdBackend creates a new storage with etcd backend.

Jump to

Keyboard shortcuts

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