File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: error:: StreamError ;
2
2
use crate :: model:: AwarenessStreamUpdate ;
3
+ use dashmap:: mapref:: entry:: Entry ;
3
4
use dashmap:: DashMap ;
4
5
use redis:: aio:: MultiplexedConnection ;
5
6
use redis:: { AsyncCommands , Client , RedisError , Value } ;
@@ -64,21 +65,18 @@ impl AwarenessGossip {
64
65
awareness_update : AwarenessStreamUpdate ,
65
66
) {
66
67
// try new per-workspace awareness stream
67
- if let Some ( channel ) = workspaces. get ( & workspace_id) {
68
- let channel = channel . value ( ) ;
68
+ if let Entry :: Occupied ( e ) = workspaces. entry ( workspace_id) {
69
+ let channel = e . get ( ) ;
69
70
if channel. send ( ( object_id, awareness_update) ) . is_err ( ) {
70
- workspaces . remove ( & workspace_id ) ;
71
+ e . remove ( ) ;
71
72
}
72
73
} else {
73
74
// fallback to per-collab awareness stream
74
- let dropped = if let Some ( channel) = collabs. get ( & object_id) {
75
- let channel = channel. value ( ) ;
76
- channel. send ( awareness_update) . is_err ( )
77
- } else {
78
- false
79
- } ;
80
- if dropped {
81
- collabs. remove ( & object_id) ;
75
+ if let Entry :: Occupied ( e) = collabs. entry ( object_id) {
76
+ let channel = e. get ( ) ;
77
+ if channel. send ( awareness_update) . is_err ( ) {
78
+ collabs. remove ( & object_id) ;
79
+ }
82
80
}
83
81
}
84
82
}
You can’t perform that action at this time.
0 commit comments