mirror of
https://github.com/syntrex-lab/gomcp.git
synced 2026-07-11 16:12:10 +02:00
Fix demo simulator and pricing UI bugs
This commit is contained in:
parent
4ce60a33d6
commit
54337f4593
2 changed files with 37 additions and 39 deletions
|
|
@ -209,6 +209,9 @@ func main() {
|
||||||
// Start background retention scheduler (§19)
|
// Start background retention scheduler (§19)
|
||||||
socSvc.StartRetentionScheduler(ctx, 0) // 0 = default 1 hour
|
socSvc.StartRetentionScheduler(ctx, 0) // 0 = default 1 hour
|
||||||
|
|
||||||
|
// Start WebSocket Event Bridge for live real-time streams
|
||||||
|
srv.StartEventBridge(ctx)
|
||||||
|
|
||||||
// pprof profiling (§P4C) — enabled by SOC_PPROF=true
|
// pprof profiling (§P4C) — enabled by SOC_PPROF=true
|
||||||
if env("SOC_PPROF", "") == "true" {
|
if env("SOC_PPROF", "") == "true" {
|
||||||
srv.EnablePprof()
|
srv.EnablePprof()
|
||||||
|
|
|
||||||
|
|
@ -16,53 +16,48 @@ func (s *Server) runDemoSimulator(ctx context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ticker := time.NewTicker(45 * time.Second)
|
ticker := time.NewTicker(10 * time.Second)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
|
||||||
slog.Info("SOC Demo event simulator active")
|
// Helper to send a fake event
|
||||||
|
sendFakeEvent := func() {
|
||||||
|
var demoTenantID string
|
||||||
|
tenants := s.tenantStore.ListTenants()
|
||||||
|
for _, t := range tenants {
|
||||||
|
if t.Slug == "syntrex-demo" || t.Slug == "demo" {
|
||||||
|
demoTenantID = t.ID
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if demoTenantID == "" {
|
||||||
|
return // Setup not done yet
|
||||||
|
}
|
||||||
|
|
||||||
|
event := s.generateFakeEvent()
|
||||||
|
event.TenantID = demoTenantID
|
||||||
|
|
||||||
|
if err := s.socSvc.Repo().InsertEvent(event); err != nil {
|
||||||
|
slog.Error("demo fake event persist failed", "error", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if bus := s.socSvc.EventBus(); bus != nil {
|
||||||
|
bus.Publish(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
slog.Info("SOC Demo event simulator active (10s intervals)")
|
||||||
|
|
||||||
|
// Send one immediately to avoid waiting 10s on fresh load.
|
||||||
|
go sendFakeEvent()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
// Ensure syntrex-demo tenant exists. Handled by /api/auth/demo
|
sendFakeEvent()
|
||||||
var demoTenantID string
|
|
||||||
tenants := s.tenantStore.ListTenants()
|
|
||||||
for _, t := range tenants {
|
|
||||||
if t.Slug == "syntrex-demo" {
|
|
||||||
demoTenantID = t.ID
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if demoTenantID == "" {
|
|
||||||
continue // Setup not done yet
|
|
||||||
}
|
|
||||||
|
|
||||||
event := s.generateFakeEvent()
|
|
||||||
event.TenantID = demoTenantID
|
|
||||||
|
|
||||||
// Bypass strict rate limits and auth for demo injection
|
|
||||||
// Directly persist, correlate, and publish SSE.
|
|
||||||
|
|
||||||
// 1. Persist
|
|
||||||
if err := s.socSvc.Repo().InsertEvent(event); err != nil {
|
|
||||||
slog.Error("demo fake event persist failed", "error", err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Publish to UI
|
|
||||||
if bus := s.socSvc.EventBus(); bus != nil {
|
|
||||||
bus.Publish(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Optional correlation (we just insert some realistic ones to trigger built-ins)
|
|
||||||
// For a fully self-contained demo, we periodically just insert incidents directly
|
|
||||||
// or rely on the actual correlate() if we bypass private scope.
|
|
||||||
// But since correlate is private, we will just simulate incidents if needed,
|
|
||||||
// or better yet, our generator can just generate some CRITICAL alerts
|
|
||||||
//.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue