Documentation ¶
Index ¶
- Variables
- type Bracket
- type DataFile
- type Demographics
- type Store
- func (store *Store) AutoRefresh(ctx context.Context, interval time.Duration)
- func (store *Store) GetAgeBrackets() (brackets []Bracket)
- func (store *Store) GetAgeGroupFigures() (figures map[string]int)
- func (store *Store) GetByAge(bracket Bracket) (count int, ok bool)
- func (store *Store) GetByRegion(region string) (count int, ok bool)
- func (store *Store) GetRegionFigures() (figures map[string]int)
- func (store *Store) GetRegions() (regions []string)
- func (store *Store) Stats() (stats map[string]int)
- func (store *Store) Update()
Constants ¶
This section is empty.
Variables ¶
var DefaultAgeBrackets = []float64{12, 16, 18, 25, 35, 45, 55, 65, 75, 85}
DefaultAgeBrackets specifies the default age brackets for the demographics by age
Functions ¶
This section is empty.
Types ¶
type Bracket ¶ added in v1.4.0
Bracket indicates a range of ages by which demographics data is grouped
type DataFile ¶ added in v1.5.0
type DataFile struct { TempDirectory string URL string Metrics metrics.APIClientMetrics // contains filtered or unexported fields }
DataFile represents a demographics data file
type Demographics ¶ added in v1.5.0
type Demographics interface { // GetAgeGroupFigures returns the demographics grouped by age groups specified in AgeBrackets GetAgeGroupFigures() (figures map[string]int) // GetRegionFigures returns the demographics grouped by region GetRegionFigures() (figures map[string]int) // Stats returns statistics on the cache Stats() (stats map[string]int) // AutoRefresh periodically updates the cache AutoRefresh(ctx context.Context, interval time.Duration) }
Demographics interface giving access to available data
type Store ¶ added in v1.5.0
type Store struct { AgeBrackets []float64 // age brackets to group the data in. Defaults to DefaultAgeBrackets TempDirectory string // directory to use for temporary files. Uses system-specified tempdir if left blank URL string // used to retrieve the data. Used for unit testing Metrics metrics.APIClientMetrics // metrics to report API performance // contains filtered or unexported fields }
Store holds the demographics data
func (*Store) AutoRefresh ¶ added in v1.8.1
AutoRefresh periodically updates the cache
func (*Store) GetAgeBrackets ¶ added in v1.5.0
GetAgeBrackets returns all age brackets found in the demographics data
func (*Store) GetAgeGroupFigures ¶ added in v1.5.0
GetAgeGroupFigures returns the demographics grouped by age groups specified in AgeBrackets
func (*Store) GetByAge ¶ added in v1.5.0
GetByAge returns the total population in the specified age brackets
func (*Store) GetByRegion ¶ added in v1.5.0
GetByRegion returns the total population for the specified region
func (*Store) GetRegionFigures ¶ added in v1.5.0
GetRegionFigures returns the demographics grouped by region
func (*Store) GetRegions ¶ added in v1.5.0
GetRegions returns all regions found in the demographics data