package poller
import "golang.org/x/pkgsite/internal/poller"
Package poller supports periodic polling to load a value.
Index ¶
Types ¶
type Getter ¶
A Getter returns a value.
type Poller ¶
type Poller struct {
// contains filtered or unexported fields
}
A Poller maintains a current value, and refreshes it by periodically polling for a new value.
func New ¶
New creates a new poller with an initial value. The getter is invoked to obtain updated values. Errors returned from the getter are passed to onError.
func (*Poller) Current ¶
Current returns the current value. Initially, this is the value passed to New. After each successful poll, the value is updated. If a poll fails, the value remains unchanged.
func (*Poller) Poll ¶
Poll calls p's getter immediately and synchronously.
func (*Poller) Start ¶
Start begins polling in a separate goroutine, at the given period. To stop the goroutine, cancel the context passed to Start.
Source Files ¶
poller.go
- Version
- v0.0.0-20250523174444-0e6de173c6b5 (latest)
- Published
- May 23, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 1 month ago –
Tools for package owners.