Files
lingniu-vehicle-ingest/go/vehicle-gateway/internal/realtime/model.go
2026-07-01 21:51:13 +08:00

39 lines
1.1 KiB
Go

package realtime
import (
"time"
"lingniu-vehicle-ingest/go/vehicle-gateway/internal/envelope"
)
type Snapshot struct {
VIN string `json:"vin"`
Protocol envelope.Protocol `json:"protocol,omitempty"`
EventID string `json:"event_id,omitempty"`
EventTimeMS int64 `json:"event_time_ms"`
ReceivedAtMS int64 `json:"received_at_ms"`
SourceEndpoint string `json:"source_endpoint,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
FieldTimesMS map[string]int64 `json:"field_times_ms,omitempty"`
UpdatedAtMS int64 `json:"updated_at_ms"`
}
type OnlineStatus struct {
VIN string `json:"vin"`
Online bool `json:"online"`
LastSeenMS int64 `json:"last_seen_ms"`
Protocols []envelope.Protocol `json:"protocols,omitempty"`
TTLSeconds int64 `json:"ttl_seconds"`
}
type Config struct {
OnlineTTL time.Duration
}
func (c Config) ttl() time.Duration {
if c.OnlineTTL <= 0 {
return 10 * time.Minute
}
return c.OnlineTTL
}