forked from apache/atlas
-
Notifications
You must be signed in to change notification settings - Fork 10
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 #2998 from atlanhq/maintenance-mode-redis
feat: add feature flag storage based on Redis and maintenance mode based on feature flag
- Loading branch information
Showing
14 changed files
with
144 additions
and
29 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
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
45 changes: 45 additions & 0 deletions
45
common/src/main/java/org/apache/atlas/service/FeatureFlagStore.java
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.apache.atlas.service; | ||
|
||
import org.apache.atlas.service.redis.RedisService; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class FeatureFlagStore { | ||
private static RedisService redisService = null; | ||
public FeatureFlagStore(@Qualifier("redisServiceImpl") RedisService redisService) { | ||
FeatureFlagStore.redisService = redisService; | ||
} | ||
|
||
public static boolean evaluate(String key, String expectedValue) { | ||
boolean ret = false; | ||
try{ | ||
if (StringUtils.isEmpty(key) || StringUtils.isEmpty(expectedValue)) | ||
return ret; | ||
String value = redisService.getValue(addFeatureFlagNamespace(key)); | ||
ret = StringUtils.equals(value, expectedValue); | ||
} catch (Exception e) { | ||
return ret; | ||
} | ||
return ret; | ||
} | ||
|
||
public static void setFlag(String key, String value) { | ||
if (StringUtils.isEmpty(key) || StringUtils.isEmpty(value)) | ||
return; | ||
|
||
redisService.putValue(addFeatureFlagNamespace(key), value); | ||
} | ||
|
||
public static void deleteFlag(String key) { | ||
if (StringUtils.isEmpty(key)) | ||
return; | ||
|
||
redisService.removeValue(addFeatureFlagNamespace(key)); | ||
} | ||
|
||
private static String addFeatureFlagNamespace(String key) { | ||
return "ff:"+key; | ||
} | ||
} |
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
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
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
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
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