From 0b7c41d7519c587b62651fce3571cd64b4797aa8 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Wed, 26 Jun 2024 20:08:12 -0700 Subject: [PATCH] Removing close chan. --- lib/ttlmap/ttlmap.go | 8 ++------ lib/ttlmap/ttlmap_test.go | 4 ---- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/ttlmap/ttlmap.go b/lib/ttlmap/ttlmap.go index 9f508dc9..89f87f70 100644 --- a/lib/ttlmap/ttlmap.go +++ b/lib/ttlmap/ttlmap.go @@ -29,16 +29,14 @@ type TTLMap struct { mu sync.RWMutex data map[string]*ItemWrapper `yaml:"data"` filePath string - closeChan chan struct{} cleanupTicker *time.Ticker flushTicker *time.Ticker } func NewMap(filePath string, cleanupInterval, flushInterval time.Duration) *TTLMap { t := &TTLMap{ - data: make(map[string]*ItemWrapper), - filePath: filePath, - closeChan: make(chan struct{}), + data: make(map[string]*ItemWrapper), + filePath: filePath, } if err := t.loadFromFile(); err != nil { @@ -94,8 +92,6 @@ func (t *TTLMap) cleanUpAndFlushRoutine() { if err := t.flush(); err != nil { logger.Panic("Failed to flush", slog.Any("err", err)) } - case <-t.closeChan: - return } } } diff --git a/lib/ttlmap/ttlmap_test.go b/lib/ttlmap/ttlmap_test.go index fb82a315..a9785df2 100644 --- a/lib/ttlmap/ttlmap_test.go +++ b/lib/ttlmap/ttlmap_test.go @@ -68,8 +68,6 @@ func TestTTLMap_Complete(t *testing.T) { _, isOk = store.Get("xyz") assert.True(t, isOk, "xyz") - - store.closeChan <- struct{}{} } func TestFlushing(t *testing.T) { @@ -95,6 +93,4 @@ func TestFlushing(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 1, len(data)) - - ttlMap.closeChan <- struct{}{} }