tangled
alpha
login
or
join now
microcosm.blue
/
Allegedly
52
fork
atom
Server tools to backfill, tail, mirror, and verify PLC logs
52
fork
atom
overview
issues
4
pulls
1
pipelines
lazy: reqwest retry crate for 429s
bad-example.com
5 months ago
1e54e467
baac66ac
+236
-25
4 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
src
client.rs
poll.rs
+219
-20
Cargo.lock
···
39
39
"futures",
40
40
"log",
41
41
"reqwest",
42
42
+
"reqwest-middleware",
43
43
+
"reqwest-retry",
42
44
"serde",
43
45
"serde_json",
44
44
-
"thiserror",
46
46
+
"thiserror 2.0.16",
45
47
"tokio",
46
48
"tokio-postgres",
47
49
"url",
···
169
171
version = "0.22.1"
170
172
source = "registry+https://github.com/rust-lang/crates.io-index"
171
173
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
174
174
+
175
175
+
[[package]]
176
176
+
name = "bitflags"
177
177
+
version = "1.3.2"
178
178
+
source = "registry+https://github.com/rust-lang/crates.io-index"
179
179
+
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
172
180
173
181
[[package]]
174
182
name = "bitflags"
···
912
920
]
913
921
914
922
[[package]]
923
923
+
name = "instant"
924
924
+
version = "0.1.13"
925
925
+
source = "registry+https://github.com/rust-lang/crates.io-index"
926
926
+
checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
927
927
+
dependencies = [
928
928
+
"cfg-if",
929
929
+
"js-sys",
930
930
+
"wasm-bindgen",
931
931
+
"web-sys",
932
932
+
]
933
933
+
934
934
+
[[package]]
915
935
name = "io-uring"
916
936
version = "0.7.10"
917
937
source = "registry+https://github.com/rust-lang/crates.io-index"
918
938
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
919
939
dependencies = [
920
920
-
"bitflags",
940
940
+
"bitflags 2.9.4",
921
941
"cfg-if",
922
942
"libc",
923
943
]
···
996
1016
source = "registry+https://github.com/rust-lang/crates.io-index"
997
1017
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
998
1018
dependencies = [
999
999
-
"bitflags",
1019
1019
+
"bitflags 2.9.4",
1000
1020
"libc",
1001
1001
-
"redox_syscall",
1021
1021
+
"redox_syscall 0.5.17",
1002
1022
]
1003
1023
1004
1024
[[package]]
···
1133
1153
source = "registry+https://github.com/rust-lang/crates.io-index"
1134
1154
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
1135
1155
dependencies = [
1136
1136
-
"bitflags",
1156
1156
+
"bitflags 2.9.4",
1137
1157
"cfg-if",
1138
1158
"foreign-types",
1139
1159
"libc",
···
1173
1193
1174
1194
[[package]]
1175
1195
name = "parking_lot"
1196
1196
+
version = "0.11.2"
1197
1197
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1198
1198
+
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
1199
1199
+
dependencies = [
1200
1200
+
"instant",
1201
1201
+
"lock_api",
1202
1202
+
"parking_lot_core 0.8.6",
1203
1203
+
]
1204
1204
+
1205
1205
+
[[package]]
1206
1206
+
name = "parking_lot"
1176
1207
version = "0.12.4"
1177
1208
source = "registry+https://github.com/rust-lang/crates.io-index"
1178
1209
checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
1179
1210
dependencies = [
1180
1211
"lock_api",
1181
1181
-
"parking_lot_core",
1212
1212
+
"parking_lot_core 0.9.11",
1213
1213
+
]
1214
1214
+
1215
1215
+
[[package]]
1216
1216
+
name = "parking_lot_core"
1217
1217
+
version = "0.8.6"
1218
1218
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1219
1219
+
checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc"
1220
1220
+
dependencies = [
1221
1221
+
"cfg-if",
1222
1222
+
"instant",
1223
1223
+
"libc",
1224
1224
+
"redox_syscall 0.2.16",
1225
1225
+
"smallvec",
1226
1226
+
"winapi",
1182
1227
]
1183
1228
1184
1229
[[package]]
···
1189
1234
dependencies = [
1190
1235
"cfg-if",
1191
1236
"libc",
1192
1192
-
"redox_syscall",
1237
1237
+
"redox_syscall 0.5.17",
1193
1238
"smallvec",
1194
1239
"windows-targets 0.52.6",
1195
1240
]
···
1264
1309
"hmac",
1265
1310
"md-5",
1266
1311
"memchr",
1267
1267
-
"rand",
1312
1312
+
"rand 0.9.2",
1268
1313
"sha2",
1269
1314
"stringprep",
1270
1315
]
···
1327
1372
1328
1373
[[package]]
1329
1374
name = "rand"
1375
1375
+
version = "0.8.5"
1376
1376
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1377
1377
+
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
1378
1378
+
dependencies = [
1379
1379
+
"libc",
1380
1380
+
"rand_chacha 0.3.1",
1381
1381
+
"rand_core 0.6.4",
1382
1382
+
]
1383
1383
+
1384
1384
+
[[package]]
1385
1385
+
name = "rand"
1330
1386
version = "0.9.2"
1331
1387
source = "registry+https://github.com/rust-lang/crates.io-index"
1332
1388
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
1333
1389
dependencies = [
1334
1334
-
"rand_chacha",
1335
1335
-
"rand_core",
1390
1390
+
"rand_chacha 0.9.0",
1391
1391
+
"rand_core 0.9.3",
1392
1392
+
]
1393
1393
+
1394
1394
+
[[package]]
1395
1395
+
name = "rand_chacha"
1396
1396
+
version = "0.3.1"
1397
1397
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1398
1398
+
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
1399
1399
+
dependencies = [
1400
1400
+
"ppv-lite86",
1401
1401
+
"rand_core 0.6.4",
1336
1402
]
1337
1403
1338
1404
[[package]]
···
1342
1408
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
1343
1409
dependencies = [
1344
1410
"ppv-lite86",
1345
1345
-
"rand_core",
1411
1411
+
"rand_core 0.9.3",
1412
1412
+
]
1413
1413
+
1414
1414
+
[[package]]
1415
1415
+
name = "rand_core"
1416
1416
+
version = "0.6.4"
1417
1417
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1418
1418
+
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
1419
1419
+
dependencies = [
1420
1420
+
"getrandom 0.2.16",
1346
1421
]
1347
1422
1348
1423
[[package]]
···
1356
1431
1357
1432
[[package]]
1358
1433
name = "redox_syscall"
1434
1434
+
version = "0.2.16"
1435
1435
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1436
1436
+
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
1437
1437
+
dependencies = [
1438
1438
+
"bitflags 1.3.2",
1439
1439
+
]
1440
1440
+
1441
1441
+
[[package]]
1442
1442
+
name = "redox_syscall"
1359
1443
version = "0.5.17"
1360
1444
source = "registry+https://github.com/rust-lang/crates.io-index"
1361
1445
checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77"
1362
1446
dependencies = [
1363
1363
-
"bitflags",
1447
1447
+
"bitflags 2.9.4",
1364
1448
]
1365
1449
1366
1450
[[package]]
···
1436
1520
]
1437
1521
1438
1522
[[package]]
1523
1523
+
name = "reqwest-middleware"
1524
1524
+
version = "0.4.2"
1525
1525
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1526
1526
+
checksum = "57f17d28a6e6acfe1733fe24bcd30774d13bffa4b8a22535b4c8c98423088d4e"
1527
1527
+
dependencies = [
1528
1528
+
"anyhow",
1529
1529
+
"async-trait",
1530
1530
+
"http",
1531
1531
+
"reqwest",
1532
1532
+
"serde",
1533
1533
+
"thiserror 1.0.69",
1534
1534
+
"tower-service",
1535
1535
+
]
1536
1536
+
1537
1537
+
[[package]]
1538
1538
+
name = "reqwest-retry"
1539
1539
+
version = "0.7.0"
1540
1540
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1541
1541
+
checksum = "29c73e4195a6bfbcb174b790d9b3407ab90646976c55de58a6515da25d851178"
1542
1542
+
dependencies = [
1543
1543
+
"anyhow",
1544
1544
+
"async-trait",
1545
1545
+
"futures",
1546
1546
+
"getrandom 0.2.16",
1547
1547
+
"http",
1548
1548
+
"hyper",
1549
1549
+
"parking_lot 0.11.2",
1550
1550
+
"reqwest",
1551
1551
+
"reqwest-middleware",
1552
1552
+
"retry-policies",
1553
1553
+
"thiserror 1.0.69",
1554
1554
+
"tokio",
1555
1555
+
"tracing",
1556
1556
+
"wasm-timer",
1557
1557
+
]
1558
1558
+
1559
1559
+
[[package]]
1560
1560
+
name = "retry-policies"
1561
1561
+
version = "0.4.0"
1562
1562
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1563
1563
+
checksum = "5875471e6cab2871bc150ecb8c727db5113c9338cc3354dc5ee3425b6aa40a1c"
1564
1564
+
dependencies = [
1565
1565
+
"rand 0.8.5",
1566
1566
+
]
1567
1567
+
1568
1568
+
[[package]]
1439
1569
name = "ring"
1440
1570
version = "0.17.14"
1441
1571
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1461
1591
source = "registry+https://github.com/rust-lang/crates.io-index"
1462
1592
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
1463
1593
dependencies = [
1464
1464
-
"bitflags",
1594
1594
+
"bitflags 2.9.4",
1465
1595
"errno",
1466
1596
"libc",
1467
1597
"linux-raw-sys",
···
1534
1664
source = "registry+https://github.com/rust-lang/crates.io-index"
1535
1665
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
1536
1666
dependencies = [
1537
1537
-
"bitflags",
1667
1667
+
"bitflags 2.9.4",
1538
1668
"core-foundation",
1539
1669
"core-foundation-sys",
1540
1670
"libc",
···
1734
1864
source = "registry+https://github.com/rust-lang/crates.io-index"
1735
1865
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
1736
1866
dependencies = [
1737
1737
-
"bitflags",
1867
1867
+
"bitflags 2.9.4",
1738
1868
"core-foundation",
1739
1869
"system-configuration-sys",
1740
1870
]
···
1764
1894
1765
1895
[[package]]
1766
1896
name = "thiserror"
1897
1897
+
version = "1.0.69"
1898
1898
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1899
1899
+
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
1900
1900
+
dependencies = [
1901
1901
+
"thiserror-impl 1.0.69",
1902
1902
+
]
1903
1903
+
1904
1904
+
[[package]]
1905
1905
+
name = "thiserror"
1767
1906
version = "2.0.16"
1768
1907
source = "registry+https://github.com/rust-lang/crates.io-index"
1769
1908
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
1770
1909
dependencies = [
1771
1771
-
"thiserror-impl",
1910
1910
+
"thiserror-impl 2.0.16",
1911
1911
+
]
1912
1912
+
1913
1913
+
[[package]]
1914
1914
+
name = "thiserror-impl"
1915
1915
+
version = "1.0.69"
1916
1916
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1917
1917
+
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
1918
1918
+
dependencies = [
1919
1919
+
"proc-macro2",
1920
1920
+
"quote",
1921
1921
+
"syn",
1772
1922
]
1773
1923
1774
1924
[[package]]
···
1818
1968
"io-uring",
1819
1969
"libc",
1820
1970
"mio",
1821
1821
-
"parking_lot",
1971
1971
+
"parking_lot 0.12.4",
1822
1972
"pin-project-lite",
1823
1973
"signal-hook-registry",
1824
1974
"slab",
···
1861
2011
"futures-channel",
1862
2012
"futures-util",
1863
2013
"log",
1864
1864
-
"parking_lot",
2014
2014
+
"parking_lot 0.12.4",
1865
2015
"percent-encoding",
1866
2016
"phf",
1867
2017
"pin-project-lite",
1868
2018
"postgres-protocol",
1869
2019
"postgres-types",
1870
1870
-
"rand",
2020
2020
+
"rand 0.9.2",
1871
2021
"socket2 0.5.10",
1872
2022
"tokio",
1873
2023
"tokio-util",
···
1918
2068
source = "registry+https://github.com/rust-lang/crates.io-index"
1919
2069
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
1920
2070
dependencies = [
1921
1921
-
"bitflags",
2071
2071
+
"bitflags 2.9.4",
1922
2072
"bytes",
1923
2073
"futures-util",
1924
2074
"http",
···
1949
2099
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
1950
2100
dependencies = [
1951
2101
"pin-project-lite",
2102
2102
+
"tracing-attributes",
1952
2103
"tracing-core",
2104
2104
+
]
2105
2105
+
2106
2106
+
[[package]]
2107
2107
+
name = "tracing-attributes"
2108
2108
+
version = "0.1.30"
2109
2109
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2110
2110
+
checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
2111
2111
+
dependencies = [
2112
2112
+
"proc-macro2",
2113
2113
+
"quote",
2114
2114
+
"syn",
1953
2115
]
1954
2116
1955
2117
[[package]]
···
2167
2329
]
2168
2330
2169
2331
[[package]]
2332
2332
+
name = "wasm-timer"
2333
2333
+
version = "0.2.5"
2334
2334
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2335
2335
+
checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f"
2336
2336
+
dependencies = [
2337
2337
+
"futures",
2338
2338
+
"js-sys",
2339
2339
+
"parking_lot 0.11.2",
2340
2340
+
"pin-utils",
2341
2341
+
"wasm-bindgen",
2342
2342
+
"wasm-bindgen-futures",
2343
2343
+
"web-sys",
2344
2344
+
]
2345
2345
+
2346
2346
+
[[package]]
2170
2347
name = "web-sys"
2171
2348
version = "0.3.78"
2172
2349
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2186
2363
"wasite",
2187
2364
"web-sys",
2188
2365
]
2366
2366
+
2367
2367
+
[[package]]
2368
2368
+
name = "winapi"
2369
2369
+
version = "0.3.9"
2370
2370
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2371
2371
+
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
2372
2372
+
dependencies = [
2373
2373
+
"winapi-i686-pc-windows-gnu",
2374
2374
+
"winapi-x86_64-pc-windows-gnu",
2375
2375
+
]
2376
2376
+
2377
2377
+
[[package]]
2378
2378
+
name = "winapi-i686-pc-windows-gnu"
2379
2379
+
version = "0.4.0"
2380
2380
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2381
2381
+
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
2382
2382
+
2383
2383
+
[[package]]
2384
2384
+
name = "winapi-x86_64-pc-windows-gnu"
2385
2385
+
version = "0.4.0"
2386
2386
+
source = "registry+https://github.com/rust-lang/crates.io-index"
2387
2387
+
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
2189
2388
2190
2389
[[package]]
2191
2390
name = "windows-core"
+2
Cargo.toml
···
14
14
futures = "0.3.31"
15
15
log = "0.4.28"
16
16
reqwest = { version = "0.12.23", features = ["stream"] }
17
17
+
reqwest-middleware = "0.4.2"
18
18
+
reqwest-retry = "0.7.0"
17
19
serde = "1.0.219"
18
20
serde_json = { version = "1.0.143", features = ["raw_value"] }
19
21
thiserror = "2.0.16"
+11
-3
src/client.rs
···
1
1
use reqwest::Client;
2
2
+
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
3
3
+
use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};
2
4
use std::sync::LazyLock;
3
5
4
4
-
pub static CLIENT: LazyLock<Client> = LazyLock::new(|| {
5
5
-
Client::builder()
6
6
+
pub static CLIENT: LazyLock<ClientWithMiddleware> = LazyLock::new(|| {
7
7
+
let inner = Client::builder()
6
8
.user_agent(concat!(
7
9
"allegedly, v",
8
10
env!("CARGO_PKG_VERSION"),
9
11
" (from @microcosm.blue; contact @bad-example.com)"
10
12
))
11
13
.build()
12
12
-
.unwrap()
14
14
+
.unwrap();
15
15
+
16
16
+
let policy = ExponentialBackoff::builder().build_with_max_retries(12);
17
17
+
18
18
+
ClientBuilder::new(inner)
19
19
+
.with(RetryTransientMiddleware::new_with_policy(policy))
20
20
+
.build()
13
21
});
+4
-2
src/poll.rs
···
8
8
#[derive(Debug, Error)]
9
9
pub enum GetPageError {
10
10
#[error(transparent)]
11
11
-
ReqwestError(#[from] reqwest::Error),
11
11
+
Reqwest(#[from] reqwest::Error),
12
12
#[error(transparent)]
13
13
-
SerdeError(#[from] serde_json::Error),
13
13
+
ReqwestMiddleware(#[from] reqwest_middleware::Error),
14
14
+
#[error(transparent)]
15
15
+
Serde(#[from] serde_json::Error),
14
16
}
15
17
16
18
/// ops are primary-keyed by (did, cid)