1
0

types.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package event
  2. // EventType represents the type of event
  3. type Type string
  4. const (
  5. TypeIndexScanning Type = "index_scanning"
  6. TypeAutoCertProcessing Type = "auto_cert_processing"
  7. TypeProcessingStatus Type = "processing_status"
  8. TypeNginxLogStatus Type = "nginx_log_status"
  9. TypeNginxLogIndexReady Type = "nginx_log_index_ready"
  10. TypeNginxLogIndexProgress Type = "nginx_log_index_progress"
  11. TypeNginxLogIndexComplete Type = "nginx_log_index_complete"
  12. TypeNotification Type = "notification"
  13. )
  14. // Event represents a generic event structure
  15. type Event struct {
  16. Type Type `json:"type"`
  17. Data interface{} `json:"data"`
  18. }
  19. // ProcessingStatusData represents the data for processing status events
  20. type ProcessingStatusData struct {
  21. IndexScanning bool `json:"index_scanning"`
  22. AutoCertProcessing bool `json:"auto_cert_processing"`
  23. NginxLogIndexing bool `json:"nginx_log_indexing"`
  24. }
  25. // NginxLogStatusData represents the data for nginx log status events (backward compatibility)
  26. type NginxLogStatusData struct {
  27. Indexing bool `json:"indexing"`
  28. }
  29. // NginxLogIndexReadyData represents the data for nginx log index ready events
  30. type NginxLogIndexReadyData struct {
  31. LogPath string `json:"log_path"`
  32. StartTime int64 `json:"start_time"`
  33. EndTime int64 `json:"end_time"`
  34. Available bool `json:"available"`
  35. IndexStatus string `json:"index_status"`
  36. }
  37. // NginxLogIndexProgressData represents the data for nginx log index progress events
  38. type NginxLogIndexProgressData struct {
  39. LogPath string `json:"log_path"`
  40. Progress float64 `json:"progress"` // 0-100 percentage
  41. Stage string `json:"stage"` // "scanning", "indexing", "stats"
  42. Status string `json:"status"` // "running", "completed", "error"
  43. ElapsedTime int64 `json:"elapsed_time"` // milliseconds
  44. EstimatedRemain int64 `json:"estimated_remain"` // milliseconds
  45. }
  46. // NginxLogIndexCompleteData represents the data for nginx log index complete events
  47. type NginxLogIndexCompleteData struct {
  48. LogPath string `json:"log_path"`
  49. Success bool `json:"success"`
  50. Duration int64 `json:"duration"` // milliseconds
  51. TotalLines int64 `json:"total_lines"`
  52. IndexedSize int64 `json:"indexed_size"` // bytes
  53. Error string `json:"error,omitempty"`
  54. }