Skip to content
Snippets Groups Projects
Commit 30c3d783 authored by m.nabokikh's avatar m.nabokikh
Browse files

fix: log device flow entities GC result if no auth entities collected

parent e3383564
No related branches found
No related tags found
No related merge requests found
...@@ -471,8 +471,8 @@ func (s *Server) startGarbageCollection(ctx context.Context, frequency time.Dura ...@@ -471,8 +471,8 @@ func (s *Server) startGarbageCollection(ctx context.Context, frequency time.Dura
case <-time.After(frequency): case <-time.After(frequency):
if r, err := s.storage.GarbageCollect(now()); err != nil { if r, err := s.storage.GarbageCollect(now()); err != nil {
s.logger.Errorf("garbage collection failed: %v", err) s.logger.Errorf("garbage collection failed: %v", err)
} else if r.AuthRequests > 0 || r.AuthCodes > 0 { } else if !r.IsEmpty() {
s.logger.Infof("garbage collection run, delete auth requests=%d, auth codes=%d, device requests =%d, device tokens=%d", s.logger.Infof("garbage collection run, delete auth requests=%d, auth codes=%d, device requests=%d, device tokens=%d",
r.AuthRequests, r.AuthCodes, r.DeviceRequests, r.DeviceTokens) r.AuthRequests, r.AuthCodes, r.DeviceRequests, r.DeviceTokens)
} }
} }
......
...@@ -55,6 +55,14 @@ type GCResult struct { ...@@ -55,6 +55,14 @@ type GCResult struct {
DeviceTokens int64 DeviceTokens int64
} }
// IsEmpty returns whether the garbage collection result is empty or not.
func (g *GCResult) IsEmpty() bool {
return g.AuthRequests == 0 &&
g.AuthCodes == 0 &&
g.DeviceRequests == 0 &&
g.DeviceTokens == 0
}
// Storage is the storage interface used by the server. Implementations are // Storage is the storage interface used by the server. Implementations are
// required to be able to perform atomic compare-and-swap updates and either // required to be able to perform atomic compare-and-swap updates and either
// support timezones or standardize on UTC. // support timezones or standardize on UTC.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment