Struct qiniu_http_client::ChooserFeedback
source · pub struct ChooserFeedback<'f> { /* private fields */ }
Expand description
选择器反馈
用以修正选择器的选择逻辑,优化选择结果
Implementations§
source§impl<'f> ChooserFeedback<'f>
impl<'f> ChooserFeedback<'f>
sourcepub fn builder(ips: &'f [IpAddrWithPort]) -> ChooserFeedbackBuilder<'f>
pub fn builder(ips: &'f [IpAddrWithPort]) -> ChooserFeedbackBuilder<'f>
创建选择器反馈构建器
Examples found in repository?
src/client/call/try_domain_or_ip_addr.rs (line 92)
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
fn make_positive_feedback<'f>(
ips: &'f [IpAddrWithPort],
domain: Option<&'f DomainWithPort>,
parts: &'f mut HttpRequestParts,
metrics: Option<&'f Metrics>,
retried: &'f RetriedStatsInfo,
) -> ChooserFeedback<'f> {
let mut builder = ChooserFeedback::builder(ips);
builder.retried(retried).extensions(parts.extensions_mut());
if let Some(domain) = domain {
builder.domain(domain);
}
if let Some(metrics) = metrics {
builder.metrics(metrics);
}
builder.build()
}
fn make_negative_feedback<'f>(
ips: &'f [IpAddrWithPort],
domain: Option<&'f DomainWithPort>,
parts: &'f mut HttpRequestParts,
err: &'f TryError,
retried: &'f RetriedStatsInfo,
) -> ChooserFeedback<'f> {
let mut builder = ChooserFeedback::builder(ips);
builder.retried(retried).extensions(parts.extensions_mut());
if let Some(domain) = domain {
builder.domain(domain);
}
if let Some(metrics) = err.response_error().metrics() {
builder.metrics(metrics);
}
if let Some(error) = err.feedback_response_error() {
builder.error(error);
}
builder.build()
}
sourcepub fn ips(&'f self) -> &'f [IpAddrWithPort]
pub fn ips(&'f self) -> &'f [IpAddrWithPort]
获取 IP 地址列表
Examples found in repository?
src/client/chooser/ip.rs (line 106)
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn feedback(&self, feedback: ChooserFeedback) {
if feedback.error().is_some() {
for &ip in feedback.ips().iter() {
self.inner.blacklist.insert(
BlacklistKey {
ip,
domain: feedback.domain().cloned(),
},
BlacklistValue {
blocked_at: Instant::now(),
},
);
}
} else {
for &ip in feedback.ips().iter() {
self.inner.blacklist.remove(&BlacklistKey {
ip,
domain: feedback.domain().cloned(),
});
}
}
}
More examples
src/client/chooser/subnet.rs (line 138)
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
fn feedback(&self, feedback: ChooserFeedback) {
if feedback.error().is_some() {
for &ip in feedback.ips().iter() {
self.inner.blacklist.insert(
BlacklistKey {
ip,
domain: feedback.domain().cloned(),
},
BlacklistValue {
blocked_at: Instant::now(),
},
);
}
} else {
for &ip in feedback.ips().iter() {
self.inner.blacklist.remove(&BlacklistKey {
ip,
domain: feedback.domain().cloned(),
});
}
}
}
sourcepub fn domain(&'f self) -> Option<&'f DomainWithPort>
pub fn domain(&'f self) -> Option<&'f DomainWithPort>
获取域名
如果不存在域名的话,则返回 None
Examples found in repository?
src/client/chooser/ip.rs (line 110)
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn feedback(&self, feedback: ChooserFeedback) {
if feedback.error().is_some() {
for &ip in feedback.ips().iter() {
self.inner.blacklist.insert(
BlacklistKey {
ip,
domain: feedback.domain().cloned(),
},
BlacklistValue {
blocked_at: Instant::now(),
},
);
}
} else {
for &ip in feedback.ips().iter() {
self.inner.blacklist.remove(&BlacklistKey {
ip,
domain: feedback.domain().cloned(),
});
}
}
}
More examples
src/client/chooser/subnet.rs (line 142)
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
fn feedback(&self, feedback: ChooserFeedback) {
if feedback.error().is_some() {
for &ip in feedback.ips().iter() {
self.inner.blacklist.insert(
BlacklistKey {
ip,
domain: feedback.domain().cloned(),
},
BlacklistValue {
blocked_at: Instant::now(),
},
);
}
} else {
for &ip in feedback.ips().iter() {
self.inner.blacklist.remove(&BlacklistKey {
ip,
domain: feedback.domain().cloned(),
});
}
}
}
sourcepub fn retried(&'f self) -> &'f RetriedStatsInfo
pub fn retried(&'f self) -> &'f RetriedStatsInfo
获取重试统计信息
sourcepub fn extensions(&'f self) -> &'f Extensions
pub fn extensions(&'f self) -> &'f Extensions
获取扩展信息
sourcepub fn extensions_mut(&'f mut self) -> &'f mut Extensions
pub fn extensions_mut(&'f mut self) -> &'f mut Extensions
获取扩展信息的可变引用
sourcepub fn error(&'f self) -> Option<&'f ResponseError>
pub fn error(&'f self) -> Option<&'f ResponseError>
获取 HTTP 响应错误
Examples found in repository?
src/client/chooser/ip.rs (line 105)
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
fn feedback(&self, feedback: ChooserFeedback) {
if feedback.error().is_some() {
for &ip in feedback.ips().iter() {
self.inner.blacklist.insert(
BlacklistKey {
ip,
domain: feedback.domain().cloned(),
},
BlacklistValue {
blocked_at: Instant::now(),
},
);
}
} else {
for &ip in feedback.ips().iter() {
self.inner.blacklist.remove(&BlacklistKey {
ip,
domain: feedback.domain().cloned(),
});
}
}
}
More examples
src/client/chooser/subnet.rs (line 137)
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
fn feedback(&self, feedback: ChooserFeedback) {
if feedback.error().is_some() {
for &ip in feedback.ips().iter() {
self.inner.blacklist.insert(
BlacklistKey {
ip,
domain: feedback.domain().cloned(),
},
BlacklistValue {
blocked_at: Instant::now(),
},
);
}
} else {
for &ip in feedback.ips().iter() {
self.inner.blacklist.remove(&BlacklistKey {
ip,
domain: feedback.domain().cloned(),
});
}
}
}
Trait Implementations§
Auto Trait Implementations§
impl<'f> !RefUnwindSafe for ChooserFeedback<'f>
impl<'f> Send for ChooserFeedback<'f>
impl<'f> Sync for ChooserFeedback<'f>
impl<'f> Unpin for ChooserFeedback<'f>
impl<'f> !UnwindSafe for ChooserFeedback<'f>
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Borrows
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Immutable access to the
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Mutable access to the
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Immutable access to the
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Mutable access to the
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Immutable access to the
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Mutable access to the
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.