Skip to content

Commit 5b73dad

Browse files
authored
Merge pull request #74 from appbaseio/feat/size_limit
feat: add support for various feature exceptions
2 parents 261727d + f334d2a commit 5b73dad

4 files changed

Lines changed: 136 additions & 39 deletions

File tree

main.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ var (
5353
FeatureCustomEvents string
5454
// FeatureSuggestions for testing
5555
FeatureSuggestions string
56+
// FeatureRules for testing
57+
FeatureRules string
58+
// FeatureTemplates for testing
59+
FeatureTemplates string
60+
// FeatureFunctions for testing
61+
FeatureFunctions string
62+
// FeatureSearchSettings for testing
63+
FeatureSearchSettings string
5664
)
5765

5866
func init() {
@@ -167,6 +175,18 @@ func main() {
167175
if FeatureSuggestions != "" && FeatureSuggestions == "true" {
168176
util.SetFeatureSuggestions(true)
169177
}
178+
if FeatureRules != "" && FeatureRules == "true" {
179+
util.SetFeatureRules(true)
180+
}
181+
if FeatureFunctions != "" && FeatureFunctions == "true" {
182+
util.SetFeatureFunctions(true)
183+
}
184+
if FeatureTemplates != "" && FeatureTemplates == "true" {
185+
util.SetFeatureTemplates(true)
186+
}
187+
if FeatureSearchSettings != "" && FeatureSearchSettings == "true" {
188+
util.SetFeatureSearchSettings(true)
189+
}
170190

171191
// ES client instantiation
172192
// ES v7 and v6 clients

util/billing.go

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,6 @@ func SetTimeValidity(time int64) {
4444
timeValidity = time
4545
}
4646

47-
// Feature custom events
48-
var featureCustomEvents bool
49-
50-
// GetFeatureCustomEvents returns the featureCustomEvents
51-
func GetFeatureCustomEvents() bool {
52-
return featureCustomEvents
53-
}
54-
55-
// SetFeatureCustomEvents returns the time validity
56-
func SetFeatureCustomEvents(val bool) {
57-
featureCustomEvents = val
58-
}
59-
60-
// Feature suggestions
61-
var featureSuggestions bool
62-
63-
// GetFeatureSuggestions returns the featureSuggestions
64-
func GetFeatureSuggestions() bool {
65-
return featureSuggestions
66-
}
67-
68-
// SetFeatureSuggestions returns the time validity
69-
func SetFeatureSuggestions(val bool) {
70-
featureSuggestions = val
71-
}
72-
7347
// maxErrorTime before showing errors if invalid trial / plan in hours
7448
var maxErrorTime int64 = 24 // in hrs
7549

@@ -122,19 +96,23 @@ type ClusterPlanResponse struct {
12296

12397
// ArcInstanceDetails contains the info about an Arc Instance
12498
type ArcInstanceDetails struct {
125-
NodeCount int `json:"node_count"`
126-
Description string `json:"description"`
127-
SubscriptionID string `json:"subscription_id"`
128-
SubscriptionCanceled bool `json:"subscription_canceled"`
129-
Trial bool `json:"trial"`
130-
TrialValidity int64 `json:"trial_validity"`
131-
CreatedAt int64 `json:"created_at"`
132-
Tier *Plan `json:"tier"`
133-
TierValidity int64 `json:"tier_validity"`
134-
TimeValidity int64 `json:"time_validity"`
135-
Metadata map[string]interface{} `json:"metadata"`
136-
FeatureCustomEvents bool `json:"feature_custom_events"`
137-
FeatureSuggestions bool `json:"feature_suggestions"`
99+
NodeCount int `json:"node_count"`
100+
Description string `json:"description"`
101+
SubscriptionID string `json:"subscription_id"`
102+
SubscriptionCanceled bool `json:"subscription_canceled"`
103+
Trial bool `json:"trial"`
104+
TrialValidity int64 `json:"trial_validity"`
105+
CreatedAt int64 `json:"created_at"`
106+
Tier *Plan `json:"tier"`
107+
TierValidity int64 `json:"tier_validity"`
108+
TimeValidity int64 `json:"time_validity"`
109+
Metadata map[string]interface{} `json:"metadata"`
110+
FeatureCustomEvents bool `json:"feature_custom_events"`
111+
FeatureSuggestions bool `json:"feature_suggestions"`
112+
FeatureRules bool `json:"feature_rules"`
113+
FeatureTemplates bool `json:"feature_templates"`
114+
FeatureFunctions bool `json:"feature_functions"`
115+
FeatureSearchSettings bool `json:"feature_search_settings"`
138116
}
139117

140118
// SetDefaultTier sets the default tier when billing is disabled
@@ -197,6 +175,10 @@ func getArcInstance(arcID string) (ArcInstance, error) {
197175
SetTier(arcInstanceByID.Tier)
198176
SetFeatureSuggestions(arcInstanceByID.FeatureSuggestions)
199177
SetFeatureCustomEvents(arcInstanceByID.FeatureCustomEvents)
178+
SetFeatureRules(arcInstanceByID.FeatureRules)
179+
SetFeatureFunctions(arcInstanceByID.FeatureFunctions)
180+
SetFeatureSearchSettings(arcInstanceByID.FeatureSearchSettings)
181+
SetFeatureTemplates(arcInstanceByID.FeatureTemplates)
200182
} else {
201183
return arcInstance, errors.New("No valid instance found for the provided ARC_ID")
202184
}

util/billing_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ func TestBilling(t *testing.T) {
3636
SetFeatureSuggestions(true)
3737
So(GetFeatureSuggestions(), ShouldEqual, true)
3838
})
39+
Convey("Set FeatureRules", func() {
40+
SetFeatureRules(true)
41+
So(GetFeatureRules(), ShouldEqual, true)
42+
})
43+
Convey("Set FeatureFunctions", func() {
44+
SetFeatureFunctions(true)
45+
So(GetFeatureFunctions(), ShouldEqual, true)
46+
})
47+
Convey("Set FeatureTemplates", func() {
48+
SetFeatureTemplates(true)
49+
So(GetFeatureTemplates(), ShouldEqual, true)
50+
})
51+
Convey("Set FeatureSearchSettings", func() {
52+
SetFeatureSearchSettings(true)
53+
So(GetFeatureSearchSettings(), ShouldEqual, true)
54+
})
3955
Convey("Validate TimeValidity: Positive Value", func() {
4056
// Set TimeValidity to a positive value
4157
var timeValidityMock = 1200000

util/feature.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package util
2+
3+
// Feature custom events
4+
var featureCustomEvents bool
5+
6+
// GetFeatureCustomEvents returns the featureCustomEvents
7+
func GetFeatureCustomEvents() bool {
8+
return featureCustomEvents
9+
}
10+
11+
// SetFeatureCustomEvents returns the time validity
12+
func SetFeatureCustomEvents(val bool) {
13+
featureCustomEvents = val
14+
}
15+
16+
// Feature suggestions
17+
var featureSuggestions bool
18+
19+
// GetFeatureSuggestions returns the featureSuggestions
20+
func GetFeatureSuggestions() bool {
21+
return featureSuggestions
22+
}
23+
24+
// SetFeatureSuggestions returns the time validity
25+
func SetFeatureSuggestions(val bool) {
26+
featureSuggestions = val
27+
}
28+
29+
// Feature rules
30+
var featureRules bool
31+
32+
// GetFeatureRules returns the featureRules
33+
func GetFeatureRules() bool {
34+
return featureRules
35+
}
36+
37+
// SetFeatureRules sets the featureRules
38+
func SetFeatureRules(val bool) {
39+
featureRules = val
40+
}
41+
42+
// Feature templates
43+
var featureTemplates bool
44+
45+
// GetFeatureTemplates returns the featureTemplates
46+
func GetFeatureTemplates() bool {
47+
return featureTemplates
48+
}
49+
50+
// SetFeatureTemplates sets the featureTemplates
51+
func SetFeatureTemplates(val bool) {
52+
featureTemplates = val
53+
}
54+
55+
// Feature functions
56+
var featureFunctions bool
57+
58+
// GetFeatureFunctions returns the featureFunctions
59+
func GetFeatureFunctions() bool {
60+
return featureFunctions
61+
}
62+
63+
// SetFeatureFunctions sets the featureFunctions
64+
func SetFeatureFunctions(val bool) {
65+
featureFunctions = val
66+
}
67+
68+
// Feature search settings
69+
var featureSearchSettings bool
70+
71+
// GetFeatureSearchSettings returns the featureSearchSettings
72+
func GetFeatureSearchSettings() bool {
73+
return featureSearchSettings
74+
}
75+
76+
// SetFeatureSearchSettings sets the featureSearchSettings
77+
func SetFeatureSearchSettings(val bool) {
78+
featureSearchSettings = val
79+
}

0 commit comments

Comments
 (0)