pkgs

package
v0.0.0-...-169d7d5 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package pkgs is silo's per-repo dependency-index facade. It opens <repo>.git/pkgs.sqlite3 lazily via the git-pkgs/index package, caches open handles in an LRU, and provides a handler for the pkgs-reindex job kind drained by internal/jobs.

Index

Constants

View Source
const DBFile = "pkgs.sqlite3"

DBFile is the per-bare-repo sqlite filename.

View Source
const DefaultCacheSize = 32

DefaultCacheSize bounds open index.Index handles in the Store LRU.

View Source
const JobKind = "pkgs-reindex"

JobKind is the registered jobs.Worker handler key.

View Source
const MaxManifestBytes = 10 * 1024 * 1024

MaxManifestBytes caps the input passed to manifests.Parse for one-sided or two-sided render calls. Mirrors the cap silo plans to land upstream in manifests; until that lands, this is silo's local bound.

Variables

This section is empty.

Functions

func IsManifest

func IsManifest(path string) bool

IsManifest reports whether silo should render path with the rich manifest view rather than the raw blob view.

func ReindexHandler

func ReindexHandler(ps *Store, gst *gitstore.Store) func(ctx context.Context, j store.Job) error

ReindexHandler builds the jobs.Handler that decodes a ReindexPayload and invokes Store.Reindex.

Types

type DeltaCache

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

DeltaCache memoises Textconv results by (oldOID, newOID, path). This is the placeholder until `git-pkgs/oidcache` lands; it intentionally uses a drop-the-whole-map eviction policy because per-pair Textconv calls are cheap to recompute.

func NewDeltaCache

func NewDeltaCache() *DeltaCache

NewDeltaCache returns a DeltaCache capped at 4096 entries.

func (*DeltaCache) GetOrCompute

func (c *DeltaCache) GetOrCompute(oldOID, newOID, path string, fn func() (*FileDelta, error)) (*FileDelta, error)

GetOrCompute returns the cached *FileDelta for the given OID pair and path, computing it via `fn` on miss. `fn` is invoked at most once per key under normal contention.

func (*DeltaCache) SetCap

func (c *DeltaCache) SetCap(n int64)

SetCap overrides the entry cap (test hook).

type DepGroup

type DepGroup struct {
	Scope manifests.Scope
	Deps  []manifests.Dependency
}

DepGroup is one runtime/dev/test scope inside a FileView.

type DepUpdate

type DepUpdate struct {
	Name string
	PURL string
	From string
	To   string
}

DepUpdate describes a name whose requirement changed between two revisions.

type FileDelta

type FileDelta struct {
	Path      string
	Ecosystem string
	Kind      manifests.Kind
	Added     []manifests.Dependency
	Removed   []manifests.Dependency
	Updated   []DepUpdate
}

FileDelta is the rich "+kamal 1.0.0 / puma 5→6" view of one changed manifest. Computed statelessly from the two blob payloads.

func Textconv

func Textconv(path string, oldBlob, newBlob []byte) (*FileDelta, error)

Textconv parses both sides and emits the +/-/Δ delta. Either oldBlob or newBlob may be nil for added/removed files. Returns (nil, nil) when the path is unrecognised, the surviving side is too large, or both sides fail to parse.

type FileView

type FileView struct {
	Path      string
	Ecosystem string
	Kind      manifests.Kind
	Groups    []DepGroup
	Total     int
	Direct    int
}

FileView is the one-sided dependency table rendered on the blob page.

func Render

func Render(path string, blob []byte) (*FileView, error)

Render parses one blob into a FileView. Returns (nil, nil) for blobs over MaxManifestBytes, files manifests doesn't recognise, or parse failures — the caller should then fall through to the raw source view.

type ReindexPayload

type ReindexPayload struct {
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
	Branch string `json:"branch"`
	Old    string `json:"old"`
	New    string `json:"new"`
}

ReindexPayload is the JSON encoded in the jobs.payload column for a pkgs-reindex job.

type Store

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

Store is an LRU of repoPath -> *index.Index. Concurrent Index calls for the same repo serialise; for different repos they overlap.

func Open

func Open(opts index.Options) *Store

Open returns a new Store with DefaultCacheSize entries.

func (*Store) Close

func (s *Store) Close()

Close releases every cached handle.

func (*Store) Index

func (s *Store) Index(repoPath string) (*index.Index, error)

Index returns (and caches) the *index.Index for the bare repo at repoPath. repoPath must end in `.git`. The db is created on first Open with the store's configured Options.

func (*Store) Reindex

func (s *Store) Reindex(ctx context.Context, gst *gitstore.Store, owner, repo, branch string, old, new plumbing.Hash) error

Reindex resolves the bare repo for owner/repo via gitstore, opens the index db, and walks old..new on the branch. Evicts any cached handle for this repo first so go-git re-reads the on-disk object store: a long-lived open *git.Repository can miss loose objects that were written by another process between the previous reindex and this one.

func (*Store) SetCap

func (s *Store) SetCap(n int)

SetCap overrides the LRU capacity (test hook).

Jump to

Keyboard shortcuts

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