digest

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package digest posts the scheduled stuck-PR reminder: a per-channel summary of open PRs that nobody has touched since before today. It rides the same slack_messages rows and repo→channel mappings the webhook flow already uses, adding only a cron-driven read pass — no new persistence.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	Report(ctx context.Context) error
}

Job is the unit the Scheduler fires on each cron tick. *Reporter satisfies it.

type MappingLookup

type MappingLookup interface {
	Get(ctx context.Context, repository string) (store.RepoMapping, error)
}

MappingLookup resolves a repository to its Slack channel and mentions.

type Poster

type Poster interface {
	PostMessage(ctx context.Context, channel string, msg slack.Message) (string, error)
	PostReply(ctx context.Context, channel, threadTS string, msg slack.Message) (string, error)
}

Poster posts a composed message to a Slack channel, either as a top-level post (PostMessage, returning its ts) or as a reply threaded under one (PostReply).

type Reporter

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

Reporter builds and posts the stuck-PR digest for every channel that owns at least one stuck PR.

func NewReporter

func NewReporter(finder StuckFinder, mappings MappingLookup, poster Poster, composer *slack.Composer, logger *slog.Logger) *Reporter

NewReporter constructs a Reporter. now defaults to time.Now.

func (*Reporter) Report

func (r *Reporter) Report(ctx context.Context) error

Report runs one digest pass: find open PRs idle since the start of today, group them by Slack channel, and post one reminder per channel. A failed post for one channel is logged and skipped so the others still go out.

type Scheduler

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

Scheduler runs a Job on a cron schedule (server-local time). It mirrors cleanup.Scheduler's Run(ctx) shape so main can start both the same way.

func NewScheduler

func NewScheduler(spec string, job Job, logger *slog.Logger) (*Scheduler, error)

NewScheduler validates the cron spec up front so a malformed schedule fails fast at startup rather than silently never firing. spec is a standard 5-field cron expression (e.g. "0 9 * * *").

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context) error

Run starts the cron loop and blocks until ctx is cancelled, then waits for an in-flight run to finish before returning. Always returns nil (the signature stays error-returning to compose with other long-running goroutines).

type StuckFinder

type StuckFinder interface {
	FindStuck(ctx context.Context, cutoff time.Time) ([]store.SlackMessage, error)
}

StuckFinder returns open PRs whose last activity predates cutoff.

Jump to

Keyboard shortcuts

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