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) GetHTTPServerWithOtel(bindAddr string, router http.Handler) HTTPServer
- func (i *Init) GetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
- func (i *Init) GetMongoClient(ctx context.Context, cfg *config.Config) (MongoClient, error)
- func (i *Init) GetResponder() Responder
- type Initialiser
- type MongoClient
- 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(context.Context) (*cantabular.ListDatasetsResponse, error)
GetDimensions(context.Context, cantabular.GetDimensionsRequest) (*cantabular.GetDimensionsResponse, error)
GetDimensionsDescription(context.Context, cantabular.GetDimensionsDescriptionRequest) (*cantabular.GetDimensionsResponse, error)
GetDimensionCategories(context.Context, cantabular.GetDimensionCategoriesRequest) (*cantabular.GetDimensionCategoriesResponse, error)
GetGeographyDimensions(ctx context.Context, req cantabular.GetGeographyDimensionsRequest) (*cantabular.GetGeographyDimensionsResponse, error)
GetAreas(context.Context, cantabular.GetAreasRequest) (*cantabular.GetAreasResponse, error)
GetAreasTotalCount(context.Context, cantabular.GetAreasRequest) (int, error)
GetArea(context.Context, cantabular.GetAreaRequest) (*cantabular.GetAreaResponse, error)
GetParents(context.Context, cantabular.GetParentsRequest) (*cantabular.GetParentsResponse, error)
GetParentAreaCount(ctx context.Context, req cantabular.GetParentAreaCountRequest) (*cantabular.GetParentAreaCountResult, error)
GetBlockedAreaCount(ctx context.Context, req cantabular.GetBlockedAreaCountRequest) (*cantabular.GetBlockedAreaCountResult, error)
GetCategorisations(context.Context, cantabular.GetCategorisationsRequest) (*cantabular.GetCategorisationsResponse, error)
GetBaseVariable(context.Context, cantabular.GetBaseVariableRequest) (*cantabular.GetBaseVariableResponse, error)
Checker(ctx context.Context, state *healthcheck.CheckState) error
CheckerAPIExt(ctx context.Context, state *healthcheck.CheckState) error
StatusCode(error) int
StaticDatasetQuery(context.Context, cantabular.StaticDatasetQueryRequest) (*cantabular.StaticDatasetQuery, error)
StaticDatasetType(ctx context.Context, datasetName string) (*gql.Dataset, error)
StaticDatasetQueryStreamJSON(context.Context, cantabular.StaticDatasetQueryRequest, stream.Consumer) (cantabular.GetObservationsResponse, error)
CheckQueryCount(context.Context, cantabular.StaticDatasetQueryRequest) (int, error)
}
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) GetHTTPServerWithOtel ¶ added in v1.31.0
func (i *Init) GetHTTPServerWithOtel(bindAddr string, router http.Handler) HTTPServer
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) GetMongoClient ¶ added in v1.22.0
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
GetMongoClient(ctx context.Context, cfg *config.Config) (MongoClient, error)
GetResponder() Responder
GetHTTPServerWithOtel(bindAddr string, router http.Handler) HTTPServer
}
Initialiser defines the methods to initialise external services
type MongoClient ¶ added in v1.22.0
type MongoClient interface {
GetDefaultDatasetMetadata(ctx context.Context, populationType string) (*datastore.DefaultDatasetMetadata, error)
PutDefaultDatasetMetadata(ctx context.Context, metadata datastore.DefaultDatasetMetadata) error
GetDefaultDatasetPopulationTypes(ctx context.Context) ([]string, error)
}
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.