store

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v1.0.8

func Init() error

Init initializes the datastoreFactories by registering different DataStoreFactory implementations. It calls the Register function to associate each implementation with a unique name. Currently, "memory" and "bolt" are registered as the names for the corresponding factories. The function returns an error if any registration fails, but in this implementation, the error is ignored.

func Register added in v1.0.8

func Register(name string, factory DataStoreFactory) error

Register is a function that registers a DataStoreFactory implementation with a given name. It takes the name string and the factory function as input. The function checks if the factory is nil and returns an error if it is. Then, it checks if the name is already registered in the datastoreFactories map. If the name is already registered, it returns an error. Otherwise, it adds the factory to the map with the name as the key and returns nil.

Types

type DataStoreFactory added in v1.0.8

type DataStoreFactory func(conf config.Config) (datastore.DataStore, error)

DataStoreFactory is a function type that creates a new instance of a raft.LogStore. It takes a configuration map as input and returns the created LogStore or an error if the creation fails.

type Store

type Store interface {
	// GetRegionByKey gets region and leader peer by region key from cluster.
	GetRegionByKey(key []byte) (*region.Region, error)
	// GetRegionByID gets region and leader peer by region id from cluster.
	GetRegionByID(id uint64) (*region.Region, error)
	// AddRegion adds a new region to cluster.
	AddRegion(region *region.Region) error
	// RemoveRegion removes a region from cluster.
	RemoveRegion(id uint64) error
	// Split splits the region into two regions.
	Split(region *region.Region, splitKey []byte) error
	// Merge merges two adjacent regions into one region.
	Merge(regionA *region.Region, regionB *region.Region) error
	// GetSize gets the total size of the store.
	GetSize() int64
}

Store is the interface of store.

Jump to

Keyboard shortcuts

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