cleanup

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cleanup runs the server-side near-duplicate scanner and its webhook notifier: on the configured interval, walk every tenant, upsert pending entries. Merging happens client-side in a scheduled agent — this package calls no LLMs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GlobalConfig added in v1.1.1

type GlobalConfig interface {
	CleanupEnabled() bool
	CleanupIntervalHours() int
	HistoryRetentionDays() int
	WebhookURL() string
}

GlobalConfig is the live global-config slice the cleanup pipeline reads each cycle; *globalconfig.Accessor satisfies it.

type Notifier

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

Notifier POSTs a cleanup-scan JSON summary to the webhook URL from the live config. An empty URL disables it: no request is made.

func NewNotifier

func NewNotifier(gc GlobalConfig) *Notifier

NewNotifier returns a Notifier that reads its target webhook URL live from gc.

func (*Notifier) SendScanSummary

func (n *Notifier) SendScanSummary(ctx context.Context, stats ScanStats) error

SendScanSummary POSTs a JSON summary of one sweep; a no-op when no URL is set.

type ScanStats

type ScanStats struct {
	TenantsScanned int
	PairsFound     int
	PairsInserted  int
	PairsSkipped   int // already enqueued
	Errors         int
	HistoryPruned  int
}

ScanStats summarises one sweep across all tenants.

type Scanner

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

Scanner runs the near-duplicate scan and keeps cleanup_queue populated.

func NewScanner

NewScanner constructs the scanner. gc supplies the live retention window, interval, and enabled flag; a nil notifier means silent scans.

func (*Scanner) RunOnce

func (s *Scanner) RunOnce(ctx context.Context) (ScanStats, error)

RunOnce performs a single sweep. Returns stats even on partial failure; per-tenant errors are counted, not fatal.

func (*Scanner) Start

func (s *Scanner) Start(ctx context.Context)

Start launches the scan loop until ctx is cancelled. Each cycle reads cleanup_enabled and cleanup_interval_hours live from the accessor, so a change applies at the next fire (next-cycle, not instant). The first sweep fires now.

Jump to

Keyboard shortcuts

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