chiark / gitweb /
server: wip plumbing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 Aug 2021 21:01:27 +0000 (22:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 15 Aug 2021 21:01:27 +0000 (22:01 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bin/server.rs

index 9446b583825acf79f06d656381aaacf8d52f3822..65b7e489e7182da08b514e3e6961f231b2ee4312 100644 (file)
@@ -24,6 +24,7 @@ struct ClientHandles {
 
 /// Sent from hyper worker pool task to client task
 #[allow(dead_code)] // xxx
+#[derive(Debug)]
 struct WebRequest {
   // initial part of body
   // used up to and including first 2 lines of metadata
@@ -39,6 +40,7 @@ struct WebRequest {
 
 /// Reply from client task to hyper worker pool task
 #[allow(dead_code)] // xxx
+#[derive(Debug)]
 struct WebResponse {
   warnings: Warnings,
   data: Result<WebResponseData, AE>,
@@ -222,7 +224,7 @@ async fn run_client(ic: Arc<InstanceConfig>,
 {
   struct Outstanding {
     reply_to: tokio::sync::oneshot::Sender<WebResponse>,
-    max_requests_outstanding: u32,
+    target_requests_outstanding: u32,
   }
   let mut outstanding: VecDeque<Outstanding> = default();
   let  downbound: VecDeque<(/*xxx*/)> = default();
@@ -240,7 +242,7 @@ async fn run_client(ic: Arc<InstanceConfig>,
       if ! downbound.is_empty() {
         outstanding.pop_front()
       } else if let Some((i,_)) = outstanding.iter().enumerate().find({
-        |(_,o)| outstanding.len() > o.max_requests_outstanding.sat()
+        |(_,o)| outstanding.len() > o.target_requests_outstanding.sat()
       }) {
         Some(outstanding.remove(i).unwrap())
       } else {
@@ -252,6 +254,7 @@ async fn run_client(ic: Arc<InstanceConfig>,
         warnings: default(),
       };
 
+      dbg!(&response);
       try_send_response(ret.reply_to, response);
     }
 
@@ -329,12 +332,14 @@ async fn run_client(ic: Arc<InstanceConfig>,
             dbg!(comp.name, DumpHex(comp.payload));
           }
 
-          Ok::<_,AE>(())
+          Ok::<_,AE>(target_requests_outstanding)
         }.await {
-          Ok(()) => outstanding.push_back(Outstanding {
-            reply_to: reply_to,
-            max_requests_outstanding: 42, // xxx
-          }),
+          Ok(target_requests_outstanding) => {
+            outstanding.push_back(Outstanding {
+              reply_to,
+              target_requests_outstanding,
+            });
+          },
           Err(e) => {
             try_send_response(reply_to, WebResponse {
               data: Err(e),