service

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventConsumer

type EventConsumer interface {
	Close(ctx context.Context) (err error)
}

EventConsumer defines the required methods from event Consumer

type ExternalServiceList

type ExternalServiceList struct {
	HealthCheck   bool
	KafkaConsumer bool
	S3Client      bool
	ESClient      bool
	ZebedeeClient bool
	Init          Initialiser
}

ExternalServiceList holds the initialiser and initialisation state of external services.

func NewServiceList

func NewServiceList(initialiser Initialiser) *ExternalServiceList

NewServiceList creates a new service list with the provided initialiser

func (*ExternalServiceList) GetESClient

func (e *ExternalServiceList) GetESClient(ctx context.Context, cfg *config.Config) (dpClient dpEsClient.Client, rawClient *es710.Client, err error)

GetESClient creates an ESClient and sets the ESClient flag to true

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

func (e *ExternalServiceList) GetKafkaConsumer(ctx context.Context, cfg *config.Config) (dpkafka.IConsumerGroup, error)

GetKafkaConsumer creates a Kafka consumer and sets the consumer flag to true

func (*ExternalServiceList) GetS3Client

func (e *ExternalServiceList) GetS3Client(cfg *config.Config) (sitemap.S3Client, error)

GetS3Client creates an S3Client and sets the S3Client flag to true

func (*ExternalServiceList) GetZebedee

GetZebedee return zebedee client

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

Init implements the Initialiser interface to initialise dependencies

func (*Init) DoGetESClients

func (e *Init) DoGetESClients(ctx context.Context, cfg *config.OpenSearchConfig) (esClient dpEsClient.Client, rawClient *es710.Client, err error)

DoGetS3Clients returns a DP and raw Elastic clients

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

func (e *Init) DoGetKafkaConsumer(ctx context.Context, kafkaCfg *config.KafkaConfig) (dpkafka.IConsumerGroup, error)

DoGetKafkaConsumer returns a Kafka Consumer group

func (*Init) DoGetS3Client

func (e *Init) DoGetS3Client(cfg *config.S3Config) (sitemap.S3Client, error)

DoGetS3Client returns a S3Client

func (*Init) DoGetZebedeeClient

func (e *Init) DoGetZebedeeClient(cfg *config.Config) clients.ZebedeeClient

DoGetZebedeeClient gets and initialises the Zebedee Client

type Initialiser

type Initialiser interface {
	DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
	DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
	DoGetKafkaConsumer(ctx context.Context, kafkaCfg *config.KafkaConfig) (kafka.IConsumerGroup, error)
	DoGetS3Client(cfg *config.S3Config) (sitemap.S3Client, error)
	DoGetESClients(ctx context.Context, cfg *config.OpenSearchConfig) (dpEsClient.Client, *es710.Client, error)
	DoGetZebedeeClient(cfg *config.Config) clients.ZebedeeClient
}

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 event handler service

func Run

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

Run the service

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