Skip to content

Commit ee47067

Browse files
RBS excluded segments
1 parent 2083e00 commit ee47067

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

src/dtos/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,19 @@ export interface ISplitCondition {
199199
conditionType?: 'ROLLOUT' | 'WHITELIST'
200200
}
201201

202+
export interface IExcludedSegments {
203+
type: string,
204+
name: string,
205+
}
206+
202207
export interface IRBSegment {
203208
name: string,
204209
changeNumber: number,
205210
status: 'ACTIVE' | 'ARCHIVED',
206211
conditions?: ISplitCondition[],
207212
excluded?: {
208213
keys?: string[],
209-
segments?: string[]
214+
segments?: IExcludedSegments[]
210215
}
211216
}
212217

src/evaluator/matchers/__tests__/rbsegment.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ const STORED_RBSEGMENTS: Record<string, IRBSegment> = {
2424
status: 'ACTIVE',
2525
excluded: {
2626
27-
segments: ['segment_test']
27+
segments: [
28+
{ type: 'regular', name: 'segment_test' }
29+
]
2830
},
2931
conditions: [
3032
{

src/evaluator/matchers/rbsegment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export function ruleBasedSegmentMatcherContext(segmentName: string, storage: ISt
3535

3636
if (excluded.keys && excluded.keys.indexOf(matchingKey) !== -1) return true;
3737

38-
const isInSegment = (excluded.segments || []).map(segmentName => {
39-
return storage.segments.isInSegment(segmentName, matchingKey);
38+
const isInSegment = (excluded.segments || []).map(segment => {
39+
return storage.segments.isInSegment(segment.name, matchingKey);
4040
});
4141

4242
return isInSegment.length && thenable(isInSegment[0]) ?

src/sync/polling/updaters/splitChangesUpdater.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function checkAllSegmentsExist(segments: ISegmentsCacheBase): Promise<boolean> {
3131
*/
3232
export function parseSegments(ruleEntity: ISplit | IRBSegment, matcherType: typeof IN_SEGMENT | typeof IN_RULE_BASED_SEGMENT = IN_SEGMENT): Set<string> {
3333
const { conditions = [], excluded } = ruleEntity as IRBSegment;
34-
const segments = new Set<string>(excluded && excluded.segments);
34+
35+
const segments = new Set<string>(
36+
excluded?.segments?.map(segment => segment.name) || []
37+
);
3538

3639
for (let i = 0; i < conditions.length; i++) {
3740
const matchers = conditions[i].matcherGroup.matchers;

0 commit comments

Comments
 (0)