Skip to content

Rust project built to understand the maturity of the RustLag ecosystem for the most common IoT Tools

License

Notifications You must be signed in to change notification settings

ralvescosta/rust_iot

Repository files navigation

Rust IoT Example

codecov

⚠️🚧 Work In Progress 🚧⚠️

This project was built to understand the maturity of the RustLag ecosystem for the most common IoT Tools, such as: MQTT and RabbitMQ. In this project was build a simples example which receive sames messages through MQTT 3.1.1, republish those messages to RabbitMQ and handle the RabbitMQ events to save this data, and also was created a HTTP and gRPC interface to get the information that has been saved. Was created six binary mqtt, amqp, dump, dummy, ggrpc and hhttp which for the respective protocol.

Also in this project we take care about some well-known practices to web development like: Unit tests, Environment variables, Logging, Tracing and Metrics with Opentelemetry, Containerization and so on.

  • MQTT binary

    • For MQTT the project has been used the rumqttc create, this create seen good offering a async client based in Tokio.
    • The main ideia for the s.mqtt binary is that receive the IoT data and delivery these data to a RabbitMQ exchange
  • AMQP Binaries

    • amqp binary:

      • The main ideia for the s.amqp binary is that receive the IoT do some works and "notify" the other services about the IoT data.
    • dummy binary:

      • The main ideia for the s.dummy binary is that receive the IoT notification and do some works.
    • dump binary:

      • The main ideia for the s.dump binary is that receive the IoT notification and do some works.

How can I build the binaries?

Make sure you have the following pre-requirements:

  • rustup@lts

  • rustc@lts

  • cargo@lts

  • protoc@lts

  • To build the MQTT Binary

    cargo build --binary mqtt --release
  • To build the AMQP Binaries

    • amqp
    cargo build --binary amqp --release
    • dummy
    cargo build --binary dummy --release
    • dump
    cargo build --binary dump --release

How can I run the project?

Make sure you have the following pre-requirements:

  • docker-ce@lts
  • minikube@lts
  • kubectl@lts

Future features

  • HTTP binary

    • For HTTP the project has been used actix-web create.
    • The main ideia for the s.http binary is that get the data that has been saved in PostgreSQL and return a friendly JSON.
  • gRPC binary

    • For gRPC the project has been used tonic create.
    • The main ideia for the s.grpc binary is that get the data that has been saved in PostgreSQL and return using proto buffer.

Conclusions:

  • MQTT:

For now there are a lot of MQTT client crates. The crate for the most famous MQTT community (Eclipse) use C bindings for the MQTT client implemented in C and because of that I think it's a not a god ideia to use that crate. In this project had used rumqttc. Very good crate, nice async support with Tokio and Eventloop runtime and also offers support for MQTTv5.

  • RabbitMQ:

For RabbitMQ the chosen was lapin. This crate offer full AMQP implementation and beautiful RabbitMQ interface.

  • Opentelemetry + Newrelic:

Opentelemetry is gaining relevance and wen this project was implemented the rust ecosystem was very mature and stable to use the Opentelemetry Rust SDK. Was easy to configure an OTLP tracing exporter and plug this export with Newrelic;

newrelic-opentelemetry

Before some days working in this project my felling is that, the Rust ecosystem is already mature to suporte a full implementation for IoT softwares, there are a lot of crates, documentation and exemplos to guid us.

Commands:

  • cargo install protobuf-codegen
  • cargo install grpcio-compiler
  • apt install -y protobuf-compiler

About

Rust project built to understand the maturity of the RustLag ecosystem for the most common IoT Tools

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •