-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
- Loading branch information
1 parent
1fa7e78
commit 80baad0
Showing
7 changed files
with
146 additions
and
136 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
37 changes: 37 additions & 0 deletions
37
src/main/java/org/opensearch/neuralsearch/util/PluginFeatureFlags.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,37 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.neuralsearch.util; | ||
|
||
import org.opensearch.common.util.FeatureFlags; | ||
import org.opensearch.core.common.Strings; | ||
import org.opensearch.transport.TransportSettings; | ||
|
||
/** | ||
* Abstracts feature flags operations specific to neural-search plugin | ||
*/ | ||
public class PluginFeatureFlags { | ||
|
||
/** | ||
* Used to test feature flags whose values are expected to be booleans. | ||
* This method returns true if the value is "true" (case-insensitive), | ||
* and false otherwise. | ||
* Checks alternative flag names as they may be different for plugins | ||
*/ | ||
public static boolean isEnabled(String featureFlagName) { | ||
return FeatureFlags.isEnabled(featureFlagName) || FeatureFlags.isEnabled(transportFeatureName(featureFlagName)); | ||
} | ||
|
||
/** | ||
* Get the feature name that is used for transport specific features. It's used by core for all features | ||
* defined at plugin level (https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/plugins/PluginsService.java#L277) | ||
*/ | ||
private static String transportFeatureName(final String name) { | ||
if (Strings.isNullOrEmpty(name)) { | ||
return name; | ||
} | ||
return String.join(".", TransportSettings.FEATURE_PREFIX, name); | ||
} | ||
} |
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
Oops, something went wrong.