@@ -20,12 +20,13 @@ use buck2_common::file_ops::TrackedFileDigest;
20
20
use buck2_common:: http:: counting_client:: CountingHttpClient ;
21
21
use buck2_common:: http:: retries:: http_retry;
22
22
use buck2_common:: http:: retries:: AsHttpError ;
23
+ use buck2_common:: http:: retries:: DispatchableHttpRetryWarning ;
23
24
use buck2_common:: http:: retries:: HttpError ;
24
- use buck2_common:: http:: retries:: NoopDispatchableHttpRetryWarning ;
25
25
use buck2_common:: http:: HttpClient ;
26
26
use buck2_core:: fs:: fs_util;
27
27
use buck2_core:: fs:: project:: ProjectRoot ;
28
28
use buck2_core:: fs:: project_rel_path:: ProjectRelativePath ;
29
+ use buck2_data:: HttpRequestRetried ;
29
30
use bytes:: Bytes ;
30
31
use digest:: DynDigest ;
31
32
use dupe:: Dupe ;
@@ -100,10 +101,36 @@ impl AsHttpError for HttpDownloadError {
100
101
}
101
102
}
102
103
104
+ struct MaterializerDispatchableHttpRetryWarning { }
105
+
106
+ impl MaterializerDispatchableHttpRetryWarning {
107
+ fn new ( ) -> Self {
108
+ Self { }
109
+ }
110
+ }
111
+
112
+ impl DispatchableHttpRetryWarning for MaterializerDispatchableHttpRetryWarning {
113
+ fn dispatch ( & self , dur : & Duration , _retries : usize , url : & str ) {
114
+ let event: HttpRequestRetried = HttpRequestRetried {
115
+ backoff_duration_secs : dur. as_secs ( ) ,
116
+ url : url. to_owned ( ) ,
117
+ } ;
118
+
119
+ match buck2_events:: dispatch:: get_dispatcher_opt ( ) {
120
+ Some ( dispatcher) => {
121
+ dispatcher. instant_event ( event) ;
122
+ }
123
+ None => {
124
+ tracing:: warn!( "Failed to dispatch HttpRequestRetried event: {:?}" , event)
125
+ }
126
+ }
127
+ }
128
+ }
129
+
103
130
pub async fn http_head ( client : & dyn HttpClient , url : & str ) -> anyhow:: Result < Response < ( ) > > {
104
131
let response = http_retry (
105
132
url,
106
- NoopDispatchableHttpRetryWarning :: new ( ) ,
133
+ MaterializerDispatchableHttpRetryWarning :: new ( ) ,
107
134
|| async {
108
135
client
109
136
. head ( url)
@@ -132,7 +159,7 @@ pub async fn http_download(
132
159
133
160
Ok ( http_retry (
134
161
url,
135
- NoopDispatchableHttpRetryWarning :: new ( ) ,
162
+ MaterializerDispatchableHttpRetryWarning :: new ( ) ,
136
163
|| async {
137
164
let file = fs_util:: create_file ( & abs_path) . map_err ( HttpDownloadError :: IoError ) ?;
138
165
0 commit comments