metadatastore

package
v0.0.0-...-caedbbb Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package metadatastore contains some datastructures that are part of a binary cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseNarinfo

func ParseNarinfo(narinfo *narinfo.NarInfo) (*PathInfo, *NarMeta, error)

ParseNarinfo parses a narinfo.NarInfo struct and returns a PathInfo and NarMeta struct, or an error.

func RenderNarinfo

func RenderNarinfo(pathInfo *PathInfo, narMeta *NarMeta, compressionType string) (string, error)

RenderNarinfo renders a minimal .narinfo from a PathInfo and NarMeta. The URL is synthesized to /nar/$narhash.nar[$compressionSuffix].

Types

type FileStore

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

func NewFileStore

func NewFileStore(baseDirectory string) (*FileStore, error)

func (*FileStore) Close

func (fs *FileStore) Close() error

func (*FileStore) DropAll

func (fs *FileStore) DropAll(ctx context.Context) error

func (*FileStore) GetNarMeta

func (fs *FileStore) GetNarMeta(ctx context.Context, narHash []byte) (*NarMeta, error)

func (*FileStore) GetPathInfo

func (fs *FileStore) GetPathInfo(ctx context.Context, outputHash []byte) (*PathInfo, error)

func (*FileStore) PutNarMeta

func (fs *FileStore) PutNarMeta(ctx context.Context, narMeta *NarMeta) error

func (*FileStore) PutPathInfo

func (fs *FileStore) PutPathInfo(ctx context.Context, pathinfo *PathInfo) error

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) Close

func (ms *MemoryStore) Close() error

func (*MemoryStore) DropAll

func (ms *MemoryStore) DropAll(ctx context.Context) error

func (*MemoryStore) GetNarMeta

func (ms *MemoryStore) GetNarMeta(ctx context.Context, narHash []byte) (*NarMeta, error)

func (*MemoryStore) GetPathInfo

func (ms *MemoryStore) GetPathInfo(ctx context.Context, outputHash []byte) (*PathInfo, error)

func (*MemoryStore) PutNarMeta

func (ms *MemoryStore) PutNarMeta(ctx context.Context, narMeta *NarMeta) error

func (*MemoryStore) PutPathInfo

func (ms *MemoryStore) PutPathInfo(ctx context.Context, pathinfo *PathInfo) error

type MetadataStore

type MetadataStore interface {
	GetPathInfo(ctx context.Context, outputHash []byte) (*PathInfo, error)
	PutPathInfo(ctx context.Context, pathInfo *PathInfo) error

	// TODO: once we have reference scanning, it shouldn't be possible to mutate existing NarMetas
	GetNarMeta(ctx context.Context, narHash []byte) (*NarMeta, error)
	PutNarMeta(ctx context.Context, narMeta *NarMeta) error
	DropAll(ctx context.Context) error
	io.Closer
}

type NarMeta

type NarMeta struct {
	NarHash []byte
	Size    uint64

	References    [][]byte // this refers to multiple PathInfo.OutputHash
	ReferencesStr []string // we still keep the strings around, so we don't need to look up all other PathInfo objects
}

func (*NarMeta) Check

func (n *NarMeta) Check() error

Check provides some sanity checking on values in the NarMeta struct.

func (*NarMeta) IsEqualTo

func (n *NarMeta) IsEqualTo(other *NarMeta, compareReferences bool) bool

IsEqualTo returns true if the other NarMeta is equal to it The compareReferences parameter controls whether references should be compared.

type PathInfo

type PathInfo struct {
	OutputHash []byte
	Name       string

	NarHash []byte

	Deriver           string
	System            string
	NarinfoSignatures []*narinfo.Signature

	CA string
}

func (*PathInfo) Check

func (pi *PathInfo) Check() error

func (*PathInfo) StorePath

func (pi *PathInfo) StorePath() string

Jump to

Keyboard shortcuts

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