go project - add a migration and rename the dockerfiles so that Go is the primary

This commit is contained in:
2026-08-06 15:54:40 -05:00
parent 459b90dcd7
commit e17fbc14a0
15 changed files with 771 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package store
import "sync"
// DeviceID is a typed device identifier.
// Using a named type (instead of plain string) makes call sites clearer
// and prevents accidentally mixing unrelated string values.
type DeviceID string
// Store holds in-memory fleet metrics for known devices.
type Store struct {
known map[DeviceID]struct{}
// mu protects the heartbeats/uploads maps (insert/lookup of entries only).
// Each per-device history has its own mutex for mutations.
mu sync.Mutex
heartbeats map[DeviceID]*heartbeatHistory
uploads map[DeviceID]*uploadHistory
}
// New creates a Store seeded with the given known device IDs.
func New(known []DeviceID) *Store {
m := make(map[DeviceID]struct{}, len(known))
for _, id := range known {
m[id] = struct{}{}
}
return &Store{
known: m,
heartbeats: make(map[DeviceID]*heartbeatHistory),
uploads: make(map[DeviceID]*uploadHistory),
}
}
// Known reports whether deviceID was present in the startup device list.
func (s *Store) Known(deviceID DeviceID) bool {
_, ok := s.known[deviceID]
return ok
}