Skip to content

Commit 5ea49af

Browse files
committed
chore: add README.md
1 parent 1815af1 commit 5ea49af

File tree

1 file changed

+148
-1
lines changed

1 file changed

+148
-1
lines changed

README.md

Lines changed: 148 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,148 @@
1-
# openfeature-go-server-sdk
1+
# Bucketeer - OpenFeature Go server provider
2+
3+
This is the official Go OpenFeature provider for accessing your feature flags with [Bucketeer](https://bucketeer.io/).
4+
5+
[Bucketeer](https://bucketeer.io) is an open-source platform created by [CyberAgent](https://www.cyberagent.co.jp/en/) to help teams make better decisions, reduce deployment lead time and release risk through feature flags. Bucketeer offers advanced features like dark launches and staged rollouts that perform limited releases based on user attributes, devices, and other segments.
6+
7+
In conjunction with the [OpenFeature SDK](https://openfeature.dev/docs/reference/concepts/provider) you will be able to evaluate your feature flags in your **server-side** applications.
8+
9+
> [!WARNING]
10+
> This is a beta version. Breaking changes may be introduced before general release.
11+
12+
For documentation related to flags management in Bucketeer, refer to the [Bucketeer documentation website](https://docs.bucketeer.io/sdk/server-side/go).
13+
14+
## Supported Go versions
15+
16+
Minimum requirements:
17+
18+
| Tool | Version |
19+
| ----- | ------- |
20+
| Go | 1.21+ |
21+
22+
## Installation
23+
24+
```bash
25+
go get github.com/bucketeer-io/openfeature-go-server-sdk
26+
```
27+
28+
## Usage
29+
30+
### Initialize the provider
31+
32+
Bucketeer provider needs to be created and then set in the global OpenFeatureAPI.
33+
34+
```go
35+
import (
36+
"context"
37+
"github.com/bucketeer-io/go-server-sdk/pkg/bucketeer"
38+
"github.com/bucketeer-io/openfeature-go-server-sdk/pkg/provider"
39+
"github.com/open-feature/go-sdk/openfeature"
40+
)
41+
42+
func main() {
43+
// SDK configuration
44+
options := []bucketeer.Option{
45+
bucketeer.WithAPI(
46+
"YOUR_API_KEY",
47+
"YOUR_API_ENDPOINT",
48+
),
49+
bucketeer.WithTag("YOUR_FEATURE_TAG"),
50+
// Add other options as needed
51+
}
52+
53+
// Create provider
54+
p, err := provider.NewProvider(options)
55+
if err != nil {
56+
// Error handling
57+
}
58+
59+
// User configuration
60+
userID := "targetingUserId"
61+
ctx := openfeature.NewEvaluationContext(
62+
userID,
63+
map[string]interface{}{
64+
// User attributes are optional
65+
},
66+
)
67+
68+
// Set context before setting provider
69+
openfeature.SetEvaluationContext(ctx)
70+
openfeature.SetProvider(p)
71+
}
72+
```
73+
74+
See our [documentation](https://docs.bucketeer.io/sdk/server-side/go) for more SDK configuration.
75+
76+
The evaluation context allows the client to specify contextual data that Bucketeer uses to evaluate the feature flags.
77+
78+
The `targetingKey` is the user ID (Unique ID) and cannot be empty.
79+
80+
### Update the Evaluation Context
81+
82+
You can update the evaluation context with the new attributes if the user attributes change.
83+
84+
```go
85+
ctx := openfeature.NewEvaluationContext(
86+
userID,
87+
map[string]interface{}{
88+
"buyer": "true",
89+
},
90+
)
91+
openfeature.SetEvaluationContext(ctx)
92+
```
93+
94+
95+
## Example
96+
97+
Check out the [example directory](./example) for a complete working example of how to use this SDK in a web application.
98+
99+
100+
## Testing
101+
102+
### Unit Tests
103+
104+
To run unit tests:
105+
106+
```bash
107+
make test
108+
```
109+
110+
### E2E Tests
111+
112+
The E2E tests can run in two modes:
113+
114+
115+
```bash
116+
export API_KEY="YOUR_API_KEY"
117+
export HOST="YOUR_API_ENDPOINT"
118+
export PORT="443"
119+
export TAG="YOUR_FEATURE_TAG" # optional
120+
121+
# You can also specify flag IDs (optional)
122+
export BOOLEAN_FLAG_ID="your-boolean-flag-id"
123+
export STRING_FLAG_ID="your-string-flag-id"
124+
export INT_FLAG_ID="your-int-flag-id"
125+
export FLOAT_FLAG_ID="your-float-flag-id"
126+
export OBJECT_FLAG_ID="your-object-flag-id"
127+
128+
make e2e
129+
```
130+
131+
2. **With mock provider** - No credentials needed:
132+
133+
```bash
134+
# Will automatically use a mock provider
135+
make e2e
136+
```
137+
138+
For more details, see the [E2E Test README](./test/e2e/README.md).
139+
140+
## Contributing
141+
142+
We would ❤️ for you to contribute to Bucketeer and help improve it! Anyone can use and enjoy it!
143+
144+
Please follow our contribution guide [here](https://docs.bucketeer.io/contribution-guide/).
145+
146+
## License
147+
148+
Apache License 2.0, see [LICENSE](https://github.com/bucketeer-io/openfeature-go-server-sdk/blob/main/LICENSE).

0 commit comments

Comments
 (0)