mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-07-07 04:14:31 +00:00
refactor: reorganize struct fields, add new handlers and storage backends
- [x] Reorder struct fields across codebase for consistency - [x] Add analytics event handlers and tests - [x] Add authentication API key management handlers and tests - [x] Add pre-warming control handlers and tests - [x] Implement S3 storage backend with tests - [x] Implement SMB/CIFS storage backend with tests - [x] Add CDN middleware tests - [x] Integrate analytics tracking into cache manager - [x] Add S3 and SMB storage initialization in app setup - [x] Add CDN caching to proxy handlers - [x] Remove distributed locking (Redis lock manager) - [x] Remove proxy common package and utilities - [x] Remove standalone HTTP server package - [x] Remove logger middleware - [x] Simplify error handling utilities - [x] Update config with S3 and SMB options - [x] Update cache manager signature to include analytics
This commit is contained in:
@@ -10,23 +10,23 @@ import (
|
||||
|
||||
// PackageDownload represents a package download event
|
||||
type PackageDownload struct {
|
||||
Timestamp time.Time
|
||||
Registry string
|
||||
Name string
|
||||
Version string
|
||||
Timestamp time.Time
|
||||
BytesSize int64
|
||||
ClientIP string
|
||||
UserAgent string
|
||||
BytesSize int64
|
||||
}
|
||||
|
||||
// PackageStats holds statistics for a package
|
||||
type PackageStats struct {
|
||||
LastDownload time.Time
|
||||
FirstSeen time.Time
|
||||
Registry string
|
||||
Name string
|
||||
TotalDownloads int64
|
||||
UniqueVersions int
|
||||
LastDownload time.Time
|
||||
FirstSeen time.Time
|
||||
BytesServed int64
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ type PopularPackage struct {
|
||||
|
||||
// Engine tracks and analyzes package downloads
|
||||
type Engine struct {
|
||||
downloads []PackageDownload
|
||||
downloadsMu sync.RWMutex
|
||||
stats map[string]*PackageStats // key: registry:name
|
||||
statsMu sync.RWMutex
|
||||
maxEvents int
|
||||
stats map[string]*PackageStats
|
||||
flushTicker *time.Ticker
|
||||
stopChan chan struct{}
|
||||
downloads []PackageDownload
|
||||
maxEvents int
|
||||
downloadsMu sync.RWMutex
|
||||
statsMu sync.RWMutex
|
||||
}
|
||||
|
||||
// Config holds analytics engine configuration
|
||||
|
||||
Reference in New Issue
Block a user