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