service

package
v0.0.0-...-14f90b6 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 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 ExternalServiceList

type ExternalServiceList struct {
	MongoDB       bool
	HealthCheck   bool
	KafkaProducer bool
	S3Client      bool
	FilesService  bool
	Init          Initialiser
}

func NewServiceList

func NewServiceList(initialiser Initialiser) *ExternalServiceList

func (*ExternalServiceList) GetAuthorisationMiddleware

func (e *ExternalServiceList) GetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)

GetAuthorisationMiddleware creates a new instance of authorisation.Middlware

func (*ExternalServiceList) GetFilesService

func (e *ExternalServiceList) GetFilesService(ctx context.Context, cfg *config.Config) (api.FilesService, error)

GetFilesService creates files service and sets the FilesService flag to true

func (*ExternalServiceList) GetGenerators

GetGenerators returns all the attribute generators necessary - i.e. uuid, resourceId and slug

func (*ExternalServiceList) GetHTTPServer

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

GetHTTPServer creates an http server and sets the Server flag to true

func (*ExternalServiceList) GetHealthCheck

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

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

func (*ExternalServiceList) GetHealthClient

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

GetHealthClient returns a healthclient for the provided URL

func (*ExternalServiceList) GetKafkaProducer

func (e *ExternalServiceList) GetKafkaProducer(ctx context.Context, cfg *config.Config) (producer kafka.IProducer, err error)

GetKafkaProducer returns a kafka producer

func (*ExternalServiceList) GetMongoDB

func (e *ExternalServiceList) GetMongoDB(ctx context.Context, cfg *config.Config) (api.MongoServer, error)

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

func (*ExternalServiceList) GetResponder

func (e *ExternalServiceList) GetResponder(ctx context.Context, cfg *config.Config) (*responder.Responder, error)

GetResponder returns rhe responder for handling responses in a generic way

func (*ExternalServiceList) GetS3Client

func (e *ExternalServiceList) GetS3Client(ctx context.Context, cfg *config.Config) (api.S3Interface, error)

GetS3Uploaded creates a S3 client and sets the S3Uploaded flag to true

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

func (*Init) DoGetAuthorisationMiddleware

func (e *Init) DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)

DoGetAuthorisationMiddleware creates authorisation middleware for the given config

func (*Init) DoGetFilesService

func (e *Init) DoGetFilesService(ctx context.Context, cfg *config.Config) (api.FilesService, error)

DoGetFilesService returns a files service backend

func (*Init) DoGetGenerators

func (e *Init) DoGetGenerators() (data.Generator, data.Generator, data.Generator)

DoGetGenerators creates authorisation middleware for the given config

func (*Init) DoGetHTTPServer

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

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

DoGetHealthCheck creates a healthcheck with versionInfo

func (*Init) DoGetHealthClient

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

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

func (*Init) DoGetKafkaProducer

func (e *Init) DoGetKafkaProducer(ctx context.Context, cfg *config.Config) (kafka.IProducer, error)

DoGetKafkaProducer creates a kafka producer for the provided broker addresses, topic and envMax values in config

func (*Init) DoGetMongoDB

func (e *Init) DoGetMongoDB(ctx context.Context, cfg *config.Config) (api.MongoServer, error)

DoGetMongoDB returns a MongoDB

func (*Init) DoGetResponder

func (e *Init) DoGetResponder(_ context.Context, _ *config.Config) (*responder.Responder, error)

DoGetResponder creates the default responder

func (*Init) DoGetS3Client

func (e *Init) DoGetS3Client(ctx context.Context, cfg *config.Config) (api.S3Interface, error)

DoGetS3Uploaded returns a S3Client

type Initialiser

type Initialiser interface {
	DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
	DoGetMongoDB(ctx context.Context, cfg *config.Config) (api.MongoServer, error)
	DoGetKafkaProducer(ctx context.Context, cfg *config.Config) (kafka.IProducer, error)
	DoGetHealthClient(name, url string) *health.Client
	DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
	DoGetS3Client(ctx context.Context, cfg *config.Config) (api.S3Interface, error)
	DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
	DoGetGenerators() (data.Generator, data.Generator, data.Generator)
	DoGetFilesService(ctx context.Context, cfg *config.Config) (api.FilesService, error)
	DoGetResponder(ctx context.Context, cfg *config.Config) (*responder.Responder, error)
}

Initialiser defines the methods to initialise external services

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service contains all the configs, server and clients to run the interactives API

func Run

func Run(ctx context.Context, cfg *config.Config, serviceList *ExternalServiceList, buildTime, gitCommit, version string, svcErrors chan error) (*Service, error)

func (*Service) Close

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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