diff options
| author | Fuwn <[email protected]> | 2026-01-28 03:12:23 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-28 03:12:23 -0800 |
| commit | defea76033f75804a45bbb650e19cb16c677295b (patch) | |
| tree | cfc507fb0d782f02925c001429df7d3c1d079420 /cmd | |
| parent | fix: Handle libsql string-based time values (diff) | |
| download | kaze-defea76033f75804a45bbb650e19cb16c677295b.tar.xz kaze-defea76033f75804a45bbb650e19cb16c677295b.zip | |
feat: Add SSE streaming for instant page load and real-time updates
New refresh_mode 'stream' eliminates blocking database queries from initial
page load. Page renders instantly with skeleton UI, then hydrates via SSE.
- Add SSE hub for managing client connections and broadcasting
- Add /api/stream endpoint with init and update events
- Add stream.html skeleton template with loading animations
- Wire scheduler to broadcast on check completion
- Backwards compatible: page/api modes unchanged
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/kaze/main.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cmd/kaze/main.go b/cmd/kaze/main.go index aaed1fa..b8895a0 100644 --- a/cmd/kaze/main.go +++ b/cmd/kaze/main.go @@ -108,6 +108,10 @@ func main() { } srv.SetVersion(version, commit, date) + sched.SetOnCheckCallback(func() { + srv.BroadcastStatusUpdate(context.Background()) + }) + // Setup graceful shutdown ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -178,10 +182,12 @@ func main() { return fmt.Errorf("failed to create new scheduler: %w", err) } - // Swap config/scheduler without restarting the HTTP listener srv.UpdateConfig(newCfg, newSched) cfg = newCfg sched = newSched + sched.SetOnCheckCallback(func() { + srv.BroadcastStatusUpdate(context.Background()) + }) sched.Start() logger.Info("configuration reloaded successfully (zero-downtime)", |