Documentation
¶
Overview ¶
Package tikv provides tcp connection to kvserver.
Index ¶
- Constants
- func NewBackoff(retry, base, cap, jitter int) func() error
- func NewMockTikvStore() kv.Storage
- type Client
- type Conn
- type CopClient
- type Driver
- type Pool
- type Pools
- type Region
- func (r *Region) Clone() *Region
- func (r *Region) Contains(key []byte) bool
- func (r *Region) EndKey() []byte
- func (r *Region) GetAddress() string
- func (r *Region) GetContext() *kvrpcpb.Context
- func (r *Region) GetID() uint64
- func (r *Region) NextPeer() (*metapb.Peer, error)
- func (r *Region) StartKey() []byte
- func (r *Region) VerID() RegionVerID
- type RegionCache
- func (c *RegionCache) DropRegion(id RegionVerID)
- func (c *RegionCache) GetRegion(key []byte) (*Region, error)
- func (c *RegionCache) GetRegionByVerID(id RegionVerID) *Region
- func (c *RegionCache) GroupKeysByRegion(keys [][]byte) (map[RegionVerID][][]byte, RegionVerID, error)
- func (c *RegionCache) NextPeer(id RegionVerID)
- func (c *RegionCache) UpdateLeader(regionID RegionVerID, leaderID uint64)
- type RegionVerID
- type Scanner
Constants ¶
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 ¶
NewBackoff creates a backoff func which implements exponential backoff with optional jitters. See http://www.awsarchitectureblog.com/2015/03/backoff.html
func NewMockTikvStore ¶
NewMockTikvStore creates a mocked tikv store.
Types ¶
type Client ¶
type Client interface { // Close should release all data. Close() error // SendKVReq sends kv request. SendKVReq(addr string, req *kvrpcpb.Request) (*kvrpcpb.Response, error) // SendCopReq sends coprocessor request. SendCopReq(addr string, req *coprocessor.Request) (*coprocessor.Response, error) }
Client is a client that sends RPC. It should not be used after calling Close().
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is a simple wrapper of net.Conn.
func NewConnection ¶
NewConnection creates a Conn with network timeout..
func NewConnectionWithSize ¶
NewConnectionWithSize creates a Conn with network timeout and read/write buffer size.
func (*Conn) BufioReader ¶
BufioReader returns a bufio.Reader for writing.
type CopClient ¶
type CopClient struct {
// contains filtered or unexported fields
}
CopClient is coprocessor client.
func (*CopClient) SupportRequestType ¶
SupportRequestType checks whether reqType is supported.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is a TCP connection pool that maintains connections with a specific addr.
type Pools ¶
type Pools struct {
// contains filtered or unexported fields
}
Pools maintains connections with multiple addrs.
func NewPools ¶
NewPools creates a Pools. It maintains a Pool for each address, and each Pool has the same capability.
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
Region stores region info. Region is a readonly class.
func (*Region) Contains ¶
Contains checks whether the key is in the region, for the maximum region endKey is empty. startKey <= key < endKey.
func (*Region) GetContext ¶
GetContext constructs kvprotopb.Context from region info.
type RegionCache ¶
type RegionCache struct {
// contains filtered or unexported fields
}
RegionCache caches Regions loaded from PD.
func NewRegionCache ¶
func NewRegionCache(pdClient pd.Client) *RegionCache
NewRegionCache creates a RegionCache.
func (*RegionCache) DropRegion ¶
func (c *RegionCache) DropRegion(id RegionVerID)
DropRegion removes a cached Region.
func (*RegionCache) GetRegion ¶
func (c *RegionCache) GetRegion(key []byte) (*Region, error)
GetRegion find in cache, or get new region.
func (*RegionCache) GetRegionByVerID ¶
func (c *RegionCache) GetRegionByVerID(id RegionVerID) *Region
GetRegionByVerID finds a Region by Region's verID.
func (*RegionCache) GroupKeysByRegion ¶
func (c *RegionCache) GroupKeysByRegion(keys [][]byte) (map[RegionVerID][][]byte, RegionVerID, error)
GroupKeysByRegion separates keys into groups by their belonging Regions. Specially it also returns the first key's region which may be used as the 'PrimaryLockKey' and should be committed ahead of others.
func (*RegionCache) NextPeer ¶
func (c *RegionCache) NextPeer(id RegionVerID)
NextPeer picks next peer as new leader, if out of range of peers delete region.
func (*RegionCache) UpdateLeader ¶
func (c *RegionCache) UpdateLeader(regionID RegionVerID, leaderID uint64)
UpdateLeader update some region cache with newer leader info.
type RegionVerID ¶
type RegionVerID struct {
// contains filtered or unexported fields
}
RegionVerID is a unique ID that can identify a Region at a specific version.