Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GetCantabularClient = func(cfg *config.Config) CantabularClient { return cantabular.NewClient( cantabular.Config{ Host: cfg.CantabularURL, ExtApiHost: cfg.CantabularExtURL, }, dphttp.NewClient(), nil, ) }
GetCantabularClient gets and initialises the Cantabular Client
View Source
var GetHTTPServer = func(bindAddr string, router http.Handler) HTTPServer { s := dphttp.NewServer(bindAddr, router) s.HandleOSSignals = false return s }
GetHTTPServer creates an HTTP Server with the provided bind address and router
View Source
var GetHealthCheck = func(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error) { versionInfo, err := healthcheck.NewVersionInfo(buildTime, gitCommit, version) if err != nil { return nil, err } hc := healthcheck.New(versionInfo, cfg.HealthCheckCriticalTimeout, cfg.HealthCheckInterval) return &hc, nil }
GetHealthCheck creates a healthcheck with versionInfo
View Source
var GetResponder = func() Responder { return responder.New() }
GetResponder gets a http request responder
Functions ¶
This section is empty.
Types ¶
type CantabularClient ¶
type CantabularClient interface {
GetCodebook(context.Context, cantabular.GetCodebookRequest) (*cantabular.GetCodebookResponse, error)
GetGeographyDimensions(context.Context, cantabular.GetGeographyDimensionsRequest) (*cantabular.GetGeographyDimensionsResponse, error)
GetAreas(ctx context.Context, req cantabular.GetAreasRequest) (*cantabular.GetAreasResponse, error)
Checker(context.Context, *healthcheck.CheckState) error
CheckerAPIExt(ctx context.Context, state *healthcheck.CheckState) error
StatusCode(error) int
}
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 Initialiser ¶
type Initialiser interface {
DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
}
Initialiser defines the methods to initialise external services
type Responder ¶
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
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.