Documentation
¶
Index ¶
- func GetListTransitions() []application.Transition
- func GetStateMachine(ctx context.Context, datastore store.Datastore) *application.StateMachine
- type BundleAPIStore
- type ExternalServiceList
- func (e *ExternalServiceList) GetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
- func (e *ExternalServiceList) GetDataBundleSlackClient(slackConfig *slack.SlackConfig, apiToken string, enabled bool) (slack.Clienter, error)
- func (e *ExternalServiceList) GetDatasetAPIClient(datasetAPIURL string) datasetAPISDK.Clienter
- func (e *ExternalServiceList) GetHTTPServer(bindAddr string, router http.Handler) HTTPServer
- func (e *ExternalServiceList) GetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
- func (e *ExternalServiceList) GetMongoDB(ctx context.Context, cfg config.MongoConfig) (store.MongoDB, error)
- func (e *ExternalServiceList) GetPermissionsAPIClient(permissionsAPIURL string) permissionsAPISDK.Clienter
- type HTTPServer
- type HealthChecker
- type Init
- func (e *Init) DoGetAuthorisationMiddleware(ctx context.Context, authorisationConfig *authorisation.Config) (authorisation.Middleware, error)
- func (e *Init) DoGetDataBundleSlackClient(slackConfig *slack.SlackConfig, apiToken string, enabled bool) (slack.Clienter, error)
- func (e *Init) DoGetDatasetAPIClient(datasetAPIURL string) datasetAPISDK.Clienter
- func (e *Init) DoGetHTTPServer(bindAddr string, router http.Handler) HTTPServer
- func (e *Init) DoGetHealthCheck(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error)
- func (e *Init) DoGetMongoDB(ctx context.Context, cfg config.MongoConfig) (store.MongoDB, error)
- func (e *Init) DoGetPermissionsAPIClient(permissionsAPIURL string) permissionsAPISDK.Clienter
- type Initialiser
- type Service
- func (svc *Service) Close(ctx context.Context) error
- func (svc *Service) Run(ctx context.Context, buildTime, gitCommit, version string, ...) (err error)
- func (svc *Service) SetHealthCheck(healthCheck HealthChecker)
- func (svc *Service) SetMongoDB(mongoDB store.MongoDB)
- func (svc *Service) SetServer(server HTTPServer)
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 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
func (e *ExternalServiceList) GetMongoDB(ctx context.Context, cfg config.MongoConfig) (store.MongoDB, error)
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 ¶
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
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) 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
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