Merge branch 'development_rhai'
This commit is contained in:
commit
d122304236
146
heromodels/Cargo.lock
generated
146
heromodels/Cargo.lock
generated
@ -60,14 +60,14 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
@ -127,9 +127,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.17.0"
|
||||
version = "3.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@ -145,18 +145,18 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.23"
|
||||
version = "1.2.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766"
|
||||
checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
@ -210,18 +210,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.4.2"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
|
||||
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
|
||||
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
@ -300,7 +300,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -348,7 +348,7 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -400,6 +400,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tst",
|
||||
"uuid",
|
||||
]
|
||||
@ -410,7 +411,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -513,7 +514,7 @@ checksum = "03343451ff899767262ec32146f6d559dd759fdadf42ff0e227c7c48f72594b4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -543,9 +544,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jsonb"
|
||||
version = "0.5.2"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "153dfebb6ad4484c84a5ae765a18976bf476b8a3f5165ce987aedd59d1f1e6c8"
|
||||
checksum = "96cbb4fba292867a2d86ed83dbe5f9d036f423bf6a491b7d884058b2fde42fcd"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"ethnum",
|
||||
@ -563,9 +564,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.172"
|
||||
version = "0.2.174"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
||||
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
@ -595,9 +596,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
version = "2.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
@ -615,7 +616,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
@ -744,9 +745,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.11.0"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e"
|
||||
checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic-util"
|
||||
@ -831,9 +832,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.2.0"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "r2d2"
|
||||
@ -926,9 +927,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rhai"
|
||||
version = "1.21.0"
|
||||
version = "1.22.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce4d759a4729a655ddfdbb3ff6e77fb9eadd902dae12319455557796e435d2a6"
|
||||
checksum = "2780e813b755850e50b178931aaf94ed24f6817f46aaaf5d21c13c12d939a249"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"bitflags",
|
||||
@ -951,14 +952,14 @@ checksum = "a5a11a05ee1ce44058fa3d5961d05194fdbe3ad6b40f904af764d81b86450e6b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust_decimal"
|
||||
version = "1.37.1"
|
||||
version = "1.37.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "faa7de2ba56ac291bd90c6b9bece784a52ae1411f9506544b3eae36dd2356d50"
|
||||
checksum = "b203a6425500a03e0919c42d3c47caca51e79f1132046626d2c8871c5092035d"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"num-traits",
|
||||
@ -972,9 +973,9 @@ checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.20"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2"
|
||||
checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
@ -1014,14 +1015,14 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.140"
|
||||
version = "1.0.142"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
@ -1047,6 +1048,15 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
version = "1.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "1.0.1"
|
||||
@ -1061,9 +1071,9 @@ checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.0"
|
||||
version = "1.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9"
|
||||
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
||||
|
||||
[[package]]
|
||||
name = "smartstring"
|
||||
@ -1135,7 +1145,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustversion",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1157,9 +1167,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.101"
|
||||
version = "2.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
|
||||
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -1189,7 +1199,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1218,21 +1228,35 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.47.0"
|
||||
version = "1.47.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35"
|
||||
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"io-uring",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
"socket2 0.6.0",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-postgres"
|
||||
version = "0.7.13"
|
||||
@ -1261,9 +1285,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.15"
|
||||
version = "0.7.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
|
||||
checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-core",
|
||||
@ -1344,9 +1368,9 @@ checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
version = "0.11.1+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
@ -1385,7 +1409,7 @@ dependencies = [
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
@ -1407,7 +1431,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
@ -1463,7 +1487,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1474,14 +1498,14 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.1.1"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
@ -1594,20 +1618,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.25"
|
||||
version = "0.8.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb"
|
||||
checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.25"
|
||||
version = "0.8.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef"
|
||||
checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.101",
|
||||
"syn 2.0.104",
|
||||
]
|
||||
|
@ -35,6 +35,7 @@ rhai = []
|
||||
|
||||
[dev-dependencies]
|
||||
chrono = "0.4"
|
||||
tokio = { version = "1.0", features = ["full"] }
|
||||
[[example]]
|
||||
name = "calendar_example"
|
||||
path = "examples/calendar_example/main.rs"
|
||||
|
171
heromodels/examples/circle_launcher_README.md
Normal file
171
heromodels/examples/circle_launcher_README.md
Normal file
@ -0,0 +1,171 @@
|
||||
# Circle Launcher - Simplified Builder Pattern
|
||||
|
||||
This example demonstrates the simplified builder pattern for creating circles and launching them using the unified launcher interface.
|
||||
|
||||
## Overview
|
||||
|
||||
The system now uses a clean builder pattern with two main builders:
|
||||
|
||||
1. **Circle Builder** (`new_circle()`) - For creating and saving circles
|
||||
2. **Launcher Builder** (`new_launcher()`) - For configuring and launching multiple circles
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Creating and Saving Circles
|
||||
|
||||
```rust
|
||||
use heromodels::models::circle::circle::new_circle;
|
||||
|
||||
// Create and save a circle
|
||||
let circle = new_circle()
|
||||
.title("My Test Circle")
|
||||
.public_key("02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4")
|
||||
.ws_url("ws://127.0.0.1:8080")
|
||||
.description("A test circle for demonstration")
|
||||
.save();
|
||||
```
|
||||
|
||||
### Simple Launcher (Direct Spawn Mode)
|
||||
|
||||
```rust
|
||||
use heromodels::models::circle::circle::new_launcher;
|
||||
|
||||
// Launch a single circle in direct spawn mode
|
||||
new_launcher()
|
||||
.add_circle("02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4")
|
||||
.redis_url("redis://127.0.0.1:6379")
|
||||
.port(8080)
|
||||
.launch()?;
|
||||
```
|
||||
|
||||
### Service Manager Mode
|
||||
|
||||
```rust
|
||||
// Launch with service manager (uses default worker binary path)
|
||||
new_launcher()
|
||||
.add_circle("02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4")
|
||||
.service_manager(true) // Enables service manager with default worker binary
|
||||
.redis_url("redis://127.0.0.1:6379")
|
||||
.port(8080)
|
||||
.launch()?;
|
||||
|
||||
// Or with custom worker binary path
|
||||
new_launcher()
|
||||
.add_circle("02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4")
|
||||
.worker_binary("./custom/path/to/worker") // Custom worker binary path
|
||||
.redis_url("redis://127.0.0.1:6379")
|
||||
.port(8080)
|
||||
.launch()?;
|
||||
```
|
||||
|
||||
### Multiple Circles with Initialization Scripts
|
||||
|
||||
```rust
|
||||
// Launch multiple circles with different configurations
|
||||
new_launcher()
|
||||
.add_circle("02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4")
|
||||
.initialization_script("init_script1.rhai")
|
||||
.add_circle("03b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d5")
|
||||
.initialization_script("init_script2.rhai")
|
||||
.add_circle("04c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d6")
|
||||
.worker_binary("./target/release/worker")
|
||||
.redis_url("redis://127.0.0.1:6379")
|
||||
.port(8080)
|
||||
.launch()?;
|
||||
```
|
||||
|
||||
### Mixed Configuration
|
||||
|
||||
```rust
|
||||
// Some circles with scripts, some without
|
||||
new_launcher()
|
||||
.add_circle("02a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4")
|
||||
.initialization_script("setup.rhai")
|
||||
.add_circle("03b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d5") // No script
|
||||
.add_circle("04c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d6")
|
||||
.initialization_script("config.rhai")
|
||||
.redis_url("redis://127.0.0.1:6379")
|
||||
.port(3000)
|
||||
.launch()
|
||||
.await?;
|
||||
```
|
||||
|
||||
## Builder Methods
|
||||
|
||||
### Circle Builder Methods
|
||||
|
||||
| Method | Description | Example |
|
||||
|--------|-------------|---------|
|
||||
| `title()` | Sets the circle title | `.title("My Circle")` |
|
||||
| `public_key()` | Sets the circle's public key | `.public_key("02a1b2c3...")` |
|
||||
| `ws_url()` | Sets the WebSocket URL | `.ws_url("ws://127.0.0.1:8080")` |
|
||||
| `description()` | Sets the description | `.description("Test circle")` |
|
||||
| `logo()` | Sets the logo URL | `.logo("https://example.com/logo.png")` |
|
||||
| `add_member()` | Adds a member | `.add_member("member_public_key")` |
|
||||
| `save()` | Saves the circle | `.save()` |
|
||||
|
||||
### Launcher Builder Methods
|
||||
|
||||
| Method | Description | Example |
|
||||
|--------|-------------|---------|
|
||||
| `add_circle()` | Adds a circle by public key | `.add_circle("02a1b2c3...")` |
|
||||
| `initialization_script()` | Sets init script for last added circle | `.initialization_script("init.rhai")` |
|
||||
| `worker_binary()` | Sets custom worker binary path (enables service manager) | `.worker_binary("./custom/worker")` |
|
||||
| `redis_url()` | Sets Redis URL | `.redis_url("redis://127.0.0.1:6379")` |
|
||||
| `port()` | Sets the port | `.port(8080)` |
|
||||
| `service_manager()` | Enables service manager with default worker binary | `.service_manager(true)` |
|
||||
| `launch()` | Launches all configured circles | `.launch()?` |
|
||||
|
||||
## Generated Commands
|
||||
|
||||
The launcher builder generates clean commands:
|
||||
|
||||
### Direct Spawn Mode
|
||||
```bash
|
||||
launcher --redis-url redis://127.0.0.1:6379 --port 8080 \
|
||||
-c 02a1b2c3... -c 03b2c3d4...:init.rhai -c 04c3d4e5...
|
||||
```
|
||||
|
||||
### Service Manager Mode
|
||||
```bash
|
||||
launcher --redis-url redis://127.0.0.1:6379 --port 8080 \
|
||||
--use-service-manager --worker-binary ../target/release/worker \
|
||||
-c 02a1b2c3...:init1.rhai -c 03b2c3d4...:init2.rhai -c 04c3d4e5...
|
||||
```
|
||||
|
||||
## Key Features
|
||||
|
||||
### Simplified API
|
||||
- Single way to do things (no multiple methods for the same functionality)
|
||||
- Clean builder pattern for both circles and launcher
|
||||
- Method chaining for fluent interface
|
||||
|
||||
### Automatic Mode Detection
|
||||
- **Direct Spawn Mode**: Default behavior
|
||||
- **Service Manager Mode**: Enabled when `service_manager(true)` is called or when `worker_binary()` is called
|
||||
- **Default Worker Binary**: Uses `../target/release/worker` unless custom path is specified
|
||||
|
||||
### Flexible Configuration
|
||||
- Add multiple circles in a single launcher
|
||||
- Each circle can have its own initialization script
|
||||
- Mix circles with and without scripts
|
||||
|
||||
### Error Handling
|
||||
- Clear error messages for missing configuration
|
||||
- Validation of required parameters
|
||||
- Proper error propagation
|
||||
|
||||
## Running the Example
|
||||
|
||||
```bash
|
||||
# From the heromodels directory
|
||||
cargo run --example circle_launcher_example
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- The `initialization_script()` method applies to the last circle added with `add_circle()`
|
||||
- Setting a `worker_binary()` automatically enables service manager mode
|
||||
- Redis must be running for the workers to function properly
|
||||
- Public keys must be valid secp256k1 format (64 hex characters)
|
||||
- The launcher binary must be available in PATH or specify full path
|
39
heromodels/examples/circle_launcher_example.rs
Normal file
39
heromodels/examples/circle_launcher_example.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use circles_launcher::{new_launcher};
|
||||
use heromodels::models::circle::circle::{new_circle};
|
||||
use secp256k1::{Secp256k1, SecretKey, PublicKey};
|
||||
use rand::rngs::OsRng;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Generate valid secp256k1 keypairs for testing
|
||||
let secp = Secp256k1::new();
|
||||
let mut rng = OsRng;
|
||||
|
||||
let secret_key1 = SecretKey::new(&mut rng);
|
||||
let public_key1 = PublicKey::from_secret_key(&secp, &secret_key1);
|
||||
let pk1_hex = hex::encode(public_key1.serialize());
|
||||
|
||||
let secret_key2 = SecretKey::new(&mut rng);
|
||||
let public_key2 = PublicKey::from_secret_key(&secp, &secret_key2);
|
||||
let pk2_hex = hex::encode(public_key2.serialize());
|
||||
|
||||
let secret_key3 = SecretKey::new(&mut rng);
|
||||
let public_key3 = PublicKey::from_secret_key(&secp, &secret_key3);
|
||||
let pk3_hex = hex::encode(public_key3.serialize());
|
||||
|
||||
println!("Generated test public keys:");
|
||||
println!(" PK1: {}", pk1_hex);
|
||||
println!(" PK2: {}", pk2_hex);
|
||||
println!(" PK3: {}", pk3_hex);
|
||||
|
||||
// Example 1: Create and save a circle
|
||||
println!("\n=== Example 1: Create and Save Circle ===");
|
||||
let _circle = new_circle()
|
||||
.title("My Test Circle")
|
||||
.public_key(&pk1_hex)
|
||||
.ws_url("ws://127.0.0.1:8080")
|
||||
.description("A test circle for demonstration")
|
||||
.save();
|
||||
|
||||
Ok(())
|
||||
}
|
@ -24,6 +24,8 @@ pub struct Circle {
|
||||
#[index]
|
||||
pub title: String,
|
||||
pub ws_url: String,
|
||||
/// Public key for this circle
|
||||
pub public_key: String,
|
||||
/// Optional description of the circle
|
||||
pub description: Option<String>,
|
||||
/// List of related circles
|
||||
@ -43,6 +45,7 @@ impl Circle {
|
||||
base_data: BaseModelData::new(),
|
||||
title: String::new(),
|
||||
ws_url: String::new(),
|
||||
public_key: String::new(),
|
||||
description: None,
|
||||
circles: Vec::new(),
|
||||
logo: None,
|
||||
@ -63,6 +66,12 @@ impl Circle {
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the public key for the circle
|
||||
pub fn public_key(mut self, public_key: impl ToString) -> Self {
|
||||
self.public_key = public_key.to_string();
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the description for the circle
|
||||
pub fn description(mut self, description: impl ToString) -> Self {
|
||||
self.description = Some(description.to_string());
|
||||
@ -98,4 +107,16 @@ impl Circle {
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Saves the circle (placeholder for actual save implementation)
|
||||
pub fn save(self) -> Self {
|
||||
// TODO: Implement actual save logic to database
|
||||
println!("Saving circle: {}", self.title);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new circle builder
|
||||
pub fn new_circle() -> Circle {
|
||||
Circle::new()
|
||||
}
|
49
heromodels/src/models/identity/kyc.rs
Normal file
49
heromodels/src/models/identity/kyc.rs
Normal file
@ -0,0 +1,49 @@
|
||||
//! KYC (Know Your Customer) identity verification structures
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// iDenfy webhook event structure
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct IdenfyWebhookEvent {
|
||||
#[serde(rename = "clientId")]
|
||||
pub client_id: String,
|
||||
#[serde(rename = "scanRef")]
|
||||
pub scan_ref: String,
|
||||
pub status: String,
|
||||
pub platform: String,
|
||||
#[serde(rename = "startedAt")]
|
||||
pub started_at: String,
|
||||
#[serde(rename = "finishedAt")]
|
||||
pub finished_at: Option<String>,
|
||||
#[serde(rename = "clientIP")]
|
||||
pub client_ip: Option<String>,
|
||||
#[serde(rename = "clientLocation")]
|
||||
pub client_location: Option<String>,
|
||||
pub data: Option<IdenfyVerificationData>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct IdenfyVerificationData {
|
||||
#[serde(rename = "docFirstName")]
|
||||
pub doc_first_name: Option<String>,
|
||||
#[serde(rename = "docLastName")]
|
||||
pub doc_last_name: Option<String>,
|
||||
#[serde(rename = "docNumber")]
|
||||
pub doc_number: Option<String>,
|
||||
#[serde(rename = "docPersonalCode")]
|
||||
pub doc_personal_code: Option<String>,
|
||||
#[serde(rename = "docExpiry")]
|
||||
pub doc_expiry: Option<String>,
|
||||
#[serde(rename = "docDob")]
|
||||
pub doc_dob: Option<String>,
|
||||
#[serde(rename = "docType")]
|
||||
pub doc_type: Option<String>,
|
||||
#[serde(rename = "docSex")]
|
||||
pub doc_sex: Option<String>,
|
||||
#[serde(rename = "docNationality")]
|
||||
pub doc_nationality: Option<String>,
|
||||
#[serde(rename = "docIssuingCountry")]
|
||||
pub doc_issuing_country: Option<String>,
|
||||
#[serde(rename = "manuallyDataChanged")]
|
||||
pub manually_data_changed: Option<bool>,
|
||||
}
|
5
heromodels/src/models/identity/mod.rs
Normal file
5
heromodels/src/models/identity/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
//! Identity-related models and types
|
||||
|
||||
pub mod kyc;
|
||||
|
||||
pub use kyc::*;
|
@ -14,6 +14,8 @@ pub mod legal;
|
||||
pub mod library;
|
||||
pub mod object;
|
||||
pub mod projects;
|
||||
pub mod payment;
|
||||
pub mod identity;
|
||||
|
||||
// Re-export key types for convenience
|
||||
pub use core::Comment;
|
||||
|
5
heromodels/src/models/payment/mod.rs
Normal file
5
heromodels/src/models/payment/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
//! Payment-related models and types
|
||||
|
||||
pub mod stripe;
|
||||
|
||||
pub use stripe::*;
|
30
heromodels/src/models/payment/stripe.rs
Normal file
30
heromodels/src/models/payment/stripe.rs
Normal file
@ -0,0 +1,30 @@
|
||||
//! Stripe payment webhook event structures
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Stripe webhook event structure
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct StripeWebhookEvent {
|
||||
pub id: String,
|
||||
pub object: String,
|
||||
pub api_version: Option<String>,
|
||||
pub created: i64,
|
||||
pub data: StripeEventData,
|
||||
pub livemode: bool,
|
||||
pub pending_webhooks: i32,
|
||||
pub request: Option<StripeEventRequest>,
|
||||
#[serde(rename = "type")]
|
||||
pub event_type: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct StripeEventData {
|
||||
pub object: serde_json::Value,
|
||||
pub previous_attributes: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize)]
|
||||
pub struct StripeEventRequest {
|
||||
pub id: Option<String>,
|
||||
pub idempotency_key: Option<String>,
|
||||
}
|
Loading…
Reference in New Issue
Block a user