@@ -23,8 +23,8 @@ use crate::worker_metrics::WORKER_METRICS;
23
23
use parking_lot:: RwLock ;
24
24
use prometheus:: IntGauge ;
25
25
use spacetimedb_client_api_messages:: websocket:: {
26
- self as ws, BsatnFormat , Compression , FormatSwitch , JsonFormat , SubscribeMulti , SubscribeSingle , TableUpdate ,
27
- Unsubscribe , UnsubscribeMulti ,
26
+ self as ws, BsatnFormat , FormatSwitch , JsonFormat , SubscribeMulti , SubscribeSingle , TableUpdate , Unsubscribe ,
27
+ UnsubscribeMulti ,
28
28
} ;
29
29
use spacetimedb_execution:: pipelined:: PipelinedProject ;
30
30
use spacetimedb_expr:: check:: parse_and_type_sub;
@@ -186,34 +186,10 @@ impl ModuleSubscriptions {
186
186
let tx = DeltaTx :: from ( tx) ;
187
187
188
188
Ok ( match sender. config . protocol {
189
- Protocol :: Binary => {
190
- collect_table_update (
191
- & plans,
192
- table_id,
193
- table_name. into ( ) ,
194
- // We will compress the outer server message,
195
- // after we release the tx lock.
196
- // There's no need to compress the inner table update too.
197
- Compression :: None ,
198
- & tx,
199
- update_type,
200
- )
201
- . map ( |( table_update, metrics) | ( FormatSwitch :: Bsatn ( table_update) , metrics) )
202
- }
203
- Protocol :: Text => {
204
- collect_table_update (
205
- & plans,
206
- table_id,
207
- table_name. into ( ) ,
208
- // We will compress the outer server message,
209
- // after we release the tx lock,
210
- // There's no need to compress the inner table update too.
211
- Compression :: None ,
212
- & tx,
213
- update_type,
214
- )
215
- . map ( |( table_update, metrics) | ( FormatSwitch :: Json ( table_update) , metrics) )
216
- }
189
+ Protocol :: Binary => collect_table_update ( & plans, table_id, table_name. into ( ) , & tx, update_type)
190
+ . map ( |( table_update, metrics) | ( FormatSwitch :: Bsatn ( table_update) , metrics) ) ,
191
+ Protocol :: Text => collect_table_update ( & plans, table_id, table_name. into ( ) , & tx, update_type)
192
+ . map ( |( table_update, metrics) | ( FormatSwitch :: Json ( table_update) , metrics) ) ,
217
193
} ?)
218
194
}
219
195
@@ -240,27 +216,11 @@ impl ModuleSubscriptions {
240
216
let tx = DeltaTx :: from ( tx) ;
241
217
match sender. config . protocol {
242
218
Protocol :: Binary => {
243
- let ( update, metrics) = execute_plans (
244
- queries,
245
- // We will compress the outer server message,
246
- // after we release the tx lock.
247
- // There's no need to compress the inner table updates too.
248
- Compression :: None ,
249
- & tx,
250
- update_type,
251
- ) ?;
219
+ let ( update, metrics) = execute_plans ( queries, & tx, update_type) ?;
252
220
Ok ( ( FormatSwitch :: Bsatn ( update) , metrics) )
253
221
}
254
222
Protocol :: Text => {
255
- let ( update, metrics) = execute_plans (
256
- queries,
257
- // We will compress the outer server message,
258
- // after we release the tx lock.
259
- // There's no need to compress the inner table updates too.
260
- Compression :: None ,
261
- & tx,
262
- update_type,
263
- ) ?;
223
+ let ( update, metrics) = execute_plans ( queries, & tx, update_type) ?;
264
224
Ok ( ( FormatSwitch :: Json ( update) , metrics) )
265
225
}
266
226
}
@@ -650,26 +610,10 @@ impl ModuleSubscriptions {
650
610
651
611
let tx = DeltaTx :: from ( & * tx) ;
652
612
let ( database_update, metrics) = match sender. config . protocol {
653
- Protocol :: Binary => execute_plans (
654
- & queries,
655
- // We will compress the outer server message,
656
- // after we release the tx lock.
657
- // There's no need to compress the inner table updates too.
658
- Compression :: None ,
659
- & tx,
660
- TableUpdateType :: Subscribe ,
661
- )
662
- . map ( |( table_update, metrics) | ( FormatSwitch :: Bsatn ( table_update) , metrics) ) ?,
663
- Protocol :: Text => execute_plans (
664
- & queries,
665
- // We will compress the outer server message,
666
- // after we release the tx lock.
667
- // There's no need to compress the inner table updates too.
668
- Compression :: None ,
669
- & tx,
670
- TableUpdateType :: Subscribe ,
671
- )
672
- . map ( |( table_update, metrics) | ( FormatSwitch :: Json ( table_update) , metrics) ) ?,
613
+ Protocol :: Binary => execute_plans ( & queries, & tx, TableUpdateType :: Subscribe )
614
+ . map ( |( table_update, metrics) | ( FormatSwitch :: Bsatn ( table_update) , metrics) ) ?,
615
+ Protocol :: Text => execute_plans ( & queries, & tx, TableUpdateType :: Subscribe )
616
+ . map ( |( table_update, metrics) | ( FormatSwitch :: Json ( table_update) , metrics) ) ?,
673
617
} ;
674
618
675
619
record_exec_metrics (
0 commit comments