dimanche 31 janvier 2021

How can I make accesible some operations of a Python application over the network?

I have a Python application that is executed to continually monitor the system to search anomalies. This project has connections to database to store information and a set of componentes that are in charge of different monitor tasks. Each component can be paused and resumed, and an in memory state (status, uptime, last anomaly detected, detection parameters...)

The question is: how can I expose the operations to pause and resumen (or even change the detection parameters) a component to a web client (for example a React webapp)?. All the options that I can think has problems:

  • Integrate a Flask API: the fundamentals of a REST API is that they should be stateless, but my backend has state (components and their status).
  • Separate Flask API. Here my problem is how communicate the Flask API with the backend. I have though in a message queue: the client send a request to the API, the API creates an event "start component 2", add it to the queue and the backend receives the event. But with this approach, the web client can not receive confirmation unless the request wait for another event from the backend with the result of the operation, which make the communication syncronous.

Maybe there is something that I'm missing and the solution is easier than all of this.

Aucun commentaire:

Enregistrer un commentaire