#iot #networking #platform #broker #unit #routes #applications

bin+lib sylvia-iot-broker

The message broker module of the Sylvia-IoT platform

54 releases

new 0.2.1 Jan 10, 2025
0.1.16 Dec 20, 2024
0.1.15 Sep 27, 2024
0.1.6 Jul 30, 2024
0.0.6 Mar 31, 2023

#92 in HTTP server

Download history 210/week @ 2024-09-23 143/week @ 2024-09-30 8/week @ 2024-10-07 2/week @ 2024-10-14 2/week @ 2024-10-21 7/week @ 2024-11-18 3/week @ 2024-11-25 7/week @ 2024-12-02 115/week @ 2024-12-09 132/week @ 2024-12-16 13/week @ 2024-12-23 258/week @ 2025-01-06

429 downloads per month
Used in 3 crates

MIT license

1MB
22K SLoC

crates.io Documentation CI Coverage Docker License

sylvia-iot-broker

The message broker module of the Sylvia-IoT platform.

This module provides:

  • Unit management for each owner, including
    • Applications
    • Private networks
    • Devices
    • Device routes to applications
    • Private network routes to applications
  • Public network management

Documentation

Mount sylvia-iot-broker in your axum App

You can simply mount sylvia-iot-broker into your 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
}

Please see src/bin/sylvia-iot-broker.rs to get the real world example.

Dependencies

~79MB
~1.5M SLoC