feedsync

package
v1.0.507 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 14 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 feedsync is the UT1 URL-category feed syncer: it periodically downloads the UT1 Capitole blacklist tarball (via the NethServer mirror), extracts the categories in the ingest map, and bulk-writes them into the community URL-category database (internal/catdb). Extracted from package main per ADR-0002; the feedSyncer singleton and the urlcategories startup slice stay in main (feedsync.go shim).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MappedCategories

func MappedCategories() []string

MappedCategories returns the URLCategory values the UT1 ingest map produces (with duplicates — multiple UT1 directories can map to one category). Consumers: the category-store seeding at startup and the admin UI's feed-backed badge enrichment.

func SyncFailures

func SyncFailures() int64

SyncFailures returns the cumulative UT1 sync failure count.

Types

type Health added in v1.0.220

type Health struct {
	LastAttempt         time.Time
	LastSuccess         time.Time
	ConsecutiveFailures int64
	TotalFailures       int64
	LastFailure         string
	SyncInterval        time.Duration
	Domains             int64
}

Health is a consistent snapshot of the UT1 syncer's state for the metrics and diagnostics surfaces.

type Syncer

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

Syncer manages periodic synchronisation of UT1 data into the community DB.

func New

func New(db *catdb.CommunityDB, feedURL string, syncInterval time.Duration) *Syncer

New creates a Syncer for the given DB. feedURL defaults to defaultUT1FeedURL when empty. syncInterval defaults to 24h when zero.

func (*Syncer) Health added in v1.0.220

func (fs *Syncer) Health() Health

Health returns the current snapshot.

func (*Syncer) SeedStats

func (fs *Syncer) SeedStats(lastSync time.Time, totalDomains int64)

SeedStats sets the last-sync timestamp and domain count directly. Test support for the metrics surface (production values are set by Sync).

func (*Syncer) Start

func (fs *Syncer) Start(ctx context.Context)

Start launches the background sync goroutine. An immediate sync is performed on first start when the DB is empty.

The loop is a feedsched.Scheduler, not a bare 24-hour ticker. Two reasons, both reachable without any infrastructure fault:

  • a failed round was not retried for a full DAY. The origin is a raw.githubusercontent.com mirror of a 50+ MB tarball; a rate-limit, a GitHub incident, or a proxy restart froze category coverage until the next day. On a node whose community DB is empty (first boot, or after the CHAOS-50 quarantine of a damaged store) that means a full day of Layer-1-only categorisation.
  • a fixed ticker keeps a fleet in phase forever, and every Culvert deployment pulls that same 50+ MB object from that same host. A synchronised fleet is answered by rate-limiting — which produces exactly the failure the missing backoff then holds for 24 hours.

func (*Syncer) Stats

func (fs *Syncer) Stats() (int64, time.Time, time.Duration)

Stats returns (totalDomains, lastSyncTime, syncInterval) for the metrics endpoint.

func (*Syncer) Sync

func (fs *Syncer) Sync()

Sync downloads the UT1 tarball, parses all mapped categories, and performs a bulk write into CommunityDB. The previous DB contents remain readable during the import; BadgerDB's WriteBatch overwrites keys as they arrive. Deliberately NOT bound to an admin request's context (see threatfeed's Sync): a manual "sync now" should survive the operator closing the tab.

func (*Syncer) Wait added in v1.0.241

func (fs *Syncer) Wait()

Wait blocks until the loop Start launched has returned; it returns at once if Start was never called. Cancel Start's context first: the loop exits after the round in flight, and a round logs through the process logger, so a test that swaps that logger must not race a round left over from an earlier test.

Jump to

Keyboard shortcuts

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