forgecache

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package forgecache provides a persistent cache for CI check-run results from code hosting forges (GitHub, GitLab, etc.). Only terminal results (all checks completed) are stored. The cache is backed by a single JSON file and is safe for concurrent use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a thread-safe persistent store of terminal CI results keyed by "owner/repo/sha". Pending states are never cached. The cache also tracks which (taskID, sha) pairs have already been notified to avoid duplicate messages to agents. Both maps are pruned on load: entries older than maxAge are discarded.

func Open

func Open(path string) (*Cache, error)

Open loads or creates a Cache backed by path. If path is empty, the cache operates in-memory only (no persistence). Returns a functional empty cache if the file does not exist or cannot be parsed. Malformed files are logged and discarded in full, including notification records; filesystem errors other than missing files are returned.

func (*Cache) Get

func (c *Cache) Get(owner, repo, sha string) (Result, bool)

Get returns the cached Result for (owner, repo, sha), or (Result{}, false) on a cache miss.

func (*Cache) IsNotified

func (c *Cache) IsNotified(taskID, sha string) bool

IsNotified reports whether a CI result has already been sent to the agent for the given task and SHA.

func (*Cache) MarkNotified

func (c *Cache) MarkNotified(taskID, sha string) error

MarkNotified records that a CI result has been sent to the agent for the given task and SHA, and persists to disk.

func (*Cache) Put

func (c *Cache) Put(owner, repo, sha string, r Result) error

Put stores a terminal Result for (owner, repo, sha) and persists to disk.

type Result

type Result struct {
	Status   forge.CIStatus
	Checks   []forge.Check
	CachedAt time.Time
}

Result is the cached outcome for a commit SHA. Only written once all check-runs for that SHA have completed.

Directories

Path Synopsis
Package data defines the on-disk CI results and notification cache.
Package data defines the on-disk CI results and notification cache.

Jump to

Keyboard shortcuts

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