11use hyper:: Uri ;
2+ use tonic:: metadata:: AsciiMetadataValue ;
23use tonic:: { transport:: Channel , Status } ;
34
45use super :: replication_log:: rpc:: replication_log_client:: ReplicationLogClient ;
@@ -19,6 +20,11 @@ impl ReplicationLogProxyService {
1920 }
2021}
2122
23+ fn mark_proxied < T > ( mut req : tonic:: Request < T > ) -> tonic:: Request < T > {
24+ req. metadata_mut ( ) . insert ( "libsql-proxied" , AsciiMetadataValue :: from_static ( "true" ) ) ;
25+ req
26+ }
27+
2228#[ tonic:: async_trait]
2329impl ReplicationLog for ReplicationLogProxyService {
2430 type LogEntriesStream = tonic:: codec:: Streaming < Frame > ;
@@ -29,30 +35,30 @@ impl ReplicationLog for ReplicationLogProxyService {
2935 req : tonic:: Request < LogOffset > ,
3036 ) -> Result < tonic:: Response < Self :: LogEntriesStream > , Status > {
3137 let mut client = self . client . clone ( ) ;
32- client. log_entries ( req) . await
38+ client. log_entries ( mark_proxied ( req) ) . await
3339 }
3440
3541 async fn batch_log_entries (
3642 & self ,
3743 req : tonic:: Request < LogOffset > ,
3844 ) -> Result < tonic:: Response < Frames > , Status > {
3945 let mut client = self . client . clone ( ) ;
40- client. batch_log_entries ( req) . await
46+ client. batch_log_entries ( mark_proxied ( req) ) . await
4147 }
4248
4349 async fn hello (
4450 & self ,
4551 req : tonic:: Request < HelloRequest > ,
4652 ) -> Result < tonic:: Response < HelloResponse > , Status > {
4753 let mut client = self . client . clone ( ) ;
48- client. hello ( req) . await
54+ client. hello ( mark_proxied ( req) ) . await
4955 }
5056
5157 async fn snapshot (
5258 & self ,
5359 req : tonic:: Request < LogOffset > ,
5460 ) -> Result < tonic:: Response < Self :: SnapshotStream > , Status > {
5561 let mut client = self . client . clone ( ) ;
56- client. snapshot ( req) . await
62+ client. snapshot ( mark_proxied ( req) ) . await
5763 }
5864}
0 commit comments