Help us shape the future of Go! Take the 2026 Go Developer Survey

popularity

package
v0.137.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package popularity prepares reusable UTC-day participation counts and ranks available works by their mean daily readers/(eligible population+20). See docs/popularity-policy.md for qualification and whole-day eligibility.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Prepare

func Prepare(ctx context.Context, source Source, availability AvailabilityProvider, kind string, until time.Time, scope signal.ActivityScope) (signal.Window, error)

Prepare prepares every known day once per kind/scope in the existing worker. It retains closed days independently of configured preset windows. Until is the worker's single refresh-cycle time, not a reader-supplied query boundary. Returned coverage contains only successfully prepared UTC days.

func Rank

func Rank(ctx context.Context, source Source, _ AvailabilityProvider, kind string, window signal.Window, scope signal.ActivityScope, limit int) ([]string, error)

Rank reads only the prepared daily scalars. Public requests may read an arbitrary whole-day range after checking DailyPopularityCoverage; they never invoke preparation or scan raw receipts.

func Rebuild

func Rebuild(ctx context.Context, source Source, availability AvailabilityProvider, kind string, until time.Time, scope signal.ActivityScope) (signal.Window, error)

Rebuild explicitly recalculates historical corrections/imports. It reports errors and creates no scheduled repair work.

Types

type AvailabilityProvider

type AvailabilityProvider interface {
	Availability(ctx context.Context, kind string, window signal.Window, scope signal.ActivityScope, contents []string) (signal.Availability, error)
}

AvailabilityProvider supplies immutable publication and access history.

type Source

type Source interface {
	PrepareDailyPopularity(ctx context.Context, kind string, availability signal.Availability, scope signal.ActivityScope, rebuild bool) (signal.DailyPopularityPreparation, error)
	DailyPopular(ctx context.Context, kind string, window signal.Window, scope signal.ActivityScope, limit int) ([]signal.PopularHit, error)
	DailyPopularityCoverage(ctx context.Context, kind string, scope signal.ActivityScope) (signal.Window, bool, error)
	PopulationCoverage(ctx context.Context, kind string, scope signal.ActivityScope, window signal.Window) (time.Time, bool, error)
}

Source is one tenant's signal plane; the engine's hub satisfies it.

Jump to

Keyboard shortcuts

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