Skip to content

Commit d519fcd

Browse files
authored
Renamed InstanceOptions to just Options (#4)
1 parent 296712f commit d519fcd

17 files changed

+57
-57
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func main() {
9292
panic(err)
9393
}
9494

95-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
95+
f := featurevisor.CreateInstance(featurevisor.Options{
9696
Datafile: datafileContent,
9797
})
9898
}
@@ -135,7 +135,7 @@ import (
135135
"github.com/featurevisor/featurevisor-go"
136136
)
137137

138-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
138+
f := featurevisor.CreateInstance(featurevisor.Options{
139139
Context: featurevisor.Context{
140140
"deviceId": "123",
141141
"country": "nl",
@@ -304,7 +304,7 @@ import (
304304
"github.com/featurevisor/featurevisor-go"
305305
)
306306

307-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
307+
f := featurevisor.CreateInstance(featurevisor.Options{
308308
Sticky: &StickyFeatures{
309309
"myFeatureKey": featurevisor.StickyFeature{
310310
Enabled: true,
@@ -428,7 +428,7 @@ import (
428428
)
429429

430430
logLevel := featurevisor.LogLevelDebug
431-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
431+
f := featurevisor.CreateInstance(featurevisor.Options{
432432
LogLevel: &logLevel,
433433
})
434434
```
@@ -437,7 +437,7 @@ Alternatively, you can also set `logLevel` directly:
437437

438438
```go
439439
logLevel := featurevisor.LogLevelDebug
440-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
440+
f := featurevisor.CreateInstance(featurevisor.Options{
441441
LogLevel: &logLevel,
442442
})
443443
```
@@ -464,7 +464,7 @@ logger := featurevisor.NewLogger(featurevisor.CreateLoggerOptions{
464464
},
465465
})
466466

467-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
467+
f := featurevisor.CreateInstance(featurevisor.Options{
468468
Logger: logger,
469469
})
470470
```
@@ -618,7 +618,7 @@ import (
618618
"github.com/featurevisor/featurevisor-go"
619619
)
620620

621-
f := featurevisor.CreateInstance(featurevisor.InstanceOptions{
621+
f := featurevisor.CreateInstance(featurevisor.Options{
622622
Hooks: []*featurevisor.Hook{
623623
myCustomHook,
624624
},

api_compatibility_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestAPICompatibilityWithStringFeatureKey(t *testing.T) {
5151
}
5252

5353
// Create instance
54-
instance := NewFeaturevisor(InstanceOptions{
54+
instance := NewFeaturevisor(Options{
5555
Datafile: datafile,
5656
Context: Context{"userId": "123"},
5757
})
@@ -108,7 +108,7 @@ func TestAPICompatibilityWithStringFeatureKey(t *testing.T) {
108108

109109
func TestAPICompatibilityWithNonExistentFeature(t *testing.T) {
110110
// Create instance with empty datafile
111-
instance := NewFeaturevisor(InstanceOptions{
111+
instance := NewFeaturevisor(Options{
112112
Datafile: DatafileContent{
113113
SchemaVersion: "2",
114114
Revision: "test",
@@ -665,7 +665,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
665665
t.Run("allowSignup", func(t *testing.T) {
666666
// Test Netherlands (NL) - should always get treatment variation
667667
// Using bucket value 60000 (60%) to ensure we get treatment variation
668-
instance := NewFeaturevisor(InstanceOptions{
668+
instance := NewFeaturevisor(Options{
669669
Datafile: datafile,
670670
Context: Context{
671671
"country": "nl",
@@ -712,7 +712,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
712712
}
713713

714714
// Test Switzerland (CH) - should get treatment variation based on weight
715-
instanceCH := NewFeaturevisor(InstanceOptions{
715+
instanceCH := NewFeaturevisor(Options{
716716
Datafile: datafile,
717717
Context: Context{
718718
"country": "ch",
@@ -735,7 +735,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
735735
}
736736

737737
// Test Germany (DE) - should get control variation in everyone segment
738-
instanceDE := NewFeaturevisor(InstanceOptions{
738+
instanceDE := NewFeaturevisor(Options{
739739
Datafile: datafile,
740740
Context: Context{
741741
"country": "de",
@@ -762,7 +762,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
762762
t.Run("bar", func(t *testing.T) {
763763
// Test with US context (should get control variation at low bucket values)
764764
// Using bucket value 15000 (15%) to get control variation
765-
instance := NewFeaturevisor(InstanceOptions{
765+
instance := NewFeaturevisor(Options{
766766
Datafile: datafile,
767767
Context: Context{
768768
"country": "us",
@@ -802,7 +802,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
802802

803803
// Test with Germany context (should get variation 'b' with overrides)
804804
// Using bucket value 20000 (20%) to get variation 'b'
805-
instanceDE := NewFeaturevisor(InstanceOptions{
805+
instanceDE := NewFeaturevisor(Options{
806806
Datafile: datafile,
807807
Context: Context{
808808
"country": "de",
@@ -829,7 +829,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
829829
t.Run("foo", func(t *testing.T) {
830830
// Test with mobile + Germany context (should get treatment variation)
831831
// Using bucket value 60000 (60%) to get treatment variation
832-
instance := NewFeaturevisor(InstanceOptions{
832+
instance := NewFeaturevisor(Options{
833833
Datafile: datafile,
834834
Context: Context{
835835
"country": "de",
@@ -874,7 +874,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
874874
}
875875

876876
// Test force rule
877-
instanceForce := NewFeaturevisor(InstanceOptions{
877+
instanceForce := NewFeaturevisor(Options{
878878
Datafile: datafile,
879879
Context: Context{
880880
"userId": "123",
@@ -905,7 +905,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
905905
t.Run("sidebar", func(t *testing.T) {
906906
// Test with Netherlands context (should get treatment variation)
907907
// Using bucket value 90000 (90%) to get treatment variation
908-
instance := NewFeaturevisor(InstanceOptions{
908+
instance := NewFeaturevisor(Options{
909909
Datafile: datafile,
910910
Context: Context{
911911
"country": "nl",
@@ -958,7 +958,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
958958

959959
// Test with Germany context (should get color override)
960960
// Using bucket value 90000 (90%) to get treatment variation
961-
instanceDE := NewFeaturevisor(InstanceOptions{
961+
instanceDE := NewFeaturevisor(Options{
962962
Datafile: datafile,
963963
Context: Context{
964964
"country": "de",
@@ -990,7 +990,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
990990
t.Run("qux", func(t *testing.T) {
991991
// Test with Netherlands context (should get variation 'b' based on allocation)
992992
// Using bucket value 70000 (70%) to get variation 'b'
993-
instance := NewFeaturevisor(InstanceOptions{
993+
instance := NewFeaturevisor(Options{
994994
Datafile: datafile,
995995
Context: Context{
996996
"country": "nl",
@@ -1025,7 +1025,7 @@ func TestProductionDatafileFeatures(t *testing.T) {
10251025

10261026
// Test with Germany context (should get variation 'b' based on allocation)
10271027
// Using bucket value 70000 (70%) to get variation 'b'
1028-
instanceDE := NewFeaturevisor(InstanceOptions{
1028+
instanceDE := NewFeaturevisor(Options{
10291029
Datafile: datafile,
10301030
Context: Context{
10311031
"country": "de",
@@ -1095,7 +1095,7 @@ func TestProductionDatafileSegments(t *testing.T) {
10951095
// Test segment evaluation
10961096
t.Run("segmentEvaluation", func(t *testing.T) {
10971097
// Test Germany segment
1098-
instance := NewFeaturevisor(InstanceOptions{
1098+
instance := NewFeaturevisor(Options{
10991099
Datafile: datafile,
11001100
Context: Context{
11011101
"country": "de",
@@ -1109,7 +1109,7 @@ func TestProductionDatafileSegments(t *testing.T) {
11091109
}
11101110

11111111
// Test Netherlands segment (should match because of everyone segment rule)
1112-
instanceNL := NewFeaturevisor(InstanceOptions{
1112+
instanceNL := NewFeaturevisor(Options{
11131113
Datafile: datafile,
11141114
Context: Context{
11151115
"country": "nl",
@@ -1123,7 +1123,7 @@ func TestProductionDatafileSegments(t *testing.T) {
11231123
}
11241124

11251125
// Test mobile segment
1126-
_ = NewFeaturevisor(InstanceOptions{
1126+
_ = NewFeaturevisor(Options{
11271127
Datafile: datafile,
11281128
Context: Context{
11291129
"device": "mobile",
@@ -1132,7 +1132,7 @@ func TestProductionDatafileSegments(t *testing.T) {
11321132
})
11331133

11341134
// Test everyone segment
1135-
instanceEveryone := NewFeaturevisor(InstanceOptions{
1135+
instanceEveryone := NewFeaturevisor(Options{
11361136
Datafile: datafile,
11371137
Context: Context{
11381138
"userId": "test-user",

child.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package featurevisor
22

3-
// ChildInstanceOptions contains options for creating a child instance
4-
type ChildInstanceOptions struct {
3+
// ChildOptions contains options for creating a child instance
4+
type ChildOptions struct {
55
Parent *Featurevisor
66
Context Context
77
Sticky *StickyFeatures
@@ -15,7 +15,7 @@ type FeaturevisorChild struct {
1515
}
1616

1717
// NewFeaturevisorChild creates a new child instance
18-
func NewFeaturevisorChild(options ChildInstanceOptions) *FeaturevisorChild {
18+
func NewFeaturevisorChild(options ChildOptions) *FeaturevisorChild {
1919
return &FeaturevisorChild{
2020
parent: options.Parent,
2121
context: options.Context,

cmd/commands/assess_distribution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func runAssessDistribution(opts CLIOptions) {
117117
json.Unmarshal(datafileBytes, &datafileContent)
118118
}
119119

120-
instance := featurevisor.CreateInstance(featurevisor.InstanceOptions{
120+
instance := featurevisor.CreateInstance(featurevisor.Options{
121121
Datafile: datafileContent,
122122
LogLevel: &level,
123123
})

cmd/commands/benchmark.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func runBenchmark(opts CLIOptions) {
176176
datafileSize := len(datafileBytes)
177177
fmt.Printf("Datafile size: %.2f kB\n", float64(datafileSize)/1024.0)
178178

179-
instance := featurevisor.CreateInstance(featurevisor.InstanceOptions{
179+
instance := featurevisor.CreateInstance(featurevisor.Options{
180180
Datafile: datafileContent,
181181
LogLevel: &level,
182182
})

cmd/commands/test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ func runTest(opts CLIOptions) {
699699
}
700700

701701
levelStr := featurevisor.LogLevel(level)
702-
instance := featurevisor.CreateInstance(featurevisor.InstanceOptions{
702+
instance := featurevisor.CreateInstance(featurevisor.Options{
703703
Datafile: datafileContent,
704704
LogLevel: &levelStr,
705705
Hooks: []*featurevisor.Hook{
@@ -755,7 +755,7 @@ func runTest(opts CLIOptions) {
755755
}
756756

757757
levelStr := featurevisor.LogLevel(level)
758-
instance = featurevisor.CreateInstance(featurevisor.InstanceOptions{
758+
instance = featurevisor.CreateInstance(featurevisor.Options{
759759
Datafile: datafileContent,
760760
LogLevel: &levelStr,
761761
Hooks: []*featurevisor.Hook{

instance.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ type OverrideOptions struct {
1212
DefaultVariableValue VariableValue
1313
}
1414

15-
// InstanceOptions contains options for creating an instance
16-
type InstanceOptions struct {
15+
// Options contains options for creating an instance
16+
type Options struct {
1717
Datafile interface{} // DatafileContent | string
1818
Context Context
1919
LogLevel *LogLevel
@@ -36,7 +36,7 @@ type Featurevisor struct {
3636
}
3737

3838
// NewFeaturevisor creates a new Featurevisor instance
39-
func NewFeaturevisor(options InstanceOptions) *Featurevisor {
39+
func NewFeaturevisor(options Options) *Featurevisor {
4040
// Set default context
4141
context := Context{}
4242
if options.Context != nil {
@@ -264,7 +264,7 @@ func (i *Featurevisor) Spawn(args ...interface{}) *FeaturevisorChild {
264264
}
265265
}
266266

267-
return NewFeaturevisorChild(ChildInstanceOptions{
267+
return NewFeaturevisorChild(ChildOptions{
268268
Parent: i,
269269
Context: i.GetContext(contextValue),
270270
Sticky: optionsValue.Sticky,
@@ -626,6 +626,6 @@ func (i *Featurevisor) GetAllEvaluations(context Context, featureKeys []string,
626626
}
627627

628628
// CreateInstance creates a new Featurevisor instance
629-
func CreateInstance(options InstanceOptions) *Featurevisor {
629+
func CreateInstance(options Options) *Featurevisor {
630630
return NewFeaturevisor(options)
631631
}

instance_deprecated_features_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestDeprecatedFeatures(t *testing.T) {
7575
t.Fatalf("Failed to parse datafile JSON: %v", err)
7676
}
7777

78-
sdk := CreateInstance(InstanceOptions{
78+
sdk := CreateInstance(Options{
7979
Datafile: datafile,
8080
Logger: customLogger,
8181
})

instance_individually_named_segments_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestIndividuallyNamedSegments(t *testing.T) {
4949
t.Fatalf("Failed to parse datafile JSON: %v", err)
5050
}
5151

52-
sdk := CreateInstance(InstanceOptions{
52+
sdk := CreateInstance(Options{
5353
Datafile: datafile,
5454
})
5555

instance_mutually_exclusive_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestMutuallyExclusiveFeatures(t *testing.T) {
3333
t.Fatalf("Failed to parse datafile JSON: %v", err)
3434
}
3535

36-
sdk := CreateInstance(InstanceOptions{
36+
sdk := CreateInstance(Options{
3737
Hooks: []*Hook{
3838
{
3939
Name: "unit-test",

0 commit comments

Comments
 (0)