mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Review comments
This commit is contained in:
parent
aec550f9b4
commit
cc95ebe1e4
@ -8,6 +8,7 @@ import (
|
|||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"github.com/ReneKroon/ttlcache/v2"
|
"github.com/ReneKroon/ttlcache/v2"
|
||||||
|
"github.com/matrix-org/sliding-sync/internal"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -169,6 +170,7 @@ func (m *ConnMap) CloseConnsForDevice(userID, deviceID string) {
|
|||||||
err := m.cache.Remove(cid.String()) // this will fire TTL callbacks which calls closeConn
|
err := m.cache.Remove(cid.String()) // this will fire TTL callbacks which calls closeConn
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Err(err).Str("cid", cid.String()).Msg("CloseConnsForDevice: cid did not exist in ttlcache")
|
logger.Err(err).Str("cid", cid.String()).Msg("CloseConnsForDevice: cid did not exist in ttlcache")
|
||||||
|
internal.GetSentryHubFromContextOrDefault(context.Background()).CaptureException(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,6 +201,7 @@ func (m *ConnMap) CloseConnsForUsers(userIDs []string) (closed int) {
|
|||||||
err := m.cache.Remove(conn.String()) // this will fire TTL callbacks which calls closeConn
|
err := m.cache.Remove(conn.String()) // this will fire TTL callbacks which calls closeConn
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Err(err).Str("cid", conn.String()).Msg("CloseConnsForDevice: cid did not exist in ttlcache")
|
logger.Err(err).Str("cid", conn.String()).Msg("CloseConnsForDevice: cid did not exist in ttlcache")
|
||||||
|
internal.GetSentryHubFromContextOrDefault(context.Background()).CaptureException(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closed += len(conns)
|
closed += len(conns)
|
||||||
|
@ -87,7 +87,7 @@ func TestConnMap_CloseConnsForUser(t *testing.T) {
|
|||||||
time.Sleep(100 * time.Millisecond) // some stuff happens asyncly in goroutines
|
time.Sleep(100 * time.Millisecond) // some stuff happens asyncly in goroutines
|
||||||
must.Equal(t, num, 6, "unexpected number of closed conns")
|
must.Equal(t, num, 6, "unexpected number of closed conns")
|
||||||
|
|
||||||
// Destroy should have been called for all alice|A connections
|
// Destroy should have been called for all alice connections
|
||||||
assertDestroyedConns(t, cidToConn, func(cid ConnID) bool {
|
assertDestroyedConns(t, cidToConn, func(cid ConnID) bool {
|
||||||
return cid.UserID == alice
|
return cid.UserID == alice
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user