Skip to content

Commit 87ae8ce

Browse files
xushichangdesmondeaufavor
authored andcommitted
allow proxy to set stream level downstream read timeout
--- Update server.rs Includes-commit: 3bfbd28 Includes-commit: f497a85 Replicated-from: #507
1 parent 67bc7cc commit 87ae8ce

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

.bleep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
34337970fa1741f4348d98c4fcbb96f306f475fb
1+
b1bf525ad94e2b8043250550bb0ae041c7b0a9bd

pingora-core/src/protocols/http/server.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,19 @@ impl Session {
188188
}
189189
}
190190

191+
/// Sets the downstream read timeout. This will trigger if we're unable
192+
/// to read from the stream after `timeout`.
193+
///
194+
/// This is a noop for h2.
195+
pub fn set_read_timeout(&mut self, timeout: Duration) {
196+
match self {
197+
Self::H1(s) => s.set_read_timeout(timeout),
198+
Self::H2(_) => {}
199+
}
200+
}
201+
191202
/// Sets the downstream write timeout. This will trigger if we're unable
192-
/// to write to the stream after `duration`. If a `min_send_rate` is
203+
/// to write to the stream after `timeout`. If a `min_send_rate` is
193204
/// configured then the `min_send_rate` calculated timeout has higher priority.
194205
///
195206
/// This is a noop for h2.
@@ -207,7 +218,7 @@ impl Session {
207218
/// rate must be greater than zero.
208219
///
209220
/// Calculated write timeout is guaranteed to be at least 1s if `min_send_rate`
210-
/// is greater than zero, a send rate of zero is a noop.
221+
/// is greater than zero, a send rate of zero is a noop.x
211222
///
212223
/// This is a noop for h2.
213224
pub fn set_min_send_rate(&mut self, rate: usize) {

pingora-core/src/protocols/http/v1/server.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,14 @@ impl HttpSession {
837837
}
838838
}
839839

840+
/// Sets the downstream read timeout. This will trigger if we're unable
841+
/// to read from the stream after `timeout`.
842+
pub fn set_read_timeout(&mut self, timeout: Duration) {
843+
self.read_timeout = Some(timeout);
844+
}
845+
840846
/// Sets the downstream write timeout. This will trigger if we're unable
841-
/// to write to the stream after `duration`. If a `min_send_rate` is
847+
/// to write to the stream after `timeout`. If a `min_send_rate` is
842848
/// configured then the `min_send_rate` calculated timeout has higher priority.
843849
pub fn set_write_timeout(&mut self, timeout: Duration) {
844850
self.write_timeout = Some(timeout);

0 commit comments

Comments
 (0)