probe

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	GetPopulation(ctx context.Context, codes string) (int64, error)
	GetCountries(ctx context.Context) ([]string, error)
}

APIClient interface representing a Population API Client

type Probe

type Probe struct {
	APIClient
	// contains filtered or unexported fields
}

Probe downloads the latest population stats per country and stores them in the database

func New added in v0.4.0

func New(apiKey string, store store.PopulationStore) *Probe

New creates a new Probe

func (*Probe) Update

func (probe *Probe) Update(ctx context.Context) (err error)

Update gets the current population for each supported country and stores it in the database

type RapidAPIClient

type RapidAPIClient struct {
	rapidapi.API
}

RapidAPIClient API Client handle

func NewAPIClient

func NewAPIClient(apiKey string) *RapidAPIClient

NewAPIClient creates a new Population API Client

func (*RapidAPIClient) Call added in v0.4.0

func (client *RapidAPIClient) Call(ctx context.Context, endpoint string) (body []byte, err error)

Call calls the Population API for the provided endpoint

func (*RapidAPIClient) GetCountries

func (client *RapidAPIClient) GetCountries(ctx context.Context) (countries []string, err error)

GetCountries returns all country names that the RapidAPI API supports

func (*RapidAPIClient) GetPopulation

func (client *RapidAPIClient) GetPopulation(ctx context.Context, country string) (population int64, err error)

GetPopulation finds the most recent data for a country

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL