Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag Sets polishing: fix issue with getNamesByFlagSets method in Redis and Pluggable splits storage #268

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading