Compare commits
3 Commits
c5f0f80492
...
9482a4e3ee
Author | SHA1 | Date | |
---|---|---|---|
|
9482a4e3ee
|
||
|
04669eb638
|
||
|
62c200b5bd
|
606
Cargo.lock
generated
606
Cargo.lock
generated
@@ -84,12 +84,27 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-waker"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "backon"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "592277618714fbcecda9a02ba7a8781f319d26532a88553bbacc77ba5d2b3a8d"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.75"
|
||||
@@ -105,12 +120,27 @@ dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
@@ -183,6 +213,35 @@ dependencies = [
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
@@ -194,6 +253,24 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.2"
|
||||
@@ -211,7 +288,6 @@ checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
@@ -234,17 +310,6 @@ version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.31"
|
||||
@@ -292,6 +357,16 @@ dependencies = [
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.16"
|
||||
@@ -300,7 +375,19 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasi 0.14.2+wasi-0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -309,6 +396,31 @@ version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"http",
|
||||
"indexmap",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
@@ -319,7 +431,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
name = "herocoordinator"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"clap",
|
||||
"jsonrpsee",
|
||||
"redis",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -327,6 +441,90 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body-util"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"http",
|
||||
"http-body",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "httparse"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
|
||||
|
||||
[[package]]
|
||||
name = "httpdate"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb3aa54a13a0dfe7fbe3a59e0c76093041720fdc77b110cc0fc260fafb4dc51e"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icu_collections"
|
||||
version = "2.0.0"
|
||||
@@ -434,6 +632,16 @@ dependencies = [
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "io-uring"
|
||||
version = "0.7.9"
|
||||
@@ -457,6 +665,97 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f3f48dc3e6b8bd21e15436c1ddd0bc22a6a54e8ec46fedd6adf3425f396ec6a"
|
||||
dependencies = [
|
||||
"jsonrpsee-core",
|
||||
"jsonrpsee-proc-macros",
|
||||
"jsonrpsee-server",
|
||||
"jsonrpsee-types",
|
||||
"tokio",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-core"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "316c96719901f05d1137f19ba598b5fe9c9bc39f4335f67f6be8613921946480"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"jsonrpsee-types",
|
||||
"parking_lot",
|
||||
"pin-project",
|
||||
"rand 0.9.2",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-proc-macros"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2da3f8ab5ce1bb124b6d082e62dffe997578ceaf0aeb9f3174a214589dc00f07"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-server"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c51b7c290bb68ce3af2d029648148403863b982f138484a73f02a9dd52dbd7f"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"jsonrpsee-core",
|
||||
"jsonrpsee-types",
|
||||
"pin-project",
|
||||
"route-recognizer",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"soketto",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"tower",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpsee-types"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc88ff4688e43cc3fa9883a8a95c6fa27aa2e76c96e610b737b6554d650d7fd5"
|
||||
dependencies = [
|
||||
"http",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.175"
|
||||
@@ -479,6 +778,12 @@ dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.5"
|
||||
@@ -501,10 +806,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.7"
|
||||
@@ -605,6 +938,15 @@ dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35"
|
||||
dependencies = [
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
@@ -623,6 +965,12 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@@ -630,8 +978,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||
dependencies = [
|
||||
"rand_chacha 0.9.0",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -641,7 +999,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -650,29 +1018,39 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.2.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
dependencies = [
|
||||
"getrandom 0.3.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redis"
|
||||
version = "0.25.4"
|
||||
version = "0.32.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0d7a6955c7511f60f3ba9e86c6d02b3c3f144f8c24b288d1f4e18074ab8bbec"
|
||||
checksum = "7cd3650deebc68526b304898b192fa4102a4ef0b9ada24da096559cb60e0eef8"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
"backon",
|
||||
"bytes",
|
||||
"cfg-if",
|
||||
"combine",
|
||||
"futures",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"itoa",
|
||||
"num-bigint",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"ryu",
|
||||
"sha1_smol",
|
||||
"socket2 0.5.10",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tokio-retry",
|
||||
"tokio-util",
|
||||
"url",
|
||||
]
|
||||
@@ -686,12 +1064,24 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "route-recognizer"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "afab94fb28594581f62d981211a9a4d53cc8130bbcbbb89a0440d9b8e81a7746"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
@@ -736,6 +1126,17 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1_smol"
|
||||
version = "1.0.1"
|
||||
@@ -763,16 +1164,6 @@ version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "socket2"
|
||||
version = "0.6.0"
|
||||
@@ -783,6 +1174,22 @@ dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "soketto"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
"futures",
|
||||
"http",
|
||||
"httparse",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
"sha1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
@@ -806,6 +1213,12 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sync_wrapper"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
version = "0.13.2"
|
||||
@@ -817,6 +1230,26 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinystr"
|
||||
version = "0.8.1"
|
||||
@@ -842,7 +1275,7 @@ dependencies = [
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
"socket2 0.6.0",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
@@ -859,14 +1292,15 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-retry"
|
||||
version = "0.3.0"
|
||||
name = "tokio-stream"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f"
|
||||
checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047"
|
||||
dependencies = [
|
||||
"pin-project",
|
||||
"rand",
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -877,11 +1311,55 @@ checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"pin-project-lite",
|
||||
"sync_wrapper",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-layer"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
|
||||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.41"
|
||||
@@ -913,6 +1391,12 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
@@ -942,27 +1426,33 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.2+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3"
|
||||
dependencies = [
|
||||
"wit-bindgen-rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
@@ -1110,6 +1600,24 @@ version = "0.53.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.6.1"
|
||||
|
@@ -9,4 +9,10 @@ serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_json = "1.0.143"
|
||||
tokio = { version = "1.47.1", features = ["full"] }
|
||||
tracing = "0.1.41"
|
||||
redis = { version = "0.25.4", features = ["tokio-comp", "connection-manager", "aio"] }
|
||||
redis = { version = "0.32.5", features = [
|
||||
"tokio-comp",
|
||||
"connection-manager",
|
||||
"aio",
|
||||
] }
|
||||
jsonrpsee = { version = "0.26.0", features = ["server", "macros"] }
|
||||
async-trait = "0.1.83"
|
||||
|
1227
specs/openrpc.json
Normal file
1227
specs/openrpc.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
pub mod models;
|
||||
pub mod storage;
|
||||
mod time;
|
||||
pub mod rpc;
|
||||
|
69
src/main.rs
69
src/main.rs
@@ -1,5 +1,6 @@
|
||||
use clap::Parser;
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, Parser)]
|
||||
#[command(
|
||||
@@ -35,13 +36,75 @@ struct Cli {
|
||||
help = "Socket address of Redis instance (default: 127.0.0.1:6379)"
|
||||
)]
|
||||
redis_addr: SocketAddr,
|
||||
|
||||
#[arg(
|
||||
long = "api-http-ip",
|
||||
env = "API_HTTP_IP",
|
||||
default_value = "127.0.0.1",
|
||||
help = "Bind IP for HTTP JSON-RPC server (default: 127.0.0.1)"
|
||||
)]
|
||||
api_http_ip: IpAddr,
|
||||
|
||||
#[arg(
|
||||
long = "api-http-port",
|
||||
env = "API_HTTP_PORT",
|
||||
default_value_t = 9652u16,
|
||||
help = "Bind port for HTTP JSON-RPC server (default: 9652)"
|
||||
)]
|
||||
api_http_port: u16,
|
||||
|
||||
#[arg(
|
||||
long = "api-ws-ip",
|
||||
env = "API_WS_IP",
|
||||
default_value = "127.0.0.1",
|
||||
help = "Bind IP for WebSocket JSON-RPC server (default: 127.0.0.1)"
|
||||
)]
|
||||
api_ws_ip: IpAddr,
|
||||
|
||||
#[arg(
|
||||
long = "api-ws-port",
|
||||
env = "API_WS_PORT",
|
||||
default_value_t = 9653u16,
|
||||
help = "Bind port for WebSocket JSON-RPC server (default: 9653)"
|
||||
)]
|
||||
api_ws_port: u16,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
||||
let http_addr = SocketAddr::new(cli.api_http_ip, cli.api_http_port);
|
||||
let ws_addr = SocketAddr::new(cli.api_ws_ip, cli.api_ws_port);
|
||||
|
||||
// Initialize Redis driver
|
||||
let redis = herocoordinator::storage::RedisDriver::new(cli.redis_addr.to_string())
|
||||
.await
|
||||
.expect("Failed to connect to Redis");
|
||||
|
||||
// Shared application state
|
||||
let state = Arc::new(herocoordinator::rpc::AppState::new(redis));
|
||||
|
||||
// Build RPC modules for both servers
|
||||
let http_module = herocoordinator::rpc::build_module(state.clone());
|
||||
let ws_module = herocoordinator::rpc::build_module(state.clone());
|
||||
|
||||
println!(
|
||||
"mycelium_ip={}, mycelium_port={}, redis_addr={}",
|
||||
cli.mycelium_ip, cli.mycelium_port, cli.redis_addr
|
||||
"Starting JSON-RPC servers: HTTP http://{} | WS ws://{} | redis_addr={}",
|
||||
http_addr, ws_addr, cli.redis_addr
|
||||
);
|
||||
|
||||
// Start servers
|
||||
let _http_handle = herocoordinator::rpc::start_http(http_addr, http_module)
|
||||
.await
|
||||
.expect("Failed to start HTTP server");
|
||||
let _ws_handle = herocoordinator::rpc::start_ws(ws_addr, ws_module)
|
||||
.await
|
||||
.expect("Failed to start WS server");
|
||||
|
||||
// Wait for Ctrl+C to terminate
|
||||
if let Err(e) = tokio::signal::ctrl_c().await {
|
||||
eprintln!("Failed to listen for shutdown signal: {e}");
|
||||
}
|
||||
println!("Shutdown signal received, exiting.");
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::time::Timestamp;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Actor {
|
||||
id: u32,
|
||||
pubkey: String,
|
||||
|
@@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::time::Timestamp;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Context {
|
||||
/// Redis DB to use
|
||||
id: u32,
|
||||
|
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::time::Timestamp;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Flow {
|
||||
/// Job Id set tby the actor which created it
|
||||
id: u32,
|
||||
@@ -24,7 +24,7 @@ pub struct Flow {
|
||||
}
|
||||
|
||||
/// The status of a flow
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub enum FlowStatus {
|
||||
Dispatched,
|
||||
Started,
|
||||
|
@@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::time::Timestamp;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Runner {
|
||||
id: u32,
|
||||
/// Mycelium public key
|
||||
|
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub enum ScriptType {
|
||||
Osis,
|
||||
Sal,
|
||||
|
613
src/rpc.rs
Normal file
613
src/rpc.rs
Normal file
@@ -0,0 +1,613 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
net::{IpAddr, SocketAddr},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use jsonrpsee::{
|
||||
RpcModule,
|
||||
server::{ServerBuilder, ServerHandle},
|
||||
types::error::ErrorObjectOwned,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::{
|
||||
models::{Actor, Context, Flow, Job, Message, Runner, ScriptType},
|
||||
storage::RedisDriver,
|
||||
time::current_timestamp,
|
||||
};
|
||||
|
||||
pub struct AppState {
|
||||
pub redis: RedisDriver,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(redis: RedisDriver) -> Self {
|
||||
Self { redis }
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Error helpers
|
||||
// -----------------------------
|
||||
|
||||
fn invalid_params_err<E: std::fmt::Display>(e: E) -> ErrorObjectOwned {
|
||||
ErrorObjectOwned::owned(-32602, "Invalid params", Some(Value::String(e.to_string())))
|
||||
}
|
||||
|
||||
fn storage_err(e: Box<dyn std::error::Error + Send + Sync>) -> ErrorObjectOwned {
|
||||
let msg = e.to_string();
|
||||
if msg.contains("Key not found") {
|
||||
ErrorObjectOwned::owned(-32001, "Not Found", Some(Value::String(msg)))
|
||||
} else {
|
||||
ErrorObjectOwned::owned(-32010, "Storage Error", Some(Value::String(msg)))
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Local enums for DTOs (to keep quirks isolated)
|
||||
// -----------------------------
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, Copy)]
|
||||
#[serde(rename_all = "PascalCase")]
|
||||
pub enum MessageFormatTypeDto {
|
||||
Html,
|
||||
Text,
|
||||
Md,
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Create DTOs and Param wrappers
|
||||
// -----------------------------
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ActorCreate {
|
||||
pub id: u32,
|
||||
pub pubkey: String,
|
||||
pub address: Vec<IpAddr>,
|
||||
}
|
||||
impl ActorCreate {
|
||||
pub fn into_domain(self) -> Result<Actor, String> {
|
||||
let ts = current_timestamp();
|
||||
let v = json!({
|
||||
"id": self.id,
|
||||
"pubkey": self.pubkey,
|
||||
"address": self.address,
|
||||
"created_at": ts,
|
||||
"updated_at": ts,
|
||||
});
|
||||
serde_json::from_value(v).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ContextCreate {
|
||||
pub id: u32,
|
||||
pub admins: Vec<u32>,
|
||||
pub readers: Vec<u32>,
|
||||
pub executors: Vec<u32>,
|
||||
}
|
||||
impl ContextCreate {
|
||||
pub fn into_domain(self) -> Result<Context, String> {
|
||||
let ts = current_timestamp();
|
||||
// Note: keep current code quirk: "upddated_at"
|
||||
let mut v = serde_json::Map::new();
|
||||
v.insert("id".to_string(), Value::from(self.id));
|
||||
v.insert(
|
||||
"admins".to_string(),
|
||||
serde_json::to_value(self.admins).unwrap(),
|
||||
);
|
||||
v.insert(
|
||||
"readers".to_string(),
|
||||
serde_json::to_value(self.readers).unwrap(),
|
||||
);
|
||||
v.insert(
|
||||
"executors".to_string(),
|
||||
serde_json::to_value(self.executors).unwrap(),
|
||||
);
|
||||
v.insert("created_at".to_string(), Value::from(ts));
|
||||
v.insert("upddated_at".to_string(), Value::from(ts));
|
||||
serde_json::from_value(Value::Object(v)).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RunnerCreate {
|
||||
pub id: u32,
|
||||
pub pubkey: String,
|
||||
pub address: IpAddr,
|
||||
pub topic: String,
|
||||
pub local: bool,
|
||||
}
|
||||
impl RunnerCreate {
|
||||
pub fn into_domain(self) -> Result<Runner, String> {
|
||||
let ts = current_timestamp();
|
||||
// Note: keep current code quirk: "crated_at"
|
||||
let v = json!({
|
||||
"id": self.id,
|
||||
"pubkey": self.pubkey,
|
||||
"address": self.address,
|
||||
"topic": self.topic,
|
||||
"local": self.local,
|
||||
"crated_at": ts,
|
||||
"updated_at": ts,
|
||||
});
|
||||
serde_json::from_value(v).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct FlowCreate {
|
||||
pub id: u32,
|
||||
pub caller_id: u32,
|
||||
pub context_id: u32,
|
||||
pub jobs: Vec<u32>,
|
||||
pub env_vars: HashMap<String, String>,
|
||||
#[serde(default)]
|
||||
pub result: Option<HashMap<String, String>>,
|
||||
}
|
||||
impl FlowCreate {
|
||||
pub fn into_domain(self) -> Result<Flow, String> {
|
||||
let ts = current_timestamp();
|
||||
let v = json!({
|
||||
"id": self.id,
|
||||
"caller_id": self.caller_id,
|
||||
"context_id": self.context_id,
|
||||
"jobs": self.jobs,
|
||||
"env_vars": self.env_vars,
|
||||
"result": self.result.unwrap_or_default(),
|
||||
"created_at": ts,
|
||||
"updated_at": ts,
|
||||
"status": "Dispatched",
|
||||
});
|
||||
serde_json::from_value(v).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobCreate {
|
||||
pub id: u32,
|
||||
pub caller_id: u32,
|
||||
pub context_id: u32,
|
||||
pub script: String,
|
||||
pub script_type: ScriptType,
|
||||
pub timeout: u32,
|
||||
pub retries: u8,
|
||||
pub env_vars: HashMap<String, String>,
|
||||
#[serde(default)]
|
||||
pub result: Option<HashMap<String, String>>,
|
||||
pub prerequisites: Vec<String>,
|
||||
pub depends: Vec<u32>,
|
||||
}
|
||||
impl JobCreate {
|
||||
pub fn into_domain(self) -> Result<Job, String> {
|
||||
let ts = current_timestamp();
|
||||
let v = json!({
|
||||
"id": self.id,
|
||||
"caller_id": self.caller_id,
|
||||
"context_id": self.context_id,
|
||||
"script": self.script,
|
||||
"script_type": self.script_type,
|
||||
"timeout": self.timeout,
|
||||
"retries": self.retries,
|
||||
"env_vars": self.env_vars,
|
||||
"result": self.result.unwrap_or_default(),
|
||||
"prerequisites": self.prerequisites,
|
||||
"depends": self.depends,
|
||||
"created_at": ts,
|
||||
"updated_at": ts,
|
||||
"status": "Dispatched",
|
||||
});
|
||||
serde_json::from_value(v).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MessageCreate {
|
||||
pub id: u32,
|
||||
pub caller_id: u32,
|
||||
pub context_id: u32,
|
||||
pub message: String,
|
||||
// Note: model uses ScriptType for message_type (keep as-is)
|
||||
pub message_type: ScriptType,
|
||||
pub message_format_type: MessageFormatTypeDto,
|
||||
pub timeout: u32,
|
||||
pub timeout_ack: u32,
|
||||
pub timeout_result: u32,
|
||||
pub job: Vec<JobCreate>,
|
||||
#[serde(default)]
|
||||
pub logs: Option<Vec<String>>,
|
||||
}
|
||||
impl MessageCreate {
|
||||
pub fn into_domain(self) -> Result<Message, String> {
|
||||
let ts = current_timestamp();
|
||||
let jobs: Result<Vec<Value>, String> = self
|
||||
.job
|
||||
.into_iter()
|
||||
.map(|j| {
|
||||
let jd: Job = j.into_domain()?;
|
||||
serde_json::to_value(jd).map_err(|e| e.to_string())
|
||||
})
|
||||
.collect();
|
||||
let v = json!({
|
||||
"id": self.id,
|
||||
"caller_id": self.caller_id,
|
||||
"context_id": self.context_id,
|
||||
"message": self.message,
|
||||
"message_type": self.message_type,
|
||||
"message_format_type": self.message_format_type, // "Html" | "Text" | "Md"
|
||||
"timeout": self.timeout,
|
||||
"timeout_ack": self.timeout_ack,
|
||||
"timeout_result": self.timeout_result,
|
||||
"job": jobs?,
|
||||
"logs": self.logs.unwrap_or_default(),
|
||||
"created_at": ts,
|
||||
"updated_at": ts,
|
||||
"status": "Dispatched",
|
||||
});
|
||||
serde_json::from_value(v).map_err(|e| e.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ActorCreateParams {
|
||||
pub context_id: u32,
|
||||
pub actor: ActorCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ActorLoadParams {
|
||||
pub context_id: u32,
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ContextCreateParams {
|
||||
pub context: ContextCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct ContextLoadParams {
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RunnerCreateParams {
|
||||
pub context_id: u32,
|
||||
pub runner: RunnerCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct RunnerLoadParams {
|
||||
pub context_id: u32,
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct FlowCreateParams {
|
||||
pub context_id: u32,
|
||||
pub flow: FlowCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct FlowLoadParams {
|
||||
pub context_id: u32,
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobCreateParams {
|
||||
pub context_id: u32,
|
||||
pub job: JobCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct JobLoadParams {
|
||||
pub context_id: u32,
|
||||
pub caller_id: u32,
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MessageCreateParams {
|
||||
pub context_id: u32,
|
||||
pub message: MessageCreate,
|
||||
}
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MessageLoadParams {
|
||||
pub context_id: u32,
|
||||
pub caller_id: u32,
|
||||
pub id: u32,
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Rpc module builder (manual registration)
|
||||
// -----------------------------
|
||||
|
||||
pub fn build_module(state: Arc<AppState>) -> RpcModule<()> {
|
||||
let mut module: RpcModule<()> = RpcModule::new(());
|
||||
|
||||
// Actor
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("actor.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: ActorCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let actor = p.actor.into_domain().map_err(invalid_params_err)?;
|
||||
state
|
||||
.redis
|
||||
.save_actor(p.context_id, &actor)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(actor).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register actor.create");
|
||||
}
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("actor.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: ActorLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let actor = state
|
||||
.redis
|
||||
.load_actor(p.context_id, p.id)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(actor).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register actor.load");
|
||||
}
|
||||
|
||||
// Context
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("context.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: ContextCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let ctx = p.context.into_domain().map_err(invalid_params_err)?;
|
||||
state.redis.save_context(&ctx).await.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(ctx).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register context.create");
|
||||
}
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("context.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: ContextLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let ctx = state.redis.load_context(p.id).await.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(ctx).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register context.load");
|
||||
}
|
||||
|
||||
// Runner
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("runner.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: RunnerCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let runner = p.runner.into_domain().map_err(invalid_params_err)?;
|
||||
state
|
||||
.redis
|
||||
.save_runner(p.context_id, &runner)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(runner).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register runner.create");
|
||||
}
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("runner.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: RunnerLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let runner = state
|
||||
.redis
|
||||
.load_runner(p.context_id, p.id)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(runner).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register runner.load");
|
||||
}
|
||||
|
||||
// Flow
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("flow.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: FlowCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let flow = p.flow.into_domain().map_err(invalid_params_err)?;
|
||||
state
|
||||
.redis
|
||||
.save_flow(p.context_id, &flow)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(flow).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register flow.create");
|
||||
}
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("flow.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: FlowLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let flow = state
|
||||
.redis
|
||||
.load_flow(p.context_id, p.id)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(flow).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register flow.load");
|
||||
}
|
||||
|
||||
// Job
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("job.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: JobCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let job = p.job.into_domain().map_err(invalid_params_err)?;
|
||||
state
|
||||
.redis
|
||||
.save_job(p.context_id, &job)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(job).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register job.create");
|
||||
}
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("job.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: JobLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let job = state
|
||||
.redis
|
||||
.load_job(p.context_id, p.caller_id, p.id)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(job).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register job.load");
|
||||
}
|
||||
|
||||
// Message
|
||||
{
|
||||
let state = state.clone();
|
||||
module
|
||||
.register_async_method("message.create", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: MessageCreateParams = params.parse().map_err(invalid_params_err)?;
|
||||
let message = p.message.into_domain().map_err(invalid_params_err)?;
|
||||
state
|
||||
.redis
|
||||
.save_message(p.context_id, &message)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(message).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register message.create");
|
||||
}
|
||||
{
|
||||
let state = state;
|
||||
module
|
||||
.register_async_method("message.load", move |params, _caller, _ctx| {
|
||||
let state = state.clone();
|
||||
async move {
|
||||
let p: MessageLoadParams = params.parse().map_err(invalid_params_err)?;
|
||||
let msg = state
|
||||
.redis
|
||||
.load_message(p.context_id, p.caller_id, p.id)
|
||||
.await
|
||||
.map_err(storage_err)?;
|
||||
{
|
||||
let out: serde_json::Value =
|
||||
serde_json::to_value(msg).map_err(invalid_params_err)?;
|
||||
Ok::<serde_json::Value, ErrorObjectOwned>(out)
|
||||
}
|
||||
}
|
||||
})
|
||||
.expect("register message.load");
|
||||
}
|
||||
|
||||
module
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Server runners (HTTP/WS on separate listeners)
|
||||
// -----------------------------
|
||||
|
||||
pub async fn start_http<C>(
|
||||
addr: SocketAddr,
|
||||
module: RpcModule<C>,
|
||||
) -> Result<ServerHandle, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let server = ServerBuilder::default().build(addr).await?;
|
||||
let handle = server.start(module);
|
||||
Ok(handle)
|
||||
}
|
||||
|
||||
pub async fn start_ws<C>(
|
||||
addr: SocketAddr,
|
||||
module: RpcModule<C>,
|
||||
) -> Result<ServerHandle, Box<dyn std::error::Error + Send + Sync>> {
|
||||
// jsonrpsee server supports both HTTP and WS; using a second listener gives us a dedicated WS port.
|
||||
let server = ServerBuilder::default().build(addr).await?;
|
||||
let handle = server.start(module);
|
||||
Ok(handle)
|
||||
}
|
||||
|
Reference in New Issue
Block a user