Files
3x-ui-agent/internal/eventbus/events.go
T
Sanaei f727d04f65
Release 3X-UI for Docker / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
v3.7.0
2026-08-24 15:07:15 +02:00

66 lines
1.7 KiB
Go

package eventbus
import "time"
// EventType identifies the kind of event flowing through the bus.
type EventType string
const (
// Outbound health (observatory-driven)
EventOutboundDown EventType = "outbound.down"
EventOutboundUp EventType = "outbound.up"
// Xray core (local)
EventXrayCrash EventType = "xray.crash"
// Node health (heartbeat-driven)
EventNodeDown EventType = "node.down"
EventNodeUp EventType = "node.up"
// System health
EventCPUHigh EventType = "cpu.high"
EventMemoryHigh EventType = "memory.high"
// Security
EventLoginAttempt EventType = "login.attempt"
)
// Event is the unit of information flowing through the bus.
type Event struct {
Type EventType
Source string // outbound tag, node name, client email, IP, etc.
Data any // event-specific payload, may be nil
Timestamp time.Time // when the event was detected
}
// OutboundHealthData carries observatory details for outbound events.
type OutboundHealthData struct {
Delay int64 // last measured delay in ms, 0 if unknown
Error string // last error if probe failed, empty if up
}
// NodeHealthData carries heartbeat details for node events.
type NodeHealthData struct {
NodeId int
LatencyMs int
CpuPct float64
MemPct float64
XrayState string // "running", "stopped", etc.
XrayError string
}
// LoginEventData carries login attempt details.
type LoginEventData struct {
Username string
IP string
Time string
Status string // "success" or "fail"
Reason string
}
// SystemMetricData carries raw system metric values for threshold-based events.
type SystemMetricData struct {
Percent float64 // current usage percentage
Threshold int // configured threshold
}