Skip to content

Commit

Permalink
✨ sync in storage
Browse files Browse the repository at this point in the history
  • Loading branch information
egorgasay committed Mar 30, 2024
1 parent ac67f5e commit 4f16997
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
2 changes: 1 addition & 1 deletion internal/service/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s Syncer) syncServer(server domains.Server) error {

currentSyncID := s.repo.GetUserChangeID()

if syncID != currentSyncID {
if syncID == currentSyncID {
return nil
}

Expand Down
23 changes: 0 additions & 23 deletions internal/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,29 +376,6 @@ func (s *Storage) GetUserIDByName(username string) (r gost.Result[int]) {
return r.Ok(*find)
}

func (s *Storage) GetUsersFromSyncID(syncID uint64) (r gost.Result[[]models.User]) {
s.users.RLock()
defer s.users.RUnlock()

var find []models.User

s.users.Iter(func(k int, v models.User) (stop bool) {
if v.GetChangeID() < syncID {
find = append(find, v)
}
return false
})

return r.Ok(find)
}

func (s *Storage) GetCurrentSyncID() uint64 {
s.users.RLock()
defer s.users.RUnlock()

return s.users.changeID
}

func (s *Storage) GetUsersFromChangeID(id uint64) gost.Result[[]models.User] {
s.users.RLock()
defer s.users.RUnlock()
Expand Down

0 comments on commit 4f16997

Please sign in to comment.