Giter Site home page Giter Site logo

astarte-message-hub's People

Contributors

bettio avatar dependabot[bot] avatar francescovaiani avatar harlem88 avatar joshuachp avatar rgallor avatar sorru94 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

astarte-message-hub's Issues

Caching nodes Introspection

Currently all node interfaces have been received during the attach procedure without being cached or persisted, so the message-hub should internally keep all interfaces until the detach method is called by the node..
This can improve in case of astarte-message restart, it already having the introspection will be able to receive the message from an Astarte instance without waiting for the interfaces to be sent froms nodes.

Implement message hub runner in the main file

The main.rs function does not yet contain anything except the initialization of the MessageHubOptions.
The initialization of the AstarteMessageHub should be added together with a runner for the MessageHubServer.

Expose mqtt `keep_alive` to config file

Add to the message-hub config file the configuration of number of seconds after which client should ping the broker if there is no other data exchange.

Possible names:
mqtt_keep_alive
mqtt_connection_keep_alive
...

Missing docstrings

Most of the sources are lacking docstrings.
It would be useful to add short comments for each function/struct.

Missing port for the protobuf server

The Astarte message hub will eventually run a protobuf server (once #75 is completed).
However, there is no way of setting a specific port to use when communicating with the protobuf server.
It should be evaluated if a dynamic configuration of the message hub protobuf server port is required.

Clearer files/structs names

Some files, modules, and functions could be renamed to have clearer names.
For example:

  • The struct Astarte could be renamed to AstarteHandler
  • The file astarte_provider.rs could be renamed to astarte_handler.rs
  • The file mock_astarte.rs could be renamed to mock_astarte_sdk.rs

NodeId via GRPC Metadata

Metadata is a side channel that allows clients and servers to provide information to each other that is associated with an RPC.

gRPC metadata is a key-value pair of data that is sent with initial or final gRPC requests or responses. It is used to provide additional information about the call, such as authentication credentials, tracing information, or custom headers.

Try to figure out if it is possible to move the node id from the Attach message to the GRPC metadata.

https://grpc.io/docs/guides/metadata/#:~:text=gRPC%20metadata%20can%20be%20sent,when%20it%20closes%20an%20RPC.

Add Statistics about nodes attached to the Message Hub

It would be nice to have an Astarte interface that collects statistics from the nodes attached to the Message Hub.
An interface name would be : org.astarte-paltform.messagehub.NodeStats

Mapping:

  • number of messages(sent/received) on specific interface : /$node_id/$interface_name/messages

Adding a layer on AstarteMessage to enrich the API

Currently AstarteMessage can only send/receive AstarteData, so it is better to add a layer on top of AstarteMessage giving the possibility to add other fields in AstarteDataMessage, without introduce a breaking changes in the API.
Other fields can be:

  • an error during the send or receive data.

  • an event from Astarte for a specific node ( for instance , an interface with higher major was added in the introscpection)

  • etc.

  • Rename astarte_message.proto to astarte_data_message.proto .

  • Add AstarteDataMessge.

message AstarteDataMessage{
     AstarteMessage astarte_message = 1;
     AstarteFailure/AstarteError? = 2;
     ...
}

Missing calls to Astarte handler `run` function

The Astarte handler run function is not called within the AstarteMessageHub.
I propose two different approaches:

  • Exposing a run function for the AstarteMessageHub, containing a call to the run function of the Astarte handler. This function however would need to be called in a separate thread due to its blocking nature. This would require the clone trait to be implemented for the AstarteMessageHub struct.
  • Starting a separate tokio task within the initialization function of the AstarteMessageHub in which to call the run function.

Save toml-config in writable path

When the configuration of Astarte-message-hub was provided via HTTP or GRPC-PROTOBUF APIs , the toml file generated by MessageHubOptions must be saved in a writable path, because the default path configured in /etc or the local path of message-hub may not be writable, so it should be saved in the store_directory provided by the MessageHubOptions.

Storing messages for a node that goes offline

If a node goes offline without calling the detach method, all messages directed to it should be stored and on return sent back to the node.

sequenceDiagram
    Node-A->>+MessageHub: Attach
    
    Node-A->>+Node-A: go offline
    Astarte->>+MessageHub: Send data
    alt check Node-A is online
        MessageHub->>MessageHub: Store message for Node-A
    end
    
    Node-A-->>-Node-A: back online
    Node-A->>+MessageHub: Attach
    MessageHub->>+Node-A: Send data

Make it configurable

Make it configurable, the Astarte Message Hub should be support different configuration ways ( config.toml, API Rest, proto method etc )

Licensing refers to edgehog

Configuration files licensing headers refer to Edgehog instead of Astarte.
The files are file.rs, http.rs, protobuf.rs, mod.rs.

* This file is part of Edgehog.

* This file is part of Edgehog.

* This file is part of Edgehog.

* This file is part of Edgehog.

Support hardware id from dbus

  • Retrieve the hardware id form the dbus.
  • Use the hardware id retrieved from the dbus to generate a valid Astarte device id.

Convert project to Cargo Workspace

Split the package into multiple library crates to separate astarte-message-hub-types from the astarte-message-hub application allowing separate distribution of the astarte-message-hub-types crate.

Cargo offers a feature called workspaces that can help manage multiple related packages that are developed in tandem.
A workspace is a set of packages that share the same Cargo.lock and output directory.
Cargo-Workspace

Write library to wrap Astarte SDK

Write simple library to wrap Astarte SDK, use something like trait Publisher that we are using in Edgehog Device Runtime.

Example of Astarte traits for wrapping Astarte SDK Device

#[async_trait]
pub trait AstartePublisher: Send + Sync {
    async fn send_object<T: 'static>(
        &self,
        interface_name: &str,
        interface_path: &str,
        data: T,
    ) -> Result<(), AstarteError>
    where
        T: serde::Serialize + Send;
    async fn send(
        &self,
        interface_name: &str,
        interface_path: &str,
        data: AstarteType,
    ) -> Result<(), AstarteError>;
}

#[async_trait]
pub trait AstarteSubscriber {
    async fn subscribe(
        &self,
        astarte_node: &AstarteNode,
    ) -> Result<Receiver<Result<AstarteMessage, Status>>, AstarteError>;
    async fn unsubscribe(&self, astarte_node: AstarteNode) -> Result<(), AstarteError>;
}

https://github.com/harlem88/astarte-message-hub/blob/5d7268c94e785d44828dfeefdf8f23385b474dd4/src/data/mod.rs#L32

Add Ack signaling when the Astarte Message Hub send a message to the node

Currently the Astarte message hub doesn't support an ack mechanism to signal the exact receipt of a message by a node.
For add the ack support the message-hub needs:

  • Add an ID to identify each message sent from Message-hub.
  • An ack method ack_message(message_id) to send the ack signal from the node to Astarte message hub.
  • Add a configuration on the node to specify whether it supports ack signaling or whether the message-hub should consider that all messages have been successfully received (the default shoud be the second option) .

Add Information about nodes attached to the Message Hub

It would be nice to have an Astarte interface that collects information about the nodes attached to the Message Hub.
An interface name would be : org.astarte-paltform.messagehub.NodeInfo

Mapping:

  • All node_id attached to the Message Hub, maybe a settable/unsettable boolean property like /${node_id}/attached.
  • The interfaces of each node, it would be a settable/unsettable strings array like /${node_id}/interfaces

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.