Skip to content

Commit 46bbf84

Browse files
committed
feat(standalone): Polishing
1 parent 8e79e74 commit 46bbf84

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

pkg/enricher/enricher.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,24 @@ type Enricher struct {
4343
enableStandalone bool
4444
}
4545

46+
func newEnricher(ctx context.Context, cache c.CacheInterface, enableStandalone bool) *Enricher {
47+
ir := container.NewRing(container.Capacity1023)
48+
return &Enricher{
49+
ctx: ctx,
50+
l: log.Logger().Named("enricher"),
51+
cache: cache,
52+
inputRing: ir,
53+
Reader: container.NewRingReader(ir, ir.OldestWrite()),
54+
outputRing: container.NewRing(container.Capacity1023),
55+
enableStandalone: enableStandalone,
56+
}
57+
}
58+
4659
func New(ctx context.Context, cache c.CacheInterface, enableStandalone bool) *Enricher {
4760
once.Do(func() {
48-
ir := container.NewRing(container.Capacity1023)
49-
e = &Enricher{
50-
ctx: ctx,
51-
l: log.Logger().Named("enricher"),
52-
cache: cache,
53-
inputRing: ir,
54-
Reader: container.NewRingReader(ir, ir.OldestWrite()),
55-
outputRing: container.NewRing(container.Capacity1023),
56-
enableStandalone: enableStandalone,
57-
}
61+
e = newEnricher(ctx, cache, enableStandalone)
5862
initialized = true
5963
})
60-
6164
return e
6265
}
6366

pkg/enricher/enricher_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func TestEnricherSecondaryIPs(t *testing.T) {
7575
require.NoError(t, err)
7676

7777
// get the enricher
78-
e := New(ctx, c, false)
78+
e := newEnricher(ctx, c, false)
7979
var wg sync.WaitGroup
8080

8181
wg.Add(1)
@@ -180,7 +180,7 @@ func TestEnricherStandaloneWithEndpointPresent(t *testing.T) {
180180
require.NoError(t, testCache.UpdateRetinaEndpoint(endpoint))
181181

182182
// Create the enricher with standalone enabled
183-
enricher := New(ctx, testCache, true)
183+
enricher := newEnricher(ctx, testCache, true)
184184
var wg sync.WaitGroup
185185

186186
wg.Add(1)
@@ -245,7 +245,7 @@ func TestEnricherStandaloneWithEndpointAbsent(t *testing.T) {
245245
sourceIP := "9.9.9.9" // No endpoint present in cache
246246

247247
// Create the enricher with standalone enabled
248-
enricher := New(ctx, testCache, true)
248+
enricher := newEnricher(ctx, testCache, true)
249249
var wg sync.WaitGroup
250250

251251
wg.Add(1)

pkg/module/metrics/standalone/metrics_module.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ func InitModule(_ context.Context, _ enricher.EnricherInterface) *Module {
1515
return &Module{}
1616
}
1717

18-
func (m *Module) Reconcile(ctx context.Context) {}
18+
func (m *Module) Reconcile(_ context.Context) {}
1919

2020
func (m *Module) Clear() {}

0 commit comments

Comments
 (0)