mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-06-29 03:12:54 +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:
+4
-11
@@ -25,9 +25,9 @@ const (
|
||||
|
||||
// Event represents a WebSocket event message
|
||||
type Event struct {
|
||||
Type EventType `json:"type"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
Type EventType `json:"type"`
|
||||
}
|
||||
|
||||
// Client represents a WebSocket client connection
|
||||
@@ -45,15 +45,15 @@ type Server struct {
|
||||
broadcast chan Event
|
||||
register chan *Client
|
||||
unregister chan *Client
|
||||
mu sync.RWMutex
|
||||
upgrader websocket.Upgrader
|
||||
mu sync.RWMutex
|
||||
}
|
||||
|
||||
// Config holds WebSocket server configuration
|
||||
type Config struct {
|
||||
CheckOrigin func(r *http.Request) bool
|
||||
ReadBufferSize int
|
||||
WriteBufferSize int
|
||||
CheckOrigin func(r *http.Request) bool
|
||||
}
|
||||
|
||||
// NewServer creates a new WebSocket server
|
||||
@@ -307,8 +307,8 @@ func (c *Client) writePump() {
|
||||
// handleMessage processes incoming client messages
|
||||
func (c *Client) handleMessage(message []byte) {
|
||||
var msg struct {
|
||||
Action string `json:"action"`
|
||||
Data interface{} `json:"data"`
|
||||
Action string `json:"action"`
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(message, &msg); err != nil {
|
||||
@@ -379,10 +379,3 @@ func (c *Client) sendPong() {
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// GetConnectedClients returns the number of connected clients
|
||||
func (s *Server) GetConnectedClients() int {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return len(s.clients)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user