-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from splitio/consumer_mode_polishing
Bugfix: handle rejected promises when using segment matchers
- Loading branch information
Showing
4 changed files
with
4 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { MaybeThenable } from '../../dtos/types'; | ||
import { ISegmentsCacheBase } from '../../storages/types'; | ||
import { thenable } from '../../utils/promise/thenable'; | ||
|
||
export function largeSegmentMatcherContext(largeSegmentName: string, storage: { largeSegments?: ISegmentsCacheBase }) { | ||
|
||
return function largeSegmentMatcher(key: string): MaybeThenable<boolean> { | ||
const isInLargeSegment = storage.largeSegments ? storage.largeSegments.isInSegment(largeSegmentName, key) : false; | ||
|
||
if (thenable(isInLargeSegment)) { | ||
isInLargeSegment.then(result => { | ||
return result; | ||
}); | ||
} | ||
|
||
return isInLargeSegment; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { MaybeThenable } from '../../dtos/types'; | ||
import { ISegmentsCacheBase } from '../../storages/types'; | ||
import { thenable } from '../../utils/promise/thenable'; | ||
|
||
export function segmentMatcherContext(segmentName: string, storage: { segments: ISegmentsCacheBase }) { | ||
|
||
return function segmentMatcher(key: string): MaybeThenable<boolean> { | ||
const isInSegment = storage.segments.isInSegment(segmentName, key); | ||
|
||
if (thenable(isInSegment)) { | ||
isInSegment.then(result => { | ||
return result; | ||
}); | ||
} | ||
|
||
return isInSegment; | ||
}; | ||
} |
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