Documentation
¶
Index ¶
- type CantabularClient
- type DatasetAPIClient
- type HTTPServer
- type HealthChecker
- type Init
- func (i *Init) GetCantabularClient(cfg config.CantabularConfig) CantabularClient
- func (i *Init) GetDatasetAPIClient(cfg *config.Config) DatasetAPIClient
- func (i *Init) GetHTTPServer(bindAddr string, router http.Handler) HTTPServer
- func (i *Init) GetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
- func (i *Init) GetResponder() Responder
- type Initialiser
- type Responder
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CantabularClient ¶ added in v1.1.0
type CantabularClient interface {
ListDatasets(ctx context.Context) ([]string, error)
GetGeographyDimensions(ctx context.Context, req cantabular.GetGeographyDimensionsRequest) (*cantabular.GetGeographyDimensionsResponse, error)
GetAreas(context.Context, cantabular.GetAreasRequest) (*cantabular.GetAreasResponse, error)
Checker(ctx context.Context, state *healthcheck.CheckState) error
StatusCode(error) int
}
CantabularClient fetches lists of datasets
type DatasetAPIClient ¶ added in v1.2.0
type DatasetAPIClient interface {
GetDatasets(ctx context.Context, uToken, svcToken, collectionID string, params *dataset.QueryParams) (dataset.List, error)
Checker(ctx context.Context, state *healthcheck.CheckState) error
}
type HTTPServer ¶
HTTPServer defines the required methods from the HTTP server
type HealthChecker ¶
type HealthChecker interface {
Handler(w http.ResponseWriter, req *http.Request)
Start(ctx context.Context)
Stop()
AddCheck(name string, checker healthcheck.Checker) (err error)
}
HealthChecker defines the required methods from Healthcheck
type Init ¶
type Init struct {
CantabularClientFactory func(cfg cantabular.Config, ua dphttp.Clienter) *cantabular.Client
}
func (*Init) GetCantabularClient ¶ added in v1.1.0
func (i *Init) GetCantabularClient(cfg config.CantabularConfig) CantabularClient
GetCantabularClient creates a cantabular client and sets the CantabularClient flag to true
func (*Init) GetDatasetAPIClient ¶ added in v1.2.0
func (i *Init) GetDatasetAPIClient(cfg *config.Config) DatasetAPIClient
func (*Init) GetHTTPServer ¶ added in v1.1.0
func (i *Init) GetHTTPServer(bindAddr string, router http.Handler) HTTPServer
GetHTTPServer creates an http server
func (*Init) GetHealthCheck ¶ added in v1.1.0
func (i *Init) GetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
GetHealthCheck creates a healthcheck with versionInfo and sets teh HealthCheck flag to true
func (*Init) GetResponder ¶ added in v1.1.0
type Initialiser ¶
type Initialiser interface {
GetHTTPServer(bindAddr string, router http.Handler) HTTPServer
GetCantabularClient(cfg config.CantabularConfig) CantabularClient
GetHealthCheck(cfg *config.Config, time, commit, version string) (HealthChecker, error)
GetDatasetAPIClient(cfg *config.Config) DatasetAPIClient
GetResponder() Responder
}
Initialiser defines the methods to initialise external services
type Responder ¶ added in v1.1.0
type Responder interface {
JSON(context.Context, http.ResponseWriter, int, interface{})
Error(context.Context, http.ResponseWriter, int, error)
StatusCode(http.ResponseWriter, int)
Bytes(context.Context, http.ResponseWriter, int, []byte)
}
Responder handles responding to http requests
type Service ¶
type Service struct {
Config *config.Config
Server HTTPServer
Router *chi.Mux
HealthCheck HealthChecker
// contains filtered or unexported fields
}
Service contains all the configs, server and clients to run the API
Click to show internal directories.
Click to hide internal directories.