Skip to content

Commit 37c41c1

Browse files
committed
feat: rename to flagsheet
1 parent 4b83d3b commit 37c41c1

File tree

12 files changed

+370
-373
lines changed

12 files changed

+370
-373
lines changed

cmd/client/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import (
66
"net/http"
77

88
"github.com/bufbuild/connect-go"
9-
featuresheetv1 "github.com/stillmatic/featuresheet/gen/featuresheet/v1"
10-
"github.com/stillmatic/featuresheet/gen/featuresheet/v1/featuresheetv1connect"
9+
flagsheetv1 "github.com/stillmatic/flagsheet/gen/flagsheet/v1"
10+
"github.com/stillmatic/flagsheet/gen/flagsheet/v1/flagsheetv1connect"
1111
)
1212

1313
func main() {
14-
client := featuresheetv1connect.NewFeatureSheetServiceClient(
14+
client := flagsheetv1connect.NewFlagSheetServiceClient(
1515
http.DefaultClient,
1616
"http://localhost:8080",
1717
)
1818
res, err := client.Evaluate(
1919
context.Background(),
20-
connect.NewRequest(&featuresheetv1.EvaluateRequest{
20+
connect.NewRequest(&flagsheetv1.EvaluateRequest{
2121
Feature: "my_key",
2222
EntityId: "my_id",
2323
}),

cmd/loadtest/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010

1111
"github.com/bufbuild/connect-go"
1212

13-
fsv1 "github.com/stillmatic/featuresheet/gen/featuresheet/v1"
14-
"github.com/stillmatic/featuresheet/gen/featuresheet/v1/featuresheetv1connect"
13+
fsv1 "github.com/stillmatic/flagsheet/gen/flagsheet/v1"
14+
"github.com/stillmatic/flagsheet/gen/flagsheet/v1/flagsheetv1connect"
1515
)
1616

1717
var (
@@ -20,7 +20,7 @@ var (
2020
)
2121

2222
func main() {
23-
client := featuresheetv1connect.NewFeatureSheetServiceClient(
23+
client := flagsheetv1connect.NewFlagSheetServiceClient(
2424
http.DefaultClient,
2525
"http://localhost:8080",
2626
)

cmd/server/main.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ import (
1414
"gopkg.in/Iwark/spreadsheet.v2"
1515

1616
grpchealth "github.com/bufbuild/connect-grpchealth-go"
17-
"github.com/stillmatic/featuresheet"
18-
fsv1 "github.com/stillmatic/featuresheet/gen/featuresheet/v1"
19-
"github.com/stillmatic/featuresheet/gen/featuresheet/v1/featuresheetv1connect"
17+
"github.com/stillmatic/flagsheet"
18+
fsv1 "github.com/stillmatic/flagsheet/gen/flagsheet/v1"
19+
"github.com/stillmatic/flagsheet/gen/flagsheet/v1/flagsheetv1connect"
2020
)
2121

2222
const (
23-
featureSheetVersionKey = "FeatureSheet-Version"
24-
featureSheetVersionValue = "v1"
23+
flagSheetVersionKey = "FlagSheet-Version"
24+
flagSheetVersionValue = "v1"
2525
)
2626

27-
type FeatureSheetServer struct {
28-
fs *featuresheet.FeatureSheet
27+
type FlagSheetServer struct {
28+
fs *flagsheet.FlagSheet
2929
}
3030

31-
func (s *FeatureSheetServer) Evaluate(
31+
func (s *FlagSheetServer) Evaluate(
3232
ctx context.Context,
3333
req *connect.Request[fsv1.EvaluateRequest],
3434
) (*connect.Response[fsv1.EvaluateResponse], error) {
@@ -42,7 +42,7 @@ func (s *FeatureSheetServer) Evaluate(
4242
res := connect.NewResponse(&fsv1.EvaluateResponse{
4343
Variant: string(fv),
4444
})
45-
res.Header().Set(featureSheetVersionKey, featureSheetVersionValue)
45+
res.Header().Set(flagSheetVersionKey, flagSheetVersionValue)
4646
return res, nil
4747
}
4848

@@ -80,20 +80,20 @@ func main() {
8080

8181
client := conf.Client(context.Background())
8282
service := spreadsheet.NewServiceWithClient(client)
83-
fs, err := featuresheet.NewFeatureSheet(service, spreadsheetID, 10*time.Second)
83+
fs, err := flagsheet.NewFlagSheet(service, spreadsheetID, 10*time.Second)
8484
if err != nil {
8585
panic(err)
8686
}
8787

8888
// serving
89-
s := &FeatureSheetServer{
89+
s := &FlagSheetServer{
9090
fs: fs,
9191
}
9292
mux := http.NewServeMux()
93-
path, handler := featuresheetv1connect.NewFeatureSheetServiceHandler(s)
93+
path, handler := flagsheetv1connect.NewFlagSheetServiceHandler(s)
9494
mux.Handle(path, handler)
9595
checker := grpchealth.NewStaticChecker(
96-
"featuresheet.v1.FeatureSheetService",
96+
"flagsheet.v1.FlagSheetService",
9797
)
9898
mux.Handle(grpchealth.NewHandler(checker))
9999
mux.Handle("/health", http.HandlerFunc(ok))

featuresheet.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package featuresheet
1+
package flagsheet
22

33
import (
44
"bytes"
@@ -49,8 +49,8 @@ type Layer struct {
4949
cnt int
5050
}
5151

52-
// featureSheet is an internal representation for goroutine purposes.
53-
type featureSheet struct {
52+
// flagSheet is an internal representation for goroutine purposes.
53+
type flagSheet struct {
5454
sheetID string
5555
service *spreadsheet.Service
5656
expiration time.Duration
@@ -61,13 +61,13 @@ type featureSheet struct {
6161
fmap map[string]Feature
6262
}
6363

64-
type FeatureSheet struct {
65-
*featureSheet
64+
type FlagSheet struct {
65+
*flagSheet
6666
}
6767

6868
// Evaluate returns the feature variant for a given flagName and id
6969
// if the feature does not exist, it returns an empty string and false
70-
func (f *featureSheet) Evaluate(key string, id *string) (FeatureValue, error) {
70+
func (f *flagSheet) Evaluate(key string, id *string) (FeatureValue, error) {
7171
feature, ok := f.fmap[key]
7272
if !ok {
7373
return "", fmt.Errorf("feature %s not found", key)
@@ -100,7 +100,7 @@ func (f *featureSheet) Evaluate(key string, id *string) (FeatureValue, error) {
100100
return fv, nil
101101
}
102102

103-
func (f *featureSheet) Refresh() error {
103+
func (f *flagSheet) Refresh() error {
104104
// get spreadsheet
105105
spreadsheet, err := f.service.FetchSpreadsheet(f.sheetID)
106106
if err != nil {
@@ -188,7 +188,7 @@ type janitor struct {
188188
stop chan bool
189189
}
190190

191-
func (j *janitor) Run(c *featureSheet) {
191+
func (j *janitor) Run(c *flagSheet) {
192192
ticker := time.NewTicker(j.Interval)
193193
for {
194194
select {
@@ -204,11 +204,11 @@ func (j *janitor) Run(c *featureSheet) {
204204
}
205205
}
206206

207-
func stopJanitor(c *FeatureSheet) {
207+
func stopJanitor(c *FlagSheet) {
208208
c.janitor.stop <- true
209209
}
210210

211-
func runJanitor(c *featureSheet, ci time.Duration) {
211+
func runJanitor(c *flagSheet, ci time.Duration) {
212212
j := &janitor{
213213
Interval: ci,
214214
stop: make(chan bool),
@@ -217,16 +217,16 @@ func runJanitor(c *featureSheet, ci time.Duration) {
217217
go j.Run(c)
218218
}
219219

220-
func NewFeatureSheet(service *spreadsheet.Service, sheetID string, duration time.Duration) (*FeatureSheet, error) {
221-
fs := &featureSheet{
220+
func NewFlagSheet(service *spreadsheet.Service, sheetID string, duration time.Duration) (*FlagSheet, error) {
221+
fs := &flagSheet{
222222
sheetID: sheetID,
223223
service: service,
224224
expiration: duration,
225225
}
226226
if err := fs.Refresh(); err != nil {
227227
return nil, err
228228
}
229-
FS := &FeatureSheet{fs}
229+
FS := &FlagSheet{fs}
230230
if duration > 0 {
231231
runJanitor(fs, duration)
232232
runtime.SetFinalizer(FS, stopJanitor)

featuresheet_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package featuresheet_test
1+
package flagsheet_test
22

33
import (
44
"context"
55
"os"
66
"testing"
77
"time"
88

9-
"github.com/stillmatic/featuresheet"
9+
"github.com/stillmatic/flagsheet"
1010
"github.com/stretchr/testify/assert"
1111
"golang.org/x/oauth2/google"
1212
"gopkg.in/Iwark/spreadsheet.v2"
@@ -27,7 +27,7 @@ func TestSheet(t *testing.T) {
2727

2828
client := conf.Client(context.TODO())
2929
service := spreadsheet.NewServiceWithClient(client)
30-
spreadsheet, err := featuresheet.NewFeatureSheet(service, testSpreadsheetID, 1*time.Second)
30+
spreadsheet, err := flagsheet.NewFlagSheet(service, testSpreadsheetID, 1*time.Second)
3131
assert.NoError(t, err)
3232
assert.NotNil(t, spreadsheet)
3333
fv, err := spreadsheet.Evaluate("my_key", stringPtr("my_id"))
@@ -45,7 +45,7 @@ func BenchmarkEvaluate(b *testing.B) {
4545

4646
client := conf.Client(context.TODO())
4747
service := spreadsheet.NewServiceWithClient(client)
48-
spreadsheet, err := featuresheet.NewFeatureSheet(service, testSpreadsheetID, 1*time.Second)
48+
spreadsheet, err := flagsheet.NewFlagSheet(service, testSpreadsheetID, 1*time.Second)
4949
assert.NoError(b, err)
5050
assert.NotNil(b, spreadsheet)
5151
b.ResetTimer()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
syntax = "proto3";
22

3-
package featuresheet.v1;
3+
package flagsheet.v1;
44

5-
option go_package = "github.com/stillmatic/featuresheet/gen/featuresheet/v1;featuresheetv1";
5+
option go_package = "github.com/stillmatic/flagsheet/gen/flagsheet/v1;flagsheetv1";
66

77
message EvaluateRequest {
88
string feature = 1;
@@ -13,6 +13,6 @@ message EvaluateResponse {
1313
string variant = 1;
1414
}
1515

16-
service FeatureSheetService {
16+
service FlagSheetService {
1717
rpc Evaluate(EvaluateRequest) returns (EvaluateResponse);
1818
}

0 commit comments

Comments
 (0)