Cache data synchronously for processing in worker. (#2424)

It is possible that state of underlying object has changed between
event posting and event processing. So, cache data synchronously
and use it during event processing.

This is still not perfect as things like `hidden` and `IsClosed` is
accessed in worker. Ideally, it can be a snapshot of current state of
all required values that can be posted to the worker and the worker just
operates with data.
This commit is contained in:
Raja Subramanian
2024-01-29 10:57:41 +05:30
committed by GitHub
parent 134b6f05b4
commit efbc985c82
3 changed files with 57 additions and 37 deletions
+4 -4
View File
@@ -577,10 +577,10 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room
}
})
newRoom.OnParticipantChanged(func(p types.LocalParticipant) {
if !p.IsDisconnected() {
if err := r.roomStore.StoreParticipant(ctx, roomName, p.ToProto()); err != nil {
newRoom.Logger.Errorw("could not handle participant change", err)
newRoom.OnParticipantChanged(func(p types.LocalParticipant, pi *livekit.ParticipantInfo) {
if pi.State != livekit.ParticipantInfo_DISCONNECTED {
if err := r.roomStore.StoreParticipant(ctx, roomName, pi); err != nil {
p.GetLogger().Errorw("could not handle participant change", err)
}
}
})