chunk

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 32 Imported by: 13

Documentation

Index

Constants

View Source
const (
	CsNone   = "none"
	CsFull   = "full"
	CsShrink = "shrink"
	CsExtend = "extend"
)

--- Checksum ---

View Source
const SlowRequest = time.Second * time.Duration(10)

Variables

This section is empty.

Functions

func NewPageReader

func NewPageReader(p *Page) *pageReader

Types

type CacheManager

type CacheManager interface {
	// contains filtered or unexported methods
}

type ChunkStore

type ChunkStore interface {
	NewReader(id uint64, length int) Reader
	NewWriter(id uint64) Writer
	Remove(id uint64, length int) error
	FillCache(id uint64, length uint32) error
	EvictCache(id uint64, length uint32) error
	CheckCache(id uint64, length uint32, handler func(exists bool, loc string, size int)) error
	UsedMemory() int64
	UpdateLimit(upload, download int64)
}

func NewCachedStore

func NewCachedStore(storage object.ObjectStorage, config Config, reg prometheus.Registerer) ChunkStore

NewCachedStore create a cached store.

type Config

type Config struct {
	CacheDir          string
	CacheMode         os.FileMode
	CacheSize         uint64
	CacheItems        int64
	CacheChecksum     string
	CacheEviction     string
	CacheScanInterval time.Duration
	CacheExpire       time.Duration
	OSCache           bool
	FreeSpace         float32
	AutoCreate        bool
	Compress          string
	MaxUpload         int
	MaxStageWrite     int
	MaxRetries        int
	UploadLimit       int64 // bytes per second
	DownloadLimit     int64 // bytes per second
	Writeback         bool
	UploadDelay       time.Duration
	UploadHours       string
	HashPrefix        bool
	BlockSize         int
	GetTimeout        time.Duration
	PutTimeout        time.Duration
	CacheFullBlock    bool
	CacheLargeWrite   bool
	BufferSize        uint64
	Readahead         int
	Prefetch          int
}

Config contains options for cachedStore

func (*Config) CacheEnabled added in v0.1.3

func (c *Config) CacheEnabled() bool

func (*Config) SelfCheck

func (c *Config) SelfCheck(uuid string)

type Controller

type Controller struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewController added in v0.1.3

func NewController() *Controller

func (*Controller) Execute

func (con *Controller) Execute(key string, fn func() (*Page, error)) (*Page, error)

func (*Controller) TryPiggyback added in v0.1.3

func (con *Controller) TryPiggyback(key string) (*Page, error)

type DiskFreeRatio added in v0.1.3

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

type Page

type Page struct {
	Data []byte
	// contains filtered or unexported fields
}

Page is a page with refcount

func NewOffPage

func NewOffPage(size int) *Page

func NewPage

func NewPage(data []byte) *Page

NewPage create a new page.

func (*Page) Acquire

func (p *Page) Acquire()

Acquire increase the refcount

func (*Page) Release

func (p *Page) Release()

Release decrease the refcount

func (*Page) Slice

func (p *Page) Slice(off, len int) *Page

type ReadCloser

type ReadCloser interface {
	// io.Reader
	io.ReaderAt
	io.Closer
}

type Reader

type Reader interface {
	ReadAt(ctx context.Context, p *Page, off int) (int, error)
}

type Writer

type Writer interface {
	io.WriterAt
	ID() uint64
	SetID(id uint64)
	SetWriteback(enabled bool)
	FlushTo(offset int) error
	Finish(length int) error
	Abort()
}

Jump to

Keyboard shortcuts

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