1
0

log_cache_status.go 911 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package nginx_log
  2. import (
  3. "sync"
  4. )
  5. var (
  6. // indexingFiles tracks which files are currently being indexed
  7. indexingFiles = make(map[string]bool)
  8. indexingMutex sync.RWMutex
  9. )
  10. // SetIndexingStatus updates the indexing status for a file
  11. func SetIndexingStatus(path string, isIndexing bool) {
  12. indexingMutex.Lock()
  13. defer indexingMutex.Unlock()
  14. if isIndexing {
  15. indexingFiles[path] = true
  16. } else {
  17. delete(indexingFiles, path)
  18. }
  19. }
  20. // IsFileIndexing checks if a file is currently being indexed
  21. func IsFileIndexing(path string) bool {
  22. indexingMutex.RLock()
  23. defer indexingMutex.RUnlock()
  24. return indexingFiles[path]
  25. }
  26. // GetIndexingFiles returns all files currently being indexed
  27. func GetIndexingFiles() []string {
  28. indexingMutex.RLock()
  29. defer indexingMutex.RUnlock()
  30. files := make([]string, 0, len(indexingFiles))
  31. for path := range indexingFiles {
  32. files = append(files, path)
  33. }
  34. return files
  35. }