mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: segments service DI (#4376)
This commit is contained in:
parent
579b08be27
commit
da5e18233c
@ -3,3 +3,4 @@ export * from './export-import-toggles/createExportImportService';
|
|||||||
export * from './feature-toggle/createFeatureToggleService';
|
export * from './feature-toggle/createFeatureToggleService';
|
||||||
export * from './project/createProjectService';
|
export * from './project/createProjectService';
|
||||||
export * from './change-request-access-service/createChangeRequestAccessReadModel';
|
export * from './change-request-access-service/createChangeRequestAccessReadModel';
|
||||||
|
export * from './segment/createSegmentService';
|
||||||
|
47
src/lib/features/segment/createSegmentService.ts
Normal file
47
src/lib/features/segment/createSegmentService.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import { Db, IUnleashConfig } from 'lib/server-impl';
|
||||||
|
import EventStore from '../../db/event-store';
|
||||||
|
import { SegmentService } from '../../services';
|
||||||
|
import FakeEventStore from '../../../test/fixtures/fake-event-store';
|
||||||
|
import { ISegmentService } from '../../segments/segment-service-interface';
|
||||||
|
import FeatureStrategiesStore from '../../db/feature-strategy-store';
|
||||||
|
import SegmentStore from '../../db/segment-store';
|
||||||
|
import FakeSegmentStore from '../../../test/fixtures/fake-segment-store';
|
||||||
|
import FakeFeatureStrategiesStore from '../../../test/fixtures/fake-feature-strategies-store';
|
||||||
|
|
||||||
|
export const createSegmentService = (
|
||||||
|
db: Db,
|
||||||
|
config: IUnleashConfig,
|
||||||
|
): ISegmentService => {
|
||||||
|
const { eventBus, getLogger, flagResolver } = config;
|
||||||
|
const eventStore = new EventStore(db, getLogger);
|
||||||
|
const segmentStore = new SegmentStore(
|
||||||
|
db,
|
||||||
|
eventBus,
|
||||||
|
getLogger,
|
||||||
|
flagResolver,
|
||||||
|
);
|
||||||
|
const featureStrategiesStore = new FeatureStrategiesStore(
|
||||||
|
db,
|
||||||
|
eventBus,
|
||||||
|
getLogger,
|
||||||
|
flagResolver,
|
||||||
|
);
|
||||||
|
|
||||||
|
return new SegmentService(
|
||||||
|
{ segmentStore, featureStrategiesStore, eventStore },
|
||||||
|
config,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const createFakeSegmentService = (
|
||||||
|
config: IUnleashConfig,
|
||||||
|
): ISegmentService => {
|
||||||
|
const eventStore = new FakeEventStore();
|
||||||
|
const segmentStore = new FakeSegmentStore();
|
||||||
|
const featureStrategiesStore = new FakeFeatureStrategiesStore();
|
||||||
|
|
||||||
|
return new SegmentService(
|
||||||
|
{ segmentStore, featureStrategiesStore, eventStore },
|
||||||
|
config,
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user