v1.2.0: skip unchanged writes, transactional schema/root counters, snapshot replay for meta:events 0-0 (drops boot republish), collect-once search driver
Build and Push Docker Image / build (push) Successful in 7m38s
Build and Push Docker Image / build (push) Successful in 7m38s
This commit is contained in:
@@ -2,29 +2,20 @@ package watchers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// RepublishCallback is a function type for republishing metadata events
|
||||
type RepublishCallback func() (int, error)
|
||||
|
||||
// Handlers provides HTTP handlers for watchers management
|
||||
type Handlers struct {
|
||||
manager *Manager
|
||||
poller *Poller
|
||||
republishCallback RepublishCallback
|
||||
manager *Manager
|
||||
poller *Poller
|
||||
}
|
||||
|
||||
// NewHandlers creates new watchers handlers
|
||||
func NewHandlers(manager *Manager, poller *Poller, republishCallback RepublishCallback) *Handlers {
|
||||
return &Handlers{
|
||||
manager: manager,
|
||||
poller: poller,
|
||||
republishCallback: republishCallback,
|
||||
}
|
||||
func NewHandlers(manager *Manager, poller *Poller) *Handlers {
|
||||
return &Handlers{manager: manager, poller: poller}
|
||||
}
|
||||
|
||||
// RegisterRoutes registers all watchers-related routes
|
||||
@@ -215,22 +206,13 @@ func (h *Handlers) handleResetAll(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// Republish all metadata events after reset
|
||||
republishedCount := 0
|
||||
if h.republishCallback != nil {
|
||||
count, err := h.republishCallback()
|
||||
if err != nil {
|
||||
log.Printf("[Handlers] Warning: failed to republish metadata after reset: %v", err)
|
||||
} else {
|
||||
republishedCount = count
|
||||
}
|
||||
}
|
||||
|
||||
// No metadata republish: a reset rescans files; it does not change
|
||||
// metadata consumers hold. A consumer that wants the whole state asks
|
||||
// /api/events/meta for "0" and gets a snapshot.
|
||||
writeJSON(w, http.StatusOK, map[string]interface{}{
|
||||
"status": "ok",
|
||||
"message": "All watchers reset",
|
||||
"totalFiles": totalCount,
|
||||
"republishedEvents": republishedCount,
|
||||
"status": "ok",
|
||||
"message": "All watchers reset",
|
||||
"totalFiles": totalCount,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user