Skip to content

Commit

Permalink
fix: pass shared event store (#3233)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Mar 1, 2023
1 parent 173e5a9 commit ad588fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
@@ -1,5 +1,5 @@
import { Db } from '../../db/db';
import { IUnleashConfig } from '../../types';
import { IEventStore, IUnleashConfig } from '../../types';
import ExportImportService from './export-import-service';
import { ImportTogglesStore } from './import-toggles-store';
import FeatureToggleStore from '../../db/feature-toggle-store';
Expand All @@ -9,7 +9,6 @@ import ProjectStore from '../../db/project-store';
import FeatureTagStore from '../../db/feature-tag-store';
import StrategyStore from '../../db/strategy-store';
import ContextFieldStore from '../../db/context-field-store';
import EventStore from '../../db/event-store';
import FeatureStrategiesStore from '../../db/feature-strategy-store';
import {
ContextService,
Expand Down Expand Up @@ -112,6 +111,7 @@ export const createFakeExportImportTogglesService = (
export const createExportImportTogglesService = (
db: Db,
config: IUnleashConfig,
eventStore: IEventStore,
): ExportImportService => {
const { eventBus, getLogger, flagResolver } = config;
const importTogglesStore = new ImportTogglesStore(db);
Expand All @@ -128,7 +128,6 @@ export const createExportImportTogglesService = (
const featureTagStore = new FeatureTagStore(db, eventBus, getLogger);
const strategyStore = new StrategyStore(db, getLogger);
const contextFieldStore = new ContextFieldStore(db, getLogger);
const eventStore = new EventStore(db, getLogger);
const featureStrategiesStore = new FeatureStrategiesStore(
db,
eventBus,
Expand All @@ -141,7 +140,11 @@ export const createExportImportTogglesService = (
getLogger,
);
const accessService = createAccessService(db, config);
const featureToggleService = createFeatureToggleService(db, config);
const featureToggleService = createFeatureToggleService(
db,
config,
eventStore,
);

const featureTagService = new FeatureTagService(
{
Expand Down
5 changes: 2 additions & 3 deletions src/lib/features/feature-toggle/createFeatureToggleService.ts
Expand Up @@ -4,7 +4,6 @@ import {
GroupService,
SegmentService,
} from '../../services';
import EventStore from '../../db/event-store';
import FeatureStrategiesStore from '../../db/feature-strategy-store';
import FeatureToggleStore from '../../db/feature-toggle-store';
import FeatureToggleClientStore from '../../db/feature-toggle-client-store';
Expand All @@ -19,7 +18,7 @@ import { AccessStore } from '../../db/access-store';
import RoleStore from '../../db/role-store';
import EnvironmentStore from '../../db/environment-store';
import { Db } from '../../db/db';
import { IUnleashConfig } from '../../types';
import { IEventStore, IUnleashConfig } from '../../types';
import FakeEventStore from '../../../test/fixtures/fake-event-store';
import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store';
import FakeFeatureToggleStore from '../../../test/fixtures/fake-feature-toggle-store';
Expand All @@ -38,9 +37,9 @@ import FakeEnvironmentStore from '../../../test/fixtures/fake-environment-store'
export const createFeatureToggleService = (
db: Db,
config: IUnleashConfig,
eventStore: IEventStore,
): FeatureToggleService => {
const { getLogger, eventBus, flagResolver } = config;
const eventStore = new EventStore(db, getLogger);
const featureStrategiesStore = new FeatureStrategiesStore(
db,
eventBus,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/services/index.ts
Expand Up @@ -164,10 +164,10 @@ export const createServices = (

// TODO: this is a temporary seam to enable packaging by feature
const exportImportService = db
? createExportImportTogglesService(db, config)
? createExportImportTogglesService(db, config, stores.eventStore)
: createFakeExportImportTogglesService(config);
const transactionalExportImportService = (txDb: Knex.Transaction) =>
createExportImportTogglesService(txDb, config);
createExportImportTogglesService(txDb, config, stores.eventStore);
const userSplashService = new UserSplashService(stores, config);
const openApiService = new OpenApiService(config);
const clientSpecService = new ClientSpecService(config);
Expand Down

0 comments on commit ad588fd

Please sign in to comment.