actionscache

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConflict     = errors.New("cache entry already exists")
	ErrNotFound     = errors.New("cache entry not found")
	ErrSizeMismatch = errors.New("cache size does not match uploaded blocks")
	ErrIncomplete   = errors.New("cache upload is incomplete")
	ErrStagingFull  = errors.New("cache staging budget exceeded")
)

Functions

func NewHandler

func NewHandler(cfg HandlerConfig) (http.Handler, error)

Types

type Entry

type Entry struct {
	ID           string
	DatabaseID   int64
	RepositoryID string
	Scope        string
	Key          string
	Version      string
	Size         int64
	Parts        []string
}

type Grant

type Grant struct {
	Scope      string
	Permission int64
}

type HandlerConfig

type HandlerConfig struct {
	Store             *Store
	Verifier          *Verifier
	BaseURL           string
	UpstreamURL       string
	UpstreamTransport http.RoundTripper
	MaxSizeBytes      int64
	MaxIdle           time.Duration
	OnCleanupError    func(error)
}

type Principal

type Principal struct {
	RepositoryID string
	Grants       []Grant
}

func (Principal) AuthorizeMetadata

func (p Principal) AuthorizeMetadata(metadata *entitypb.CacheMetadata) error

AuthorizeMetadata ensures request metadata cannot widen a signed grant. Cache identity is always derived from the verified token, never metadata.

func (Principal) CanRead

func (p Principal) CanRead(scope string) bool

func (Principal) FirstWritableScope

func (p Principal) FirstWritableScope() string

func (Principal) ReadableScopes

func (p Principal) ReadableScopes() []string

type Reservation

type Reservation struct{ ID string }

type Service

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

func NewService

func NewService(cfg config.ActionsCacheConfig, logger *slog.Logger) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Failures

func (s *Service) Failures() <-chan error

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

func (*Service) Status

func (s *Service) Status() ServiceStatus

type ServiceStatus

type ServiceStatus struct {
	Ready    bool
	Degraded bool
	Entries  int64
	Bytes    int64
}

type Store

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

func OpenStore

func OpenStore(root string) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) EntryByID

func (s *Store) EntryByID(ctx context.Context, id string) (Entry, error)

func (*Store) Finalize

func (s *Store) Finalize(ctx context.Context, p Principal, key, version string, declaredSize int64) (Entry, error)

func (*Store) Lookup

func (s *Store) Lookup(ctx context.Context, p Principal, key string, restoreKeys []string, version string) (Entry, bool, error)

func (*Store) OpenEntry

func (s *Store) OpenEntry(entry Entry) (io.ReadSeekCloser, error)

func (*Store) PutBlob

func (s *Store) PutBlob(ctx context.Context, id string, body io.Reader) error

func (*Store) PutPart

func (s *Store) PutPart(ctx context.Context, id, blockID string, body io.Reader) error

func (*Store) Reserve

func (s *Store) Reserve(ctx context.Context, p Principal, key, version string) (Reservation, error)

func (*Store) SetBlockList

func (s *Store) SetBlockList(ctx context.Context, id string, blockIDs []string) error

func (*Store) SetStagingLimit

func (s *Store) SetStagingLimit(bytes int64)

func (*Store) Stats

func (s *Store) Stats(ctx context.Context) (StoreStats, error)

func (*Store) Sweep

func (s *Store) Sweep(ctx context.Context, maxBytes int64, maxIdle time.Duration) error

Sweep reclaims expired reservations, idle entries, then least-recently-used entries until completed bytes are below 90 percent of the configured budget. A reader pin keeps its object available until the transfer closes.

type StoreStats

type StoreStats struct {
	Entries int64
	Bytes   int64
}

func ReadStoreStats

func ReadStoreStats(ctx context.Context, root string) (StoreStats, error)

ReadStoreStats opens an existing database read-only for operator reporting. It never creates a cache directory or starts the receiver.

type Verifier

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

func NewVerifier

func NewVerifier(cfg VerifierConfig) (*Verifier, error)

func (*Verifier) Bootstrap

func (v *Verifier) Bootstrap(ctx context.Context) error

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, raw string) (Principal, error)

type VerifierConfig

type VerifierConfig struct {
	Issuer    string
	JWKSURL   string
	Audiences []string
	Client    *http.Client
}

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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