Merge branch 'harlow:master' into main

This commit is contained in:
Alex 2025-01-16 10:23:20 +01:00 committed by GitHub
commit 87842eb384
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -393,32 +393,22 @@ func isShardClosed(nextShardIterator, currentShardIterator *string) bool {
} }
type shards struct { type shards struct {
*sync.RWMutex shardsInProcess sync.Map
shardsInProcess map[string]struct{}
} }
func newShardsInProcess() *shards { func newShardsInProcess() *shards {
return &shards{ return &shards{}
RWMutex: &sync.RWMutex{},
shardsInProcess: make(map[string]struct{}),
}
} }
func (s *shards) addShard(shardId string) { func (s *shards) addShard(shardId string) {
s.Lock() s.shardsInProcess.Store(shardId, struct{}{})
defer s.Unlock()
s.shardsInProcess[shardId] = struct{}{}
} }
func (s *shards) doesShardExist(shardId string) bool { func (s *shards) doesShardExist(shardId string) bool {
s.RLock() _, ok := s.shardsInProcess.Load(shardId)
defer s.RUnlock()
_, ok := s.shardsInProcess[shardId]
return ok return ok
} }
func (s *shards) deleteShard(shardId string) { func (s *shards) deleteShard(shardId string) {
s.Lock() s.shardsInProcess.Delete(shardId)
defer s.Unlock()
delete(s.shardsInProcess, shardId)
} }