Documentation
¶
Overview ¶
Package dailymed is the library behind the dailymed command line: the HTTP client, request shaping, and the typed data models for DailyMed.
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 API throws under load.
Index ¶
- Constants
- type Client
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) GetSPL(ctx context.Context, setid string) (*SPL, error)
- func (c *Client) ListNDCs(ctx context.Context, setid string, limit int) ([]NDC, error)
- func (c *Client) SearchSPLs(ctx context.Context, query string, limit, page int) ([]SPL, error)
- type Domain
- type NDC
- type SPL
Constants ¶
const BaseURL = "https://" + Host
BaseURL is the root every request is built from.
const DefaultRate = 300 * time.Millisecond
DefaultRate is the minimum gap between requests.
const DefaultRetries = 3
DefaultRetries is the number of retry attempts on transient errors.
const DefaultTimeout = 15 * time.Second
DefaultTimeout is the per-request HTTP timeout.
const DefaultUserAgent = "dailymed-cli/0.1 (tamnd87@gmail.com)"
DefaultUserAgent identifies the client to DailyMed in a transparent, polite way.
const Host = "dailymed.nlm.nih.gov"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
UserAgent 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 the DailyMed public API over HTTPS.
func (*Client) Get ¶
Get fetches a URL and returns the response body. It paces and retries according to the client's settings.
func (*Client) GetSPL ¶
GetSPL fetches a single SPL record by its setid (UUID string). It uses the packaging.json sub-endpoint which returns full SPL metadata.
type Domain ¶
type Domain struct{}
Domain is the DailyMed 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.