stub

package
v0.0.0-...-13785af Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IteratorStub

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

IteratorStub can be used like a txnkv.kv.Iterator while it redirects all function calls to an httpproxy server.

func (*IteratorStub) Close

func (iter *IteratorStub) Close() error

Close releases the iterator.

func (*IteratorStub) Key

func (iter *IteratorStub) Key() ([]byte, error)

Key returns the key the iterator currently positioned at.

func (*IteratorStub) Next

func (iter *IteratorStub) Next() error

Next move the iterator to next position.

func (*IteratorStub) Valid

func (iter *IteratorStub) Valid() (bool, error)

Valid returns if the iterator is valid to use.

func (*IteratorStub) Value

func (iter *IteratorStub) Value() ([]byte, error)

Value returns the valid the iterator currently positioned at.

type RawClientStub

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

RawClientStub can be used like a rawkv.Client while it redirects all function calls to an httpproxy server.

func NewRawClientStub

func NewRawClientStub(proxyServer string, pdServers []string) (*RawClientStub, error)

NewRawClientStub creates a client for rawkv calls.

func (*RawClientStub) BatchDelete

func (c *RawClientStub) BatchDelete(keys [][]byte) error

BatchDelete deletes key-value pairs from TiKV.

func (*RawClientStub) BatchGet

func (c *RawClientStub) BatchGet(keys [][]byte) ([][]byte, error)

BatchGet queries values with the keys.

func (*RawClientStub) BatchPut

func (c *RawClientStub) BatchPut(keys, values [][]byte) error

BatchPut stores key-value pairs to TiKV.

func (*RawClientStub) Close

func (c *RawClientStub) Close() error

Close closes the client and releases resources in proxy server.

func (*RawClientStub) Delete

func (c *RawClientStub) Delete(key []byte) error

Delete deletes a key-value pair from TiKV.

func (*RawClientStub) DeleteRange

func (c *RawClientStub) DeleteRange(startKey, endKey []byte) error

DeleteRange deletes all key-value pairs in a range from TiKV.

func (*RawClientStub) Get

func (c *RawClientStub) Get(key []byte) ([]byte, error)

Get queries value with the key. When the key does not exist, it returns `nil, nil`.

func (*RawClientStub) Put

func (c *RawClientStub) Put(key, value []byte) error

Put stores a key-value pair to TiKV.

func (*RawClientStub) Scan

func (c *RawClientStub) Scan(startKey, endKey []byte, limit int) ([][]byte, [][]byte, error)

Scan queries continuous kv pairs in range [startKey, endKey), up to limit pairs.

type RawRequest

type RawRequest struct {
	PDAddrs  []string `json:"pd_addrs,omitempty"`  // for new
	Key      []byte   `json:"key,omitempty"`       // for get, put, delete
	Keys     [][]byte `json:"keys,omitempty"`      // for batchGet, batchPut, batchDelete
	Value    []byte   `json:"value,omitempty"`     // for put
	Values   [][]byte `json:"values,omitmepty"`    // for batchPut
	StartKey []byte   `json:"start_key,omitempty"` // for scan, deleteRange
	EndKey   []byte   `json:"end_key,omitempty"`   // for scan, deleteRange
	Limit    int      `json:"limit,omitempty"`     // for scan
}

RawRequest is the structure of a rawkv request that the http proxy accepts. It should be kept synced with the proxy server.

type RawResponse

type RawResponse struct {
	ID     string   `json:"id,omitempty"`     // for new
	Value  []byte   `json:"value,omitempty"`  // for get
	Keys   [][]byte `json:"keys,omitempty"`   // for scan
	Values [][]byte `json:"values,omitempty"` // for batchGet
}

RawResponse is the structure of a rawkv response that the http proxy sends. It should be kept synced with the proxy server.

type TransactionStub

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

TransactionStub can be used like a txnkv.Trasaction while it redirects all function calls to an httpproxy server.

func (*TransactionStub) BatchGet

func (txn *TransactionStub) BatchGet(keys [][]byte) (map[string][]byte, error)

BatchGet gets a batch of values.

func (*TransactionStub) Commit

func (txn *TransactionStub) Commit() error

Commit commits the transaction operations.

func (*TransactionStub) Delete

func (txn *TransactionStub) Delete(k []byte) error

Delete removes the entry for key k.

func (*TransactionStub) Get

func (txn *TransactionStub) Get(k []byte) ([]byte, error)

Get retrives the value for the given key.

func (*TransactionStub) IsReadOnly

func (txn *TransactionStub) IsReadOnly() (bool, error)

IsReadOnly returns if there are pending key-value to commit in the transaction.

func (*TransactionStub) Iter

func (txn *TransactionStub) Iter(k []byte, upperBound []byte) (*IteratorStub, error)

Iter creates an Iterator positioned on the first entry that k <= entry's key.

func (*TransactionStub) IterReverse

func (txn *TransactionStub) IterReverse(k []byte) (*IteratorStub, error)

IterReverse creates a reversed Iterator positioned on the first entry which key is less than k.

func (*TransactionStub) Len

func (txn *TransactionStub) Len() (int, error)

Len returns the count of key-value pairs in the transaction's memory buffer.

func (*TransactionStub) LockKeys

func (txn *TransactionStub) LockKeys(keys ...[]byte) error

LockKeys tries to lock the entries with the keys.

func (*TransactionStub) Rollback

func (txn *TransactionStub) Rollback() error

Rollback undoes the transaction operations.

func (*TransactionStub) Set

func (txn *TransactionStub) Set(k []byte, v []byte) error

Set sets the value for key k as v.

func (*TransactionStub) Size

func (txn *TransactionStub) Size() (int, error)

Size returns the length (in bytes) of the transaction's memory buffer.

func (*TransactionStub) String

func (txn *TransactionStub) String() string

func (*TransactionStub) Valid

func (txn *TransactionStub) Valid() (bool, error)

Valid returns if the transaction is valid. A transaction becomes invalid after commit or rollback.

type TxnClientStub

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

TxnClientStub can be used like a txnkv.Client while it redirects all function calls to an httpproxy server.

func NewTxnClientStub

func NewTxnClientStub(proxyServer string, pdServers []string) (*TxnClientStub, error)

NewTxnClientStub creates a client for txnkv calls.

func (*TxnClientStub) Begin

func (c *TxnClientStub) Begin() (*TransactionStub, error)

Begin creates a transaction for read/write.

func (*TxnClientStub) BeginWithTS

func (c *TxnClientStub) BeginWithTS(ts uint64) (*TransactionStub, error)

BeginWithTS creates a transaction which is normally readonly.

func (*TxnClientStub) Close

func (c *TxnClientStub) Close() error

Close closes the client and releases resources in proxy server.

func (*TxnClientStub) GetTS

func (c *TxnClientStub) GetTS() (uint64, error)

GetTS returns a latest timestamp.

type TxnRequest

type TxnRequest struct {
	PDAddrs    []string `json:"pd_addrs,omitempty"`    // for new
	TS         uint64   `json:"ts,omitempty"`          // for beginWithTS
	Key        []byte   `json:"key,omitempty"`         // for get, set, delete, iter, iterReverse
	Value      []byte   `json:"value,omitempty"`       // for set
	Keys       [][]byte `json:"keys,omitempty"`        // for batchGet, lockKeys
	UpperBound []byte   `json:"upper_bound,omitempty"` // for iter
}

TxnRequest is the structure of a txnkv request that the http proxy accepts. It should be kept synced with the proxy server.

type TxnResponse

type TxnResponse struct {
	ID         string   `json:"id,omitempty"`          // for new, begin, beginWithTS, iter, iterReverse
	TS         uint64   `json:"ts,omitempty"`          // for getTS
	Key        []byte   `json:"key,omitempty"`         // for iterKey
	Value      []byte   `json:"value,omitempty"`       // for get, iterValue
	Keys       [][]byte `json:"keys,omitempty"`        // for batchGet
	Values     [][]byte `json:"values,omitempty"`      // for batchGet
	IsValid    bool     `json:"is_valid,omitempty"`    // for valid, iterValid
	IsReadOnly bool     `json:"is_readonly,omitempty"` // for isReadOnly
	Size       int      `json:"size,omitempty"`        // for size
	Length     int      `json:"length,omitempty"`      // for length
}

TxnResponse is the structure of a txnkv response that the http proxy sends. It should be kept synced with the proxy server.

Jump to

Keyboard shortcuts

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