service

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExternalServiceList

type ExternalServiceList struct {
	AuthorisationMiddleware bool
	HealthCheck             bool
	Init                    Initialiser
	Redis                   bool
}

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) GetAuthorisationMiddleware added in v0.3.2

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

GetAuthorisationMiddleware creates a new instance of authorisation.Middlware

func (*ExternalServiceList) GetHTTPServer

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

GetHTTPServer creates an http server

func (*ExternalServiceList) GetHealthCheck

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

func (e *ExternalServiceList) GetRedisClient(ctx context.Context, cfg *config.Config) (store.Redis, error)

GetRedisClient creates a Redis client and sets the Redis 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{}

Init implements the Initialiser interface to initialise dependencies

func (*Init) DoGetAuthorisationMiddleware added in v0.3.2

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

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

func (e *Init) DoGetRedisClient(ctx context.Context, cfg *config.Config) (store.Redis, error)

DoGetRedisClient initialises a dis-redis client

type Initialiser

type Initialiser interface {
	DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
	DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
	DoGetRedisClient(ctx context.Context, cfg *config.Config) (store.Redis, error)
	DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
}

Initialiser defines the methods to initialise external services

type RedisAPIStore added in v0.3.0

type RedisAPIStore struct {
	store.Redis
}

RedisAPIStore wraps the Redis client to implement the store.Redis interface.

type Service

type Service struct {
	Config         *config.Config
	Server         HTTPServer
	Router         *mux.Router
	API            *api.RedirectAPI
	ServiceList    *ExternalServiceList
	HealthCheck    HealthChecker
	AuthMiddleware authorisation.Middleware
}

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

func Run

func Run(ctx context.Context, cfg *config.Config, 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