store

package
v0.0.0-...-82e51c3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAddressNotReachable       = errors.New("address not reachable")
	ErrNonExistentLocationDelete = errors.New("cannot delete non existent location")
	ErrNonLeaderNode             = fmt.Errorf("cannot execute operation not leader")
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Op         string                 `json:"op,omitempty"`
	LocationID string                 `json:"location_id,omitempty"`
	Lat        float64                `json:"lat,omitempty"`
	Long       float64                `json:"lon,omitempty"`
	Data       map[string]interface{} `json:"data,omitempty"`
}

type OperationType

type OperationType string
const (
	OperationInsert         OperationType = "insert"
	OperationDelete         OperationType = "delete"
	OperationUpdate         OperationType = "update"
	OperationUpdateLocation OperationType = "updateloc"
	OperationUpdateData     OperationType = "updatedata"
)

type Server

type Server struct {
	ID   string `json:"id,omitempty"`
	Addr string `json:"addr,omitempty"`
}

Server represents another node in the cluster.

type Servers

type Servers []*Server

Servers is a set of Servers.

func (Servers) Len

func (s Servers) Len() int

func (Servers) Less

func (s Servers) Less(i, j int) bool

func (Servers) Swap

func (s Servers) Swap(i, j int)

type Store

type Store interface {
	Open(enableSingle bool, localID string) error

	Get(key string) (ds.QuadTreeLeaf, error)

	Insert(locationID string, position ds.GeoLocation, data map[string]interface{}) error

	Update(locationID string, position ds.GeoLocation, data map[string]interface{}) error

	UpdateLocation(locationID string, position ds.GeoLocation) error

	UpdateData(locationID string, data map[string]interface{}) error

	Delete(key string) error

	BulkWrite(commands []Command) error

	// Join joins the node, identitifed by nodeID and reachable at addr, to the cluster.
	Join(nodeID string, addr string) error
	GetLeader() raft.ServerAddress
	GetNeighbors(ds.Position, int, int) []ds.QuadTreeNeighborResult
	Remove(nodeId string) error
	Nodes() ([]*Server, error)
	IsLeader() bool
}

Store is the interface Raft-backed key-value stores must implement.

func New

func New(raftDir, raftBind string) Store

New returns a new Store.

Jump to

Keyboard shortcuts

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