container

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChunkHashSize         = 32
	ChunkRecordSizeSize   = 4
	ChunkRecordHeaderSize = ChunkHashSize + ChunkRecordSizeSize
)
View Source
const (
	ContainerMagic  = "ColdKeep" // must be exactly 8 bytes
	ContainerHdrLen = 64         // fixed header size in bytes
)
View Source
const (
	ContainerVersionMajor = 0
	ContainerVersionMinor = 6
)
View Source
const (
	FLAG_BLOCK_LAYOUT  = 1 << 0 // container uses block-based layout
	FLAG_HAS_BLOCK_TBL = 1 << 1 // optional block index present
)

Reserved future flags (not used yet)

Variables

View Source
var ContainersDir = utils_env.GetenvOrDefault("COLDKEEP_STORAGE_DIR", "./storage/containers")

Functions

func BuildChunkRecord added in v0.6.0

func BuildChunkRecord(chunk []byte) []byte

func CheckContainerHashFile added in v0.4.0

func CheckContainerHashFile(id int, filename, storedHash string) error

func GetContainerMaxSize

func GetContainerMaxSize() int64

GetContainerMaxSize returns the current container max size

func ReadChunkDataAt added in v0.6.0

func ReadChunkDataAt(c Container, offset int64, expectedSize int64) ([]byte, error)

func SealContainer

func SealContainer(tx db.DBTX, containerID int64, filename string) error

func SetContainerMaxSize

func SetContainerMaxSize(size int64)

SetContainerMaxSize sets the container max size (for testing)

func UpdateContainerSize

func UpdateContainerSize(tx db.DBTX, containerID int64, newSize int64) error

Types

type ActiveContainer added in v0.6.0

type ActiveContainer struct {
	ID        int64
	Filename  string
	Container Container
	MaxSize   int64
}

func GetOrCreateOpenContainer

func GetOrCreateOpenContainer(db db.DBTX) (ActiveContainer, error)

type Container added in v0.6.0

type Container interface {
	Append(data []byte) (offset int64, err error)
	ReadAt(offset int64, size int64) ([]byte, error)
	Sync() error
	Close() error
}

type FileContainer added in v0.6.0

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

func OpenExistingContainer added in v0.6.0

func OpenExistingContainer(readonly bool, path string, maxSize int64) (*FileContainer, error)

func (*FileContainer) Append added in v0.6.0

func (c *FileContainer) Append(data []byte) (int64, error)

func (*FileContainer) Close added in v0.6.0

func (c *FileContainer) Close() error

func (*FileContainer) ReadAt added in v0.6.0

func (c *FileContainer) ReadAt(offset int64, size int64) ([]byte, error)

func (*FileContainer) Sync added in v0.6.0

func (c *FileContainer) Sync() error

Jump to

Keyboard shortcuts

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