-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: feature oriented architecture for project-environment (#5510)
- Loading branch information
Showing
32 changed files
with
217 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
src/lib/features/project-environments/createEnvironmentService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Db } from '../../db/db'; | ||
import EventStore from '../../db/event-store'; | ||
import { IUnleashConfig } from '../../types'; | ||
import { EventService } from '../../services'; | ||
import FeatureTagStore from '../../db/feature-tag-store'; | ||
import FakeEventStore from '../../../test/fixtures/fake-event-store'; | ||
import FakeFeatureTagStore from '../../../test/fixtures/fake-feature-tag-store'; | ||
import EnvironmentService from './environment-service'; | ||
import EnvironmentStore from './environment-store'; | ||
import FeatureStrategiesStore from '../feature-toggle/feature-toggle-strategies-store'; | ||
import { FeatureEnvironmentStore } from '../../db/feature-environment-store'; | ||
import ProjectStore from '../../db/project-store'; | ||
import FakeFeatureEnvironmentStore from '../../../test/fixtures/fake-feature-environment-store'; | ||
import FakeProjectStore from '../../../test/fixtures/fake-project-store'; | ||
import FakeFeatureStrategiesStore from '../feature-toggle/fakes/fake-feature-strategies-store'; | ||
import FakeEnvironmentStore from './fake-environment-store'; | ||
|
||
export const createEnvironmentService = | ||
(config: IUnleashConfig) => | ||
(db: Db): EnvironmentService => { | ||
const { getLogger, eventBus, flagResolver } = config; | ||
const eventStore = new EventStore(db, getLogger); | ||
const featureTagStore = new FeatureTagStore(db, eventBus, getLogger); | ||
const featureEnvironmentStore = new FeatureEnvironmentStore( | ||
db, | ||
eventBus, | ||
getLogger, | ||
); | ||
const projectStore = new ProjectStore( | ||
db, | ||
eventBus, | ||
getLogger, | ||
flagResolver, | ||
); | ||
const featureStrategiesStore = new FeatureStrategiesStore( | ||
db, | ||
eventBus, | ||
getLogger, | ||
flagResolver, | ||
); | ||
const environmentStore = new EnvironmentStore(db, eventBus, getLogger); | ||
const eventService = new EventService( | ||
{ | ||
eventStore, | ||
featureTagStore, | ||
}, | ||
config, | ||
); | ||
return new EnvironmentService( | ||
{ | ||
environmentStore, | ||
featureStrategiesStore, | ||
featureEnvironmentStore, | ||
projectStore, | ||
}, | ||
config, | ||
eventService, | ||
); | ||
}; | ||
|
||
export const createFakeEnvironmentService = ( | ||
config: IUnleashConfig, | ||
): EnvironmentService => { | ||
const eventStore = new FakeEventStore(); | ||
const featureTagStore = new FakeFeatureTagStore(); | ||
const featureEnvironmentStore = new FakeFeatureEnvironmentStore(); | ||
const projectStore = new FakeProjectStore(); | ||
const featureStrategiesStore = new FakeFeatureStrategiesStore(); | ||
const environmentStore = new FakeEnvironmentStore(); | ||
const eventService = new EventService( | ||
{ | ||
eventStore, | ||
featureTagStore, | ||
}, | ||
config, | ||
); | ||
|
||
return new EnvironmentService( | ||
{ | ||
environmentStore, | ||
featureStrategiesStore, | ||
featureEnvironmentStore, | ||
projectStore, | ||
}, | ||
config, | ||
eventService, | ||
); | ||
}; |
14 changes: 7 additions & 7 deletions
14
.../e2e/services/environment-service.test.ts → ...-environments/environment-service.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
src/lib/db/environment-store.ts → ...project-environments/environment-store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...pi/admin/project/environments.e2e.test.ts → ...ect-environments/environments.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/test/fixtures/fake-environment-store.ts → ...ct-environments/fake-environment-store.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.