sweep

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sweep implements M4's bounded-staleness reconciliation, resumable authoritative listings, disappearance verification, delivery-gap healing, and retention work on River's sweep queue.

Index

Constants

View Source
const (
	KindRepositories = "repositories"
	KindStacks       = "stacks"
	KindPullRequests = "pull_requests"
	KindRepoRules    = "repo_rules"
	KindClosed       = "closed_tracked"
)

Variables

This section is empty.

Functions

func PrunerPeriodicJobs

func PrunerPeriodicJobs(config *Config) []*river.PeriodicJob

func ReconciliationPeriodicJobs

func ReconciliationPeriodicJobs(config *Config) []*river.PeriodicJob

Types

type Config

type Config struct {
	// InstallationID selects the GitHub installation reconciled by this service.
	InstallationID int64

	// OpenStackMaxStaleness bounds how long an open stack may go unchecked.
	OpenStackMaxStaleness time.Duration
	// OpenPRMaxStaleness bounds how long an open pull request may go unchecked.
	OpenPRMaxStaleness time.Duration
	// RepoRulesMaxStaleness bounds repository-rules cache staleness.
	RepoRulesMaxStaleness time.Duration
	// ClosedMaxStaleness bounds checks of tracked closed entities.
	ClosedMaxStaleness time.Duration
	// RepositoryListPeriod controls authoritative installation listings.
	RepositoryListPeriod time.Duration

	// PageSize bounds authoritative GitHub list pages.
	PageSize int

	// GapHealPeriod controls delivery-gap scan scheduling.
	GapHealPeriod time.Duration
	// GapWindow is the delivery-history interval inspected by each scan.
	GapWindow time.Duration
	// GapPageSize bounds one deliveries API page.
	GapPageSize int
	// GapMaxPages bounds pages inspected before scheduling a continuation.
	GapMaxPages int

	// RetentionPeriod controls payload-pruner scheduling.
	RetentionPeriod time.Duration
	// RetentionAge determines when bulky retained data becomes eligible.
	RetentionAge time.Duration
	// RetentionBatchSize bounds deletes per transaction.
	RetentionBatchSize int

	// Now supplies service time; it defaults to time.Now.
	Now func() time.Time
	// Observer receives sweep-overrun and gap-healing signals.
	Observer Observer
	// OnPrune receives per-kind deletion totals after a prune pass.
	OnPrune PruneHook
}

type GapHealArgs

type GapHealArgs struct {
	Installation int64  `json:"installation_id"`
	Cursor       string `json:"cursor,omitempty"`
}

func (GapHealArgs) Kind

func (GapHealArgs) Kind() string

type KickoffArgs

type KickoffArgs struct {
	SweepKind    string `json:"sweep_kind"`
	Installation int64  `json:"installation_id"`
}

func (KickoffArgs) Kind

func (KickoffArgs) Kind() string

type ListPageArgs

type ListPageArgs struct {
	SweepKind    string `json:"sweep_kind"`
	Installation int64  `json:"installation_id"`
	ScopeKey     string `json:"scope_key"`
	Cursor       string `json:"cursor"`
}

func (ListPageArgs) Kind

func (ListPageArgs) Kind() string

type LogObserver

type LogObserver struct{}

func (LogObserver) GapRedelivery

func (LogObserver) GapRedelivery(
	_ context.Context,
	deliveryID int64,
	guid string,
)

func (LogObserver) GapWindowIncomplete

func (LogObserver) GapWindowIncomplete(
	_ context.Context,
	cursor string,
	pages int,
)

func (LogObserver) SweepOverrun

func (LogObserver) SweepOverrun(
	_ context.Context,
	kind string,
	scope string,
	elapsed time.Duration,
)

type Observer

type Observer interface {
	SweepOverrun(
		context.Context,
		string,
		string,
		time.Duration,
	)
	GapRedelivery(context.Context, int64, string)
	GapWindowIncomplete(context.Context, string, int)
}

type Observers

type Observers []Observer

func (Observers) GapRedelivery

func (observers Observers) GapRedelivery(
	ctx context.Context,
	deliveryID int64,
	guid string,
)

func (Observers) GapWindowIncomplete

func (observers Observers) GapWindowIncomplete(
	ctx context.Context,
	cursor string,
	pages int,
)

func (Observers) SweepOverrun

func (observers Observers) SweepOverrun(
	ctx context.Context,
	kind string,
	scope string,
	elapsed time.Duration,
)

type Options

type Options struct {
	Pool       *pgxpool.Pool
	REST       *gh.RESTClient
	Deliveries *gh.DeliveriesClient
	Config     Config
}

type PruneArgs

type PruneArgs struct{}

func (PruneArgs) Kind

func (PruneArgs) Kind() string

type PruneHook

type PruneHook func(context.Context, string, int64)

PruneHook is M6's C-R retention-deletion accounting seam.

type SchedulePlan

type SchedulePlan struct {
	Bound              time.Duration
	Cadence            time.Duration
	CompletionHeadroom time.Duration
}

type Service

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

func New

func New(options Options) (*Service, error)

func (*Service) HealDeliveryGaps

func (s *Service) HealDeliveryGaps(
	ctx context.Context,
	args GapHealArgs,
) error

func (*Service) Kickoff

func (s *Service) Kickoff(
	ctx context.Context,
	args KickoffArgs,
) error

func (*Service) Prune

func (s *Service) Prune(ctx context.Context) (int64, int64, error)

Prune enforces the decided 90-day bulky-data policy. Delivery skeleton rows remain for C-R4; M5 alone owns change_events retention.

func (*Service) PrunerPeriodicJobs

func (s *Service) PrunerPeriodicJobs() []*river.PeriodicJob

func (*Service) ReconcilePage

func (s *Service) ReconcilePage(
	ctx context.Context,
	args ListPageArgs,
) error

func (*Service) ReconciliationPeriodicJobs

func (s *Service) ReconciliationPeriodicJobs() []*river.PeriodicJob

func (*Service) RegisterPrunerWorker

func (s *Service) RegisterPrunerWorker(workers *river.Workers)

func (*Service) RegisterReconciliationWorkers

func (s *Service) RegisterReconciliationWorkers(
	workers *river.Workers,
)

func (*Service) SetRiverClient

func (s *Service) SetRiverClient(client *river.Client[pgx.Tx])

Jump to

Keyboard shortcuts

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