trans

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 23 Imported by: 0

README

trans

Documentation

Index

Constants

View Source
const RecoverMode = "recover"

Variables

View Source
var (
	ErrMsgFormat   = fmt.Errorf("message format broken")
	ErrTimeout     = fmt.Errorf("read or write timeout")
	ErrReplyFormat = fmt.Errorf("reply format broken")
	ErrNotFound    = fmt.Errorf("trans - key not found")
)
View Source
var (
	ReadHeaderTimeout  = time.Second * 30
	ReadBodyTimeout    = time.Second * 40
	WriteHeaderTimeout = time.Second * 30
	WriteBodyTimeout   = time.Second * 40
)

Functions

func ErasueDecode

func ErasueDecode(shards [][]byte, dataShards int, parShards int) (data []byte, recoverShards [][]byte, err error)

func ErasueEncode

func ErasueEncode(data []byte, dataShards int, parShards int) (shards [][]byte, err error)

func ErasueRecover added in v0.0.3

func ErasueRecover(shards [][]byte, dataShards int, parShards int) (data [][]byte, err error)

func NewEraBS

func NewEraBS(esclient Client, batch int) (*blostore, error)

func NewErasureBlockstore

func NewErasureBlockstore(ctx context.Context, servAddrs []string, connNum int, dataShards, parShards int, batch int, mode string) (*blostore, error)

Types

type Chunker

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

func NewChunker

func NewChunker(r io.Reader, size int) *Chunker

func (*Chunker) NextBytes

func (k *Chunker) NextBytes() ([]byte, error)

type Client

type Client interface {
	Size(string) (int, error)
	Has(string) (bool, error)
	Delete(string) error
	Get(string) ([]byte, error)
	Put(string, []byte) error
	AllKeysChan(string) (chan string, error)
	Close()
	TargetActive() bool
	CheckSum(string) (string, error)
}

type ClientWithInfo added in v0.0.3

type ClientWithInfo struct {
	Client  Client
	Index   int
	Recover bool
}

type ErasureClient

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

func NewErasureClient

func NewErasureClient(chunkClients []Client, dataShards, parShards int, mode string) (*ErasureClient, error)

func (*ErasureClient) AllKeysChan

func (ec *ErasureClient) AllKeysChan(startKey string) (chan string, error)

func (*ErasureClient) CheckSum added in v0.0.5

func (ec *ErasureClient) CheckSum(key string) (string, error)

func (*ErasureClient) Close

func (ec *ErasureClient) Close()

func (*ErasureClient) Delete

func (ec *ErasureClient) Delete(key string) (err error)

func (*ErasureClient) Get

func (ec *ErasureClient) Get(key string) (value []byte, err error)

func (*ErasureClient) Has

func (ec *ErasureClient) Has(key string) (has bool, err error)

func (*ErasureClient) Put

func (ec *ErasureClient) Put(key string, value []byte) (err error)

func (*ErasureClient) Size

func (ec *ErasureClient) Size(key string) (n int, err error)

func (*ErasureClient) TargetActive

func (ec *ErasureClient) TargetActive() bool
type Head struct {
	Act   action
	KSize uint32
	VSize uint32
}

func HeadFrom

func HeadFrom(buf []byte) (h *Head, err error)

type Msg

type Msg struct {
	Act   action
	Key   string
	Value []byte
}

func (*Msg) Encode

func (m *Msg) Encode() []byte

*

action		:	key size	:	value size	: 	key		:	value
	1   	:   	4   	:   	4		:	n		:	n

*

func (*Msg) From

func (m *Msg) From(h *Head, buf []byte)

the buf here only contains bytes of key and value, no header bytes here

func (*Msg) FromBytes

func (m *Msg) FromBytes(buf []byte) (err error)

type PServ

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

func NewPServ

func NewPServ(ctx context.Context, addr string, db kv.KVDB) (*PServ, error)

func (*PServ) Close

func (s *PServ) Close()

type RecoverClient added in v0.0.3

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

func NewRecoverClient added in v0.0.3

func NewRecoverClient(chunkClients []*ClientWithInfo, dataShards, parShards int) (*RecoverClient, error)

func (*RecoverClient) Close added in v0.0.3

func (ec *RecoverClient) Close()

func (*RecoverClient) ExportAllKeys added in v0.0.3

func (ec *RecoverClient) ExportAllKeys(startKey, pathToAllKeys string) error

func (*RecoverClient) Recover added in v0.0.3

func (ec *RecoverClient) Recover(startKey string) (err error)

func (*RecoverClient) RecoverCheck added in v0.0.3

func (ec *RecoverClient) RecoverCheck(pathToAllKeys, pathToUnrecoverKeys string) (err error)

func (*RecoverClient) RecoverFromFile added in v0.0.3

func (ec *RecoverClient) RecoverFromFile(startKey, pathToAllKeys string) (err error)

func (*RecoverClient) RecoverKey added in v0.0.3

func (ec *RecoverClient) RecoverKey(key string) (err error)

type Reply

type Reply struct {
	Code repcode
	Body []byte
}

func (*Reply) Dump added in v0.0.3

func (r *Reply) Dump(w net.Conn) (n int, err error)

func (*Reply) DumpQuic added in v0.1.1

func (r *Reply) DumpQuic(w quic.Stream) (n int, err error)

func (*Reply) Encode

func (r *Reply) Encode() []byte

*

repcode		:	body size	:		body
	1   	:   	4   	:   	n

*

func (*Reply) From

func (r *Reply) From(h *ReplyHead, buf []byte)

Caution: buf here only contains bytes of body

type ReplyHead

type ReplyHead struct {
	Code     repcode
	BodySize uint32
}

func ReplyHeadFrom

func ReplyHeadFrom(buf []byte) (h *ReplyHead, err error)

type TransClient

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

func NewTransClient

func NewTransClient(ctx context.Context, target string, connNum int) *TransClient

func (*TransClient) AllKeysChan

func (tc *TransClient) AllKeysChan(startKey string) (chan string, error)

func (*TransClient) CheckSum added in v0.0.5

func (tc *TransClient) CheckSum(key string) (string, error)

func (*TransClient) Close

func (tc *TransClient) Close()

func (*TransClient) Delete

func (tc *TransClient) Delete(key string) error

func (*TransClient) Get

func (tc *TransClient) Get(key string) ([]byte, error)

func (*TransClient) Has

func (tc *TransClient) Has(key string) (bool, error)

func (*TransClient) Put

func (tc *TransClient) Put(key string, value []byte) error

func (*TransClient) Size

func (tc *TransClient) Size(key string) (int, error)

func (*TransClient) TargetActive

func (tc *TransClient) TargetActive() bool

Jump to

Keyboard shortcuts

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