Documentation
¶
Overview ¶
Package ntrs asks NASA's Technical Reports Server for citations, one search a call, and for the PDF a citation holds.
Public documents need no account and no key. NTRS states no limit, but when it answers 429 it is asking us to stop: nothing more is asked. There are no retries here, and no loops.
How often NTRS is asked, and whether a failure with no word from it is asked again, is the web package's gentle's to say, by Policy; a Doer that goes through it, as web.Through gives, asks gently.
The shape of what NTRS asks and answers is the one its own OpenAPI description gives, at https://ntrs.nasa.gov/api/openapi-yaml.
A search is a POST of JSON to /api/citations/search. A citation is a GET of /api/citations/{id}. A citation lists the files it holds, each with the address it is downloaded from.
Index ¶
Constants ¶
const Host = "ntrs.nasa.gov"
Host is NTRS's host, as the web package names a host: in lower case, with no dot at its end. A search, a citation and a PDF are all asked of it.
Variables ¶
var ErrNotFound = errors.New("ntrs: NTRS answered 404, there is no " +
"such page")
ErrNotFound is what a lookup's error wraps when NTRS answers 404: it has no such citation.
Functions ¶
func AnswerLimit ¶
func AnswerLimit() int64
AnswerLimit is the most bytes the answer to a search or a lookup may hold, as ntrs-answer-most says.
func ParseID ¶
ParseID is an NTRS id from the text given. An id is digits and nothing else: it is put into an address, so nothing more is let in.
func Policy ¶
Policy is how NTRS is asked: the pace, the rest, the tries and the opens its numbers say, and the rest the web package's default.
A search is a POST, and the policy says it may be sent again after a failure with no word from NTRS, because it only asks a question. See ntrs-repeats-posts in numbers.yaml for why.
A PDF is a large answer, so the gate is held until its body is closed: a slow download is still the only request to NTRS. That is this package's code saying so, as arXiv's does.
Types ¶
type Archive ¶
type Archive struct{}
Archive is NTRS as celestial-data lists it. NTRS holds reports, not observations of a place on the sky, so a circle finds nothing in it: it is asked by words, through Search and Lookup.
func (*Archive) ByNameOnly ¶
ByNameOnly says the archive is asked only when it is named.
type Citation ¶
type Citation struct {
// contains filtered or unexported fields
}
Citation is a citation NTRS found.
func Lookup ¶
Lookup asks NTRS for one citation by its id, which it takes only as ParseID does. It sends one request and does not retry. A 404 is an error that wraps ErrNotFound, and a 429 a *Stopped.
func (Citation) FirstAuthor ¶
FirstAuthor is the author NTRS puts first, or none when it names no author.
type Found ¶
type Found struct {
// contains filtered or unexported fields
}
Found is what a search found.
func Search ¶
Search asks NTRS one question and gives what it found: at most so many citations, in the order NTRS ranks them. It sends one request and does not retry. It refuses an empty query, and a number of citations below one or above what NTRS gives, before it sends anything.
A 429 is NTRS asking us to stop: its error is a *Stopped, for errors.As. Any other status but 200 is an error that names it. The agent is how the request names itself.