Documentation
¶
Index ¶
- Constants
- func RegisterConfigHandlers(ctx context.Context, configManager *config.Manager, poolManager Manager)
- type Manager
- type MetricsSnapshot
- type MetricsTracker
- func (mt *MetricsTracker) GetSnapshot() MetricsSnapshot
- func (mt *MetricsTracker) IncArticlesDownloaded()
- func (mt *MetricsTracker) IncArticlesPosted()
- func (mt *MetricsTracker) Reset(ctx context.Context, resetPeak bool, resetTotals bool) error
- func (mt *MetricsTracker) Start(ctx context.Context)
- func (mt *MetricsTracker) Stop()
- func (mt *MetricsTracker) UpdateDownloadProgress(id string, bytesDownloaded int64)
- type StatsRepository
Constants ¶
const MissingRateWarningThreshold = 10.0
MissingRateWarningThreshold is the missing articles per minute rate that triggers a warning.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Manager ¶
type Manager interface {
// GetPool returns the current connection pool or error if not available
GetPool() (*nntppool.Client, error)
// SetProviders creates/recreates the pool with new providers
SetProviders(providers []nntppool.Provider) error
// ClearPool shuts down and removes the current pool
ClearPool() error
// HasPool returns true if a pool is currently available
HasPool() bool
// GetMetrics returns the current pool metrics with calculated speeds
GetMetrics() (MetricsSnapshot, error)
// ResetMetrics resets specific cumulative metrics
ResetMetrics(ctx context.Context, resetPeak bool, resetTotals bool) error
// IncArticlesDownloaded increments the count of articles successfully downloaded
IncArticlesDownloaded()
// UpdateDownloadProgress updates the bytes downloaded for a specific stream
UpdateDownloadProgress(id string, bytesDownloaded int64)
// IncArticlesPosted increments the count of articles successfully posted
IncArticlesPosted()
// AddProvider adds a single provider to the running pool.
// If no pool exists, a new one is created with this provider.
AddProvider(provider nntppool.Provider) error
// RemoveProvider removes a provider by its nntppool name (host:port or host:port+username).
// If the last provider is removed, the pool is closed.
RemoveProvider(name string) error
}
Manager provides centralized NNTP connection pool management
func NewManager ¶
func NewManager(ctx context.Context, repo StatsRepository) Manager
NewManager creates a new pool manager
type MetricsSnapshot ¶
type MetricsSnapshot struct {
BytesDownloaded int64 `json:"bytes_downloaded"`
BytesUploaded int64 `json:"bytes_uploaded"`
ArticlesDownloaded int64 `json:"articles_downloaded"`
ArticlesPosted int64 `json:"articles_posted"`
TotalErrors int64 `json:"total_errors"`
ProviderErrors map[string]int64 `json:"provider_errors"`
ProviderBytes map[string]int64 `json:"provider_bytes"`
ProviderBytes24h map[string]int64 `json:"provider_bytes_24h"`
DownloadSpeedBytesPerSec float64 `json:"download_speed_bytes_per_sec"`
MaxDownloadSpeedBytesPerSec float64 `json:"max_download_speed_bytes_per_sec"`
UploadSpeedBytesPerSec float64 `json:"upload_speed_bytes_per_sec"`
Timestamp time.Time `json:"timestamp"`
ProviderMissingRates map[string]float64 `json:"provider_missing_rates"`
ProviderMissingWarning map[string]bool `json:"provider_missing_warning"`
}
MetricsSnapshot represents pool metrics at a point in time with calculated values
type MetricsTracker ¶
type MetricsTracker struct {
// contains filtered or unexported fields
}
MetricsTracker tracks pool metrics over time and calculates rates
func NewMetricsTracker ¶
func NewMetricsTracker(pool *nntppool.Client, repo StatsRepository) *MetricsTracker
NewMetricsTracker creates a new metrics tracker
func (*MetricsTracker) GetSnapshot ¶
func (mt *MetricsTracker) GetSnapshot() MetricsSnapshot
GetSnapshot returns the current metrics with calculated speeds
func (*MetricsTracker) IncArticlesDownloaded ¶
func (mt *MetricsTracker) IncArticlesDownloaded()
IncArticlesDownloaded increments the count of articles successfully downloaded
func (*MetricsTracker) IncArticlesPosted ¶
func (mt *MetricsTracker) IncArticlesPosted()
IncArticlesPosted increments the count of articles successfully posted
func (*MetricsTracker) Reset ¶
Reset resets cumulative metrics both in memory and in the database based on flags
func (*MetricsTracker) Start ¶
func (mt *MetricsTracker) Start(ctx context.Context)
Start begins collecting metrics samples
func (*MetricsTracker) Stop ¶
func (mt *MetricsTracker) Stop()
Stop stops collecting metrics samples
func (*MetricsTracker) UpdateDownloadProgress ¶
func (mt *MetricsTracker) UpdateDownloadProgress(id string, bytesDownloaded int64)
UpdateDownloadProgress updates the live bytes downloaded counter
type StatsRepository ¶
type StatsRepository interface {
UpdateSystemStat(ctx context.Context, key string, value int64) error
BatchUpdateSystemStats(ctx context.Context, stats map[string]int64) error
GetSystemStats(ctx context.Context) (map[string]int64, error)
AddBytesDownloadedToDailyStat(ctx context.Context, bytes int64) error
AddProviderBytesToHourlyStat(ctx context.Context, providerID string, bytes int64) error
GetProviderHourlyStats(ctx context.Context, hours int) (map[string]int64, error)
ClearProviderHourlyStats(ctx context.Context) error
}
StatsRepository defines the interface for persisting pool statistics