Lock room creation to ensure atomic creation & node assignment (#46)

* Lock room creation to ensure atomic creation & node assignment

* more tests
This commit is contained in:
David Zhao
2021-07-12 14:50:14 -07:00
committed by GitHub
parent c0bff83a36
commit d38fc43b89
9 changed files with 287 additions and 7 deletions
+12
View File
@@ -16,6 +16,7 @@ type LocalRoomStore struct {
// map of roomName => { identity: participant }
participants map[string]map[string]*livekit.ParticipantInfo
lock sync.RWMutex
globalLock sync.Mutex
}
func NewLocalRoomStore() *LocalRoomStore {
@@ -80,6 +81,17 @@ func (p *LocalRoomStore) DeleteRoom(idOrName string) error {
return nil
}
func (p *LocalRoomStore) LockRoom(name string, duration time.Duration) (string, error) {
// local rooms lock & unlock globally
p.globalLock.Lock()
return "", nil
}
func (p *LocalRoomStore) UnlockRoom(name string, uid string) error {
p.globalLock.Unlock()
return nil
}
func (p *LocalRoomStore) PersistParticipant(roomName string, participant *livekit.ParticipantInfo) error {
p.lock.Lock()
defer p.lock.Unlock()