tangled
alpha
login
or
join now
smokesignal.events
/
quickdid
50
fork
atom
QuickDID is a high-performance AT Protocol identity resolution service written in Rust. It provides handle-to-DID resolution with Redis-backed caching and queue processing.
50
fork
atom
overview
issues
pulls
pipelines
refactor: removing unecessary deps
Nick Gerakines
6 months ago
0ce1bed8
d3f53a2f
+34
-247
6 changed files
expand all
collapse all
unified
split
Cargo.lock
Cargo.toml
src
config.rs
handle_resolver
memory.rs
redis.rs
queue_adapter.rs
-213
Cargo.lock
···
33
33
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
34
34
35
35
[[package]]
36
36
-
name = "android-tzdata"
37
37
-
version = "0.1.1"
38
38
-
source = "registry+https://github.com/rust-lang/crates.io-index"
39
39
-
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
40
40
-
41
41
-
[[package]]
42
42
-
name = "android_system_properties"
43
43
-
version = "0.1.5"
44
44
-
source = "registry+https://github.com/rust-lang/crates.io-index"
45
45
-
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
46
46
-
dependencies = [
47
47
-
"libc",
48
48
-
]
49
49
-
50
50
-
[[package]]
51
36
name = "anstream"
52
37
version = "0.6.20"
53
38
source = "registry+https://github.com/rust-lang/crates.io-index"
···
153
138
]
154
139
155
140
[[package]]
156
156
-
name = "atproto-oauth"
157
157
-
version = "0.11.3"
158
158
-
source = "registry+https://github.com/rust-lang/crates.io-index"
159
159
-
checksum = "ee92a16f57838093bf72aa517a462613d3786603a2b5e5cd734e2215a971448f"
160
160
-
dependencies = [
161
161
-
"anyhow",
162
162
-
"async-trait",
163
163
-
"atproto-identity",
164
164
-
"base64",
165
165
-
"chrono",
166
166
-
"ecdsa",
167
167
-
"elliptic-curve",
168
168
-
"k256",
169
169
-
"lru",
170
170
-
"multibase",
171
171
-
"p256",
172
172
-
"p384",
173
173
-
"rand 0.8.5",
174
174
-
"reqwest",
175
175
-
"reqwest-chain",
176
176
-
"reqwest-middleware",
177
177
-
"serde",
178
178
-
"serde_ipld_dagcbor",
179
179
-
"serde_json",
180
180
-
"sha2",
181
181
-
"thiserror 2.0.16",
182
182
-
"tokio",
183
183
-
"tracing",
184
184
-
"ulid",
185
185
-
]
186
186
-
187
187
-
[[package]]
188
188
-
name = "atproto-record"
189
189
-
version = "0.11.3"
190
190
-
source = "registry+https://github.com/rust-lang/crates.io-index"
191
191
-
checksum = "34e7c05334833c46feb38e2dbc5e80df6c2f044d32e6248198665809b405dc28"
192
192
-
dependencies = [
193
193
-
"anyhow",
194
194
-
"atproto-identity",
195
195
-
"base64",
196
196
-
"chrono",
197
197
-
"serde",
198
198
-
"serde_ipld_dagcbor",
199
199
-
"serde_json",
200
200
-
"thiserror 2.0.16",
201
201
-
]
202
202
-
203
203
-
[[package]]
204
204
-
name = "atproto-xrpcs"
205
205
-
version = "0.11.3"
206
206
-
source = "registry+https://github.com/rust-lang/crates.io-index"
207
207
-
checksum = "c25b0475dc63f9db54c6c0397860f8368796ba2067dc137ea5bcb7fbbee43575"
208
208
-
dependencies = [
209
209
-
"anyhow",
210
210
-
"async-trait",
211
211
-
"atproto-identity",
212
212
-
"atproto-oauth",
213
213
-
"atproto-record",
214
214
-
"axum",
215
215
-
"base64",
216
216
-
"chrono",
217
217
-
"elliptic-curve",
218
218
-
"hickory-resolver",
219
219
-
"http",
220
220
-
"rand 0.8.5",
221
221
-
"reqwest",
222
222
-
"reqwest-chain",
223
223
-
"reqwest-middleware",
224
224
-
"serde",
225
225
-
"serde_json",
226
226
-
"thiserror 2.0.16",
227
227
-
"tokio",
228
228
-
"tracing",
229
229
-
]
230
230
-
231
231
-
[[package]]
232
141
name = "autocfg"
233
142
version = "1.5.0"
234
143
source = "registry+https://github.com/rust-lang/crates.io-index"
···
241
150
checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5"
242
151
dependencies = [
243
152
"axum-core",
244
244
-
"axum-macros",
245
153
"bytes",
246
154
"form_urlencoded",
247
155
"futures-util",
···
287
195
"tower-layer",
288
196
"tower-service",
289
197
"tracing",
290
290
-
]
291
291
-
292
292
-
[[package]]
293
293
-
name = "axum-macros"
294
294
-
version = "0.5.0"
295
295
-
source = "registry+https://github.com/rust-lang/crates.io-index"
296
296
-
checksum = "604fde5e028fea851ce1d8570bbdc034bec850d157f7569d10f347d06808c05c"
297
297
-
dependencies = [
298
298
-
"proc-macro2",
299
299
-
"quote",
300
300
-
"syn",
301
198
]
302
199
303
200
[[package]]
···
427
324
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
428
325
429
326
[[package]]
430
430
-
name = "chrono"
431
431
-
version = "0.4.41"
432
432
-
source = "registry+https://github.com/rust-lang/crates.io-index"
433
433
-
checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d"
434
434
-
dependencies = [
435
435
-
"android-tzdata",
436
436
-
"iana-time-zone",
437
437
-
"js-sys",
438
438
-
"num-traits",
439
439
-
"serde",
440
440
-
"wasm-bindgen",
441
441
-
"windows-link",
442
442
-
]
443
443
-
444
444
-
[[package]]
445
327
name = "cid"
446
328
version = "0.11.1"
447
329
source = "registry+https://github.com/rust-lang/crates.io-index"
···
718
600
"digest",
719
601
"elliptic-curve",
720
602
"rfc6979",
721
721
-
"serdect",
722
603
"signature",
723
604
"spki",
724
605
]
···
1205
1086
]
1206
1087
1207
1088
[[package]]
1208
1208
-
name = "iana-time-zone"
1209
1209
-
version = "0.1.63"
1210
1210
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1211
1211
-
checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8"
1212
1212
-
dependencies = [
1213
1213
-
"android_system_properties",
1214
1214
-
"core-foundation-sys",
1215
1215
-
"iana-time-zone-haiku",
1216
1216
-
"js-sys",
1217
1217
-
"log",
1218
1218
-
"wasm-bindgen",
1219
1219
-
"windows-core",
1220
1220
-
]
1221
1221
-
1222
1222
-
[[package]]
1223
1223
-
name = "iana-time-zone-haiku"
1224
1224
-
version = "0.1.2"
1225
1225
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1226
1226
-
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
1227
1227
-
dependencies = [
1228
1228
-
"cc",
1229
1229
-
]
1230
1230
-
1231
1231
-
[[package]]
1232
1089
name = "icu_collections"
1233
1090
version = "2.0.0"
1234
1091
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1533
1390
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
1534
1391
1535
1392
[[package]]
1536
1536
-
name = "mime_guess"
1537
1537
-
version = "2.0.5"
1538
1538
-
source = "registry+https://github.com/rust-lang/crates.io-index"
1539
1539
-
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
1540
1540
-
dependencies = [
1541
1541
-
"mime",
1542
1542
-
"unicase",
1543
1543
-
]
1544
1544
-
1545
1545
-
[[package]]
1546
1393
name = "miniz_oxide"
1547
1394
version = "0.8.9"
1548
1395
source = "registry+https://github.com/rust-lang/crates.io-index"
···
1745
1592
"ecdsa",
1746
1593
"elliptic-curve",
1747
1594
"primeorder",
1748
1748
-
"serdect",
1749
1595
"sha2",
1750
1596
]
1751
1597
···
1758
1604
"ecdsa",
1759
1605
"elliptic-curve",
1760
1606
"primeorder",
1761
1761
-
"serdect",
1762
1607
"sha2",
1763
1608
]
1764
1609
···
1859
1704
checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6"
1860
1705
dependencies = [
1861
1706
"elliptic-curve",
1862
1862
-
"serdect",
1863
1707
]
1864
1708
1865
1709
[[package]]
···
1878
1722
"anyhow",
1879
1723
"async-trait",
1880
1724
"atproto-identity",
1881
1881
-
"atproto-xrpcs",
1882
1725
"axum",
1883
1726
"bincode",
1884
1884
-
"chrono",
1885
1727
"clap",
1886
1886
-
"deadpool",
1887
1728
"deadpool-redis",
1888
1729
"http",
1889
1730
"metrohash",
···
1895
1736
"tokio-util",
1896
1737
"tracing",
1897
1738
"tracing-subscriber",
1898
1898
-
"uuid",
1899
1739
]
1900
1740
1901
1741
[[package]]
···
2046
1886
"rustls",
2047
1887
"rustls-native-certs",
2048
1888
"ryu",
2049
2049
-
"sha1_smol",
2050
1889
"socket2 0.5.10",
2051
1890
"tokio",
2052
1891
"tokio-rustls",
···
2090
1929
"bytes",
2091
1930
"encoding_rs",
2092
1931
"futures-core",
2093
2093
-
"futures-util",
2094
1932
"h2",
2095
1933
"http",
2096
1934
"http-body",
···
2102
1940
"js-sys",
2103
1941
"log",
2104
1942
"mime",
2105
2105
-
"mime_guess",
2106
1943
"native-tls",
2107
1944
"percent-encoding",
2108
1945
"pin-project-lite",
···
2127
1964
]
2128
1965
2129
1966
[[package]]
2130
2130
-
name = "reqwest-chain"
2131
2131
-
version = "1.0.0"
2132
2132
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2133
2133
-
checksum = "da5c014fb79a8227db44a0433d748107750d2550b7fca55c59a3d7ee7d2ee2b2"
2134
2134
-
dependencies = [
2135
2135
-
"anyhow",
2136
2136
-
"async-trait",
2137
2137
-
"http",
2138
2138
-
"reqwest-middleware",
2139
2139
-
]
2140
2140
-
2141
2141
-
[[package]]
2142
2142
-
name = "reqwest-middleware"
2143
2143
-
version = "0.4.2"
2144
2144
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2145
2145
-
checksum = "57f17d28a6e6acfe1733fe24bcd30774d13bffa4b8a22535b4c8c98423088d4e"
2146
2146
-
dependencies = [
2147
2147
-
"anyhow",
2148
2148
-
"async-trait",
2149
2149
-
"http",
2150
2150
-
"reqwest",
2151
2151
-
"serde",
2152
2152
-
"thiserror 1.0.69",
2153
2153
-
"tower-service",
2154
2154
-
]
2155
2155
-
2156
2156
-
[[package]]
2157
1967
name = "resolv-conf"
2158
1968
version = "0.7.4"
2159
1969
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2440
2250
]
2441
2251
2442
2252
[[package]]
2443
2443
-
name = "sha1_smol"
2444
2444
-
version = "1.0.1"
2445
2445
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2446
2446
-
checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"
2447
2447
-
2448
2448
-
[[package]]
2449
2253
name = "sha2"
2450
2254
version = "0.10.9"
2451
2255
source = "registry+https://github.com/rust-lang/crates.io-index"
···
2706
2510
"io-uring",
2707
2511
"libc",
2708
2512
"mio",
2709
2709
-
"parking_lot",
2710
2513
"pin-project-lite",
2711
2514
"signal-hook-registry",
2712
2515
"slab",
···
2879
2682
version = "1.18.0"
2880
2683
source = "registry+https://github.com/rust-lang/crates.io-index"
2881
2684
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
2882
2882
-
2883
2883
-
[[package]]
2884
2884
-
name = "ulid"
2885
2885
-
version = "1.2.1"
2886
2886
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2887
2887
-
checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe"
2888
2888
-
dependencies = [
2889
2889
-
"rand 0.9.2",
2890
2890
-
"web-time",
2891
2891
-
]
2892
2892
-
2893
2893
-
[[package]]
2894
2894
-
name = "unicase"
2895
2895
-
version = "2.8.1"
2896
2896
-
source = "registry+https://github.com/rust-lang/crates.io-index"
2897
2897
-
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
2898
2685
2899
2686
[[package]]
2900
2687
name = "unicode-ident"
+3
-7
Cargo.toml
···
17
17
anyhow = "1.0"
18
18
async-trait = "0.1"
19
19
atproto-identity = { version = "0.11.3" }
20
20
-
atproto-xrpcs = { version = "0.11.3" }
21
21
-
axum = { version = "0.8", features = ["macros"] }
20
20
+
axum = { version = "0.8" }
22
21
bincode = { version = "2.0.1", features = ["serde"] }
23
23
-
chrono = "0.4"
24
22
clap = { version = "4", features = ["derive", "env"] }
25
25
-
deadpool = "0.12.2"
26
26
-
deadpool-redis = { version = "0.20.0", features = ["connection-manager", "tokio-comp", "tokio-rustls-comp", "script"] }
23
23
+
deadpool-redis = { version = "0.20.0", features = ["connection-manager", "tokio-comp", "tokio-rustls-comp"] }
27
24
http = "1.0"
28
25
metrohash = "1.0.7"
29
26
reqwest = { version = "0.12", features = ["json"] }
30
27
serde = { version = "1.0", features = ["derive"] }
31
28
serde_json = "1.0"
32
29
thiserror = "2.0"
33
33
-
tokio = { version = "1.35", features = ["full"] }
30
30
+
tokio = { version = "1.35", features = ["rt-multi-thread", "macros", "signal", "sync", "time", "net", "fs"] }
34
31
tokio-util = { version = "0.7", features = ["rt"] }
35
32
tracing = "0.1"
36
33
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
37
37
-
uuid = { version = "1.11", features = ["v4"] }
+13
-11
src/config.rs
···
210
210
/// Worker ID for Redis queue operations
211
211
///
212
212
/// Examples: "worker-001", "prod-us-east-1", "quickdid-1"
213
213
-
/// Default: Auto-generated UUID
213
213
+
/// Default: "worker1"
214
214
///
215
215
/// Use for identifying specific workers in logs
216
216
#[arg(long, env = "QUEUE_WORKER_ID")]
···
315
315
/// Redis key prefix for queues (e.g., "queue:handleresolver:")
316
316
pub queue_redis_prefix: String,
317
317
318
318
-
/// Worker ID for queue operations (auto-generated if not set)
319
319
-
pub queue_worker_id: Option<String>,
318
318
+
/// Worker ID for queue operations (defaults to "worker1")
319
319
+
pub queue_worker_id: String,
320
320
321
321
/// Buffer size for MPSC queue (e.g., 1000)
322
322
pub queue_buffer_size: usize,
···
458
458
}
459
459
}),
460
460
queue_redis_prefix: args.queue_redis_prefix,
461
461
-
queue_worker_id: args.queue_worker_id.or_else(|| {
462
462
-
let env_val = optional_env("QUEUE_WORKER_ID");
463
463
-
if env_val.is_empty() {
464
464
-
None
465
465
-
} else {
466
466
-
Some(env_val)
467
467
-
}
468
468
-
}),
461
461
+
queue_worker_id: args.queue_worker_id
462
462
+
.or_else(|| {
463
463
+
let env_val = optional_env("QUEUE_WORKER_ID");
464
464
+
if env_val.is_empty() {
465
465
+
None
466
466
+
} else {
467
467
+
Some(env_val)
468
468
+
}
469
469
+
})
470
470
+
.unwrap_or_else(|| "worker1".to_string()),
469
471
queue_buffer_size: args.queue_buffer_size,
470
472
cache_ttl_memory: args.cache_ttl_memory,
471
473
cache_ttl_redis: args.cache_ttl_redis,
+5
-2
src/handle_resolver/memory.rs
···
7
7
use super::errors::HandleResolverError;
8
8
use super::traits::HandleResolver;
9
9
use async_trait::async_trait;
10
10
-
use chrono::Utc;
10
10
+
use std::time::{SystemTime, UNIX_EPOCH};
11
11
use std::collections::HashMap;
12
12
use std::sync::Arc;
13
13
use tokio::sync::RwLock;
···
73
73
}
74
74
75
75
fn current_timestamp() -> u64 {
76
76
-
Utc::now().timestamp() as u64
76
76
+
SystemTime::now()
77
77
+
.duration_since(UNIX_EPOCH)
78
78
+
.unwrap_or_default()
79
79
+
.as_secs()
77
80
}
78
81
79
82
fn is_expired(&self, timestamp: u64) -> bool {
+2
-2
src/handle_resolver/redis.rs
···
297
297
});
298
298
299
299
// Create Redis-backed resolver with a unique key prefix for testing
300
300
-
let test_prefix = format!("test:handle:{}:", uuid::Uuid::new_v4());
300
300
+
let test_prefix = format!("test:handle:{}:", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos());
301
301
let redis_resolver = RedisHandleResolver::with_full_config(
302
302
mock_resolver,
303
303
pool.clone(),
···
339
339
});
340
340
341
341
// Create Redis-backed resolver with a unique key prefix for testing
342
342
-
let test_prefix = format!("test:handle:{}:", uuid::Uuid::new_v4());
342
342
+
let test_prefix = format!("test:handle:{}:", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos());
343
343
let redis_resolver = RedisHandleResolver::with_full_config(
344
344
mock_resolver,
345
345
pool.clone(),
+11
-12
src/queue_adapter.rs
···
208
208
/// Create a new Redis queue adapter with custom configuration
209
209
fn with_config(
210
210
pool: RedisPool,
211
211
-
worker_id: Option<String>,
211
211
+
worker_id: String,
212
212
key_prefix: String,
213
213
timeout_seconds: u64,
214
214
) -> Self {
215
215
-
let worker_id = worker_id.unwrap_or_else(|| uuid::Uuid::new_v4().to_string());
216
215
Self {
217
216
pool,
218
217
worker_id,
···
489
488
/// # Arguments
490
489
///
491
490
/// * `pool` - Redis connection pool
492
492
-
/// * `worker_id` - Optional worker identifier (auto-generated if None)
491
491
+
/// * `worker_id` - Worker identifier for this queue instance
493
492
/// * `key_prefix` - Redis key prefix for queue operations
494
493
/// * `timeout_seconds` - Timeout for blocking operations
495
494
pub fn create_redis_queue<T>(
496
495
pool: RedisPool,
497
497
-
worker_id: Option<String>,
496
496
+
worker_id: String,
498
497
key_prefix: String,
499
498
timeout_seconds: u64,
500
499
) -> Arc<dyn QueueAdapter<T>>
···
552
551
};
553
552
554
553
// Create adapter with unique prefix for testing
555
555
-
let test_prefix = format!("test:queue:{}:", uuid::Uuid::new_v4());
554
554
+
let test_prefix = format!("test:queue:{}:", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos());
556
555
let adapter = Arc::new(RedisQueueAdapter::<String>::with_config(
557
556
pool.clone(),
558
558
-
Some("test-worker".to_string()),
557
557
+
"test-worker".to_string(),
559
558
test_prefix.clone(),
560
559
1, // 1 second timeout for tests
561
560
));
···
585
584
None => return,
586
585
};
587
586
588
588
-
let test_prefix = format!("test:queue:{}:", uuid::Uuid::new_v4());
587
587
+
let test_prefix = format!("test:queue:{}:", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos());
589
588
let worker_id = "test-worker-reliable";
590
589
591
590
// Create first adapter
592
591
let adapter1 = Arc::new(RedisQueueAdapter::<String>::with_config(
593
592
pool.clone(),
594
594
-
Some(worker_id.to_string()),
593
593
+
worker_id.to_string(),
595
594
test_prefix.clone(),
596
595
1,
597
596
));
···
609
608
// Create second adapter with same worker_id (simulating restart)
610
609
let adapter2 = Arc::new(RedisQueueAdapter::<String>::with_config(
611
610
pool.clone(),
612
612
-
Some(worker_id.to_string()),
611
611
+
worker_id.to_string(),
613
612
test_prefix.clone(),
614
613
1,
615
614
));
···
627
626
None => return,
628
627
};
629
628
630
630
-
let test_prefix = format!("test:queue:{}:", uuid::Uuid::new_v4());
629
629
+
let test_prefix = format!("test:queue:{}:", std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos());
631
630
let adapter = Arc::new(RedisQueueAdapter::<String>::with_config(
632
631
pool.clone(),
633
633
-
None,
632
632
+
"test-worker-depth".to_string(),
634
633
test_prefix.clone(),
635
634
1,
636
635
));
···
663
662
664
663
let adapter = Arc::new(RedisQueueAdapter::<String>::with_config(
665
664
pool,
666
666
-
None,
665
665
+
"test-worker-health".to_string(),
667
666
"test:queue:health:".to_string(),
668
667
1,
669
668
));