Documentation
¶
Overview ¶
Package allenbrain is the library behind the allenbrain command line: the HTTP client, request shaping, and typed data models for the Allen Brain Atlas public API (api.brain-map.org/api/v2).
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 Atlas
- type Client
- func (c *Client) Atlases(ctx context.Context) ([]Atlas, error)
- func (c *Client) Datasets(ctx context.Context, limit, start int) ([]Dataset, error)
- func (c *Client) Genes(ctx context.Context, limit, start int) ([]Gene, error)
- func (c *Client) Get(ctx context.Context, rawURL string) ([]byte, error)
- func (c *Client) SearchGenes(ctx context.Context, query string, limit int) ([]Gene, error)
- type Dataset
- type Domain
- type Gene
Constants ¶
const BaseURL = "http://api.brain-map.org/api/v2"
BaseURL is the root every request is built from.
const BrainURL = "https://mouse.brain-map.org"
BrainURL is the human-facing site URL for gene pages.
const DefaultUserAgent = "allenbrain-cli/dev (+https://github.com/tamnd/allenbrain-cli)"
DefaultUserAgent identifies the client to Allen Brain Atlas.
const Host = "api.brain-map.org"
Host is the site this client talks to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Atlas ¶
type Atlas struct {
ID int `json:"id" kit:"id"`
Name string `json:"name"`
ImageType string `json:"image_type,omitempty"`
}
Atlas is one reference atlas from the Allen Brain Atlas.
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 the Allen Brain Atlas API over HTTP.
func NewClient ¶
func NewClient() *Client
NewClient returns a Client with sensible defaults: a 15s timeout, a 300ms minimum gap between requests, and three retries on transient errors.
type Dataset ¶
type Dataset struct {
ID int `json:"id" kit:"id"`
PlaneSection int `json:"plane_section_id,omitempty"`
Genes []Gene `json:"genes,omitempty"`
}
Dataset is one section dataset from the Allen Brain Atlas.
type Domain ¶
type Domain struct{}
Domain is the Allen Brain Atlas 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) pair, 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.