service

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 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 DatsetAPIStore added in v0.3.0

type DatsetAPIStore struct {
	store.MongoDB
}

DatsetAPIStore is a wrapper which embeds (Neo4j) Mongo structs which between them satisfy the store.Storer interface.

type ExternalServiceList added in v0.2.0

type ExternalServiceList struct {
	HealthCheck bool
	Init        Initialiser
	MongoDB     bool
}

ExternalServiceList holds the initialiser and initialisation state of external services.

func NewServiceList added in v0.2.0

func NewServiceList(initialiser Initialiser) *ExternalServiceList

NewServiceList creates a new service list with the provided initialiser

func (*ExternalServiceList) GetHTTPServer added in v0.2.0

func (e *ExternalServiceList) GetHTTPServer(bindAddr string, router http.Handler) HTTPServer

GetHTTPServer creates an http server

func (*ExternalServiceList) GetHealthCheck added in v0.2.0

func (e *ExternalServiceList) GetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)

GetHealthCheck creates a healthcheck with versionInfo and sets the HealthCheck flag to true

func (*ExternalServiceList) GetHealthClient added in v0.2.0

func (e *ExternalServiceList) GetHealthClient(name, url string) *health.Client

GetHealthClient returns a healthclient for the provided URL

func (*ExternalServiceList) GetMongoDB added in v0.2.0

GetMongoDB creates a mongoDB client and sets the Mongo flag to true

type HTTPServer added in v0.2.0

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

HTTPServer defines the required methods from the HTTP server

type HealthChecker added in v0.2.0

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 added in v0.2.0

type Init struct{}

Init implements the Initialiser interface to initialise dependencies

func (*Init) DoGetHTTPServer added in v0.2.0

func (e *Init) DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer

DoGetHTTPServer creates an HTTP Server with the provided bind address and router

func (*Init) DoGetHealthCheck added in v0.2.0

func (e *Init) DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)

DoGetHealthCheck creates a healthcheck with versionInfo

func (*Init) DoGetHealthClient added in v0.2.0

func (e *Init) DoGetHealthClient(name, url string) *health.Client

DoGetHealthClient creates a new Health Client for the provided name and url

func (*Init) DoGetMongoDB added in v0.2.0

func (e *Init) DoGetMongoDB(ctx context.Context, cfg config.MongoConfig) (store.MongoDB, error)

DoGetMongoDB returns a MongoDB

type Initialiser added in v0.2.0

type Initialiser interface {
	DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
	DoGetMongoDB(ctx context.Context, cfg config.MongoConfig) (store.MongoDB, error)
	DoGetHealthClient(name, url string) *health.Client
	DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
}

Initialiser defines the methods to initialise external services

type Service

type Service struct {
	Config      *config.Config
	ServiceList *ExternalServiceList
	Server      HTTPServer
	Router      *mux.Router
	API         *api.API
	HealthCheck HealthChecker

	IdentityClient *clientsidentity.Client
	// contains filtered or unexported fields
}

Service contains all the configs, server and clients to run the dp-topic-api API

func New added in v0.3.0

func New(cfg *config.Config, serviceList *ExternalServiceList) *Service

New creates a 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) Run added in v0.3.0

func (svc *Service) Run(ctx context.Context, buildTime, gitCommit, version string, svcErrors chan error) (err error)

Run the service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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