@@ -34,7 +34,6 @@ use crate::{
3434 utils:: RedisConnections ,
3535} ;
3636use async_trait:: async_trait;
37- use deadpool_redis:: Pool ;
3837use std:: sync:: Arc ;
3938
4039#[ async_trait]
@@ -68,19 +67,6 @@ pub trait RelayerRepository: Repository<RelayerRepoModel, String> + Send + Sync
6867 /// Returns true if this repository uses persistent storage (e.g., Redis).
6968 /// Returns false for in-memory storage.
7069 fn is_persistent_storage ( & self ) -> bool ;
71-
72- /// Returns connection info for distributed operations.
73- ///
74- /// This method provides access to the underlying connection and key prefix
75- /// when using persistent storage. This is useful for distributed locking and
76- /// other coordination operations that need direct storage access.
77- ///
78- /// # Returns
79- /// * `Some((pool, prefix))` - If using persistent storage (e.g., Redis)
80- /// * `None` - If using in-memory storage (default)
81- fn connection_info ( & self ) -> Option < ( Arc < Pool > , String ) > {
82- None
83- }
8470}
8571
8672#[ cfg( test) ]
@@ -110,7 +96,6 @@ mockall::mock! {
11096 async fn disable_relayer( & self , relayer_id: String , reason: DisabledReason ) -> Result <RelayerRepoModel , RepositoryError >;
11197 async fn update_policy( & self , id: String , policy: RelayerNetworkPolicy ) -> Result <RelayerRepoModel , RepositoryError >;
11298 fn is_persistent_storage( & self ) -> bool ;
113- fn connection_info( & self ) -> Option <( Arc <Pool >, String ) >;
11499 }
115100}
116101
@@ -135,24 +120,6 @@ impl RelayerRepositoryStorage {
135120 key_prefix,
136121 ) ?) )
137122 }
138-
139- /// Returns connection info for distributed operations.
140- ///
141- /// This method provides access to the underlying Redis connection and key prefix
142- /// when using Redis-backed storage. This is useful for distributed locking and
143- /// other coordination operations that need direct Redis access.
144- ///
145- /// # Returns
146- /// * `Some((pool, prefix))` - If using persistent storage (e.g., Redis)
147- /// * `None` - If using in-memory storage
148- pub fn connection_info ( & self ) -> Option < ( Arc < Pool > , String ) > {
149- match self {
150- RelayerRepositoryStorage :: InMemory ( _) => None ,
151- RelayerRepositoryStorage :: Redis ( repo) => {
152- Some ( ( repo. connections . primary ( ) . clone ( ) , repo. key_prefix . clone ( ) ) )
153- }
154- }
155- }
156123}
157124
158125impl Default for RelayerRepositoryStorage {
@@ -318,15 +285,6 @@ impl RelayerRepository for RelayerRepositoryStorage {
318285 RelayerRepositoryStorage :: Redis ( _) => true ,
319286 }
320287 }
321-
322- fn connection_info ( & self ) -> Option < ( Arc < Pool > , String ) > {
323- match self {
324- RelayerRepositoryStorage :: InMemory ( _) => None ,
325- RelayerRepositoryStorage :: Redis ( repo) => {
326- Some ( ( repo. connections . primary ( ) . clone ( ) , repo. key_prefix . clone ( ) ) )
327- }
328- }
329- }
330288}
331289
332290#[ cfg( test) ]
@@ -541,38 +499,4 @@ mod tests {
541499 repo. drop_all_entries ( ) . await . unwrap ( ) ;
542500 assert ! ( !repo. has_entries( ) . await . unwrap( ) ) ;
543501 }
544-
545- #[ tokio:: test]
546- async fn test_connection_info_returns_none_for_in_memory ( ) {
547- let storage = RelayerRepositoryStorage :: new_in_memory ( ) ;
548-
549- // In-memory storage should return None for connection_info
550- assert ! ( storage. connection_info( ) . is_none( ) ) ;
551- }
552-
553- #[ tokio:: test]
554- async fn test_is_persistent_storage_returns_false_for_in_memory ( ) {
555- let storage = RelayerRepositoryStorage :: new_in_memory ( ) ;
556-
557- // In-memory storage should return false for is_persistent_storage
558- assert ! ( !storage. is_persistent_storage( ) ) ;
559- }
560-
561- #[ tokio:: test]
562- async fn test_trait_connection_info_returns_none_for_in_memory ( ) {
563- let storage = RelayerRepositoryStorage :: new_in_memory ( ) ;
564-
565- // Test the RelayerRepository trait's connection_info method
566- let trait_ref: & dyn RelayerRepository = & storage;
567- assert ! ( trait_ref. connection_info( ) . is_none( ) ) ;
568- }
569-
570- #[ tokio:: test]
571- async fn test_struct_connection_info_returns_none_for_in_memory ( ) {
572- let storage = RelayerRepositoryStorage :: new_in_memory ( ) ;
573-
574- // Test the struct's own connection_info method
575- let result: Option < ( Arc < Pool > , String ) > = storage. connection_info ( ) ;
576- assert ! ( result. is_none( ) ) ;
577- }
578502}
0 commit comments