feat: add go realtime redis api
This commit is contained in:
38
go/vehicle-gateway/internal/realtime/model.go
Normal file
38
go/vehicle-gateway/internal/realtime/model.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user