pulllock

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pulllock is the cross-process gate between image pulls (held shared by every runner's Docker proxy, which lives in its own process) and image GC (held exclusively around a prune pass).

Two flock(2) files implement a writer-preferring lock so a steady stream of overlapping pulls cannot starve GC: <path>.gate is held shared, briefly, by a pull while it takes <path>; GC holds <path>.gate exclusively for the whole pass, which keeps new pulls out, and then takes <path> exclusively, which waits for the pulls already running.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exclusive

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

Exclusive is the held exclusive side.

func (*Exclusive) Close

func (e *Exclusive) Close()

Close releases both files.

type File

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

File is a held lock; Close releases it.

func (*File) Close

func (f *File) Close()

Close releases the lock. Safe on nil and repeatedly.

type Gate

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

Gate adapts a Lock to the Pause/Resume/InFlight shape of imagegc.PullGate. Pause keeps new pulls out; InFlight reports 1 until the pulls already running have finished, then 0 (and stays 0 while paused, since nothing can start). Resume lets pulls go again. Calls nest.

func NewGate

func NewGate(l *Lock) *Gate

NewGate returns a Gate over l.

func (*Gate) InFlight

func (g *Gate) InFlight() int

InFlight is 0 once paused and no pull holds the shared lock, else 1. An unusable lock file also reads as busy, so GC skips rather than racing pulls.

func (*Gate) Pause

func (g *Gate) Pause()

Pause stops new pulls.

func (*Gate) Resume

func (g *Gate) Resume()

Resume undoes one Pause.

type Lock

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

Lock is the pair of lock files next to path.

func New

func New(path string) *Lock

New returns a Lock rooted at path (the file is created on first use).

func (*Lock) Lock

func (l *Lock) Lock(ctx context.Context) (*Exclusive, error)

Lock takes the exclusive side: it blocks new pulls, then waits for running ones, up to ctx. Close the result to let pulls proceed.

func (*Lock) Path

func (l *Lock) Path() string

Path is the main lock file.

func (*Lock) RLock

func (l *Lock) RLock(ctx context.Context) (*File, error)

RLock takes the shared side, held for the duration of a pull. It waits while GC holds or is waiting for the exclusive side.

Jump to

Keyboard shortcuts

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