Skip to content

Commit 41d6078

Browse files
committed
docs: Add Experimentation section in README
1 parent a4fe3ae commit 41d6078

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ SDK, the Go version.
3232
- [Kafka specific configuration](#kafka-specific-configuration)
3333
- [Cache](#cache)
3434
- [Redis](#redis-specific-configuration)
35+
- [Experimentation](#experimentation)
36+
- [Initialization of Statsig](#initialization-of-statsig)
37+
- [Usage of Statsig](#usage-of-statsig)
3538
- [AWS configuration](#aws-configuration)
3639
- [AWS Common configuration](#aws-common-configuration)
3740
- [AWS Service configuration](#aws-service-configuration)
@@ -987,6 +990,77 @@ To secure the requests to Redis, Go SDK provides a configuration set for TLS:
987990
| Passphrase | Passphrase is used in case the private key needs to be decrypted | `passphrase` | `APP_CACHE_REDIS_TLS_PASSPHRASE` | string | pass phrase |
988991
| Skip TLS verification | Turn on / off TLS verification | `insecure_skip_verify` | `APP_CACHE_REDIS_TLS_INSECURE_SKIP_VERIFY` | bool | true, false |
989992

993+
### Experimentation
994+
995+
`go-sdk` comes with an integration with [Statsig](https://statsig.com) to
996+
leverage its experimentation and feature flag functionality.
997+
998+
#### Initialization of Statsig
999+
1000+
The respective configuration file is `statsig.yml` and it should include
1001+
the following content:
1002+
1003+
```yaml
1004+
# config/statsig.yml
1005+
common: &common
1006+
secret_key: ""
1007+
local_mode: false
1008+
config_sync_interval: 10s
1009+
id_list_sync_interval: 60s
1010+
1011+
development:
1012+
<<: *common
1013+
1014+
test:
1015+
<<: *common
1016+
1017+
staging:
1018+
<<: *common
1019+
1020+
production:
1021+
<<: *common
1022+
```
1023+
1024+
For more details on the configuration check the
1025+
[Statsig Go Server SDK](https://docs.statsig.com/server/golangSDK).
1026+
1027+
Using the configuration details, the statsig client can be initialized as
1028+
follows:
1029+
1030+
```go
1031+
package main
1032+
1033+
import (
1034+
sdkstatsig "github.com/scribd/go-sdk/pkg/statsig"
1035+
)
1036+
1037+
func main() {
1038+
// Loads the statsig configuration.
1039+
statsigConfig, err := sdkstatsig.NewConfig()
1040+
1041+
// Initialize statsig connection using the configuration.
1042+
sdkstatsig.Initialize(statsigConfig)
1043+
}
1044+
```
1045+
1046+
#### Usage of Statsig
1047+
1048+
After initializing the statsig client, one can start using experiments or
1049+
feature flags using the following code:
1050+
1051+
```go
1052+
import (
1053+
sdkstatsig "github.com/scribd/go-sdk/pkg/statsig"
1054+
statsig "github.com/statsig-io/go-sdk"
1055+
)
1056+
1057+
func main() {
1058+
u := statsig.User{}
1059+
1060+
experiment := sdkstatsig.GetExperiment(u, "experiment_name")
1061+
featureFlag := sdkstatsig.GetFeatureFlag(u, "feature_flag_name")
1062+
}
1063+
```
9901064

9911065
### AWS configuration
9921066

0 commit comments

Comments
 (0)