mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-04 01:18:20 +02:00
refactor: segment read model used in proxy-repository (#6421)
This commit is contained in:
parent
76f379a4dc
commit
f3df7269cb
@ -42,6 +42,7 @@ import LastSeenStore from '../features/metrics/last-seen/last-seen-store';
|
|||||||
import FeatureSearchStore from '../features/feature-search/feature-search-store';
|
import FeatureSearchStore from '../features/feature-search/feature-search-store';
|
||||||
import { InactiveUsersStore } from '../users/inactive/inactive-users-store';
|
import { InactiveUsersStore } from '../users/inactive/inactive-users-store';
|
||||||
import { TrafficDataUsageStore } from '../features/traffic-data-usage/traffic-data-usage-store';
|
import { TrafficDataUsageStore } from '../features/traffic-data-usage/traffic-data-usage-store';
|
||||||
|
import { SegmentReadModel } from '../features/segment/segment-read-model';
|
||||||
|
|
||||||
export const createStores = (
|
export const createStores = (
|
||||||
config: IUnleashConfig,
|
config: IUnleashConfig,
|
||||||
@ -145,6 +146,7 @@ export const createStores = (
|
|||||||
featureSearchStore: new FeatureSearchStore(db, eventBus, getLogger),
|
featureSearchStore: new FeatureSearchStore(db, eventBus, getLogger),
|
||||||
inactiveUsersStore: new InactiveUsersStore(db, eventBus, getLogger),
|
inactiveUsersStore: new InactiveUsersStore(db, eventBus, getLogger),
|
||||||
trafficDataUsageStore: new TrafficDataUsageStore(db, getLogger),
|
trafficDataUsageStore: new TrafficDataUsageStore(db, getLogger),
|
||||||
|
segmentReadModel: new SegmentReadModel(db),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,11 +21,14 @@ import { PROXY_FEATURES_FOR_TOKEN_TIME } from '../metric-events';
|
|||||||
|
|
||||||
type Config = Pick<IUnleashConfig, 'getLogger' | 'frontendApi' | 'eventBus'>;
|
type Config = Pick<IUnleashConfig, 'getLogger' | 'frontendApi' | 'eventBus'>;
|
||||||
|
|
||||||
type Stores = Pick<IUnleashStores, 'projectStore' | 'eventStore'>;
|
type Stores = Pick<
|
||||||
|
IUnleashStores,
|
||||||
|
'projectStore' | 'eventStore' | 'segmentReadModel'
|
||||||
|
>;
|
||||||
|
|
||||||
type Services = Pick<
|
type Services = Pick<
|
||||||
IUnleashServices,
|
IUnleashServices,
|
||||||
'featureToggleServiceV2' | 'segmentService' | 'configurationRevisionService'
|
'featureToggleServiceV2' | 'configurationRevisionService'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export class ProxyRepository
|
export class ProxyRepository
|
||||||
@ -164,7 +167,7 @@ export class ProxyRepository
|
|||||||
|
|
||||||
private async segmentsForToken(): Promise<Segment[]> {
|
private async segmentsForToken(): Promise<Segment[]> {
|
||||||
return mapSegmentsForClient(
|
return mapSegmentsForClient(
|
||||||
await this.services.segmentService.getAll(),
|
await this.stores.segmentReadModel.getAll(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,6 @@ export const createServices = (
|
|||||||
const proxyService = new ProxyService(config, stores, {
|
const proxyService = new ProxyService(config, stores, {
|
||||||
featureToggleServiceV2,
|
featureToggleServiceV2,
|
||||||
clientMetricsServiceV2,
|
clientMetricsServiceV2,
|
||||||
segmentService,
|
|
||||||
settingService,
|
settingService,
|
||||||
configurationRevisionService,
|
configurationRevisionService,
|
||||||
});
|
});
|
||||||
|
@ -23,12 +23,14 @@ type Config = Pick<
|
|||||||
'getLogger' | 'frontendApi' | 'frontendApiOrigins' | 'eventBus'
|
'getLogger' | 'frontendApi' | 'frontendApiOrigins' | 'eventBus'
|
||||||
>;
|
>;
|
||||||
|
|
||||||
type Stores = Pick<IUnleashStores, 'projectStore' | 'eventStore'>;
|
type Stores = Pick<
|
||||||
|
IUnleashStores,
|
||||||
|
'projectStore' | 'eventStore' | 'segmentReadModel'
|
||||||
|
>;
|
||||||
|
|
||||||
type Services = Pick<
|
type Services = Pick<
|
||||||
IUnleashServices,
|
IUnleashServices,
|
||||||
| 'featureToggleServiceV2'
|
| 'featureToggleServiceV2'
|
||||||
| 'segmentService'
|
|
||||||
| 'clientMetricsServiceV2'
|
| 'clientMetricsServiceV2'
|
||||||
| 'settingService'
|
| 'settingService'
|
||||||
| 'configurationRevisionService'
|
| 'configurationRevisionService'
|
||||||
|
@ -39,6 +39,7 @@ import { ILastSeenStore } from '../features/metrics/last-seen/types/last-seen-st
|
|||||||
import { IFeatureSearchStore } from '../features/feature-search/feature-search-store-type';
|
import { IFeatureSearchStore } from '../features/feature-search/feature-search-store-type';
|
||||||
import { IInactiveUsersStore } from '../users/inactive/types/inactive-users-store-type';
|
import { IInactiveUsersStore } from '../users/inactive/types/inactive-users-store-type';
|
||||||
import { ITrafficDataUsageStore } from '../features/traffic-data-usage/traffic-data-usage-store-type';
|
import { ITrafficDataUsageStore } from '../features/traffic-data-usage/traffic-data-usage-store-type';
|
||||||
|
import { ISegmentReadModel } from '../features/segment/segment-read-model-type';
|
||||||
|
|
||||||
export interface IUnleashStores {
|
export interface IUnleashStores {
|
||||||
accessStore: IAccessStore;
|
accessStore: IAccessStore;
|
||||||
@ -82,6 +83,7 @@ export interface IUnleashStores {
|
|||||||
featureSearchStore: IFeatureSearchStore;
|
featureSearchStore: IFeatureSearchStore;
|
||||||
inactiveUsersStore: IInactiveUsersStore;
|
inactiveUsersStore: IInactiveUsersStore;
|
||||||
trafficDataUsageStore: ITrafficDataUsageStore;
|
trafficDataUsageStore: ITrafficDataUsageStore;
|
||||||
|
segmentReadModel: ISegmentReadModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -124,4 +126,5 @@ export {
|
|||||||
ILastSeenStore,
|
ILastSeenStore,
|
||||||
IFeatureSearchStore,
|
IFeatureSearchStore,
|
||||||
ITrafficDataUsageStore,
|
ITrafficDataUsageStore,
|
||||||
|
ISegmentReadModel,
|
||||||
};
|
};
|
||||||
|
2
src/test/fixtures/store.ts
vendored
2
src/test/fixtures/store.ts
vendored
@ -42,6 +42,7 @@ import { FakeLastSeenStore } from '../../lib/features/metrics/last-seen/fake-las
|
|||||||
import FakeFeatureSearchStore from '../../lib/features/feature-search/fake-feature-search-store';
|
import FakeFeatureSearchStore from '../../lib/features/feature-search/fake-feature-search-store';
|
||||||
import { FakeInactiveUsersStore } from '../../lib/users/inactive/fakes/fake-inactive-users-store';
|
import { FakeInactiveUsersStore } from '../../lib/users/inactive/fakes/fake-inactive-users-store';
|
||||||
import { FakeTrafficDataUsageStore } from '../../lib/features/traffic-data-usage/fake-traffic-data-usage-store';
|
import { FakeTrafficDataUsageStore } from '../../lib/features/traffic-data-usage/fake-traffic-data-usage-store';
|
||||||
|
import { FakeSegmentReadModel } from '../../lib/features/segment/fake-segment-read-model';
|
||||||
|
|
||||||
const db = {
|
const db = {
|
||||||
select: () => ({
|
select: () => ({
|
||||||
@ -93,6 +94,7 @@ const createStores: () => IUnleashStores = () => {
|
|||||||
featureSearchStore: new FakeFeatureSearchStore(),
|
featureSearchStore: new FakeFeatureSearchStore(),
|
||||||
inactiveUsersStore: new FakeInactiveUsersStore(),
|
inactiveUsersStore: new FakeInactiveUsersStore(),
|
||||||
trafficDataUsageStore: new FakeTrafficDataUsageStore(),
|
trafficDataUsageStore: new FakeTrafficDataUsageStore(),
|
||||||
|
segmentReadModel: new FakeSegmentReadModel(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user