service

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetListTransitions added in v1.2.0

func GetListTransitions() []application.Transition

func GetStateMachine added in v1.2.0

func GetStateMachine(ctx context.Context, datastore store.Datastore) *application.StateMachine

Types

type BundleAPIStore added in v1.0.0

type BundleAPIStore struct {
	store.MongoDB
}

type ExternalServiceList

type ExternalServiceList struct {
	MongoDB                 bool
	DatasetAPIClient        bool
	PermissionsAPIClient    bool
	DataBundleSlackClient   bool
	AuthorisationMiddleware bool
	HealthCheck             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) GetAuthorisationMiddleware added in v1.2.0

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

GetAuthorisationMiddleware creates authorisation middleware for the given config and sets the AuthorisationMiddleware flag to true

func (*ExternalServiceList) GetDataBundleSlackClient added in v1.12.0

func (e *ExternalServiceList) GetDataBundleSlackClient(slackConfig *slack.SlackConfig, apiToken string, enabled bool) (slack.Clienter, error)

GetDataBundleSlackClient creates a new Slack Client and sets the DataBundleSlackClient flag to true

func (*ExternalServiceList) GetDatasetAPIClient added in v1.3.0

func (e *ExternalServiceList) GetDatasetAPIClient(datasetAPIURL string) datasetAPISDK.Clienter

GetDatasetAPIClient creates a new Dataset API client with the provided datasetAPIURL and sets the DatasetAPIClient flag to true

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) GetMongoDB added in v1.0.0

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

func (*ExternalServiceList) GetPermissionsAPIClient added in v1.12.0

func (e *ExternalServiceList) GetPermissionsAPIClient(permissionsAPIURL string) permissionsAPISDK.Clienter

GetPermissionsAPIClient creates a new Permissions API client with the provided permissionsAPIURL and sets the PermissionsAPIClient 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 v1.2.0

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

DoGetAuthorisationMiddleware creates authorisation middleware for the given config

func (*Init) DoGetDataBundleSlackClient added in v1.12.0

func (e *Init) DoGetDataBundleSlackClient(slackConfig *slack.SlackConfig, apiToken string, enabled bool) (slack.Clienter, error)

DoGetDataBundleSlackClient creates a new Slack Client If enabled is false, a no-op slack client is returned

func (*Init) DoGetDatasetAPIClient added in v1.3.0

func (e *Init) DoGetDatasetAPIClient(datasetAPIURL string) datasetAPISDK.Clienter

DoGetDatasetAPIClient returns a new Dataset API client with the provided datasetAPIURL

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) DoGetMongoDB added in v1.0.0

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

DoGetMongoDB returns a MongoDB

func (*Init) DoGetPermissionsAPIClient added in v1.12.0

func (e *Init) DoGetPermissionsAPIClient(permissionsAPIURL string) permissionsAPISDK.Clienter

DoGetPermissionsAPIClient returns a new Permissions API client with the provided permissionsAPIURL

type Initialiser

type Initialiser interface {
	DoGetMongoDB(ctx context.Context, cfg config.MongoConfig) (store.MongoDB, error)
	DoGetDatasetAPIClient(datasetAPIURL string) datasetAPISDK.Clienter
	DoGetPermissionsAPIClient(permissionsAPIURL string) permissionsAPISDK.Clienter
	DoGetDataBundleSlackClient(slackConfig *slack.SlackConfig, apiToken string, enabled bool) (slack.Clienter, error)
	DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
	DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
	DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
}

Initialiser defines the methods to initialise external services

type Service

type Service struct {
	Config *config.Config
	Server HTTPServer
	Router *mux.Router
	API    *api.BundleAPI

	ServiceList *ExternalServiceList
	HealthCheck HealthChecker

	AuthMiddleware auth.Middleware
	ZebedeeClient  *health.Client
	// contains filtered or unexported fields
}

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

func New added in v1.0.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 v1.0.0

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

Run the service

func (*Service) SetHealthCheck added in v1.0.0

func (svc *Service) SetHealthCheck(healthCheck HealthChecker)

SetHealthCheck sets the healthchecker for a service

func (*Service) SetMongoDB added in v1.0.0

func (svc *Service) SetMongoDB(mongoDB store.MongoDB)

SetMongoDB sets the mongoDB connection for a service

func (*Service) SetServer added in v1.0.0

func (svc *Service) SetServer(server HTTPServer)

SetServer sets the http server for a service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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