Move ConcurrentMap to container package.

This commit is contained in:
Joachim Bauch 2025-12-10 16:31:29 +01:00
commit f1a719cb23
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
3 changed files with 8 additions and 7 deletions

View file

@ -427,7 +427,7 @@ func (b *BackendServer) sendRoomUpdate(roomid string, backend *Backend, notified
}
}
func (b *BackendServer) lookupByRoomSessionId(ctx context.Context, roomSessionId RoomSessionId, cache *ConcurrentMap[RoomSessionId, PublicSessionId]) (PublicSessionId, error) {
func (b *BackendServer) lookupByRoomSessionId(ctx context.Context, roomSessionId RoomSessionId, cache *container.ConcurrentMap[RoomSessionId, PublicSessionId]) (PublicSessionId, error) {
if roomSessionId == sessionIdNotInMeeting {
b.logger.Printf("Trying to lookup empty room session id: %s", roomSessionId)
return "", nil
@ -452,7 +452,7 @@ func (b *BackendServer) lookupByRoomSessionId(ctx context.Context, roomSessionId
return sid, nil
}
func (b *BackendServer) fixupUserSessions(ctx context.Context, cache *ConcurrentMap[RoomSessionId, PublicSessionId], users []api.StringMap) []api.StringMap {
func (b *BackendServer) fixupUserSessions(ctx context.Context, cache *container.ConcurrentMap[RoomSessionId, PublicSessionId], users []api.StringMap) []api.StringMap {
if len(users) == 0 {
return users
}
@ -504,7 +504,7 @@ func (b *BackendServer) sendRoomIncall(roomid string, backend *Backend, request
ctx := log.NewLoggerContext(context.Background(), b.logger)
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
var cache ConcurrentMap[RoomSessionId, PublicSessionId]
var cache container.ConcurrentMap[RoomSessionId, PublicSessionId]
// Convert (Nextcloud) session ids to signaling session ids.
request.InCall.Users = b.fixupUserSessions(ctx, &cache, request.InCall.Users)
// Entries in "Changed" are most likely already fetched through the "Users" list.
@ -528,7 +528,7 @@ func (b *BackendServer) sendRoomParticipantsUpdate(ctx context.Context, roomid s
// Convert (Nextcloud) session ids to signaling session ids.
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
var cache ConcurrentMap[RoomSessionId, PublicSessionId]
var cache container.ConcurrentMap[RoomSessionId, PublicSessionId]
request.Participants.Users = b.fixupUserSessions(ctx, &cache, request.Participants.Users)
request.Participants.Changed = b.fixupUserSessions(ctx, &cache, request.Participants.Changed)

View file

@ -19,7 +19,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package signaling
package container
import (
"sync"

View file

@ -19,9 +19,10 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package signaling
package container
import (
"crypto/rand"
"strconv"
"sync"
"testing"
@ -83,7 +84,7 @@ func TestConcurrentStringStringMap(t *testing.T) {
defer wg.Done()
key := "key-" + strconv.Itoa(x)
rnd := newRandomString(32)
rnd := rand.Text()
for y := range count {
value := rnd + "-" + strconv.Itoa(y)
m.Set(key, value)