pkg

package
v0.0.0-...-f223905 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxKeyLength = 65535
	SizeOfUUID   = 16
)
View Source
const (
	MajorKeyField = Field(iota)
	RegionNameField
	MinorKeyField
	TimestampField
)

Variables

View Source
var (
	ErrorIndexOutOfBounds     = errors.New("index out of bounds")
	ErrorEmptyKey             = errors.New("empty key")
	ErrorWrongSize            = errors.New("wrong size")
	ErrorUnsupportedOperation = errors.New("unsupported operation")
)

Functions

func DecodeKey

func DecodeKey(entryKey []byte) (*pb.Key, error)

func EncodeKey

func EncodeKey(key *pb.Key) (entryKey, rowKey []byte)

func EncodeKeyPrefix

func EncodeKeyPrefix(key *pb.Key, lastField Field) ([]byte, error)

func Equal

func Equal(left *pb.Key, right *pb.Key) bool

func FetchRecord

func FetchRecord(key *pb.Key, item *badger.Item, headOnly bool) (*pb.Record, error)

func NewLogger

func NewLogger(logdir, filename string) (*zap.Logger, error)

func RecordFetched

func RecordFetched(key *pb.Key, item *badger.Item, data []byte) *pb.Record

func RecordNotFetched

func RecordNotFetched(key *pb.Key, item *badger.Item) *pb.Record

func RecordNotFound

func RecordNotFound(key *pb.Key) *pb.Record

func SanitizeKeyLen

func SanitizeKeyLen(len int) int

Types

type BlockSender

type BlockSender interface {
	Send(*pb.Block) error
}

type Configuration

type Configuration struct {
	Host     string `yaml:"host"`
	HttpPort int    `yaml:"httpPort"`
	GrpcPort int    `yaml:"grpcPort"`

	HttpAddress string
	GrpcAddress string

	DataDir string `yaml:"dataDir"`

	KeyDir   string
	ValueDir string
	WalDir   string
	SnapDir  string
	LogDir   string

	NumCPU int `yaml:"numCPU"` // use all of <= 0

}

func LoadConfiguration

func LoadConfiguration(fileName string) (conf *Configuration, err error)

func NewDefaultConfiguration

func NewDefaultConfiguration(dataDir string) (conf *Configuration, err error)

type DefaultServer

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

func NewServer

func NewServer(conf *Configuration) (server *DefaultServer, err error)

func (*DefaultServer) Close

func (this *DefaultServer) Close()

func (*DefaultServer) Get

func (this *DefaultServer) Get(ctx context.Context, keyRequest *pb.KeyRequest) (*pb.Record, error)

Gets exact match entry

func (*DefaultServer) GetRange

func (this *DefaultServer) GetRange(ctx context.Context, rangeRequest *pb.RangeRequest) (*pb.Block, error)

Gets range of timestamps inside a row

func (*DefaultServer) GetRecent

func (this *DefaultServer) GetRecent(ctx context.Context, keyRequest *pb.KeyRequest) (*pb.Record, error)

Gets early or equal timestamp entry

func (*DefaultServer) GetRegion

func (this *DefaultServer) GetRegion(keyRequest *pb.KeyRequest, response pb.KeyValueService_GetRegionServer) error

Gets the whole region of records

func (*DefaultServer) GetRow

func (this *DefaultServer) GetRow(keyRequest *pb.KeyRequest, response pb.KeyValueService_GetRowServer) error

Gets the whole raw of records with all available timestamps with latest versions

func (*DefaultServer) GetSpace

func (this *DefaultServer) GetSpace(keyRequest *pb.KeyRequest, response pb.KeyValueService_GetSpaceServer) error

Gets the whole space of records associated with majorKey

func (*DefaultServer) Put

func (this *DefaultServer) Put(ctx context.Context, recordRequest *pb.RecordRequest) (*pb.Status, error)

Puts the record

func (*DefaultServer) Remove

func (this *DefaultServer) Remove(ctx context.Context, keyRequest *pb.KeyRequest) (*pb.Status, error)

Remove the record

func (*DefaultServer) Scan

func (this *DefaultServer) Scan(scanRequest *pb.ScanRequest, response pb.KeyValueService_ScanServer) error

Gets all records

func (*DefaultServer) ServeGRPC

func (this *DefaultServer) ServeGRPC() error

func (*DefaultServer) Touch

func (this *DefaultServer) Touch(ctx context.Context, recordRequest *pb.RecordRequest) (*pb.Status, error)

Touches the record

type Field

type Field int

type KeyValueStorage

type KeyValueStorage interface {
	Get(keyRequest *pb.KeyRequest) (*pb.Record, error)

	GetRecent(keyRequest *pb.KeyRequest) (*pb.Record, error)

	GetRange(rangeRequest *pb.RangeRequest) (*pb.Block, error)

	GetArea(keyRequest *pb.KeyRequest, lastField Field, sender BlockSender) error

	Scan(scanRequest *pb.ScanRequest, sender BlockSender) error

	Touch(recordRequest *pb.RecordRequest) (*pb.Status, error)

	Put(recordRequest *pb.RecordRequest) (*pb.Status, error)

	Remove(keyRequest *pb.KeyRequest) (*pb.Status, error)

	Close() error
}

type KeyValueStorageCtx

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

func OpenKeyValueStorage

func OpenKeyValueStorage(conf *Configuration, log *zap.Logger) (context *KeyValueStorageCtx, err error)

func (*KeyValueStorageCtx) Close

func (this *KeyValueStorageCtx) Close() error

func (*KeyValueStorageCtx) Get

func (this *KeyValueStorageCtx) Get(keyRequest *pb.KeyRequest) (*pb.Record, error)

func (*KeyValueStorageCtx) GetArea

func (this *KeyValueStorageCtx) GetArea(keyRequest *pb.KeyRequest, lastField Field, sender BlockSender) error

func (*KeyValueStorageCtx) GetRange

func (this *KeyValueStorageCtx) GetRange(rangeRequest *pb.RangeRequest) (*pb.Block, error)

func (*KeyValueStorageCtx) GetRecent

func (this *KeyValueStorageCtx) GetRecent(keyRequest *pb.KeyRequest) (*pb.Record, error)

func (*KeyValueStorageCtx) Put

func (this *KeyValueStorageCtx) Put(recordRequest *pb.RecordRequest) (*pb.Status, error)

func (*KeyValueStorageCtx) Remove

func (this *KeyValueStorageCtx) Remove(keyRequest *pb.KeyRequest) (*pb.Status, error)

func (*KeyValueStorageCtx) Scan

func (this *KeyValueStorageCtx) Scan(scanRequest *pb.ScanRequest, sender BlockSender) error

func (*KeyValueStorageCtx) Touch

func (this *KeyValueStorageCtx) Touch(recordRequest *pb.RecordRequest) (*pb.Status, error)

Directories

Path Synopsis
Package pb is a reverse proxy.
Package pb is a reverse proxy.

Jump to

Keyboard shortcuts

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