Skip to content

Commit 2f3e213

Browse files
committed
chore: cleaning up
1 parent 5da7d16 commit 2f3e213

File tree

4 files changed

+19
-38
lines changed

4 files changed

+19
-38
lines changed

cmd/node/benchmark_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/stretchr/testify/require"
1414
"google.golang.org/grpc"
1515

16-
"github.com/rudderlabs/keydb/cache"
1716
"github.com/rudderlabs/keydb/client"
1817
"github.com/rudderlabs/keydb/node"
1918
pb "github.com/rudderlabs/keydb/proto"
@@ -54,10 +53,7 @@ func BenchmarkSingleNode(b *testing.B) {
5453
conf := config.New()
5554
conf.GetString("BadgerDB.Dedup.Path", b.TempDir())
5655
cs := &mockedCloudStorage{}
57-
cf := func(hashRange uint32) (node.Cache, error) {
58-
return cache.BadgerFactory(conf, logger.NOP)(hashRange)
59-
}
60-
service, err := node.NewService(ctx, nodeConfig, cf, cs, stats.NOP, logger.NOP)
56+
service, err := node.NewService(ctx, nodeConfig, cs, conf, stats.NOP, logger.NOP)
6157
require.NoError(b, err)
6258

6359
// Create a gRPC server

cmd/node/main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
svcMetric "github.com/rudderlabs/rudder-go-kit/stats/metric"
2323
obskit "github.com/rudderlabs/rudder-observability-kit/go/labels"
2424

25-
"github.com/rudderlabs/keydb/cache"
2625
"github.com/rudderlabs/keydb/internal/cloudstorage"
2726
"github.com/rudderlabs/keydb/internal/hash"
2827
"github.com/rudderlabs/keydb/internal/release"
@@ -105,10 +104,7 @@ func run(ctx context.Context, cancel func(), conf *config.Config, stat stats.Sta
105104
logger.NewIntField("noOfAddresses", int64(len(nodeConfig.Addresses))),
106105
)
107106

108-
badgerCacheFactory := func(hashRange uint32) (node.Cache, error) {
109-
return cache.BadgerFactory(conf, log)(hashRange)
110-
}
111-
service, err := node.NewService(ctx, nodeConfig, badgerCacheFactory, cloudStorage, stat, log.Child("service"))
107+
service, err := node.NewService(ctx, nodeConfig, cloudStorage, conf, stat, log.Child("service"))
112108
if err != nil {
113109
return fmt.Errorf("failed to create node service: %w", err)
114110
}

node/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ type cloudStorage interface {
134134
// NewService creates a new NodeService
135135
func NewService(
136136
ctx context.Context, config Config, storage cloudStorage,
137-
stat stats.Stats, kitConf *config.Config, log logger.Logger,
137+
kitConf *config.Config, stat stats.Stats, log logger.Logger,
138138
) (*Service, error) {
139139
// Set defaults for unspecified config values
140140
if config.TotalHashRanges == 0 {

node/node_test.go

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"google.golang.org/grpc"
2121

2222
"github.com/rudderlabs/keydb/client"
23-
"github.com/rudderlabs/keydb/internal/cache/badger"
2423
"github.com/rudderlabs/keydb/internal/cloudstorage"
2524
pb "github.com/rudderlabs/keydb/proto"
2625
"github.com/rudderlabs/rudder-go-kit/config"
@@ -43,7 +42,7 @@ func TestSimple(t *testing.T) {
4342
require.NoError(t, err)
4443
pool.MaxWait = 1 * time.Minute
4544

46-
run := func(t *testing.T, conf *config.Config, cf cacheFactory) {
45+
run := func(t *testing.T, conf *config.Config) {
4746
t.Parallel()
4847

4948
_, cloudStorage := getCloudStorage(t, pool, conf)
@@ -58,7 +57,7 @@ func TestSimple(t *testing.T) {
5857
ClusterSize: 1,
5958
TotalHashRanges: totalHashRanges,
6059
SnapshotInterval: 60 * time.Second,
61-
}, cf)
60+
}, conf)
6261
c := getClient(t, totalHashRanges, node0Address)
6362

6463
// Test Put
@@ -82,7 +81,7 @@ func TestSimple(t *testing.T) {
8281
ClusterSize: 1,
8382
TotalHashRanges: totalHashRanges,
8483
SnapshotInterval: 60 * time.Second,
85-
}, cf)
84+
}, conf)
8685
c = getClient(t, totalHashRanges, node0Address)
8786

8887
exists, err = c.Get(ctx, []string{"key1", "key2", "key3", "key4"})
@@ -94,14 +93,13 @@ func TestSimple(t *testing.T) {
9493
}
9594

9695
t.Run("badger", func(t *testing.T) {
97-
conf := config.New()
98-
run(t, conf, getBadgerCache(t, conf))
96+
run(t, config.New())
9997
})
10098

10199
t.Run("badger compressed", func(t *testing.T) {
102100
conf := config.New()
103101
conf.Set("BadgerDB.Dedup.Compress", true)
104-
run(t, conf, getBadgerCache(t, conf))
102+
run(t, conf)
105103
})
106104
}
107105

@@ -110,7 +108,7 @@ func TestScaleUpAndDown(t *testing.T) {
110108
require.NoError(t, err)
111109
pool.MaxWait = 1 * time.Minute
112110

113-
run := func(t *testing.T, conf *config.Config, cf cacheFactory) {
111+
run := func(t *testing.T, conf *config.Config) {
114112
minioClient, cloudStorage := getCloudStorage(t, pool, conf)
115113

116114
ctx, cancel := context.WithCancel(context.Background())
@@ -123,7 +121,7 @@ func TestScaleUpAndDown(t *testing.T) {
123121
ClusterSize: 1,
124122
TotalHashRanges: totalHashRanges,
125123
SnapshotInterval: 60 * time.Second,
126-
}, cf)
124+
}, conf)
127125
c := getClient(t, totalHashRanges, node0Address)
128126

129127
// Test Put
@@ -150,7 +148,7 @@ func TestScaleUpAndDown(t *testing.T) {
150148
TotalHashRanges: totalHashRanges,
151149
SnapshotInterval: 60 * time.Second,
152150
Addresses: []string{node0Address},
153-
}, cf)
151+
}, conf)
154152
require.NoError(t, operator.Scale(ctx, node0Address, node1Address))
155153
require.NoError(t, operator.ScaleComplete(ctx))
156154

@@ -186,8 +184,7 @@ func TestScaleUpAndDown(t *testing.T) {
186184
}
187185

188186
t.Run("badger", func(t *testing.T) {
189-
conf := config.New()
190-
run(t, conf, getBadgerCache(t, conf))
187+
run(t, config.New())
191188
})
192189
}
193190

@@ -196,7 +193,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
196193
require.NoError(t, err)
197194
pool.MaxWait = 1 * time.Minute
198195

199-
run := func(t *testing.T, conf *config.Config, cf cacheFactory) {
196+
run := func(t *testing.T, conf *config.Config) {
200197
minioClient, cloudStorage := getCloudStorage(t, pool, conf)
201198

202199
ctx, cancel := context.WithCancel(context.Background())
@@ -209,7 +206,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
209206
ClusterSize: 1,
210207
TotalHashRanges: totalHashRanges,
211208
SnapshotInterval: 60 * time.Second,
212-
}, cf)
209+
}, conf)
213210
c := getClient(t, totalHashRanges, node0Address)
214211

215212
// Test Put
@@ -236,7 +233,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
236233
TotalHashRanges: totalHashRanges,
237234
SnapshotInterval: 60 * time.Second,
238235
Addresses: []string{node0Address},
239-
}, cf)
236+
}, conf)
240237
require.NoError(t, operator.Scale(ctx, node0Address, node1Address))
241238
require.NoError(t, operator.ScaleComplete(ctx))
242239

@@ -253,7 +250,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
253250
TotalHashRanges: totalHashRanges,
254251
SnapshotInterval: 60 * time.Second,
255252
Addresses: []string{node0Address, node1Address},
256-
}, cf)
253+
}, conf)
257254
require.NoError(t, operator.Scale(ctx, node0Address, node1Address, node2Address))
258255
require.NoError(t, operator.ScaleComplete(ctx))
259256

@@ -290,8 +287,7 @@ func TestGetPutAddressBroadcast(t *testing.T) {
290287
}
291288

292289
t.Run("badger", func(t *testing.T) {
293-
conf := config.New()
294-
run(t, conf, getBadgerCache(t, conf))
290+
run(t, config.New())
295291
})
296292
}
297293

@@ -314,15 +310,8 @@ func getCloudStorage(t testing.TB, pool *dockertest.Pool, conf *config.Config) (
314310
return minioClient, cloudStorage
315311
}
316312

317-
func getBadgerCache(t testing.TB, conf *config.Config) cacheFactory {
318-
return func(_ uint32) (Cache, error) {
319-
t.Helper()
320-
return badger.New(t.TempDir(), conf, logger.NOP)
321-
}
322-
}
323-
324313
func getService(
325-
ctx context.Context, t testing.TB, cs cloudStorage, nodeConfig Config, cf cacheFactory,
314+
ctx context.Context, t testing.TB, cs cloudStorage, nodeConfig Config, conf *config.Config,
326315
) (*Service, string) {
327316
t.Helper()
328317

@@ -331,7 +320,7 @@ func getService(
331320
address := "localhost:" + strconv.Itoa(freePort)
332321
nodeConfig.Addresses = append(nodeConfig.Addresses, address)
333322

334-
service, err := NewService(ctx, nodeConfig, cf, cs, stats.NOP, logger.NOP)
323+
service, err := NewService(ctx, nodeConfig, cs, conf, stats.NOP, logger.NOP)
335324
require.NoError(t, err)
336325

337326
// Create a gRPC server

0 commit comments

Comments
 (0)