Documentation
¶
Overview ¶
Package imo is the library behind the imo command line: the HTTP client, request shaping, and typed data models for imo-official.org.
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://www." + Host
BaseURL is the root every request is built from.
const DefaultUserAgent = "Mozilla/5.0 (compatible; imo-cli/dev; +https://github.com/tamnd/imo-cli)"
DefaultUserAgent identifies the client to the site.
const Host = "imo-official.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 imo-official.org 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 IMO driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input — a bare year or a full URL — into the canonical (type, id), so `ant resolve` and `ant url` touch no network.
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"`
URL string `json:"url" table:"URL"`
}
Edition represents one year of the International Mathematical Olympiad.
type Problem ¶
type Problem struct {
Year int `json:"year" table:"YEAR"`
Number int `json:"number" table:"NUM" kit:"id"`
Day int `json:"day" table:"DAY"`
Text string `json:"text" table:"TEXT" kit:"body"`
PDFURL string `json:"pdf_url" table:"PDF_URL"`
URL string `json:"url" table:"URL"`
}
Problem represents one competition problem from an IMO edition.