puller

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PullStateCache added in v0.19.0

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

PullStateCache stores the outcome of the most recent pull attempts. It implements both PullStateWriter (written by the puller) and ReadinessStatus (read by the readiness handler — see pkg/handler). Safe for concurrent use.

func NewPullStateCache added in v0.19.0

func NewPullStateCache(
	currentDateTime libtime.CurrentDateTimeGetter,
	freshnessThreshold time.Duration,
) *PullStateCache

NewPullStateCache returns a PullStateCache with the given freshness threshold. Threshold is typically 3 × PullInterval. A zero threshold disables freshness checking (always fresh after first success). currentDateTime is the time source — pass libtime.NewCurrentDateTime() in production.

func (*PullStateCache) ReadinessStatus added in v0.19.0

func (c *PullStateCache) ReadinessStatus() (bool, string)

ReadinessStatus returns (true, "ok") when the cache is healthy, or (false, reason) when the pod should not receive traffic.

Rules (checked in order):

  1. lastConflict is set → immediate 503 naming the conflict path (sticky until resolved by success)
  2. lastSuccessAt is zero → "no successful pull yet"
  3. time since lastSuccessAt > freshnessThreshold → stale; include last error if any
  4. Otherwise → ready

func (*PullStateCache) RecordPull added in v0.19.0

func (c *PullStateCache) RecordPull(err error)

RecordPull records the outcome of one pull attempt at the current time. On success: lastSuccessAt is updated, lastErr is cleared, AND lastConflict is cleared. On rebase conflict: lastConflict is set (sticky until next success), lastErr also stores it. On transient error: lastErr is updated; lastConflict is NOT touched (preserves conflict visibility in readiness body across intervening transient errors).

type PullStateWriter added in v0.19.0

type PullStateWriter interface {
	RecordPull(err error)
}

PullStateWriter is the write side of the pull outcome cache. The puller calls RecordPull after every pull attempt.

type Puller

type Puller interface {
	Run(ctx context.Context) error
}

Puller periodically runs git pull on a repository.

func New

func New(
	g git.Git,
	interval libtime.Duration,
	pullTimeout time.Duration,
	state PullStateWriter,
) Puller

New returns a Puller that calls g.Pull on the given interval. pullTimeout bounds each individual pull subprocess; 0 means no timeout. state receives the outcome of every pull attempt.

Jump to

Keyboard shortcuts

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