refactor: remove redundant constructors
Some checks failed
Go Tests / Run Tests (1.24.2) (push) Has been cancelled

This commit is contained in:
Jeremy Tregunna 2025-05-02 22:36:50 -06:00
parent eefc915f3a
commit bbb54a0d6c
Signed by: jer
GPG Key ID: 1278B36BA6F5D5E4
2 changed files with 8 additions and 18 deletions

View File

@ -72,17 +72,7 @@ type LatencyTracker struct {
min atomic.Uint64 // min in nanoseconds (initialized to max uint64)
}
// NewCollector creates a new statistics collector
func NewCollector() *AtomicCollector {
return &AtomicCollector{
counts: make(map[OperationType]*atomic.Uint64),
lastOpTime: make(map[OperationType]time.Time),
errors: make(map[string]*atomic.Uint64),
latencies: make(map[OperationType]*LatencyTracker),
}
}
// NewAtomicCollector creates a new atomic statistics collector
// NewAtomicCollector creates a new statistics collector
// This is the recommended collector implementation for production use
func NewAtomicCollector() *AtomicCollector {
return &AtomicCollector{

View File

@ -7,7 +7,7 @@ import (
)
func TestCollector_TrackOperation(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
// Track operations
collector.TrackOperation(OpPut)
@ -37,7 +37,7 @@ func TestCollector_TrackOperation(t *testing.T) {
}
func TestCollector_TrackOperationWithLatency(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
// Track operations with latency
collector.TrackOperationWithLatency(OpGet, 100)
@ -71,7 +71,7 @@ func TestCollector_TrackOperationWithLatency(t *testing.T) {
}
func TestCollector_ConcurrentAccess(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
const numGoroutines = 10
const opsPerGoroutine = 1000
@ -126,7 +126,7 @@ func TestCollector_ConcurrentAccess(t *testing.T) {
}
func TestCollector_GetStatsFiltered(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
// Track different operations
collector.TrackOperation(OpPut)
@ -161,7 +161,7 @@ func TestCollector_GetStatsFiltered(t *testing.T) {
}
func TestCollector_TrackBytes(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
// Track read and write bytes
collector.TrackBytes(true, 1000) // write
@ -179,7 +179,7 @@ func TestCollector_TrackBytes(t *testing.T) {
}
func TestCollector_TrackMemTableSize(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
// Track memtable size
collector.TrackMemTableSize(2048)
@ -201,7 +201,7 @@ func TestCollector_TrackMemTableSize(t *testing.T) {
}
func TestCollector_RecoveryStats(t *testing.T) {
collector := NewCollector()
collector := NewAtomicCollector()
// Start recovery
startTime := collector.StartRecovery()