Complete refactor to new grpc control plane and only http proxy for carts #4
@@ -53,6 +53,8 @@ func (s *DiskStorage[V]) SaveLoop(duration time.Duration) {
|
||||
}
|
||||
|
||||
func (s *DiskStorage[V]) save() {
|
||||
carts := 0
|
||||
lines := 0
|
||||
s.queue.Range(func(key, value any) bool {
|
||||
id := key.(uint64)
|
||||
path := s.logPath(id)
|
||||
@@ -68,12 +70,16 @@ func (s *DiskStorage[V]) save() {
|
||||
if err := s.Append(fh, msg.Message, msg.TimeStamp); err != nil {
|
||||
log.Printf("failed to append event to log file: %v", err)
|
||||
}
|
||||
lines++
|
||||
}
|
||||
}
|
||||
carts++
|
||||
s.queue.Delete(id)
|
||||
return true
|
||||
})
|
||||
log.Print("Appended carts to disk")
|
||||
if lines > 0 {
|
||||
log.Printf("Appended %d carts and %d lines to disk", carts, lines)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DiskStorage[V]) logPath(id uint64) string {
|
||||
|
||||
Reference in New Issue
Block a user