tikv

package
v0.0.0-...-887f819 Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package tikv provides tcp connection to kvserver.

Index

Constants

View Source
const (
	// NoJitter makes the backoff sequence strict exponential.
	NoJitter = 1 + iota
	// FullJitter applies random factors to strict exponential.
	FullJitter
	// EqualJitter is also randomized, but prevents very short sleeps.
	EqualJitter
	// DecorrJitter increases the maximum jitter based on the last random value.
	DecorrJitter
)

Variables

This section is empty.

Functions

func NewBackoff

func NewBackoff(retry, base, cap, jitter int) func() error

NewBackoff creates a backoff func which implements exponential backoff with optional jitters. See: http://www.awsarchitectureblog.com/2015/03/backoff.html

Types

type Client

type Client interface {
	// Close should release all data.
	Close() error
	// SendKVReq sends kv request.
	SendKVReq(req *kvrpcpb.Request) (*kvrpcpb.Response, error)
	// SendCopReq sends coprocessor request.
	SendCopReq(req *coprocessor.Request) (*coprocessor.Response, error)
}

Client is a client that sends RPC. It should not be used after calling Close().

func NewRPCClient

func NewRPCClient(srvHost string) (Client, error)

NewRPCClient new client that sends protobuf to do RPC.

type CopClient

type CopClient struct {
	// contains filtered or unexported fields
}

CopClient is coprocessor client.

func (*CopClient) Send

func (c *CopClient) Send(req *kv.Request) kv.Response

Send builds the request and gets the coprocessor iterator response.

func (*CopClient) SupportRequestType

func (c *CopClient) SupportRequestType(reqType, subType int64) bool

SupportRequestType checks whether reqType is supported.

type Driver

type Driver struct {
}

Driver implements engine Driver.

func (Driver) Open

func (d Driver) Open(path string) (kv.Storage, error)

Open opens or creates an TiKV storage with given path. Path example: tikv://etcd-node1:port,etcd-node2:port/pd-path?cluster=1

type Region

type Region struct {
	// contains filtered or unexported fields
}

Region store region info. Region is a readonly class.

func (*Region) Contains

func (r *Region) Contains(key []byte) bool

Contains checks whether the key is in the region, for the maximum region endKey is empty. startKey <= key < endKey.

func (*Region) EndKey

func (r *Region) EndKey() []byte

EndKey return EndKey.

func (*Region) GetAddress

func (r *Region) GetAddress() string

GetAddress return address.

func (*Region) GetContext

func (r *Region) GetContext() *kvrpcpb.Context

GetContext construct kvprotopb.Context from region info.

func (*Region) GetID

func (r *Region) GetID() uint64

GetID return id.

func (*Region) NextStore

func (r *Region) NextStore() (uint64, error)

NextStore picks next store as leader, if out of range return error.

func (*Region) StartKey

func (r *Region) StartKey() []byte

StartKey return StartKey.

type RegionCache

type RegionCache struct {
	// contains filtered or unexported fields
}

RegionCache store region cache by region id.

func NewRegionCache

func NewRegionCache(pdClient pd.Client) *RegionCache

NewRegionCache new region cache.

func (*RegionCache) DropRegion

func (c *RegionCache) DropRegion(regionID uint64)

DropRegion remove some region cache.

func (*RegionCache) GetRegion

func (c *RegionCache) GetRegion(key []byte) (*Region, error)

GetRegion find in cache, or get new region.

func (*RegionCache) NextStore

func (c *RegionCache) NextStore(regionID uint64)

NextStore picks next store as new leader, if out of range of stores delete region.

func (*RegionCache) UpdateLeader

func (c *RegionCache) UpdateLeader(regionID, leaderStoreID uint64)

UpdateLeader update some region cache with newer leader store ID.

type Scanner

type Scanner struct {
	StartKey []byte // len(StartKey) == 0 stands for minimum key.
	Version  uint64
	// contains filtered or unexported fields
}

Scanner support tikv scan

func (*Scanner) Close

func (s *Scanner) Close()

Close close iterator.

func (*Scanner) Key

func (s *Scanner) Key() kv.Key

Key return key.

func (*Scanner) Next

func (s *Scanner) Next() error

Next return next element.

func (*Scanner) Valid

func (s *Scanner) Valid() bool

Valid return valid.

func (*Scanner) Value

func (s *Scanner) Value() []byte

Value return value.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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