Documentation
¶
Overview ¶
Package mavencentral is the library behind the mavencentral command line: the HTTP client, request shaping, and the typed data models for Maven Central.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.
Index ¶
Constants ¶
const BaseURL = "https://search.maven.org/solrsearch"
BaseURL is the root every request is built from.
const DefaultUserAgent = "mavencentral-cli/dev (+https://github.com/tamnd/mavencentral-cli)"
DefaultUserAgent identifies the client to Maven Central. A real, honest User-Agent is both polite and the thing most likely to keep you unblocked.
const Host = "search.maven.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 Artifact ¶
type Artifact struct {
ID string `kit:"id" json:"id"`
GroupID string `json:"group_id"`
ArtifactID string `json:"artifact_id"`
LatestVersion string `json:"latest_version"`
Packaging string `json:"packaging"`
VersionCount int `json:"version_count"`
UpdatedAt int64 `json:"updated_at_ms"`
Extensions []string `json:"extensions"`
}
Artifact is one Maven artifact, as returned by a default-mode search (latest version per artifact).
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent string
BaseURL string
// Rate is the minimum gap between requests. Zero means no pacing.
Rate time.Duration
Retries int
// contains filtered or unexported fields
}
Client talks to Maven Central over HTTP.
func NewClientFromConfig ¶
NewClientFromConfig returns a Client configured from cfg.
func (*Client) Get ¶
Get fetches url and returns the response body. It paces and retries according to the client's settings. The caller owns nothing extra; the body is read fully and closed here.
type Config ¶
Config holds the tunable settings for the client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with sensible defaults.
type Domain ¶
type Domain struct{}
Domain is the Maven Central 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 into the canonical (type, id). A "group:artifact:version" or "group:artifact" pattern (contains ":") is an artifact; anything else is treated as a query string.
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 Version ¶
type Version struct {
ID string `kit:"id" json:"id"`
GroupID string `json:"group_id"`
ArtifactID string `json:"artifact_id"`
Version string `json:"version"`
Packaging string `json:"packaging"`
UpdatedAt int64 `json:"updated_at_ms"`
}
Version is one released version of a specific Maven artifact, as returned by a core=gav search.