@@ -41,6 +41,7 @@ use crate::heartbeat::{HeartbeatData, HeartbeatKey, HeartbeatValue, HeartbeatsCa
4141use crate :: subscription:: {
4242 SubscriptionData , SubscriptionMachine , SubscriptionMachineState , SubscriptionStatsCounters
4343} ;
44+ use crate :: database:: schema:: redis:: v1:: subscription:: * ;
4445use futures_util:: stream:: StreamExt ;
4546
4647use super :: schema:: { Migration , MigrationBase , Version } ;
@@ -440,11 +441,11 @@ impl Database for RedisDatabase {
440441 let mut subscriptions = Vec :: new ( ) ;
441442
442443 for key in keys {
443- let subscription_json : Option < String > = conn. get ( & key) . await . context ( "Failed to get subscription data" ) ?;
444+ let subscription_redis_data : Option < String > = conn. get ( & key) . await . context ( "Failed to get subscription data" ) ?;
444445
445- if let Some ( subscription_json ) = subscription_json {
446- match serde_json:: from_str :: < SubscriptionData > ( & subscription_json ) {
447- Ok ( subscription) => subscriptions. push ( subscription) ,
446+ if let Some ( subscription_redis_data ) = subscription_redis_data {
447+ match serde_json:: from_str :: < SubscriptionRedisData > ( & subscription_redis_data ) {
448+ Ok ( subscription) => subscriptions. push ( subscription. into_subscription_data ( ) ) ,
448449 Err ( err) => {
449450 log:: warn!( "Failed to deserialize subscription data for key {}: {}" , key, err) ;
450451 }
@@ -473,8 +474,8 @@ impl Database for RedisDatabase {
473474 if !filtered. is_empty ( ) {
474475 let result: Option < String > = conn. get ( & filtered[ 0 ] ) . await . context ( "Failed to get subscription data" ) ?;
475476 if result. is_some ( ) {
476- let subscription : SubscriptionData = serde_json:: from_str ( & result. unwrap ( ) ) . context ( "Failed to deserialize subscription data" ) ?;
477- return Ok ( Some ( subscription ) ) ;
477+ let subscription_redis_data : SubscriptionRedisData = serde_json:: from_str ( & result. unwrap ( ) ) . context ( "Failed to deserialize subscription data" ) ?;
478+ return Ok ( Some ( subscription_redis_data . into_subscription_data ( ) ) ) ;
478479 }
479480 }
480481 Ok ( None )
@@ -489,8 +490,11 @@ impl Database for RedisDatabase {
489490 let _: ( ) = conn. del ( keys) . await ?;
490491 }
491492
493+
494+ let subscription_redis_data = SubscriptionRedisData :: from_subscription_data ( subscription) ;
495+
492496 let key = format ! ( "{}:{}:{}" , RedisDomain :: Subscription , subscription. uuid( ) . to_string( ) . to_uppercase( ) , subscription. name( ) ) ;
493- let value = serde_json:: to_string ( subscription ) . context ( "Failed to serialize subscription data" ) ?;
497+ let value = serde_json:: to_string ( & subscription_redis_data ) . context ( "Failed to serialize subscription data" ) ?;
494498 let _ : String = conn. set ( key, value) . await . context ( "Failed to store subscription data" ) ?;
495499 Ok ( ( ) )
496500 }
0 commit comments