46个版本

新版本 0.1.10 2024年8月16日
0.1.6 2024年7月30日
0.0.36 2024年2月16日
0.0.35 2023年12月15日
0.0.6 2023年3月31日

358HTTP服务器 中排名

Download history 297/week @ 2024-05-13 265/week @ 2024-05-20 84/week @ 2024-05-27 10/week @ 2024-06-03 3/week @ 2024-06-10 109/week @ 2024-07-22 500/week @ 2024-07-29 86/week @ 2024-08-05

每月695次下载
用于 3 crates

MIT许可证

1MB
22K SLoC

crates.io Documentation CI Coverage Docker License

sylvia-iot-broker

Sylvia-IoT平台的消息代理模块。

此模块提供

  • 为每个所有者提供单元管理,包括
    • 应用程序
    • 私有网络
    • 设备
    • 设备路由到应用程序
    • 私有网络路由到应用程序
  • 公共网络管理

文档

在您的axum App中挂载sylvia-iot-broker

您可以将sylvia-iot-broker简单地挂载到您的axum App中

use axum::Router;
use clap::App as ClapApp;
use std::net::SocketAddr;
use sylvia_iot_broker::{libs, routes};
use tokio::{self, net::TcpListener};

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let args = ClapApp::new("your-project-name").get_matches();

    let conf = libs::config::read_args(&args);
    let broker_state = match routes::new_state("/broker", &conf).await {
        Err(e) => {
            println!("Error: {}", e);
            return Ok(());
        },
        Ok(state) => state,
    };
    let app = Router::new().merge(routes::new_service(&broker_state));
    let listener = match TcpListener::bind("0.0.0.0:1080").await.unwrap();
    axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await
}

请参阅src/bin/sylvia-iot-broker.rs以获取真实世界示例。

依赖关系

~77MB
~1.5M SLoC