Documentation
¶
Overview ¶
Package putnam is the library behind the putnam command line: the HTTP client, request shaping, and typed data models for the Putnam Competition archive at kskedlaya.org/putnam-archive/.
The Client sets a real User-Agent, paces requests so a busy session stays polite, and retries transient failures (429 and 5xx) with exponential backoff.
Index ¶
Constants ¶
const BaseURL = "https://kskedlaya.org/putnam-archive"
BaseURL is the root every request is built from.
const DefaultUserAgent = "Mozilla/5.0 (compatible; putnam-cli/dev; +https://github.com/tamnd/putnam-cli)"
DefaultUserAgent identifies the client to the site.
const Host = "kskedlaya.org"
Host is the site this client talks to, and the host the URI driver in domain.go claims.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to kskedlaya.org/putnam-archive/ over HTTP.
type Config ¶
type Config struct {
BaseURL string
UserAgent string
Rate time.Duration
Timeout time.Duration
Retries int
}
Config holds all tunable parameters for the client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults: 300 ms between requests, 30 s timeout, 3 retries.
type Domain ¶
type Domain struct{}
Domain is the Putnam archive driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Edition ¶
type Edition struct {
Rank int `json:"rank" table:"RANK" kit:"id"`
Year int `json:"year" table:"YEAR"`
ProblemsURL string `json:"problems_url" table:"PROBLEMS_URL"`
SolutionsURL string `json:"solutions_url" table:"SOLUTIONS_URL"`
WinnersURL string `json:"winners_url" table:"WINNERS_URL"`
ResultsURL string `json:"results_url" table:"RESULTS_URL"`
}
Edition represents one year of the Putnam Mathematical Competition.