topicrank

package
v0.2.74 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package topicrank marks topics for asynchronous score updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Defer

func Defer(ctx context.Context, entry ScheduledTopic, until time.Time) error

func Import

func Import(ctx context.Context, entries []Entity) error

Import preserves any schedule already written by a previous migration attempt or a running producer. It never resets an existing version or deadline.

func MarkAt

func MarkAt(ctx context.Context, topicID uint64, now time.Time) error

One atomic upsert coalesces triggers, retains queue age and advances version.

func Notify

func Notify(topicID uint64)

Notify uses the existing asynchronous event bus; it performs no database I/O.

func SetNext

func SetNext(ctx context.Context, entry ScheduledTopic, next *time.Time) error

SetNext confirms only the generation that was processed. A new trigger wins. Even completion/retry advances version so stale acknowledgements cannot win.

func Wakeups

func Wakeups() <-chan struct{}

Types

type Entity

type Entity struct {
	TopicID   uint64     `gorm:"column:topic_id;primaryKey;autoIncrement:false"`
	NextRunAt *time.Time `gorm:"column:next_run_at;index:idx_topic_rank_due,priority:1"`
	Version   uint64     `gorm:"column:version;not null;default:1"`
}

Keep settled rows so versions cannot reset after deleting/recreating a task.

func Get

func Get(ctx context.Context, topicID uint64) (Entity, error)

func (Entity) TableName

func (Entity) TableName() string

type ScheduledTopic

type ScheduledTopic struct {
	ID      uint64    `gorm:"column:topic_id"`
	At      time.Time `gorm:"column:next_run_at"`
	Version uint64    `gorm:"column:version"`
}

func Pending

func Pending(ctx context.Context, limit int) ([]ScheduledTopic, error)

type TopicRankRequested

type TopicRankRequested struct {
	TopicID    uint64
	OccurredAt time.Time
}

TopicRankRequested carries values only, never a request context or transaction handle.

Jump to

Keyboard shortcuts

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