Tools for managing Valkey deployments

rust? #3

open opened by nesv.ca targeting main from push-yytolxprwtrm
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:o443yqwekyukw67l6jn22qds/sh.tangled.repo.pull/3m6o6qa3cph22
+917
Diff #2
+7
.gitignore
··· 1 vkadm 2 !cmd/vkadm
··· 1 vkadm 2 !cmd/vkadm 3 + 4 + vendor/** 5 + 6 + 7 + # Added by cargo 8 + 9 + /target
+25
.tangled/workflows/rust.yaml
···
··· 1 + when: 2 + - event: ["pull_request"] 3 + branch: ["main"] 4 + - event: ["push", "manual"] 5 + branch: ["main"] 6 + 7 + engine: "nixery" 8 + 9 + clone: 10 + skip: false 11 + depth: 1 12 + submodules: false 13 + 14 + dependencies: 15 + nixpkgs: 16 + - rustup 17 + - cargo 18 + 19 + steps: 20 + - name: "Install the stable toolchain" 21 + command: "rustup toolchain add stable" 22 + - name: "Update toolchains" 23 + command: "rustup update" 24 + - name: "test" 25 + command: "cargo test"
+709
Cargo.lock
···
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "anstream" 7 + version = "0.6.21" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" 10 + dependencies = [ 11 + "anstyle", 12 + "anstyle-parse", 13 + "anstyle-query", 14 + "anstyle-wincon", 15 + "colorchoice", 16 + "is_terminal_polyfill", 17 + "utf8parse", 18 + ] 19 + 20 + [[package]] 21 + name = "anstyle" 22 + version = "1.0.13" 23 + source = "registry+https://github.com/rust-lang/crates.io-index" 24 + checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78" 25 + 26 + [[package]] 27 + name = "anstyle-parse" 28 + version = "0.2.7" 29 + source = "registry+https://github.com/rust-lang/crates.io-index" 30 + checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" 31 + dependencies = [ 32 + "utf8parse", 33 + ] 34 + 35 + [[package]] 36 + name = "anstyle-query" 37 + version = "1.1.5" 38 + source = "registry+https://github.com/rust-lang/crates.io-index" 39 + checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" 40 + dependencies = [ 41 + "windows-sys", 42 + ] 43 + 44 + [[package]] 45 + name = "anstyle-wincon" 46 + version = "3.0.11" 47 + source = "registry+https://github.com/rust-lang/crates.io-index" 48 + checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" 49 + dependencies = [ 50 + "anstyle", 51 + "once_cell_polyfill", 52 + "windows-sys", 53 + ] 54 + 55 + [[package]] 56 + name = "anyhow" 57 + version = "1.0.100" 58 + source = "registry+https://github.com/rust-lang/crates.io-index" 59 + checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" 60 + 61 + [[package]] 62 + name = "autocfg" 63 + version = "1.5.0" 64 + source = "registry+https://github.com/rust-lang/crates.io-index" 65 + checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" 66 + 67 + [[package]] 68 + name = "bytes" 69 + version = "1.11.0" 70 + source = "registry+https://github.com/rust-lang/crates.io-index" 71 + checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" 72 + 73 + [[package]] 74 + name = "clap" 75 + version = "4.5.53" 76 + source = "registry+https://github.com/rust-lang/crates.io-index" 77 + checksum = "c9e340e012a1bf4935f5282ed1436d1489548e8f72308207ea5df0e23d2d03f8" 78 + dependencies = [ 79 + "clap_builder", 80 + "clap_derive", 81 + ] 82 + 83 + [[package]] 84 + name = "clap_builder" 85 + version = "4.5.53" 86 + source = "registry+https://github.com/rust-lang/crates.io-index" 87 + checksum = "d76b5d13eaa18c901fd2f7fca939fefe3a0727a953561fefdf3b2922b8569d00" 88 + dependencies = [ 89 + "anstream", 90 + "anstyle", 91 + "clap_lex", 92 + "strsim", 93 + ] 94 + 95 + [[package]] 96 + name = "clap_derive" 97 + version = "4.5.49" 98 + source = "registry+https://github.com/rust-lang/crates.io-index" 99 + checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" 100 + dependencies = [ 101 + "heck", 102 + "proc-macro2", 103 + "quote", 104 + "syn", 105 + ] 106 + 107 + [[package]] 108 + name = "clap_lex" 109 + version = "0.7.6" 110 + source = "registry+https://github.com/rust-lang/crates.io-index" 111 + checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" 112 + 113 + [[package]] 114 + name = "colorchoice" 115 + version = "1.0.4" 116 + source = "registry+https://github.com/rust-lang/crates.io-index" 117 + checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" 118 + 119 + [[package]] 120 + name = "combine" 121 + version = "4.6.7" 122 + source = "registry+https://github.com/rust-lang/crates.io-index" 123 + checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" 124 + dependencies = [ 125 + "bytes", 126 + "memchr", 127 + ] 128 + 129 + [[package]] 130 + name = "displaydoc" 131 + version = "0.2.5" 132 + source = "registry+https://github.com/rust-lang/crates.io-index" 133 + checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" 134 + dependencies = [ 135 + "proc-macro2", 136 + "quote", 137 + "syn", 138 + ] 139 + 140 + [[package]] 141 + name = "form_urlencoded" 142 + version = "1.2.2" 143 + source = "registry+https://github.com/rust-lang/crates.io-index" 144 + checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" 145 + dependencies = [ 146 + "percent-encoding", 147 + ] 148 + 149 + [[package]] 150 + name = "heck" 151 + version = "0.5.0" 152 + source = "registry+https://github.com/rust-lang/crates.io-index" 153 + checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" 154 + 155 + [[package]] 156 + name = "icu_collections" 157 + version = "2.1.1" 158 + source = "registry+https://github.com/rust-lang/crates.io-index" 159 + checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43" 160 + dependencies = [ 161 + "displaydoc", 162 + "potential_utf", 163 + "yoke", 164 + "zerofrom", 165 + "zerovec", 166 + ] 167 + 168 + [[package]] 169 + name = "icu_locale_core" 170 + version = "2.1.1" 171 + source = "registry+https://github.com/rust-lang/crates.io-index" 172 + checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6" 173 + dependencies = [ 174 + "displaydoc", 175 + "litemap", 176 + "tinystr", 177 + "writeable", 178 + "zerovec", 179 + ] 180 + 181 + [[package]] 182 + name = "icu_normalizer" 183 + version = "2.1.1" 184 + source = "registry+https://github.com/rust-lang/crates.io-index" 185 + checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599" 186 + dependencies = [ 187 + "icu_collections", 188 + "icu_normalizer_data", 189 + "icu_properties", 190 + "icu_provider", 191 + "smallvec", 192 + "zerovec", 193 + ] 194 + 195 + [[package]] 196 + name = "icu_normalizer_data" 197 + version = "2.1.1" 198 + source = "registry+https://github.com/rust-lang/crates.io-index" 199 + checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" 200 + 201 + [[package]] 202 + name = "icu_properties" 203 + version = "2.1.1" 204 + source = "registry+https://github.com/rust-lang/crates.io-index" 205 + checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" 206 + dependencies = [ 207 + "icu_collections", 208 + "icu_locale_core", 209 + "icu_properties_data", 210 + "icu_provider", 211 + "zerotrie", 212 + "zerovec", 213 + ] 214 + 215 + [[package]] 216 + name = "icu_properties_data" 217 + version = "2.1.1" 218 + source = "registry+https://github.com/rust-lang/crates.io-index" 219 + checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" 220 + 221 + [[package]] 222 + name = "icu_provider" 223 + version = "2.1.1" 224 + source = "registry+https://github.com/rust-lang/crates.io-index" 225 + checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614" 226 + dependencies = [ 227 + "displaydoc", 228 + "icu_locale_core", 229 + "writeable", 230 + "yoke", 231 + "zerofrom", 232 + "zerotrie", 233 + "zerovec", 234 + ] 235 + 236 + [[package]] 237 + name = "idna" 238 + version = "1.1.0" 239 + source = "registry+https://github.com/rust-lang/crates.io-index" 240 + checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" 241 + dependencies = [ 242 + "idna_adapter", 243 + "smallvec", 244 + "utf8_iter", 245 + ] 246 + 247 + [[package]] 248 + name = "idna_adapter" 249 + version = "1.2.1" 250 + source = "registry+https://github.com/rust-lang/crates.io-index" 251 + checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" 252 + dependencies = [ 253 + "icu_normalizer", 254 + "icu_properties", 255 + ] 256 + 257 + [[package]] 258 + name = "is_terminal_polyfill" 259 + version = "1.70.2" 260 + source = "registry+https://github.com/rust-lang/crates.io-index" 261 + checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" 262 + 263 + [[package]] 264 + name = "itoa" 265 + version = "1.0.15" 266 + source = "registry+https://github.com/rust-lang/crates.io-index" 267 + checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 268 + 269 + [[package]] 270 + name = "libc" 271 + version = "0.2.177" 272 + source = "registry+https://github.com/rust-lang/crates.io-index" 273 + checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" 274 + 275 + [[package]] 276 + name = "litemap" 277 + version = "0.8.1" 278 + source = "registry+https://github.com/rust-lang/crates.io-index" 279 + checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77" 280 + 281 + [[package]] 282 + name = "memchr" 283 + version = "2.7.6" 284 + source = "registry+https://github.com/rust-lang/crates.io-index" 285 + checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" 286 + 287 + [[package]] 288 + name = "num-bigint" 289 + version = "0.4.6" 290 + source = "registry+https://github.com/rust-lang/crates.io-index" 291 + checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" 292 + dependencies = [ 293 + "num-integer", 294 + "num-traits", 295 + ] 296 + 297 + [[package]] 298 + name = "num-integer" 299 + version = "0.1.46" 300 + source = "registry+https://github.com/rust-lang/crates.io-index" 301 + checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" 302 + dependencies = [ 303 + "num-traits", 304 + ] 305 + 306 + [[package]] 307 + name = "num-traits" 308 + version = "0.2.19" 309 + source = "registry+https://github.com/rust-lang/crates.io-index" 310 + checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 311 + dependencies = [ 312 + "autocfg", 313 + ] 314 + 315 + [[package]] 316 + name = "once_cell_polyfill" 317 + version = "1.70.2" 318 + source = "registry+https://github.com/rust-lang/crates.io-index" 319 + checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" 320 + 321 + [[package]] 322 + name = "percent-encoding" 323 + version = "2.3.2" 324 + source = "registry+https://github.com/rust-lang/crates.io-index" 325 + checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" 326 + 327 + [[package]] 328 + name = "potential_utf" 329 + version = "0.1.4" 330 + source = "registry+https://github.com/rust-lang/crates.io-index" 331 + checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77" 332 + dependencies = [ 333 + "zerovec", 334 + ] 335 + 336 + [[package]] 337 + name = "proc-macro2" 338 + version = "1.0.103" 339 + source = "registry+https://github.com/rust-lang/crates.io-index" 340 + checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" 341 + dependencies = [ 342 + "unicode-ident", 343 + ] 344 + 345 + [[package]] 346 + name = "quote" 347 + version = "1.0.42" 348 + source = "registry+https://github.com/rust-lang/crates.io-index" 349 + checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" 350 + dependencies = [ 351 + "proc-macro2", 352 + ] 353 + 354 + [[package]] 355 + name = "redis" 356 + version = "0.32.7" 357 + source = "registry+https://github.com/rust-lang/crates.io-index" 358 + checksum = "014cc767fefab6a3e798ca45112bccad9c6e0e218fbd49720042716c73cfef44" 359 + dependencies = [ 360 + "combine", 361 + "itoa", 362 + "num-bigint", 363 + "percent-encoding", 364 + "ryu", 365 + "sha1_smol", 366 + "socket2", 367 + "url", 368 + ] 369 + 370 + [[package]] 371 + name = "ryu" 372 + version = "1.0.20" 373 + source = "registry+https://github.com/rust-lang/crates.io-index" 374 + checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 375 + 376 + [[package]] 377 + name = "serde" 378 + version = "1.0.228" 379 + source = "registry+https://github.com/rust-lang/crates.io-index" 380 + checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" 381 + dependencies = [ 382 + "serde_core", 383 + "serde_derive", 384 + ] 385 + 386 + [[package]] 387 + name = "serde_core" 388 + version = "1.0.228" 389 + source = "registry+https://github.com/rust-lang/crates.io-index" 390 + checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" 391 + dependencies = [ 392 + "serde_derive", 393 + ] 394 + 395 + [[package]] 396 + name = "serde_derive" 397 + version = "1.0.228" 398 + source = "registry+https://github.com/rust-lang/crates.io-index" 399 + checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" 400 + dependencies = [ 401 + "proc-macro2", 402 + "quote", 403 + "syn", 404 + ] 405 + 406 + [[package]] 407 + name = "sha1_smol" 408 + version = "1.0.1" 409 + source = "registry+https://github.com/rust-lang/crates.io-index" 410 + checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" 411 + 412 + [[package]] 413 + name = "smallvec" 414 + version = "1.15.1" 415 + source = "registry+https://github.com/rust-lang/crates.io-index" 416 + checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" 417 + 418 + [[package]] 419 + name = "socket2" 420 + version = "0.6.1" 421 + source = "registry+https://github.com/rust-lang/crates.io-index" 422 + checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" 423 + dependencies = [ 424 + "libc", 425 + "windows-sys", 426 + ] 427 + 428 + [[package]] 429 + name = "stable_deref_trait" 430 + version = "1.2.1" 431 + source = "registry+https://github.com/rust-lang/crates.io-index" 432 + checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" 433 + 434 + [[package]] 435 + name = "strsim" 436 + version = "0.11.1" 437 + source = "registry+https://github.com/rust-lang/crates.io-index" 438 + checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 439 + 440 + [[package]] 441 + name = "syn" 442 + version = "2.0.111" 443 + source = "registry+https://github.com/rust-lang/crates.io-index" 444 + checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87" 445 + dependencies = [ 446 + "proc-macro2", 447 + "quote", 448 + "unicode-ident", 449 + ] 450 + 451 + [[package]] 452 + name = "synstructure" 453 + version = "0.13.2" 454 + source = "registry+https://github.com/rust-lang/crates.io-index" 455 + checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" 456 + dependencies = [ 457 + "proc-macro2", 458 + "quote", 459 + "syn", 460 + ] 461 + 462 + [[package]] 463 + name = "tabwriter" 464 + version = "1.4.1" 465 + source = "registry+https://github.com/rust-lang/crates.io-index" 466 + checksum = "fce91f2f0ec87dff7e6bcbbeb267439aa1188703003c6055193c821487400432" 467 + dependencies = [ 468 + "unicode-width", 469 + ] 470 + 471 + [[package]] 472 + name = "thiserror" 473 + version = "2.0.17" 474 + source = "registry+https://github.com/rust-lang/crates.io-index" 475 + checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" 476 + dependencies = [ 477 + "thiserror-impl", 478 + ] 479 + 480 + [[package]] 481 + name = "thiserror-impl" 482 + version = "2.0.17" 483 + source = "registry+https://github.com/rust-lang/crates.io-index" 484 + checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" 485 + dependencies = [ 486 + "proc-macro2", 487 + "quote", 488 + "syn", 489 + ] 490 + 491 + [[package]] 492 + name = "tinystr" 493 + version = "0.8.2" 494 + source = "registry+https://github.com/rust-lang/crates.io-index" 495 + checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869" 496 + dependencies = [ 497 + "displaydoc", 498 + "zerovec", 499 + ] 500 + 501 + [[package]] 502 + name = "unicode-ident" 503 + version = "1.0.22" 504 + source = "registry+https://github.com/rust-lang/crates.io-index" 505 + checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" 506 + 507 + [[package]] 508 + name = "unicode-width" 509 + version = "0.2.2" 510 + source = "registry+https://github.com/rust-lang/crates.io-index" 511 + checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" 512 + 513 + [[package]] 514 + name = "url" 515 + version = "2.5.7" 516 + source = "registry+https://github.com/rust-lang/crates.io-index" 517 + checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" 518 + dependencies = [ 519 + "form_urlencoded", 520 + "idna", 521 + "percent-encoding", 522 + "serde", 523 + ] 524 + 525 + [[package]] 526 + name = "utf8_iter" 527 + version = "1.0.4" 528 + source = "registry+https://github.com/rust-lang/crates.io-index" 529 + checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" 530 + 531 + [[package]] 532 + name = "utf8parse" 533 + version = "0.2.2" 534 + source = "registry+https://github.com/rust-lang/crates.io-index" 535 + checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" 536 + 537 + [[package]] 538 + name = "valkey-tools" 539 + version = "0.1.0" 540 + dependencies = [ 541 + "anyhow", 542 + "clap", 543 + "redis", 544 + "tabwriter", 545 + "thiserror", 546 + ] 547 + 548 + [[package]] 549 + name = "windows-link" 550 + version = "0.2.1" 551 + source = "registry+https://github.com/rust-lang/crates.io-index" 552 + checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" 553 + 554 + [[package]] 555 + name = "windows-sys" 556 + version = "0.60.2" 557 + source = "registry+https://github.com/rust-lang/crates.io-index" 558 + checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" 559 + dependencies = [ 560 + "windows-targets", 561 + ] 562 + 563 + [[package]] 564 + name = "windows-targets" 565 + version = "0.53.5" 566 + source = "registry+https://github.com/rust-lang/crates.io-index" 567 + checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" 568 + dependencies = [ 569 + "windows-link", 570 + "windows_aarch64_gnullvm", 571 + "windows_aarch64_msvc", 572 + "windows_i686_gnu", 573 + "windows_i686_gnullvm", 574 + "windows_i686_msvc", 575 + "windows_x86_64_gnu", 576 + "windows_x86_64_gnullvm", 577 + "windows_x86_64_msvc", 578 + ] 579 + 580 + [[package]] 581 + name = "windows_aarch64_gnullvm" 582 + version = "0.53.1" 583 + source = "registry+https://github.com/rust-lang/crates.io-index" 584 + checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" 585 + 586 + [[package]] 587 + name = "windows_aarch64_msvc" 588 + version = "0.53.1" 589 + source = "registry+https://github.com/rust-lang/crates.io-index" 590 + checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 591 + 592 + [[package]] 593 + name = "windows_i686_gnu" 594 + version = "0.53.1" 595 + source = "registry+https://github.com/rust-lang/crates.io-index" 596 + checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" 597 + 598 + [[package]] 599 + name = "windows_i686_gnullvm" 600 + version = "0.53.1" 601 + source = "registry+https://github.com/rust-lang/crates.io-index" 602 + checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" 603 + 604 + [[package]] 605 + name = "windows_i686_msvc" 606 + version = "0.53.1" 607 + source = "registry+https://github.com/rust-lang/crates.io-index" 608 + checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" 609 + 610 + [[package]] 611 + name = "windows_x86_64_gnu" 612 + version = "0.53.1" 613 + source = "registry+https://github.com/rust-lang/crates.io-index" 614 + checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" 615 + 616 + [[package]] 617 + name = "windows_x86_64_gnullvm" 618 + version = "0.53.1" 619 + source = "registry+https://github.com/rust-lang/crates.io-index" 620 + checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 621 + 622 + [[package]] 623 + name = "windows_x86_64_msvc" 624 + version = "0.53.1" 625 + source = "registry+https://github.com/rust-lang/crates.io-index" 626 + checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" 627 + 628 + [[package]] 629 + name = "writeable" 630 + version = "0.6.2" 631 + source = "registry+https://github.com/rust-lang/crates.io-index" 632 + checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9" 633 + 634 + [[package]] 635 + name = "yoke" 636 + version = "0.8.1" 637 + source = "registry+https://github.com/rust-lang/crates.io-index" 638 + checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954" 639 + dependencies = [ 640 + "stable_deref_trait", 641 + "yoke-derive", 642 + "zerofrom", 643 + ] 644 + 645 + [[package]] 646 + name = "yoke-derive" 647 + version = "0.8.1" 648 + source = "registry+https://github.com/rust-lang/crates.io-index" 649 + checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" 650 + dependencies = [ 651 + "proc-macro2", 652 + "quote", 653 + "syn", 654 + "synstructure", 655 + ] 656 + 657 + [[package]] 658 + name = "zerofrom" 659 + version = "0.1.6" 660 + source = "registry+https://github.com/rust-lang/crates.io-index" 661 + checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" 662 + dependencies = [ 663 + "zerofrom-derive", 664 + ] 665 + 666 + [[package]] 667 + name = "zerofrom-derive" 668 + version = "0.1.6" 669 + source = "registry+https://github.com/rust-lang/crates.io-index" 670 + checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" 671 + dependencies = [ 672 + "proc-macro2", 673 + "quote", 674 + "syn", 675 + "synstructure", 676 + ] 677 + 678 + [[package]] 679 + name = "zerotrie" 680 + version = "0.2.3" 681 + source = "registry+https://github.com/rust-lang/crates.io-index" 682 + checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851" 683 + dependencies = [ 684 + "displaydoc", 685 + "yoke", 686 + "zerofrom", 687 + ] 688 + 689 + [[package]] 690 + name = "zerovec" 691 + version = "0.11.5" 692 + source = "registry+https://github.com/rust-lang/crates.io-index" 693 + checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002" 694 + dependencies = [ 695 + "yoke", 696 + "zerofrom", 697 + "zerovec-derive", 698 + ] 699 + 700 + [[package]] 701 + name = "zerovec-derive" 702 + version = "0.11.2" 703 + source = "registry+https://github.com/rust-lang/crates.io-index" 704 + checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" 705 + dependencies = [ 706 + "proc-macro2", 707 + "quote", 708 + "syn", 709 + ]
+15
Cargo.toml
···
··· 1 + [package] 2 + name = "valkey-tools" 3 + version = "0.1.0" 4 + edition = "2024" 5 + 6 + [[bin]] 7 + name = "valkeyadm" 8 + path = "src/main.rs" 9 + 10 + [dependencies] 11 + anyhow = "1.0.100" 12 + clap = { version = "4.5.53", features = ["derive"] } 13 + redis = "0.32.7" 14 + tabwriter = "1.4.1" 15 + thiserror = "2.0.17"
+161
src/main.rs
···
··· 1 + use anyhow::{Result, bail}; 2 + use clap::{Parser, Subcommand}; 3 + use redis; 4 + use std::fmt; 5 + use std::io::Write; 6 + use std::net::SocketAddr; 7 + use std::ops::Range; 8 + use tabwriter::TabWriter; 9 + 10 + #[derive(Parser)] 11 + #[command(version,about,long_about=None)] 12 + struct Cli { 13 + #[command(subcommand)] 14 + command: Commands, 15 + } 16 + 17 + #[derive(Subcommand)] 18 + enum Commands { 19 + /// Manage clusters 20 + Cluster { 21 + #[command(subcommand)] 22 + command: ClusterCommands, 23 + }, 24 + } 25 + 26 + #[derive(Subcommand)] 27 + enum ClusterCommands { 28 + /// Initialize a cluster 29 + Init { 30 + /// Addresses of nodes to bootstrap the cluster 31 + node_addrs: Vec<String>, 32 + }, 33 + /// Rebalance the shards across a cluster 34 + Rebalance, 35 + } 36 + 37 + fn main() -> Result<()> { 38 + let cli = Cli::parse(); 39 + 40 + match &cli.command { 41 + Commands::Cluster { command } => match &command { 42 + ClusterCommands::Init { node_addrs } => { 43 + if node_addrs.len() == 0 { 44 + bail!("At least one node address is required"); 45 + } 46 + 47 + let addrs = node_addrs.clone(); 48 + initialize_cluster(addrs)?; 49 + } 50 + ClusterCommands::Rebalance => { 51 + todo!() 52 + } 53 + }, 54 + } 55 + 56 + Ok(()) 57 + } 58 + 59 + fn initialize_cluster(addrs: Vec<String>) -> Result<()> { 60 + let ranges = distribute_slots(NUM_SLOTS, addrs.len()); 61 + let mut nodes: Vec<Node> = Vec::new(); 62 + for (address, range) in std::iter::zip(addrs, ranges) { 63 + let addr: SocketAddr = address.parse()?; 64 + let role = NodeRole::Primary; 65 + let slots = range; 66 + 67 + let client_addr = format!("redis://{address}"); 68 + let client = redis::Client::open(client_addr)?; 69 + 70 + nodes.push(Node { 71 + addr, 72 + role, 73 + slots, 74 + client, 75 + }); 76 + } 77 + 78 + let stdout = std::io::stdout().lock(); 79 + let mut tw = TabWriter::new(stdout); 80 + writeln!(&mut tw, "ADDR\tROLE\tSLOTS START\tEND")?; 81 + 82 + for node in nodes { 83 + let addr = node.addr(); 84 + let role = node.role(); 85 + let slots = node.slots(); 86 + let slots_start = slots.start; 87 + let slots_end = slots.end; 88 + writeln!(&mut tw, "{addr}\t{role}\t{slots_start}\t{slots_end}")?; 89 + } 90 + 91 + tw.flush()?; 92 + 93 + Ok(()) 94 + } 95 + 96 + /// Total number of shard slots available in a cluster. 97 + const NUM_SLOTS: usize = 16384; 98 + 99 + /// Create an even distribution of shard slots across the given number of nodes. 100 + fn distribute_slots(num_slots: usize, num_nodes: usize) -> Vec<Range<usize>> { 101 + let slots_per_node = num_slots / num_nodes; 102 + let mut ranges = Vec::with_capacity(num_nodes); 103 + for n in 0..num_nodes { 104 + let start = n * slots_per_node; 105 + let end = start + slots_per_node - 1; 106 + let range = Range { start, end }; 107 + ranges.push(range); 108 + } 109 + ranges 110 + } 111 + 112 + struct Node { 113 + addr: SocketAddr, 114 + role: NodeRole, 115 + slots: Range<usize>, 116 + client: redis::Client, 117 + } 118 + 119 + impl Node { 120 + fn addr(&self) -> SocketAddr { 121 + self.addr 122 + } 123 + 124 + fn role(&self) -> NodeRole { 125 + self.role 126 + } 127 + 128 + fn slots(&self) -> Range<usize> { 129 + self.slots.clone() 130 + } 131 + 132 + /// Check to see if the node has already been initialized as a cluster member. 133 + fn is_initialized(&self) -> Result<bool> { 134 + todo!() 135 + } 136 + } 137 + 138 + impl fmt::Display for Node { 139 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 140 + let addr = self.addr; 141 + let role = self.role; 142 + let slots_start = self.slots.start; 143 + let slots_end = self.slots.end; 144 + write!(f, "{addr} {role} {slots_start}..{slots_end}") 145 + } 146 + } 147 + 148 + #[derive(Copy, Clone)] 149 + enum NodeRole { 150 + Primary, 151 + Replica, 152 + } 153 + 154 + impl fmt::Display for NodeRole { 155 + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 156 + match self { 157 + Self::Primary => write!(f, "primary"), 158 + Self::Replica => write!(f, "replica"), 159 + } 160 + } 161 + }

Submissions

sign up or login to add to the discussion
nesv.ca submitted #5
1 commit
expand
rust?
2/2 failed
expand
no conflicts, ready to merge
nesv.ca submitted #4
1 commit
expand
rust?
2/2 failed
expand
nesv.ca submitted #3
1 commit
expand
rust?
1/2 failed, 1/2 timeout
expand
nesv.ca submitted #2
1 commit
expand
rust?
1/2 failed, 1/2 success
expand
nesv.ca submitted #1
1 commit
expand
rust?
1/2 failed, 1/2 success
expand
nesv.ca submitted #0
1 commit
expand
rust?
1/1 success
expand