Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GetCantabularClient = func(cfg *config.Config) CantabularClient { return cantabular.NewClient( cantabular.Config{ Host: cfg.CantabularURL, ExtApiHost: cfg.CantabularExtURL, GraphQLTimeout: cfg.DefaultRequestTimeout, }, dphttp.NewClient(), nil, ) }
GetCantabularClient gets and initialises the Cantabular Client
var GetDatasetAPIClient = func(cfg *config.Config) DatasetAPIClient { return dataset.NewAPIClient(cfg.DatasetAPIURL) }
GetDatasetAPIClient gets and initialises the DatasetAPI Client
var GetGenerator = func() Generator { return generator.New() }
var GetHTTPServer = func(bindAddr string, router http.Handler) HTTPServer { s := dphttp.NewServer(bindAddr, router) s.HandleOSSignals = false return s }
GetHTTPServer creates an http server and sets the Server
var GetHealthCheck = func(cfg *config.Config, buildTime, gitCommit, version string) (HealthChecker, error) { versionInfo, err := healthcheck.NewVersionInfo(buildTime, gitCommit, version) if err != nil { return nil, fmt.Errorf("failed to get version info: %w", err) } hc := healthcheck.New( versionInfo, cfg.HealthCheckCriticalTimeout, cfg.HealthCheckInterval, ) return &hc, nil }
GetHealthCheck creates a healthcheck with versionInfo
var GetMongoDB = func(ctx context.Context, cfg *config.Config, g Generator) (Datastore, error) { return mongo.NewClient(ctx, g, mongo.Config{ MongoDriverConfig: cfg.Mongo, FilterFlexAPIURL: cfg.BindAddr, FiltersCollection: cfg.FiltersCollection, FilterOutputsCollection: cfg.FilterOutputsCollection, }) }
var GetResponder = func() Responder { return responder.New() }
GetResponder gets a http request responder
Functions ¶
This section is empty.
Types ¶
type CantabularClient ¶
type CantabularClient interface {
GetDimensionOptions(context.Context, cantabular.GetDimensionOptionsRequest) (*cantabular.GetDimensionOptionsResponse, error)
StatusCode(error) int
Checker(context.Context, *healthcheck.CheckState) error
CheckerAPIExt(context.Context, *healthcheck.CheckState) error
}
type DatasetAPIClient ¶
type Datastore ¶
type Datastore interface {
CreateFilter(context.Context, *model.Filter) error
GetFilter(context.Context, string) (*model.Filter, error)
CreateFilterOutput(context.Context, *model.FilterOutput) error
GetFilterDimensions(context.Context, string, int, int) ([]model.Dimension, int, error)
AddFilterDimension(ctx context.Context, s string, dimension model.Dimension) error
Checker(context.Context, *healthcheck.CheckState) error
Conn() *mongo.MongoConnection
}
Datastore is the interface for interacting with the storage backend
type Generator ¶
type Generator interface {
PSK() ([]byte, error)
UUID() (uuid.UUID, error)
Timestamp() time.Time
UniqueTimestamp() primitive.Timestamp
URL(host, path string, args ...interface{}) string
}
Generator is the interface for generating dynamic tokens and timestamps
type HTTPServer ¶
HTTPServer defines the required methods from the HTTP server
type HealthChecker ¶
type HealthChecker interface {
Handler(http.ResponseWriter, *http.Request)
Start(context.Context)
Stop()
AddAndGetCheck(name string, checker healthcheck.Checker) (*healthcheck.Check, error)
Subscribe(healthcheck.Subscriber, ...*healthcheck.Check)
}
HealthChecker defines the required methods from Healthcheck
type Responder ¶
type Responder interface {
JSON(context.Context, http.ResponseWriter, int, interface{})
Error(context.Context, http.ResponseWriter, int, error)
StatusCode(http.ResponseWriter, int)
Bytes(context.Context, http.ResponseWriter, int, []byte)
Errors(context.Context, http.ResponseWriter, int, []error)
}
Responder handles responding to http requests
type Service ¶
type Service struct {
Cfg *config.Config
Server HTTPServer
HealthCheck HealthChecker
Api *api.API
// contains filtered or unexported fields
}
Service contains all the configs, server and clients to run the event handler service