application

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package application holds the digest use cases — the stuck-PR reporter and the cron scheduler — behind the domain's use-case interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calendar added in v0.23.0

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

Calendar answers whether a digest tick falls on a day the team is off. It is the application's DigestCalendar.

func NewCalendar added in v0.23.0

func NewCalendar(params domain.CalendarParams) *Calendar

NewCalendar resolves the country code to a holiday table.

It never fails. An unset or unrecognized code degrades to weekends-only and warns; it does not abort startup the way an invalid cron spec or timezone does. Those two decide *when* the server runs at all, whereas the country only enriches one feature — so a typo in it must not take the deployment down. This mirrors the token degradation elsewhere (an absent GITHUB_TOKEN makes path rules inert rather than fatal).

Both warnings fire once, here, rather than on every tick: with no usable table there is no way to know that a given day was a holiday, so a per-tick line would carry no information and would repeat daily forever.

func (*Calendar) Country added in v0.23.0

func (c *Calendar) Country() string

Country is the resolved country code, empty when none is configured.

func (*Calendar) HolidayName added in v0.23.0

func (c *Calendar) HolidayName(now time.Time) (string, bool)

HolidayName returns the holiday falling on now's calendar day, if any. It reports false for every day when no country is configured.

func (*Calendar) SkipReason added in v0.23.0

func (c *Calendar) SkipReason(now time.Time) (string, bool)

SkipReason reports whether the digest should be suppressed for now's calendar day. now is expected to already be in the digest timezone; the calendar reads its fields as given and never re-derives a location.

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. It is the application's DigestReporter and, via ReportSchedule, its ScheduleJob.

func NewReporter

func NewReporter(params domain.ReporterParams) *Reporter

NewReporter constructs a Reporter from its params. Now defaults to time.Now and TZ to UTC when unset.

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 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

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 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 the maintenance cleaner's Run(ctx) shape so the composition root can start both the same way.

func NewScheduler

func NewScheduler(params domain.SchedulerParams) (*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).

Jump to

Keyboard shortcuts

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