Skip to content

Commit fa764da

Browse files
replace ApiKey with SdkKey (FF-2390) (#43)
* replace ApiKey with SdkKey (FF-2390) * adjust panic messages
1 parent e9cfbe4 commit fa764da

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

README.md

Lines changed: 6 additions & 6 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/v2
25+
github.com/Eppo-exp/golang-sdk/v3
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/v2
32+
go get github.com/Eppo-exp/golang-sdk/v3
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/v2/eppoclient"
43+
"github.com/Eppo-exp/golang-sdk/v3/eppoclient"
4444
)
4545

4646
var eppoClient = &eppoclient.EppoClient{}
@@ -49,7 +49,7 @@ func main() {
4949
assignmentLogger := NewExampleAssignmentLogger()
5050

5151
eppoClient = eppoclient.InitClient(eppoclient.Config{
52-
ApiKey: "<your_sdk_key>",
52+
SdkKey: "<your_sdk_key>",
5353
AssignmentLogger: assignmentLogger,
5454
})
5555
}
@@ -60,7 +60,7 @@ func main() {
6060

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

6666
var eppoClient = &eppoclient.EppoClient{}
@@ -133,4 +133,4 @@ func main() {
133133

134134
## Philosophy
135135

136-
Eppo's SDKs are built for simplicity, speed and reliability. Flag configurations are compressed and distributed over a global CDN (Fastly), typically reaching your servers in under 15ms. Server SDKs continue polling Eppo’s API at 30-second intervals. Configurations are then cached locally, ensuring that each assignment is made instantly. Evaluation logic within each SDK consists of a few lines of simple numeric and string comparisons. The typed functions listed above are all developers need to understand, abstracting away the complexity of the Eppo's underlying (and expanding) feature set.
136+
Eppo's SDKs are built for simplicity, speed and reliability. Flag configurations are compressed and distributed over a global CDN (Fastly), typically reaching your servers in under 15ms. Server SDKs continue polling Eppo’s API at 10-second intervals. Configurations are then cached locally, ensuring that each assignment is made instantly. Evaluation logic within each SDK consists of a few lines of simple numeric and string comparisons. The typed functions listed above are all developers need to understand, abstracting away the complexity of the Eppo's underlying (and expanding) feature set.

eppoclient/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ const default_base_url = "https://fscdn.eppo.cloud/api"
66

77
type Config struct {
88
BaseUrl string
9-
ApiKey string
9+
SdkKey string
1010
AssignmentLogger IAssignmentLogger
1111
PollerInterval time.Duration
1212
}
1313

1414
func (cfg *Config) validate() {
15-
if cfg.ApiKey == "" {
16-
panic("api key not set")
15+
if cfg.SdkKey == "" {
16+
panic("sdk key not set")
1717
}
1818

1919
if cfg.BaseUrl == "" {

eppoclient/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func Test_config_defaultPollerInterval(t *testing.T) {
1111
cfg := Config{
12-
ApiKey: "blah",
12+
SdkKey: "blah",
1313
}
1414

1515
cfg.validate()

eppoclient/configurationrequestor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func newConfigurationRequestor(httpClient httpClient, configStore *configuration
2727
func (ecr *configurationRequestor) GetConfiguration(experimentKey string) (flagConfiguration, error) {
2828
if ecr.httpClient.isUnauthorized {
2929
// should we panic here or return an error?
30-
panic("Unauthorized: please check your API key")
30+
panic("Unauthorized: please check your SDK key")
3131
}
3232

3333
result, err := ecr.configStore.GetConfiguration(experimentKey)

eppoclient/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
func main() {
1414
eppoClient = eppoclient.InitClient(eppoclient.Config{
15-
ApiKey: "<your_api_key>",
15+
SdkKey: "<your_sdk_key>",
1616
AssignmentLogger: eppoclient.AssignmentLogger{},
1717
})
1818
}

eppoclient/eppoclient_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func Test_e2e(t *testing.T) {
3636

3737
mockLogger := new(mockLogger)
3838
mockLogger.Mock.On("LogAssignment", mock.Anything).Return()
39-
client := InitClient(Config{BaseUrl: serverUrl, ApiKey: "dummy", AssignmentLogger: mockLogger})
39+
client := InitClient(Config{BaseUrl: serverUrl, SdkKey: "dummy", AssignmentLogger: mockLogger})
4040

4141
// give client the time to "fetch" the mock config
4242
time.Sleep(2 * time.Second)

eppoclient/httpclient.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type httpClient struct {
1818
}
1919

2020
type SDKParams struct {
21-
apiKey string
21+
sdkKey string
2222
sdkName string
2323
sdkVersion string
2424
}
@@ -43,7 +43,8 @@ func (hc *httpClient) get(resource string) (string, error) {
4343
req.Header.Set("Content-Type", "application/json; charset=UTF-8")
4444

4545
q := req.URL.Query()
46-
q.Add("apiKey", hc.sdkParams.apiKey)
46+
// todo: migrate to bearer token authorization header
47+
q.Add("apiKey", hc.sdkParams.sdkKey) // origin server uses apiKey
4748
q.Add("sdkName", hc.sdkParams.sdkName)
4849
q.Add("sdkVersion", hc.sdkParams.sdkVersion)
4950
req.URL.RawQuery = q.Encode()

eppoclient/httpclient_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestHttpClientGet(t *testing.T) {
3030

3131
client := &http.Client{}
3232
hc := newHttpClient(server.URL, client, SDKParams{
33-
apiKey: "testApiKey",
33+
sdkKey: "testSdkKey",
3434
sdkName: "testSdkName",
3535
sdkVersion: "testSdkVersion",
3636
})

eppoclient/initclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var __version__ = "3.0.0"
1010
// an instance of EppoClient, which could be used to get assignments information.
1111
func InitClient(config Config) *EppoClient {
1212
config.validate()
13-
sdkParams := SDKParams{apiKey: config.ApiKey, sdkName: "go", sdkVersion: __version__}
13+
sdkParams := SDKParams{sdkKey: config.SdkKey, sdkName: "go", sdkVersion: __version__}
1414

1515
httpClient := newHttpClient(config.BaseUrl, &http.Client{Timeout: REQUEST_TIMEOUT_SECONDS}, sdkParams)
1616
configStore := newConfigurationStore()

0 commit comments

Comments
 (0)