2016-11-04 09:03:13 +01:00
|
|
|
'use strict';
|
2016-11-04 09:35:53 +01:00
|
|
|
|
2016-11-05 14:08:47 +01:00
|
|
|
const { createDb } = require('./db-pool');
|
2016-11-05 10:16:48 +01:00
|
|
|
const EventStore = require('./event-store');
|
|
|
|
const FeatureToggleStore = require('./feature-toggle-store');
|
|
|
|
const StrategyStore = require('./strategy-store');
|
2016-11-05 14:08:47 +01:00
|
|
|
const ClientInstanceStore = require('./client-instance-store');
|
2016-11-28 17:11:11 +01:00
|
|
|
const ClientMetricsDb = require('./client-metrics-db');
|
2016-11-05 13:36:44 +01:00
|
|
|
const ClientMetricsStore = require('./client-metrics-store');
|
2016-12-06 09:19:15 +01:00
|
|
|
const ClientApplicationsStore = require('./client-applications-store');
|
2020-02-27 21:26:18 +01:00
|
|
|
const ContextFieldStore = require('./context-field-store');
|
2016-11-04 09:03:13 +01:00
|
|
|
|
2019-10-02 23:14:53 +02:00
|
|
|
module.exports.createStores = (config, eventBus) => {
|
2019-04-30 21:14:23 +02:00
|
|
|
const getLogger = config.getLogger;
|
2019-10-02 23:14:53 +02:00
|
|
|
const db = createDb(config);
|
2019-04-30 21:14:23 +02:00
|
|
|
const eventStore = new EventStore(db, getLogger);
|
|
|
|
const clientMetricsDb = new ClientMetricsDb(db, getLogger);
|
2016-11-05 10:16:48 +01:00
|
|
|
|
|
|
|
return {
|
2016-11-05 14:08:47 +01:00
|
|
|
db,
|
2016-11-05 10:16:48 +01:00
|
|
|
eventStore,
|
2019-04-30 21:14:23 +02:00
|
|
|
featureToggleStore: new FeatureToggleStore(db, eventStore, getLogger),
|
|
|
|
strategyStore: new StrategyStore(db, eventStore, getLogger),
|
2019-08-04 11:10:51 +02:00
|
|
|
clientApplicationsStore: new ClientApplicationsStore(
|
|
|
|
db,
|
|
|
|
eventBus,
|
|
|
|
getLogger
|
|
|
|
),
|
|
|
|
clientInstanceStore: new ClientInstanceStore(db, eventBus, getLogger),
|
|
|
|
clientMetricsStore: new ClientMetricsStore(
|
|
|
|
clientMetricsDb,
|
|
|
|
eventBus,
|
|
|
|
getLogger
|
|
|
|
),
|
2020-02-27 21:26:18 +01:00
|
|
|
contextFieldStore: new ContextFieldStore(
|
|
|
|
db,
|
|
|
|
config.customContextFields,
|
|
|
|
eventStore,
|
|
|
|
getLogger
|
|
|
|
),
|
2016-11-05 10:16:48 +01:00
|
|
|
};
|
|
|
|
};
|