vs

package
v0.0.0-...-e1f8a17 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorNotFound error when no matching records are found
	ErrorNotFound = errors.New("not found")
	// ErrorWrongDataFormat error when data type is unexpected
	ErrorWrongDataFormat = errors.New("wrong data format")
)

Functions

This section is empty.

Types

type AccessConfig

type AccessConfig struct {
	Replica int // control which replica instance to read from or write to. 0 means the primary copy.
}

AccessConfig stores options for reading and writing

type ClusterClient

type ClusterClient struct {
	ClusterListener *clusterlistener.ClusterListener
	WriteConfig
	AccessConfig
	// contains filtered or unexported fields
}

ClusterClient is used to access the keyspace in current data center.

func (*ClusterClient) AddFloat64

func (c *ClusterClient) AddFloat64(key *KeyObject, value float64) error

AddFloat64 adds a float64 value to the key

func (*ClusterClient) Append

func (c *ClusterClient) Append(key *KeyObject, value []byte) error

Append appends []byte to existing value

func (*ClusterClient) BatchGet

func (c *ClusterClient) BatchGet(keys []*KeyObject) (ret []*KeyValue, err error)

BatchGet gets the key value pairs from different partitions by the keys

func (*ClusterClient) BatchProcess

func (c *ClusterClient) BatchProcess(requests []*pb.Request,
	processResultFunc func([]*pb.Response, error) error) error

BatchProcess devides requests, groups them by the destination, and sends to the partitions by batch. Expert usage expected.

func (*ClusterClient) BatchPut

func (c *ClusterClient) BatchPut(rows []*KeyValue) error

BatchPut puts the key value pairs to different partitions

func (*ClusterClient) Clone

func (c *ClusterClient) Clone() *ClusterClient

Clone creates a new instance of ClusterClient, mostly to adjust the write config and access config.

func (*ClusterClient) CollectByPrefix

func (c *ClusterClient) CollectByPrefix(prefix []byte, limit uint32, lastSeenKey []byte) ([]*KeyValue, error)

CollectByPrefix collects entries keyed by the prefix from all partitions prefix: the entries should have a key with this prefix limit: number of entries to return lastSeenKey: the last key seen during pagination

func (*ClusterClient) Delete

func (c *ClusterClient) Delete(key *KeyObject) error

Delete deletes one entry by the key.

func (*ClusterClient) Get

func (c *ClusterClient) Get(key *KeyObject) ([]byte, pb.OpAndDataType, error)

Get gets the value bytes by the key

func (*ClusterClient) GetByPrefix

func (c *ClusterClient) GetByPrefix(partitionKey, prefix []byte, limit uint32, lastSeenKey []byte) ([]*KeyValue, error)

GetByPrefix list the entries keyed with the same prefix partitionKey: limit the prefix query to one specific shard. prefix: the entries should have a key with this prefix limit: number of entries to return lastSeenKey: the last key seen during pagination

func (*ClusterClient) GetCluster

func (c *ClusterClient) GetCluster() (*topology.Cluster, error)

GetCluster get access to topology.Cluster for cluster topology information.

func (*ClusterClient) GetFloat64

func (c *ClusterClient) GetFloat64(key *KeyObject) (float64, error)

GetFloat64 get the float64 value by the key The value could have been set by PutFloat64, AddFloat64, PutMaxFloat64, or PutMinFloat64.

func (*ClusterClient) Put

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

Put puts one key value pair to one partition

func (*ClusterClient) PutFloat64

func (c *ClusterClient) PutFloat64(key *KeyObject, value float64) error

PutFloat64 sets a float64 value to the key

func (*ClusterClient) PutMaxFloat64

func (c *ClusterClient) PutMaxFloat64(key *KeyObject, value float64) error

PutMaxFloat64 sets a float64 value to the key, and when getting by the key, the maximum value of all previous values will be returned.

func (*ClusterClient) PutMinFloat64

func (c *ClusterClient) PutMinFloat64(key *KeyObject, value float64) error

PutMinFloat64 sets a float64 value to the key, and when getting by the key, the mininum value of all previous values will be returned.

type KeyObject

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

KeyObject locates a entry, usually by a []byte as a key. Additionally, there could be multiple store partitions. A partition key or partition hash can be used to locate the store partitions. Prefix queries can be fairly fast if the entries shares the same partition.

func Key

func Key(key []byte) *KeyObject

Key creates a key object

func (*KeyObject) GetKey

func (k *KeyObject) GetKey() []byte

GetKey returns the key bytes

func (*KeyObject) GetPartitionHash

func (k *KeyObject) GetPartitionHash() uint64

GetPartitionHash returns the partition hash value

func (*KeyObject) SetPartitionHash

func (k *KeyObject) SetPartitionHash(partitionHash uint64) *KeyObject

SetPartitionHash sets the partition hash to route the key to the right partition.

func (*KeyObject) SetPartitionKey

func (k *KeyObject) SetPartitionKey(partitionKey []byte) *KeyObject

SetPartitionKey sets the partition key, which hash value is used to route the key to the right partition.

type KeyValue

type KeyValue struct {
	*KeyObject
	*ValueObject
}

KeyValue stores a reference to KeyObject, data type, and actual data bytes

func NewKeyValue

func NewKeyValue(key *KeyObject, value *ValueObject) *KeyValue

NewKeyValue creates a KeyValue with a bytes value

type ValueObject

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

func BytesValue

func BytesValue(value []byte) *ValueObject

BytesValue creates a ValueObject with a bytes value

func Float64Value

func Float64Value(value float64) *ValueObject

Float64Value creates a ValueObject with a float64 value

func Value

func Value(value []byte, valueType pb.OpAndDataType) *ValueObject

Value creates a ValueObject with a specific type

func (*ValueObject) GetFloat64

func (v *ValueObject) GetFloat64() float64

GetFloat64 returns the value float64

func (*ValueObject) GetValue

func (v *ValueObject) GetValue() []byte

GetValue returns the value bytes

func (*ValueObject) GetValueType

func (v *ValueObject) GetValueType() pb.OpAndDataType

GetValueType returns the data type of the value

type VastoClient

type VastoClient struct {
	Master          string
	ClientName      string
	ClusterListener *clusterlistener.ClusterListener
	MasterClient    pb.VastoMasterClient
	// contains filtered or unexported fields
}

VastoClient communicates with master to manage and listen to clusters topology changes.

func NewVastoClient

func NewVastoClient(ctx context.Context, clientName, master string) *VastoClient

NewVastoClient creates a vasto client which contains a listener for the vasto system topology changes

func (*VastoClient) CompactCluster

func (c *VastoClient) CompactCluster(keyspace string) error

CompactCluster deletes the cluster of the keyspace in the data center

func (*VastoClient) CreateCluster

func (c *VastoClient) CreateCluster(keyspace string, clusterSize, replicationFactor int) (*pb.Cluster, error)

CreateCluster creates a new cluster of the keyspace in the data center, with size and replication factor

func (*VastoClient) DeleteCluster

func (c *VastoClient) DeleteCluster(keyspace string) error

DeleteCluster deletes the cluster of the keyspace in the data center

func (*VastoClient) NewClusterClient

func (c *VastoClient) NewClusterClient(keyspace string) (clusterClient *ClusterClient)

NewClusterClient create a lightweight client to access a specific cluster in a specific data center. The call will block if the keyspace is not created in this data center.

func (*VastoClient) ReplaceNode

func (c *VastoClient) ReplaceNode(keyspace string, nodeId uint32, newAddress string) error

ReplaceNode replaces one server in the cluster of the keyspace and data center.

func (*VastoClient) ResizeCluster

func (c *VastoClient) ResizeCluster(keyspace string, newClusterSize int) error

ResizeCluster changes the size of the cluster of the keyspace and data center

type WriteConfig

type WriteConfig struct {
	UpdatedAtNs uint64 // the update timestamp in nano seconds. Newer entries overwrite older ones. O means now.
	TtlSecond   uint32 // TTL in seconds. Updated_at + TTL determines the life of the entry. 0 means no TTL.
}

WriteConfig stores options for writing

Jump to

Keyboard shortcuts

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