implement models for payment and id verification
This commit is contained in:
parent
149c177def
commit
f2a3aeb418
262
heromodels/Cargo.lock
generated
262
heromodels/Cargo.lock
generated
@ -2,6 +2,21 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.24.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.12"
|
||||
@ -43,6 +58,21 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.75"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "2.0.1"
|
||||
@ -75,6 +105,12 @@ version = "3.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.23"
|
||||
@ -177,6 +213,12 @@ dependencies = [
|
||||
"wasi 0.14.2+wasi-0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.31.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
@ -199,6 +241,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"tokio",
|
||||
"tst",
|
||||
"uuid",
|
||||
]
|
||||
@ -275,6 +318,16 @@ version = "0.2.172"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.27"
|
||||
@ -287,6 +340,26 @@ version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "no-std-compat"
|
||||
version = "0.4.1"
|
||||
@ -305,6 +378,15 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
@ -324,6 +406,35 @@ dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.11.0"
|
||||
@ -393,6 +504,15 @@ dependencies = [
|
||||
"getrandom 0.2.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rhai"
|
||||
version = "1.21.0"
|
||||
@ -443,6 +563,12 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.20"
|
||||
@ -455,6 +581,12 @@ version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.219"
|
||||
@ -493,6 +625,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.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.0"
|
||||
@ -510,6 +651,16 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[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 = "spin"
|
||||
version = "0.5.2"
|
||||
@ -598,6 +749,35 @@ dependencies = [
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio"
|
||||
version = "1.45.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.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.101",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tst"
|
||||
version = "0.1.0"
|
||||
@ -773,6 +953,88 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen-rt"
|
||||
version = "0.39.0"
|
||||
|
@ -27,6 +27,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