Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

48 wiersze
1.3KB

  1. package app
  2. import "time"
  3. type FaultSeverity int
  4. const (
  5. FaultSeverityWarn FaultSeverity = iota
  6. FaultSeverityDegraded
  7. FaultSeverityMuted
  8. FaultSeverityFaulted
  9. )
  10. var faultSeverityNames = []string{"warn", "degraded", "muted", "faulted"}
  11. func (s FaultSeverity) String() string {
  12. if int(s) < 0 || int(s) >= len(faultSeverityNames) {
  13. return "unknown"
  14. }
  15. return faultSeverityNames[s]
  16. }
  17. // MarshalText implements encoding.TextMarshaler so that FaultSeverity
  18. // renders as a human-friendly string in JSON and other text contexts.
  19. func (s FaultSeverity) MarshalText() ([]byte, error) {
  20. return []byte(s.String()), nil
  21. }
  22. type FaultReason string
  23. const (
  24. FaultReasonUnknown FaultReason = "unknown"
  25. FaultReasonQueueCritical FaultReason = "queueCritical"
  26. FaultReasonLateBuffers FaultReason = "lateBuffers"
  27. FaultReasonWriteTimeout FaultReason = "writeTimeout"
  28. FaultReasonQueueEmpty FaultReason = "queueEmpty"
  29. )
  30. // FaultEvent captures a single fault observation along with its severity and
  31. // optional human-readable hint. Fault history and last-fault exposure rely on
  32. // this struct so operators can reason about runtime behavior.
  33. type FaultEvent struct {
  34. Time time.Time `json:"time"`
  35. Reason FaultReason `json:"reason"`
  36. Severity FaultSeverity `json:"severity"`
  37. Message string `json:"message,omitempty"`
  38. }