Skip to content

Commit

Permalink
Merge pull request #268 from splitio/flag_sets_polishing
Browse files Browse the repository at this point in the history
Flag Sets polishing: fix issue with `getNamesByFlagSets` method in Redis and Pluggable splits storage
  • Loading branch information
EmilianoSanchez authored Nov 3, 2023
2 parents ab50d43 + 827b91e commit 59b55dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/evaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function evaluateFeaturesByFlagSets(
flagSets: string[],
attributes: SplitIO.Attributes | undefined,
storage: IStorageSync | IStorageAsync,
): MaybeThenable<Record<string,IEvaluationResult>> {
): MaybeThenable<Record<string, IEvaluationResult>> {
let storedFlagNames: MaybeThenable<ISet<string>>;

// get features by flag sets
Expand All @@ -107,7 +107,10 @@ export function evaluateFeaturesByFlagSets(

// evaluate related features
return thenable(storedFlagNames) ?
storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage)) :
storedFlagNames.then((splitNames) => evaluateFeatures(log, key, setToArray(splitNames), attributes, storage))
.catch(() => {
return {};
}) :
evaluateFeatures(log, key, setToArray(storedFlagNames), attributes, storage);
}

Expand Down
6 changes: 3 additions & 3 deletions src/storages/inRedis/SplitsCacheInRedis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types';
import { LOG_PREFIX } from './constants';
import { ISplit } from '../../dtos/types';
import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
import { ISet, _Set } from '../../utils/lang/sets';
import { ISet } from '../../utils/lang/sets';

/**
* Discard errors for an answer of multiple operations.
Expand Down Expand Up @@ -196,8 +196,8 @@ export class SplitsCacheInRedis extends AbstractSplitsCacheAsync {
* @todo this is a no-op method to be implemented
*/
getNamesByFlagSets(): Promise<ISet<string>> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return new Promise(flagSets => new _Set([]));
this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with Redis storage yet.');
return Promise.reject();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/storages/pluggable/SplitsCachePluggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ILogger } from '../../logger/types';
import { ISplit } from '../../dtos/types';
import { LOG_PREFIX } from './constants';
import { AbstractSplitsCacheAsync } from '../AbstractSplitsCacheAsync';
import { ISet, _Set } from '../../utils/lang/sets';
import { ISet } from '../../utils/lang/sets';

/**
* ISplitsCacheAsync implementation for pluggable storages.
Expand Down Expand Up @@ -162,8 +162,8 @@ export class SplitsCachePluggable extends AbstractSplitsCacheAsync {
* @todo this is a no-op method to be implemented
*/
getNamesByFlagSets(): Promise<ISet<string>> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return new Promise(flagSets => new _Set([]));
this.log.error(LOG_PREFIX + 'ByFlagSet/s evaluations are not supported with pluggable storage yet.');
return Promise.reject();
}

/**
Expand Down

0 comments on commit 59b55dd

Please sign in to comment.