1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Simple Echo Connector - The easiest way to build a connector!
//!
//! This demonstrates the simplified API. Compare this to echo_connector.rs
//! which uses the low-level API.
//!
//! Run with:
//! STRIKE48_HOST=localhost:50061 TENANT_ID=default cargo run --example simple_echo
use strike48_connector::prelude::*;
/// Echo connector - just 15 lines!
struct EchoConnector;
#[async_trait]
impl SimpleConnector for EchoConnector {
fn name(&self) -> &str {
"echo"
}
fn version(&self) -> &str {
"1.0.0"
}
async fn handle(&self, request: Value) -> Result<Value> {
// Just return the request as-is, wrapped in an echo response
Ok(json!({
"success": true,
"echo": request,
"timestamp": chrono::Utc::now().to_rfc3339()
}))
}
}
#[tokio::main]
async fn main() -> Result<()> {
println!("🚀 Starting Echo Connector...");
println!(" This connector echoes back any request it receives.");
println!();
// That's it! The connector reads config from environment variables
// and handles signal shutdown automatically.
EchoConnector.run().await
}