2022-11-09 08:30:00 +05:30
|
|
|
package featureManager
|
|
|
|
|
|
|
|
|
|
import (
|
2025-03-20 21:01:41 +05:30
|
|
|
"github.com/SigNoz/signoz/pkg/query-service/constants"
|
|
|
|
|
"github.com/SigNoz/signoz/pkg/query-service/model"
|
2023-05-17 16:10:43 +05:30
|
|
|
"go.uber.org/zap"
|
2022-11-09 08:30:00 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type FeatureManager struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func StartManager() *FeatureManager {
|
2023-05-17 16:10:43 +05:30
|
|
|
fM := &FeatureManager{}
|
2022-11-09 08:30:00 +05:30
|
|
|
return fM
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CheckFeature will be internally used by backend routines
|
|
|
|
|
// for feature gating
|
|
|
|
|
func (fm *FeatureManager) CheckFeature(featureKey string) error {
|
2023-05-17 16:10:43 +05:30
|
|
|
|
|
|
|
|
feature, err := fm.GetFeatureFlag(featureKey)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
2022-11-09 08:30:00 +05:30
|
|
|
}
|
2023-05-17 16:10:43 +05:30
|
|
|
|
|
|
|
|
if feature.Active {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-09 08:30:00 +05:30
|
|
|
return model.ErrFeatureUnavailable{Key: featureKey}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-17 16:10:43 +05:30
|
|
|
// GetFeatureFlags returns current features
|
|
|
|
|
func (fm *FeatureManager) GetFeatureFlags() (model.FeatureSet, error) {
|
chore(ff): remove some more unused ffs (#7532)
### Summary
remove unused feature flags
- ENTERPRISE_PLAN = 'ENTERPRISE_PLAN',
- BASIC_PLAN = 'BASIC_PLAN',
- ALERT_CHANNEL_SLACK = 'ALERT_CHANNEL_SLACK',
- ALERT_CHANNEL_WEBHOOK = 'ALERT_CHANNEL_WEBHOOK',
- ALERT_CHANNEL_PAGERDUTY = 'ALERT_CHANNEL_PAGERDUTY',
- ALERT_CHANNEL_OPSGENIE = 'ALERT_CHANNEL_OPSGENIE',
- ALERT_CHANNEL_MSTEAMS = 'ALERT_CHANNEL_MSTEAMS',
- CUSTOM_METRICS_FUNCTION = 'CUSTOM_METRICS_FUNCTION',
- QUERY_BUILDER_PANELS = 'QUERY_BUILDER_PANELS',
- QUERY_BUILDER_ALERTS = 'QUERY_BUILDER_ALERTS',
- DISABLE_UPSELL = 'DISABLE_UPSELL',
- OSS = 'OSS',
- QUERY_BUILDER_SEARCH_V2 = 'QUERY_BUILDER_SEARCH_V2',
- AWS_INTEGRATION = 'AWS_INTEGRATION',
remove ProPlan concept
2025-04-07 22:58:46 +05:30
|
|
|
features := constants.DEFAULT_FEATURE_SET
|
2023-05-17 16:10:43 +05:30
|
|
|
return features, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fm *FeatureManager) InitFeatures(req model.FeatureSet) error {
|
2024-03-27 00:07:29 +05:30
|
|
|
zap.L().Error("InitFeatures not implemented in OSS")
|
2023-05-17 16:10:43 +05:30
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (fm *FeatureManager) UpdateFeatureFlag(req model.Feature) error {
|
2024-03-27 00:07:29 +05:30
|
|
|
zap.L().Error("UpdateFeatureFlag not implemented in OSS")
|
2023-05-17 16:10:43 +05:30
|
|
|
return nil
|
2022-11-09 08:30:00 +05:30
|
|
|
}
|
2023-05-17 16:10:43 +05:30
|
|
|
|
|
|
|
|
func (fm *FeatureManager) GetFeatureFlag(key string) (model.Feature, error) {
|
|
|
|
|
features, err := fm.GetFeatureFlags()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return model.Feature{}, err
|
|
|
|
|
}
|
|
|
|
|
for _, feature := range features {
|
|
|
|
|
if feature.Name == key {
|
|
|
|
|
return feature, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return model.Feature{}, model.ErrFeatureUnavailable{Key: key}
|
2024-03-27 00:07:29 +05:30
|
|
|
}
|