Skip to content

Commit d635a3f

Browse files
authored
feat: add feature exception for search grader (#130)
* feat: add searchgrader category * fix: export port * feat: add feature exception for search grader
1 parent efefe0b commit d635a3f

5 files changed

Lines changed: 38 additions & 6 deletions

File tree

main.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ var (
6363
FeatureFunctions string
6464
// FeatureSearchRelevancy for testing
6565
FeatureSearchRelevancy string
66+
// FeatureSearchGrader for testing
67+
FeatureSearchGrader string
6668
)
6769

6870
func init() {
@@ -172,24 +174,29 @@ func main() {
172174
}
173175
util.SetTier(temp2.Tier)
174176
}
175-
if FeatureCustomEvents != "" && FeatureCustomEvents == "true" {
177+
if FeatureCustomEvents == "true" {
176178
util.SetFeatureCustomEvents(true)
177179
}
178-
if FeatureSuggestions != "" && FeatureSuggestions == "true" {
180+
if FeatureSuggestions == "true" {
179181
util.SetFeatureSuggestions(true)
180182
}
181-
if FeatureRules != "" && FeatureRules == "true" {
183+
if FeatureRules == "true" {
182184
util.SetFeatureRules(true)
183185
}
184-
if FeatureFunctions != "" && FeatureFunctions == "true" {
186+
if FeatureFunctions == "true" {
185187
util.SetFeatureFunctions(true)
186188
}
187-
if FeatureTemplates != "" && FeatureTemplates == "true" {
189+
if FeatureTemplates == "true" {
188190
util.SetFeatureTemplates(true)
189191
}
190-
if FeatureSearchRelevancy != "" && FeatureSearchRelevancy == "true" {
192+
if FeatureSearchRelevancy == "true" {
191193
util.SetFeatureSearchRelevancy(true)
192194
}
195+
if FeatureSearchGrader == "true" {
196+
util.SetFeatureSearchGrader(true)
197+
}
198+
// Set port variable
199+
util.Port = port
193200

194201
// ES client instantiation
195202
// ES v7 and v6 clients

util/billing.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type ClusterPlan struct {
7070
FeatureTemplates bool `json:"feature_templates"`
7171
FeatureFunctions bool `json:"feature_functions"`
7272
FeatureSearchRelevancy bool `json:"feature_search_relevancy"`
73+
FeatureSearchGrader bool `json:"feature_search_grader"`
7374
Trial bool `json:"trial"`
7475
TrialValidity int64 `json:"trial_validity"`
7576
TierValidity int64 `json:"tier_validity"`
@@ -121,6 +122,7 @@ type ArcInstanceDetails struct {
121122
FeatureTemplates bool `json:"feature_templates"`
122123
FeatureFunctions bool `json:"feature_functions"`
123124
FeatureSearchRelevancy bool `json:"feature_search_relevancy"`
125+
FeatureSearchGrader bool `json:"feature_search_grader"`
124126
}
125127

126128
// SetDefaultTier sets the default tier when billing is disabled
@@ -206,6 +208,7 @@ func getArcInstance(arcID string) (ArcInstance, error) {
206208
SetFeatureRules(arcInstanceByID.FeatureRules)
207209
SetFeatureFunctions(arcInstanceByID.FeatureFunctions)
208210
SetFeatureSearchRelevancy(arcInstanceByID.FeatureSearchRelevancy)
211+
SetFeatureSearchGrader(arcInstanceByID.FeatureSearchGrader)
209212
SetFeatureTemplates(arcInstanceByID.FeatureTemplates)
210213
} else {
211214
return arcInstance, errors.New("No valid instance found for the provided ARC_ID")
@@ -256,6 +259,7 @@ func getArcClusterInstance(clusterID string) (ArcInstance, error) {
256259
SetFeatureRules(arcInstanceDetails.FeatureRules)
257260
SetFeatureFunctions(arcInstanceDetails.FeatureFunctions)
258261
SetFeatureSearchRelevancy(arcInstanceDetails.FeatureSearchRelevancy)
262+
SetFeatureSearchGrader(arcInstanceDetails.FeatureSearchGrader)
259263
SetFeatureTemplates(arcInstanceDetails.FeatureTemplates)
260264
} else {
261265
return arcInstance, errors.New("No valid instance found for the provided CLUSTER_ID")
@@ -304,6 +308,7 @@ func getClusterPlan(clusterID string) (ClusterPlan, error) {
304308
SetFeatureRules(response.Plan.FeatureRules)
305309
SetFeatureFunctions(response.Plan.FeatureFunctions)
306310
SetFeatureSearchRelevancy(response.Plan.FeatureSearchRelevancy)
311+
SetFeatureSearchGrader(response.Plan.FeatureSearchGrader)
307312
SetFeatureTemplates(response.Plan.FeatureTemplates)
308313

309314
return clusterPlan, nil

util/billing_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func TestBilling(t *testing.T) {
4242
SetFeatureSearchRelevancy(true)
4343
So(GetFeatureSearchRelevancy(), ShouldEqual, true)
4444
})
45+
Convey("Set FeatureSearchGrader", func() {
46+
SetFeatureSearchGrader(true)
47+
So(GetFeatureSearchGrader(), ShouldEqual, true)
48+
})
4549
Convey("Validate TimeValidity: Positive Value", func() {
4650
// Set TimeValidity to a positive value
4751
var timeValidityMock = 1200000

util/feature.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,16 @@ func GetFeatureSearchRelevancy() bool {
7777
func SetFeatureSearchRelevancy(val bool) {
7878
featureSearchRelevancy = val
7979
}
80+
81+
// Feature search grader
82+
var featureSearchGrader bool
83+
84+
// GetFeatureSearchGrader returns the featureSearchGrader
85+
func GetFeatureSearchGrader() bool {
86+
return featureSearchGrader
87+
}
88+
89+
// SetFeatureSearchGrader sets the featureSearchGrader
90+
func SetFeatureSearchGrader(val bool) {
91+
featureSearchGrader = val
92+
}

util/util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ var ClusterBilling string
3434
// Version arc version
3535
var Version string
3636

37+
// Port arc port
38+
var Port int
39+
3740
// RandStr returns "node" field of a UUID.
3841
// See: https://tools.ietf.org/html/rfc4122#section-4.1.6
3942
func RandStr() string {

0 commit comments

Comments
 (0)