File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/query/pipeline/transforms/src/processors/transforms Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,16 @@ pub struct RetryStrategy {
30
30
}
31
31
32
32
pub struct AsyncRetryWrapper < T : AsyncRetry + ' static > {
33
+ retries : usize ,
33
34
t : T ,
34
35
}
35
36
36
37
impl < T : AsyncRetry + ' static > AsyncRetryWrapper < T > {
37
38
pub fn create ( inner : T ) -> Self {
38
- Self { t : inner }
39
+ Self {
40
+ t : inner,
41
+ retries : 0 ,
42
+ }
39
43
}
40
44
}
41
45
@@ -45,14 +49,14 @@ impl<T: AsyncRetry + 'static> AsyncTransform for AsyncRetryWrapper<T> {
45
49
46
50
async fn transform ( & mut self , data : DataBlock ) -> Result < DataBlock > {
47
51
let strategy = self . t . retry_strategy ( ) ;
48
- for i in 0 .. strategy. retry_times {
52
+ while self . retries < strategy. retry_times {
49
53
match self . t . transform ( data. clone ( ) ) . await {
50
54
Ok ( v) => return Ok ( v) ,
51
55
Err ( e) => {
52
56
// Add log to know which error is retrying
53
57
info ! (
54
58
"Retry {} times for transform {} error: {:?}" ,
55
- i ,
59
+ self . retries ,
56
60
Self :: NAME ,
57
61
e
58
62
) ;
@@ -62,6 +66,7 @@ impl<T: AsyncRetry + 'static> AsyncTransform for AsyncRetryWrapper<T> {
62
66
if let Some ( duration) = strategy. retry_sleep_duration {
63
67
tokio:: time:: sleep ( duration) . await ;
64
68
}
69
+ self . retries += 1 ;
65
70
}
66
71
}
67
72
}
You can’t perform that action at this time.
0 commit comments