A Distributed Systems course project developed by Justine F., Bruno P., Paul V., Aymeric L.
{
"idAirport": "string",
"idSensor": "integer",
"value": "float",
"measure": "string",
"date": "string"
}At the root, run every command in a terminal, distinct from the others.
- Init the REDIS database:
docker-compose up- Run the subscriber connected to the database
go run cmd/mqtt_sub/subscriber.go configs/config_redis.json- Run the one writing the measures to CSV files:
go run cmd/mqtt_sub/subscriber.go configs/config_csv.json- Run a first publisher (the (mocked) temperature sensor installed in Nantes Airport):
go run cmd/mqtt_pub/publisher.go configs/capteur_NTE_temp.json- Run a second one (the (mocked) pressure sensor installed in Pointe-à-Pitre Airport):
go run cmd/mqtt_pub/publisher.go configs/capteur_PTP_pres.json- Launch the API:
go run pkg/api/main.go- For API discovery: see
pkg/api/openapi.yamlfile
- JSON config file: sensor & MQTT Broker connexion configurations
- Connexion to the topic
airport/{airportID}through the MQTT client --> MQTT broker
- A mocked datum is generated by trigonometric function depending on time (by calling
time.Now()), with very little variation. The value is stored as a float number in the defined data structure, see thevaluefield. - A SensorData is created, with
{sensorID, airportID, measureType, value, timestamp}fields - It is then marshalled, and straight after
- it is sent to the MQTT broker
- The process is repeated every 10 minutes
- JSON config file: sub (writing to CSV files or the REDIS DB) configuration & connexion to MQTT Broker configuration
FactoryControllerDAO-->SensorControllerREDIS or CSV- Listening to all topics
airport/#by MQTT client--> MQTT broker
Interface writing the received data (the SensorData objects) through the Write method. It's implemented according to the chosen storage method: CSV file or the REDIS DB.
The DAO embeds a REDIS client that connects to the database, using the address and the password given by the configuration file.
Every call to the implemented Write method writes the SensorData (containing the value) in the DB with a unique ID (key) in the form of {sensorID}_{airportID}_{currentTime}.
Eventually, it ends up by:
MQTT broker ---> sub REDIS -- REDIS_client.Set (key, value) --> BDD REDIS
- Connexion to the DB
- HTTP Request to the REST API ---> route ---> handler ---> DB call
- DB reponse ---> marshalling ---> JSON response payload
- JSON config for each sensor --> PubOfAnAirportSensor -- random data --> MQTT broker <-- sub REDIS/CSV <-- JSON config for each sub
- sub REDIS --> DB --> API
- sub CSV --> CSV datalake