server

package
v0.0.0-...-ff2926d Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("not supported")
View Source
var ErrTxnDifferentShard = errors.Wrap(ErrNotSupported, "txn in different shard")

Functions

This section is empty.

Types

type BackendServers

type BackendServers struct {
	KV pb.KVServer
}

type DefaultResponseFilter

type DefaultResponseFilter struct {
}

func (DefaultResponseFilter) FilterDeleteRange

func (DefaultResponseFilter) FilterDeleteRange(resps []*pb.DeleteRangeResponse) (*pb.DeleteRangeResponse, error)

func (DefaultResponseFilter) FilterRange

func (DefaultResponseFilter) FilterRange(req *pb.RangeRequest, resps []*pb.RangeResponse) (*pb.RangeResponse, error)

type DefaultShardingConfigs

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

func NewDefaultShardingConfigs

func NewDefaultShardingConfigs(shards []Shard) *DefaultShardingConfigs

func (*DefaultShardingConfigs) GetShardCli

func (d *DefaultShardingConfigs) GetShardCli(shard int) ShardClient

func (*DefaultShardingConfigs) GetShardClis

func (d *DefaultShardingConfigs) GetShardClis(key []byte, rangeEnd []byte) []ShardClient

type EtcdGrpcClient

type EtcdGrpcClient interface {
	// pb.ClusterClient
	pb.KVClient
}

type GroupRunner

type GroupRunner interface {
	Add(func() error)
	Do() error
}

type GroupRunnerFactory

type GroupRunnerFactory interface {
	GetGroupRunner() GroupRunner
}

func NewDefaultGroupRunnerFactory

func NewDefaultGroupRunnerFactory() GroupRunnerFactory

type GroupRunnerFactoryImpl

type GroupRunnerFactoryImpl struct {
}

func (*GroupRunnerFactoryImpl) GetGroupRunner

func (d *GroupRunnerFactoryImpl) GetGroupRunner() GroupRunner

type GroupRunnerImpl

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

func (*GroupRunnerImpl) Add

func (d *GroupRunnerImpl) Add(f func() error)

func (*GroupRunnerImpl) Do

func (d *GroupRunnerImpl) Do() error

type GrpcServer

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

func NewGrpcServer

func NewGrpcServer(servers BackendServers, opts ...grpc.ServerOption) (*GrpcServer, error)

func (*GrpcServer) Serve

func (s *GrpcServer) Serve(addr string, port int) error

type ResponseFilter

type ResponseFilter interface {
	FilterRange(req *pb.RangeRequest, resps []*pb.RangeResponse) (*pb.RangeResponse, error)
	FilterDeleteRange([]*pb.DeleteRangeResponse) (*pb.DeleteRangeResponse, error)
}

type Shard

type Shard interface {
	Contains(key []byte, rangeEnd []byte) bool
	GetClient() ShardClient
}

type ShardClient

type ShardClient interface {
	pb.KVClient
	GetShardID() int
}

type ShardClientConfig

type ShardClientConfig struct {
}

TODO:

type ShardClientImpl

type ShardClientImpl struct {
	EtcdGrpcClient
	// contains filtered or unexported fields
}

func NewShardClientImpl

func NewShardClientImpl(shardID int, address string) (*ShardClientImpl, error)

func (*ShardClientImpl) GetShardID

func (s *ShardClientImpl) GetShardID() int

type ShardImpl

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

ShardImpl is the implementation of Shard

func NewShardImpl

func NewShardImpl(shardID int, totalShards int, conf config.Shard) (*ShardImpl, error)

func (*ShardImpl) Contains

func (s *ShardImpl) Contains(key []byte, rangeEnd []byte) bool

Contains returns true if the key is in the range of the shard.

func (*ShardImpl) GetClient

func (s *ShardImpl) GetClient() ShardClient

GetClient returns the client of the shard.

type ShardingConfigs

type ShardingConfigs interface {
	GetShardClis(key []byte, rangeEnd []byte) []ShardClient
	GetShardCli(shard int) ShardClient
}

type ShardingProxy

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

func NewShardingProxy

func NewShardingProxy(groupRunners GroupRunnerFactory, configs ShardingConfigs, respFilter ResponseFilter) *ShardingProxy

func (*ShardingProxy) Compact

Compact compacts the event history in the etcd key-value store. The key-value store should be periodically compacted or the event history will continue to grow indefinitely.

func (*ShardingProxy) DeleteRange

DeleteRange deletes the given range from the key-value store. A delete request increments the revision of the key-value store and generates a delete event in the event history for every deleted key.

func (*ShardingProxy) Put

func (s *ShardingProxy) Put(ctx context.Context, req *pb.PutRequest) (*pb.PutResponse, error)

Put puts the given key into the key-value store. A put request increments the revision of the key-value store and generates one event in the event history.

func (*ShardingProxy) Range

Range gets the keys in the range from the key-value store.

func (*ShardingProxy) Txn

func (s *ShardingProxy) Txn(ctx context.Context, req *pb.TxnRequest) (*pb.TxnResponse, error)

Txn processes multiple requests in a single transaction. A txn request increments the revision of the key-value store and generates events with the same revision for every completed request. It is not allowed to modify the same key several times within one txn.

Jump to

Keyboard shortcuts

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