region

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 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.12

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.12

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.12

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 Region

type Region interface {
	// Put puts a key-value pair to region.
	Put(key []byte, value []byte) error
	// Get gets value by key from region.
	Get(key []byte) ([]byte, error)
	// Delete deletes a key-value pair from region.
	Delete(key []byte) error
	// GetStartKey gets the start key of the region.
	GetStartKey() []byte
	// GetEndKey gets the end key of the region.
	GetEndKey() []byte
	// GetLeader gets the leader peer of the region.
	GetLeader() string
	// GetPeers gets the peers of the region.
	GetPeers() []string
	// TransferLeader transfers the leader role to a specified peer.
	TransferLeader(peer string) error
	// AddPeer adds a new peer to the raft group.
	AddPeer(peer string) error
	// RemovePeer removes a peer from the raft group.
	RemovePeer(peer string) error
	// GetSize gets the total size of the region.
	GetSize() int64
	// GetID gets the id of the region.
	GetID() int64
}

Region is the interface of region.

func NewRegion added in v1.0.12

func NewRegion(conf config.RegionConfig) (Region, error)

Jump to

Keyboard shortcuts

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