@@ -28,6 +28,7 @@ use utils::auth::AuthConfig;
2828#[ cfg( not( target_family = "wasm" ) ) ]
2929use utils:: singleflight:: Group ;
3030
31+ use crate :: adaptive_concurrency_control:: ConnectionPermit ;
3132#[ cfg( not( target_family = "wasm" ) ) ]
3233use crate :: download_utils:: * ;
3334use crate :: error:: { CasClientError , Result } ;
@@ -596,11 +597,12 @@ impl Client for RemoteClient {
596597 #[ instrument( skip_all, name = "RemoteClient::upload_xorb" , fields( key = Key { prefix : prefix. to_string( ) , hash : serialized_cas_object. hash} . to_string( ) ,
597598 xorb. len = serialized_cas_object. serialized_data. len( ) , xorb. num_chunks = serialized_cas_object. num_chunks
598599 ) ) ]
599- async fn upload_xorb (
600+ async fn upload_xorb_with_permit (
600601 & self ,
601602 prefix : & str ,
602603 serialized_cas_object : SerializedCasObject ,
603604 upload_tracker : Option < Arc < CompletionTracker > > ,
605+ upload_permit : ConnectionPermit ,
604606 ) -> Result < u64 > {
605607 let key = Key {
606608 prefix : prefix. to_string ( ) ,
@@ -639,6 +641,7 @@ impl Client for RemoteClient {
639641 let api_tag = "cas::upload_xorb" ;
640642
641643 let response: UploadXorbResponse = RetryWrapper :: new ( api_tag)
644+ . with_connection_permit ( upload_permit)
642645 . run_and_extract_json ( move || {
643646 let upload_stream = upload_stream. clone_with_reset ( ) ;
644647 let url = url. clone ( ) ;
@@ -773,13 +776,14 @@ impl Client for RemoteClient {
773776
774777 #[ instrument( skip_all, name = "RemoteClient::upload_shard" , fields( shard. hash = hash. hex( ) , shard. len = shard_data. len( )
775778 ) ) ]
776- async fn upload_shard (
779+ async fn upload_shard_with_permit (
777780 & self ,
778781 prefix : & str ,
779782 hash : & MerkleHash ,
780783 force_sync : bool ,
781784 shard_data : bytes:: Bytes ,
782785 _salt : & [ u8 ; 32 ] ,
786+ upload_permit : ConnectionPermit ,
783787 ) -> Result < bool > {
784788 if self . dry_run {
785789 return Ok ( true ) ;
@@ -801,6 +805,7 @@ impl Client for RemoteClient {
801805 let url = Url :: parse ( & format ! ( "{}/shard/{key}" , self . endpoint) ) ?;
802806
803807 let response: UploadShardResponse = RetryWrapper :: new ( api_tag)
808+ . with_connection_permit ( upload_permit)
804809 . run_and_extract_json ( move || {
805810 client
806811 . request ( method. clone ( ) , url. clone ( ) )
0 commit comments