Help us shape the future of Go! Take the 2026 Go Developer Survey

poller

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package poller runs each view's GitHub query on an interval.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backoff

func Backoff(base time.Duration, failures int) time.Duration

Backoff returns base × 2^failures, capped at 8× base.

Types

type Poller

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

func New

func New(s Searcher, views []config.View, interval time.Duration, limitFor func(config.View) int) *Poller

New returns a poller for views. limitFor gives each view's PR limit; nil uses config.DefaultMaxPRs for every view.

func (*Poller) PollNow

func (p *Poller) PollNow()

PollNow asks Run to start a new round immediately. It never blocks.

func (*Poller) Results

func (p *Poller) Results() <-chan Result

func (*Poller) Run

func (p *Poller) Run(ctx context.Context)

Run polls every view once, then again after each interval (backed off while every view fails) or when PollNow is called, until ctx is cancelled. Views that fail transiently (GitHub 5xx, network) while others succeed are re-polled on their own after retryBase, doubling each time, until they recover or the next full round is due.

func (*Poller) SetViews

func (p *Poller) SetViews(views []config.View)

SetViews replaces the views to poll and starts a new round now.

type Result

type Result struct {
	View  string
	Query string // the query that produced this result
	PRs   []github.PR
	Err   error
	At    time.Time
	// Truncated reports that GitHub has more matches than the view's limit.
	Truncated bool
}

Result is one view's poll outcome. Err with nil PRs is a failed poll and the caller keeps whatever it showed before; Err with PRs is a warning.

type Searcher

type Searcher interface {
	// SearchPRs returns up to limit PRs and the total number of matches.
	SearchPRs(ctx context.Context, query string, limit int) ([]github.PR, int, error)
}

Jump to

Keyboard shortcuts

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