ax(database): replace prose interface comments with usage examples
AX Principle 2: comments must show how to call the function with real values, not restate what the type signature already says. All six HashrateStore interface methods now carry concrete call-site examples. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
44223f0c67
commit
8b22e9dda6
1 changed files with 8 additions and 7 deletions
|
|
@ -8,23 +8,24 @@ import (
|
|||
// HashrateStore defines the interface for hashrate data persistence.
|
||||
// This interface allows for dependency injection and easier testing.
|
||||
type HashrateStore interface {
|
||||
// InsertHashratePoint stores a hashrate measurement.
|
||||
// If ctx is nil, a default timeout will be used.
|
||||
// store.InsertHashratePoint(ctx, "xmrig", "xmrig", HashratePoint{Timestamp: time.Now(), Hashrate: 1234}, ResolutionHigh)
|
||||
InsertHashratePoint(ctx context.Context, minerName, minerType string, point HashratePoint, resolution Resolution) error
|
||||
|
||||
// GetHashrateHistory retrieves hashrate history for a miner within a time range.
|
||||
// points, err := store.GetHashrateHistory("xmrig", ResolutionHigh, time.Now().Add(-time.Hour), time.Now())
|
||||
GetHashrateHistory(minerName string, resolution Resolution, since, until time.Time) ([]HashratePoint, error)
|
||||
|
||||
// GetHashrateStats retrieves aggregated statistics for a specific miner.
|
||||
// stats, err := store.GetHashrateStats("xmrig")
|
||||
// if stats != nil { log.Printf("avg: %d H/s", stats.AverageRate) }
|
||||
GetHashrateStats(minerName string) (*HashrateStats, error)
|
||||
|
||||
// GetAllMinerStats retrieves statistics for all miners.
|
||||
// allStats, err := store.GetAllMinerStats()
|
||||
// for _, stats := range allStats { log.Printf("%s avg: %d H/s", stats.MinerName, stats.AverageRate) }
|
||||
GetAllMinerStats() ([]HashrateStats, error)
|
||||
|
||||
// Cleanup removes old data based on retention settings.
|
||||
// store.Cleanup(30) // remove data older than 30 days
|
||||
Cleanup(retentionDays int) error
|
||||
|
||||
// Close closes the store and releases resources.
|
||||
// store.Close()
|
||||
Close() error
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue