Documentation
¶
Overview ¶
Package changes reads the feeds in which registries list the packages that changed since a given point, so a cache or mirror can refresh just those.
Feeds are stateless: the caller keeps the Cursor, starting from Start and passing the one Changes returns to the next call. A caller that acts on the changes moves on to the new cursor only once it has, so a failure leaves the changes to be read again. A Cursor is a plain string and can be stored.
Index ¶
Constants ¶
const NPMURL = "https://replicate.npmjs.com/registry/_changes"
NPMURL is the change feed of the public npm registry.
const PackagistURL = "https://packagist.org/metadata/changes.json"
PackagistURL is the metadata change feed of packagist.org.
Variables ¶
This section is empty.
Functions ¶
func PackagistFeedURL ¶
PackagistFeedURL returns where a Packagist instance at apiURL, such as https://packagist.org, publishes its metadata change feed. Packagist advertises it as "metadata-changes-url" in its packages.json.
Types ¶
type Changes ¶
type Changes struct {
// Names are the packages that changed, as the registry names them.
Names []string
// All is set when the feed can't say what changed since the cursor, so
// every package has to be treated as changed.
All bool
}
Changes is what one read of a feed found.
type Cursor ¶
type Cursor string
Cursor is a position in a feed, as the feed's registry gives it. Treat it as opaque.
type Feed ¶
type Feed interface {
// Ecosystem is the ecosystem the changed names belong to.
Ecosystem() string
// Start returns the feed's current position, from which Changes reports
// what changes next.
Start(ctx context.Context) (Cursor, error)
// Changes returns what changed after cursor, and the cursor to read on
// from. On error the returned cursor is the one passed in.
Changes(ctx context.Context, cursor Cursor) (Changes, Cursor, error)
}
Feed is one registry's change feed.
type NPM ¶
type NPM struct {
// contains filtered or unexported fields
}
NPM reads the npm registry's CouchDB-style changes feed at replicate.npmjs.com.
Its cursor is a sequence, which npm asks followers to treat as opaque; the database document at the feed's parent URL, with its trailing slash (without it the URL is 404), gives the current one as update_seq. A page holds at most 10000 changes (1000 when no limit is given), and Changes reads up to ten pages. Each result's id is a package name; design documents are left out.
type Option ¶
type Option func(*options)
Option configures a feed.
func WithClient ¶
WithClient sets the client a feed makes its requests with. The default is client.DefaultClient().
type Packagist ¶
type Packagist struct {
// contains filtered or unexported fields
}
Packagist reads Packagist's metadata change feed (https://packagist.org/apidoc#track-package-updates).
Its cursor is a timestamp in units of 1/10000 s. Asked without one the feed answers 400 with the current timestamp; asked with one older than its 24 hours of history it answers with a single "resync" action, reported as Changes.All. Each update names the metadata file that changed, "vendor/package" or "vendor/package~dev" for its dev versions; a delete names the package and is reported as both.
func NewPackagist ¶
NewPackagist returns the feed of packagist.org, or of the instance set with WithURL (see PackagistFeedURL).