feat(demo): reset the demo instance every 20 minutes with a countdown
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m34s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m34s
DEMO_RESET_MINUTES (default 20, 0 = off) resets the database to the sample data. Demo accounts get fixed IDs so sessions survive; requests hold a read lock so the reset never runs under a half-finished request (streams excluded). DEMO_RESET goes to every connection, /auth/status announces the next reset. The app shows "✨ Demo · Reset in MM:SS" in place of the version, then clears cached answers, remounts the views, reloads in the background and shows a short notice; if no event arrives (long polling) it asks the server after the countdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
afd3b0347c
commit
6b9eb62caf
12 files changed
+348
-9
No files matched your search
@@ -371,6 +371,26 @@ func (h *Hub) BroadcastToUser(userID, event string, payload interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// BroadcastSystem sends an event to every connection. Only for events without user data (e.g. the
|
||||
// demo reset notice).
|
||||
func (h *Hub) BroadcastSystem(event string) {
|
||||
data, err := json.Marshal(domain.WSMessage{Event: event, Timestamp: domain.NowISO()})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
h.mu.RLock()
|
||||
defer h.mu.RUnlock()
|
||||
if h.closed {
|
||||
return
|
||||
}
|
||||
for client := range h.allClients {
|
||||
client.trySend(data)
|
||||
}
|
||||
for sseClient := range h.sseClients {
|
||||
sseClient.trySend(data)
|
||||
}
|
||||
}
|
||||
|
||||
// BroadcastToUsers sends one event to every connection of the given users (duplicates are ignored).
|
||||
func (h *Hub) BroadcastToUsers(userIDs []string, event string, payload interface{}) {
|
||||
seen := make(map[string]bool, len(userIDs))
|
||||
|
||||
Reference in new issue
Block a user