digest

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 10 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 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, digests Resolver, logger *slog.Logger, tz *time.Location) *Reporter

NewReporter constructs a Reporter. now defaults to time.Now; tz is the timezone the "start of day" cutoff is computed in (nil defaults to UTC) and must match the scheduler's timezone so a digest fires and cuts off in the same zone.

func (*Reporter) Report

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

Report runs one digest pass including all enabled repos: 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.

func (*Reporter) ReportSchedule added in v0.18.0

func (r *Reporter) ReportSchedule(ctx context.Context, spec string) error

ReportSchedule runs one digest pass for a single cron spec: it includes only stuck PRs whose repo's effective digest is enabled and scheduled at spec.

type Resolver added in v0.18.0

type Resolver interface {
	DigestFor(repository string) mappings.DigestConfig
}

Resolver looks up the effective digest configuration for a repository.

type ScheduleJob added in v0.18.0

type ScheduleJob interface {
	ReportSchedule(ctx context.Context, spec string) error
}

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

type Scheduler

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

Scheduler runs one cron per distinct schedule spec, calling its job for each tick with the matching spec. It mirrors cleanup.Scheduler's Run(ctx) shape so main can start both the same way.

func NewScheduler

func NewScheduler(specs []string, job ScheduleJob, logger *slog.Logger, tz *time.Location) (*Scheduler, error)

NewScheduler validates every cron spec up front so a malformed schedule fails fast at startup rather than silently never firing. specs is a list of standard 5-field cron expressions (e.g. ["0 9 * * *", "0 18 * * *"]); tz is the timezone every spec is interpreted in (nil defaults to UTC).

func (*Scheduler) Run

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

Run starts the cron loop with one entry per spec and blocks until ctx is cancelled, then waits for in-flight runs 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.PullRequest, error)
}

StuckFinder returns open PRs (with their messages) idle since before cutoff.

Jump to

Keyboard shortcuts

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