service

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: MIT Imports: 16 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

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

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) 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

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
	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

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