Documentation
¶
Overview ¶
Package domain holds the maintenance domain's contracts: the ports, DTOs, enums, and constants for stale-message cleanup and PR reconcile. It depends only on the standard library and the shared kernel.
Index ¶
Constants ¶
const Interval = 24 * time.Hour
Interval is the fixed cadence between stale-message cleanup passes. 24h is conservative enough that a transient DB error has nearly a full day to clear before the next attempt.
Variables ¶
var ErrPRDraft = errors.New("reconcile: pull request is a draft")
ErrPRDraft marks a draft PR. A draft must never stay in the database (regardless of open/closed state), so the reconciler deletes its row the same way the live converted_to_draft webhook does — the difference being this catches drafts in the pre-tracking backlog.
var ErrPRNotFound = errors.New("reconcile: pull request not found")
ErrPRNotFound marks a PR that GitHub reports as 404 — deleted, or in a repo that was renamed or is no longer accessible. The reconciler treats it distinctly from other API errors: rather than leave the row untouched, it removes the PR from the digest (a 404 will never resolve on its own).
Functions ¶
This section is empty.
Types ¶
type CleanerParams ¶
type CleanerParams struct {
Deleter StaleMessageDeleter
TTL time.Duration
Interval time.Duration
Logger *slog.Logger
Now func() time.Time
}
CleanerParams bundles everything the stale-message cleaner needs. TTL is the maximum age a row may reach before it becomes eligible for deletion; Interval is the cadence between passes (use the Interval constant in production); Now supplies the clock (time.Now in production, a fixed clock in tests).
type Deleter ¶
Deleter removes a PR's row entirely. Used for drafts, which must not stay in the database at all (a draft is not review-ready; the row is recreated by the open webhook if it is later marked ready_for_review).
type OpenLister ¶
OpenLister lists the tracked PR rows not yet marked closed.
type PRChecker ¶
type PRChecker interface {
IsOpen(ctx context.Context, repository string, prNumber int) (bool, error)
}
PRChecker reports whether a PR is still open on GitHub.
type PRRow ¶
PRRow is the maintenance view of one tracked PR: the fields the reconciler reads to check and resolve it. It is mapped from the store's persistence model at the repository boundary, so no gorm-tagged type crosses a port.
type Reconciler ¶
Reconciler resolves every not-yet-closed tracked PR against GitHub: a merged/closed PR is marked closed, a 404 is removed from the digest, and a draft is deleted outright (a draft must never stay in the database). Per-PR errors are logged and counted, never fatal — an unconfirmable row is left untouched so a token-scope miss never wrongly hides an open PR, and re-running is safe. Run reports the tallies in a Summary.
type ReconcilerParams ¶
type ReconcilerParams struct {
Lister OpenLister
Checker PRChecker
Closer Closer
Deleter Deleter
Logger *slog.Logger
DryRun bool
// Provider is the deployment's git host; it selects the web-URL form the
// per-PR log lines are reconstructed in. The zero value builds github.com URLs.
Provider kernel.Provider
}
ReconcilerParams bundles everything the reconciler needs. DryRun reports what would change without writing.
type StaleMessageCleaner ¶
StaleMessageCleaner prunes stale slack_messages rows on a fixed cadence: one pass immediately on start, then one every Interval, until its context is cancelled. It deletes only database rows — never the Slack messages themselves. A pass's error is logged and swallowed so the next tick retries; Run always returns nil (so callers can compose it with other long-running goroutines without special-casing).
type StaleMessageDeleter ¶
type StaleMessageDeleter interface {
DeleteStaleBefore(ctx context.Context, cutoff time.Time) (int64, error)
}
StaleMessageDeleter deletes tracked-PR rows whose message predates a cutoff. It is the persistence port the cleanup use case drives; the maintenance infrastructure layer satisfies it over the store.