api

package
Version: v0.0.0-...-388e21d Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(server Server) http.Handler

NewHandler create s a HTTP handler for API

Types

type Cluster

type Cluster struct {
	ID      uint64    `json:"id"`
	Regions []*Region `json:"regions"`
	Stores  []*Store  `json:"stores"`
	Members []*Member `json:"members"`
}

Cluster contains all information about a mock tikv cluster

type Member

type Member struct {
	Name       string   `json:"name"`
	MemberID   uint64   `json:"member_id"`
	ClientUrls []string `json:"client_urls"`
}

Member contains information about a PD member

type Peer

type Peer struct {
	ID      uint64 `json:"id"`
	StoreID uint64 `json:"store_id"`
}

Peer contains id of backing store

type Region

type Region struct {
	ID          uint64       `json:"id"`
	StartKey    []byte       `json:"-"`
	EndKey      []byte       `json:"-"`
	RegionEpoch *RegionEpoch `json:"region_epoch"`
	Peers       []*Peer      `json:"peers"`
}

Region records region setup for api usage.

func (*Region) MarshalJSON

func (r *Region) MarshalJSON() ([]byte, error)

MarshalJSON marshal Region to json using unified hex key format

func (*Region) UnmarshalJSON

func (r *Region) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal Region from json with unified hex key format

type RegionEpoch

type RegionEpoch struct {
	ConfVer uint64 `json:"conf_ver"`
	Version uint64 `json:"version"`
}

RegionEpoch records epoch data of a region

type Server

type Server interface {
	GetCluster(id uint64) *Cluster
	GetClusters() []*Cluster
	DeleteCluster(id uint64)
	CreateCluster(cluster *Cluster) (*Cluster, error)
	GetClusterStore(clusterID, storeID uint64) (*Store, error)
	GetClusterStores(clusterID uint64) ([]*Store, error)
	GetStoreFailPoints(clusterID, storeID uint64) (map[string]interface{}, error)
	GetStoreFailPoint(clusterID, storeID uint64, failPoint string) (interface{}, error)
	UpdateStoreFailPoint(clusterID, storeID uint64, failPoint, value string) (interface{}, error)
	DeleteStoreFailPoint(clusterID, storeID uint64, failPoint string) (interface{}, error)
}

Server defines public surface between internal implementation and api

type Store

type Store struct {
	ID      uint64     `json:"id"`
	Address string     `json:"address"`
	State   StoreState `json:"state"`
	Version string     `json:"version"`
}

Store contains information about a store

type StoreState

type StoreState string

StoreState contains state about a store.

const (
	// StoreStateUp store is up and running
	StoreStateUp StoreState = "Up"
	// StoreStateOffline store is offline
	StoreStateOffline StoreState = "Offline"
	// StoreStateTombstone store is set to tombstone state
	StoreStateTombstone StoreState = "Tombstone"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL