-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start support for AWS IoT setup #1103
base: main
Are you sure you want to change the base?
Conversation
@impl Supervisor | ||
def init(opts) do | ||
opts = | ||
Application.get_env(:nerves_hub, __MODULE__, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if the sup took these arguments in start_link/1
rather than pulling them from application env on init. You can keep the same pattern if you want to use app env e.g.
opts = Application.get_env(:nerves_hub, __MODULE__, [])
{NervesHub.AWSIoT, opts}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The incoming opts to the GenServer are merged into the Application env so the end result is the same where opts provided to start_link will take precedence . The preference here is mostly that it is contained
This is really cool. Regarding the MQTT to SQS dance, just to confirm, you are essentially starting a Broadway consumer for MQTT events then popping them onto SQS, right? And then there is another Broadway consumer for SQS events? |
Not quite. Broadway is only for consuming SQS. Servers publish directly to the MQTT broker (via an HTTP request) which distributes messages to topic subscribers |
Ok, in your diagram is shows MQTT publishing to SQS, is that a function supported by MQTT? |
Ah, yes. My draft of doc changes talk about this but just realized it wasn't mentioned here. MQTT is only a broker, but it's common to put a "rules engine" in front of it to run some query/checks on the topic and/or payload and perform an action on it. This is included as part of AWS IoT. You would pick topics devices use for directing messages to a server and the rules engine would have a rule that matches at the broker and sends the message to a queue, like SQS, instead. |
ahhhh, cool, thanks for the extra information. |
Initial support for an MQTT and message queue setup for device connections as an alternative to websockets
Initial support for an MQTT and message queue setup for device connections as an alternative to websockets.
This first focus is on a typical AWS IoT setup which handles device connection (including authentication), provides connect/disconnect lifecycle events, and forwards messages directed for the server to an SQS queue which server nodes will poll from when available to do work.
Documentation on setting up this type of infrastructure is still being worked on, but much of the code is annotated and a general overview is in the graph below. It mainly showcases some message flow between multiple server nodes and devices through MQTT+queue system
Note
nh/#{device.identifier}
topic is for server->devicenh/device_messages
topic is for device->server