Skip to content

Commit bcc0614

Browse files
schmitgiorgiomartini0rasendubi
authored
[ufc] update "get_assignment" args ordering to comply with ufc spec (#47)
* update getassignment args ordering to comply with ufc spec * ssubject -> subject, ubject -> subject * Argument spacing * Update documentation and bump version --------- Co-authored-by: Giorgio Martini <[email protected]> Co-authored-by: Oleksii Shmalko <[email protected]>
1 parent edd837b commit bcc0614

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ In your `go.mod`, add the SDK package as a dependency:
2222

2323
```
2424
require (
25-
github.com/Eppo-exp/golang-sdk/v3
25+
github.com/Eppo-exp/golang-sdk/v4
2626
)
2727
```
2828

2929
Or you can install the SDK from the command line with:
3030

3131
```
32-
go get github.com/Eppo-exp/golang-sdk/v3
32+
go get github.com/Eppo-exp/golang-sdk/v4
3333
```
3434

3535
## Quick start
@@ -40,7 +40,7 @@ Begin by initializing a singleton instance of Eppo's client. Once initialized, t
4040

4141
```go
4242
import (
43-
"github.com/Eppo-exp/golang-sdk/v3/eppoclient"
43+
"github.com/Eppo-exp/golang-sdk/v4/eppoclient"
4444
)
4545

4646
var eppoClient = &eppoclient.EppoClient{}
@@ -60,16 +60,16 @@ func main() {
6060

6161
```go
6262
import (
63-
"github.com/Eppo-exp/golang-sdk/v3/eppoclient"
63+
"github.com/Eppo-exp/golang-sdk/v4/eppoclient"
6464
)
6565

6666
var eppoClient = &eppoclient.EppoClient{}
6767

6868
variation := eppoClient.GetStringAssignment(
69+
"new-user-onboarding",
6970
user.id,
70-
'new-user-onboarding',
7171
user.attributes,
72-
'control'
72+
"control"
7373
);
7474
```
7575

@@ -89,8 +89,8 @@ Each function has the same signature, but returns the type in the function name.
8989

9090
```go
9191
func getBooleanAssignment(
92-
subjectKey string,
9392
flagKey string,
93+
subjectKey string,
9494
subjectAttributes SubjectAttributes,
9595
defaultValue string
9696
) bool
@@ -105,7 +105,7 @@ The code below illustrates an example implementation of a logging callback using
105105

106106
```go
107107
import (
108-
"github.com/Eppo-exp/golang-sdk/v2/eppoclient"
108+
"github.com/Eppo-exp/golang-sdk/v4/eppoclient"
109109
"gopkg.in/segmentio/analytics-go.v3"
110110
)
111111

eppoclient/client.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ func newEppoClient(configRequestor iConfigRequestor, poller *poller, assignmentL
2424
return ec
2525
}
2626

27-
func (ec *EppoClient) GetBoolAssignment(subjectKey string, flagKey string, subjectAttributes SubjectAttributes, defaultValue bool) (bool, error) {
28-
variation, err := ec.getAssignment(subjectKey, flagKey, subjectAttributes, booleanVariation)
27+
func (ec *EppoClient) GetBoolAssignment(flagKey string, subjectKey string, subjectAttributes SubjectAttributes, defaultValue bool) (bool, error) {
28+
variation, err := ec.getAssignment(flagKey, subjectKey, subjectAttributes, booleanVariation)
2929
if err != nil || variation == nil {
3030
return defaultValue, err
3131
}
@@ -36,8 +36,8 @@ func (ec *EppoClient) GetBoolAssignment(subjectKey string, flagKey string, subje
3636
return result, err
3737
}
3838

39-
func (ec *EppoClient) GetNumericAssignment(subjectKey string, flagKey string, subjectAttributes SubjectAttributes, defaultValue float64) (float64, error) {
40-
variation, err := ec.getAssignment(subjectKey, flagKey, subjectAttributes, numericVariation)
39+
func (ec *EppoClient) GetNumericAssignment(flagKey string, subjectKey string, subjectAttributes SubjectAttributes, defaultValue float64) (float64, error) {
40+
variation, err := ec.getAssignment(flagKey, subjectKey, subjectAttributes, numericVariation)
4141
if err != nil || variation == nil {
4242
return defaultValue, err
4343
}
@@ -48,8 +48,8 @@ func (ec *EppoClient) GetNumericAssignment(subjectKey string, flagKey string, su
4848
return result, err
4949
}
5050

51-
func (ec *EppoClient) GetIntegerAssignment(subjectKey string, flagKey string, subjectAttributes SubjectAttributes, defaultValue int64) (int64, error) {
52-
variation, err := ec.getAssignment(subjectKey, flagKey, subjectAttributes, integerVariation)
51+
func (ec *EppoClient) GetIntegerAssignment(flagKey string, subjectKey string, subjectAttributes SubjectAttributes, defaultValue int64) (int64, error) {
52+
variation, err := ec.getAssignment(flagKey, subjectKey, subjectAttributes, integerVariation)
5353
if err != nil || variation == nil {
5454
return defaultValue, err
5555
}
@@ -60,8 +60,8 @@ func (ec *EppoClient) GetIntegerAssignment(subjectKey string, flagKey string, su
6060
return result, err
6161
}
6262

63-
func (ec *EppoClient) GetStringAssignment(subjectKey string, flagKey string, subjectAttributes SubjectAttributes, defaultValue string) (string, error) {
64-
variation, err := ec.getAssignment(subjectKey, flagKey, subjectAttributes, stringVariation)
63+
func (ec *EppoClient) GetStringAssignment(flagKey string, subjectKey string, subjectAttributes SubjectAttributes, defaultValue string) (string, error) {
64+
variation, err := ec.getAssignment(flagKey, subjectKey, subjectAttributes, stringVariation)
6565
if err != nil || variation == nil {
6666
return defaultValue, err
6767
}
@@ -72,15 +72,15 @@ func (ec *EppoClient) GetStringAssignment(subjectKey string, flagKey string, sub
7272
return result, err
7373
}
7474

75-
func (ec *EppoClient) GetJSONAssignment(subjectKey string, flagKey string, subjectAttributes SubjectAttributes, defaultValue interface{}) (interface{}, error) {
76-
variation, err := ec.getAssignment(subjectKey, flagKey, subjectAttributes, jsonVariation)
75+
func (ec *EppoClient) GetJSONAssignment(flagKey string, subjectKey string, subjectAttributes SubjectAttributes, defaultValue interface{}) (interface{}, error) {
76+
variation, err := ec.getAssignment(flagKey, subjectKey, subjectAttributes, jsonVariation)
7777
if err != nil || variation == nil {
7878
return defaultValue, err
7979
}
8080
return variation, err
8181
}
8282

83-
func (ec *EppoClient) getAssignment(subjectKey string, flagKey string, subjectAttributes SubjectAttributes, variationType variationType) (interface{}, error) {
83+
func (ec *EppoClient) getAssignment(flagKey string, subjectKey string, subjectAttributes SubjectAttributes, variationType variationType) (interface{}, error) {
8484
if subjectKey == "" {
8585
panic("no subject key provided")
8686
}

eppoclient/client_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Test_AssignBlankExperiment(t *testing.T) {
1515
client := newEppoClient(mockConfigRequestor, poller, mockLogger)
1616

1717
assert.Panics(t, func() {
18-
_, err := client.GetStringAssignment("subject-1", "", SubjectAttributes{}, "")
18+
_, err := client.GetStringAssignment("", "subject-1", SubjectAttributes{}, "")
1919
if err != nil {
2020
log.Println(err)
2121
}
@@ -29,7 +29,7 @@ func Test_AssignBlankSubject(t *testing.T) {
2929
client := newEppoClient(mockConfigRequestor, poller, mockLogger)
3030

3131
assert.Panics(t, func() {
32-
_, err := client.GetStringAssignment("", "experiment-1", SubjectAttributes{}, "")
32+
_, err := client.GetStringAssignment("experiment-1", "", SubjectAttributes{}, "")
3333
if err != nil {
3434
log.Println(err)
3535
}
@@ -82,7 +82,7 @@ func Test_LogAssignment(t *testing.T) {
8282

8383
client := newEppoClient(mockConfigRequestor, poller, mockLogger)
8484

85-
assignment, err := client.GetStringAssignment("user-1", "experiment-key-1", SubjectAttributes{}, "")
85+
assignment, err := client.GetStringAssignment("experiment-key-1", "user-1",SubjectAttributes{}, "")
8686
expected := "control"
8787

8888
assert.Nil(t, err)
@@ -136,7 +136,7 @@ func Test_GetStringAssignmentHandlesLoggingPanic(t *testing.T) {
136136

137137
client := newEppoClient(mockConfigRequestor, poller, mockLogger)
138138

139-
assignment, err := client.GetStringAssignment("user-1", "experiment-key-1", SubjectAttributes{}, "")
139+
assignment, err := client.GetStringAssignment("experiment-key-1", "user-1", SubjectAttributes{}, "")
140140
expected := "control"
141141

142142
assert.Nil(t, err)

eppoclient/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Usage:
66
77
import (
8-
"github.com/Eppo-exp/golang-sdk/v2/eppoclient"
8+
"github.com/Eppo-exp/golang-sdk/v4/eppoclient"
99
)
1010
1111
var eppoClient = &eppoclient.EppoClient{}
@@ -18,7 +18,7 @@
1818
}
1919
2020
func apiEndpoint() {
21-
assignment, _ := eppoClient.GetStringAssignment("subject-1", "experiment_5", sbjAttrs)
21+
assignment, _ := eppoClient.GetStringAssignment("experiment_5", "subject-1", sbjAttrs, "control")
2222
2323
if assignment == "control" {
2424
// do something

eppoclient/eppoclient_e2e_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ func Test_e2e(t *testing.T) {
4747
t.Run(subject.SubjectKey, func(t *testing.T) {
4848
switch test.VariationType {
4949
case booleanVariation:
50-
value, _ := client.GetBoolAssignment(subject.SubjectKey, test.Flag, subject.SubjectAttributes, test.DefaultValue.(bool))
50+
value, _ := client.GetBoolAssignment(test.Flag, subject.SubjectKey, subject.SubjectAttributes, test.DefaultValue.(bool))
5151
assert.Equal(t, subject.Assignment, value)
5252
case numericVariation:
53-
value, _ := client.GetNumericAssignment(subject.SubjectKey, test.Flag, subject.SubjectAttributes, test.DefaultValue.(float64))
53+
value, _ := client.GetNumericAssignment(test.Flag, subject.SubjectKey, subject.SubjectAttributes, test.DefaultValue.(float64))
5454
assert.Equal(t, subject.Assignment, value)
5555
case integerVariation:
56-
value, _ := client.GetIntegerAssignment(subject.SubjectKey, test.Flag, subject.SubjectAttributes, int64(test.DefaultValue.(float64)))
56+
value, _ := client.GetIntegerAssignment(test.Flag, subject.SubjectKey, subject.SubjectAttributes, int64(test.DefaultValue.(float64)))
5757
assert.Equal(t, int64(subject.Assignment.(float64)), value)
5858

5959
case jsonVariation:
60-
value, _ := client.GetJSONAssignment(subject.SubjectKey, test.Flag, subject.SubjectAttributes, test.DefaultValue)
60+
value, _ := client.GetJSONAssignment(test.Flag, subject.SubjectKey, subject.SubjectAttributes, test.DefaultValue)
6161
assert.Equal(t, subject.Assignment, value)
6262
case stringVariation:
63-
value, _ := client.GetStringAssignment(subject.SubjectKey, test.Flag, subject.SubjectAttributes, test.DefaultValue.(string))
63+
value, _ := client.GetStringAssignment(test.Flag, subject.SubjectKey, subject.SubjectAttributes, test.DefaultValue.(string))
6464
assert.Equal(t, subject.Assignment, value)
6565
default:
6666
panic(fmt.Sprintf("unknown variation: %v", test.VariationType))

eppoclient/initclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package eppoclient
44

55
import "net/http"
66

7-
var __version__ = "3.0.0"
7+
var __version__ = "4.0.0"
88

99
// InitClient is required to start polling of experiments configurations and create
1010
// an instance of EppoClient, which could be used to get assignments information.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/Eppo-exp/golang-sdk/v3
1+
module github.com/Eppo-exp/golang-sdk/v4
22

33
go 1.19
44

0 commit comments

Comments
 (0)