packs

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedReader added in v0.2.0

type CachedReader struct {
	Limiter rate.Limiter
	// contains filtered or unexported fields
}

func NewCachedReader added in v0.2.0

func NewCachedReader(log *slog.Logger, cache lru.Cache[*Pack]) *CachedReader

NewCachedReader creates a new cached reader

func (*CachedReader) Read added in v0.2.0

func (r *CachedReader) Read(ctx context.Context, repo repos.Repo, packId string) (*Pack, error)

type Chunk added in v0.2.0

type Chunk struct {
	Path    string      `json:"path,omitempty"`
	Mode    fs.FileMode `json:"mode,omitempty"`
	Size    int64       `json:"size,omitempty"`
	Hash    string      `json:"hash,omitempty"`
	ModTime int64       `json:"modtime,omitempty"`
	// Data can be set if the file is small enough to fit in one chunk. Otherwise
	// it will be nil and the file will be chunked with links to the blobs
	Data []byte `json:"data,omitempty"`
	Refs []*Ref `json:"refs,omitempty"`
}

Chunk can either be file metadata or a blob. If the file is small enough to fit in one chunk, it can be a file with data.

func (*Chunk) Key added in v0.2.0

func (c *Chunk) Key() string

func (*Chunk) Kind added in v0.2.0

func (c *Chunk) Kind() string

func (*Chunk) Length added in v0.2.0

func (c *Chunk) Length() int
func (c *Chunk) Link(pack string, chunk *Chunk)
func (c *Chunk) Links() []*Ref

func (*Chunk) Print added in v0.2.0

func (c *Chunk) Print(w io.StringWriter)

func (*Chunk) String added in v0.2.0

func (c *Chunk) String() string

type Pack

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

func New

func New() *Pack

func Read

func Read(ctx context.Context, repo repos.Repo, packId string) (*Pack, error)

func Unpack

func Unpack(data []byte) (*Pack, error)

Unpack reads a pack from a byte slice

func (*Pack) Add

func (p *Pack) Add(chunks ...*Chunk)

func (*Pack) Chunk added in v0.2.0

func (p *Pack) Chunk(key string) (*Chunk, bool)

func (*Pack) Chunks added in v0.2.0

func (p *Pack) Chunks() []*Chunk

func (*Pack) Encode

func (p *Pack) Encode(w io.Writer) error

func (*Pack) Length added in v0.2.0

func (p *Pack) Length() int

Length returns the number of bytes in the pack

func (*Pack) Pack

func (p *Pack) Pack() ([]byte, error)

func (*Pack) Print added in v0.2.0

func (p *Pack) Print(w io.StringWriter)

func (*Pack) String added in v0.2.0

func (p *Pack) String() string

type Reader added in v0.2.0

type Reader interface {
	Read(ctx context.Context, repo repos.Repo, packId string) (*Pack, error)
}

type Ref added in v0.2.0

type Ref struct {
	Pack string
	Hash string
}

Ref is a reference to another blob chunk

Jump to

Keyboard shortcuts

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