service

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

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

type HTTPServer interface {
	ListenAndServe() error
	Shutdown(ctx context.Context) error
}

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 NewInit added in v1.1.0

func NewInit() *Init

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 (i *Init) GetMongoClient(ctx context.Context, cfg *config.Config) (MongoClient, error)

func (*Init) GetResponder added in v1.1.0

func (i *Init) GetResponder() Responder

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

func New added in v1.1.0

func New() *Service

func (*Service) Close

func (svc *Service) Close(ctx context.Context) error

Close gracefully shuts the service down in the required order, with timeout

func (*Service) Init added in v1.1.0

func (svc *Service) Init(ctx context.Context, init Initialiser, cfg *config.Config, buildTime, gitCommit, version string) error

func (*Service) Start added in v1.1.0

func (svc *Service) Start(ctx context.Context, svcErrors chan error)

Start the service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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