{"id":14983564,"url":"https://github.com/andrea-cavallo/go_grpc_temperature_monitoring","last_synced_at":"2025-04-10T18:44:58.674Z","repository":{"id":253422708,"uuid":"843457206","full_name":"Andrea-Cavallo/go_grpc_temperature_monitoring","owner":"Andrea-Cavallo","description":"Real-Time Temperature Monitoring with Go and gRPC ( Twilio Integration, MongoDB, weatherAPI, Plot diagrams, Jaeger - Grafana - Loki ) 😜","archived":false,"fork":false,"pushed_at":"2024-08-19T08:38:59.000Z","size":648,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T16:34:51.292Z","etag":null,"topics":["dashboard","golang","grafana-dashboard","grpc","grpc-client","grpc-go","grpc-server","jaeger","loki","mongodb","plot","protocol-buffers","temperature-monitoring","twilio","weather"],"latest_commit_sha":null,"homepage":"https://medium.com/@andreacavallo","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Andrea-Cavallo.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-16T14:57:11.000Z","updated_at":"2024-10-04T20:39:26.000Z","dependencies_parsed_at":"2024-09-24T15:24:37.464Z","dependency_job_id":"3c824214-8b21-48bc-8135-c99ac71b23ca","html_url":"https://github.com/Andrea-Cavallo/go_grpc_temperature_monitoring","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"42cbef180a95ec19483b1fc86d3491f3608ca818"},"previous_names":["andrea-cavallo/go_grpc_temperature_monitoring"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrea-Cavallo%2Fgo_grpc_temperature_monitoring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrea-Cavallo%2Fgo_grpc_temperature_monitoring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrea-Cavallo%2Fgo_grpc_temperature_monitoring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andrea-Cavallo%2Fgo_grpc_temperature_monitoring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andrea-Cavallo","download_url":"https://codeload.github.com/Andrea-Cavallo/go_grpc_temperature_monitoring/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248271925,"owners_count":21075800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dashboard","golang","grafana-dashboard","grpc","grpc-client","grpc-go","grpc-server","jaeger","loki","mongodb","plot","protocol-buffers","temperature-monitoring","twilio","weather"],"created_at":"2024-09-24T14:07:26.605Z","updated_at":"2025-04-10T18:44:58.650Z","avatar_url":"https://github.com/Andrea-Cavallo.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"#  Real-Time Temperature Monitoring with Go and gRPC\n\n## Introduzione\n\nQuesto progetto dimostra l'integrazione di servizi gRPC con il linguaggio Go,\nfornendo un esempio completo di un server gRPC che serve dati di temperatura e un client gRPC che li consuma,\nil tutto con una gestione avanzata delle metriche, connessione a MongoDB per persistere i dati, funzionalità di allerta tramite Twilio.\nIl progetto utilizza Docker per facilitare l'impostazione dell'ambiente, inclusi la configurazione di MongoDB e altre dipendenze tipo jaeger.\n\n\u003cimg src=\"./extra/img/GRPC.png\" height=\"300\" width=\"300\"\u003e\n\n[Click here for the English version](#english-version)\n\n# Struttura del progetto\n\n\n```text\n├── api --\u003e qua dentro il file .proto\n│   ├── protos\n│   │   ├── temperature.proto\n│   ├── api.md\n├── docker ---\u003e tutto cio' relativo a docker\n│   ├── docker-compose.yml\n│   ├── init-mongo.js\n│   ├── loki-config.yml\n│   ├── otel-collector-config.yaml\n│   ├── prometheus.yml\n├── extra --\u003e immagini del progetto\n├── pkg --\u003e pkg tutto quello che deve essere visibile e condiviso\n│   ├── telemetry\n│   ├── temperature\n├── temperature_grpc_client -\u003e il Client GRPC\n│   ├── cmd\n│   ├── plot\n│   ├── service\n│   ├── client.md\n├── temperature_grpc_server --\u003e il Server GRPC\n│   ├── alert_twilio\n│   │   ├── alert.go\n│   ├── cmd\n│   │   ├── server\n│   │   │   ├── main.go\n│   ├── mongodb --\u003e connessione a MONGODB\n│   │   ├── config\n│   │   ├── temperature_repo\n│   ├── service\n│   │   ├── server.go\n│   ├── server.md\n├── .editorconfig\n├── .gitignore\n├── changelog.md\n├── go.mod\n├── go.sum\n```\n\n# Diagramma UML\n\n\u003cimg src=\"./extra/img/diagram.png\" height=\"500\" width=\"500\"\u003e\n\n\n# Esecuzione del Progetto\n\n## 1. Prerequisiti\n\nPrima di eseguire il progetto, è necessario ottenere una chiave API per utilizzare il servizio WeatherAPI. Questo servizio è completamente gratuito e puoi ottenere la tua chiave API seguendo questi passi:\n\n1. Visita il sito [WeatherAPI](https://www.weatherapi.com/).\n2. Registrati e segui le istruzioni per ottenere la tua chiave API.\n3. Una volta ottenuta, salva la chiave API in un luogo sicuro.\n\n## 2. Configurare l'API Key come Variabile d'Ambiente\n\nPer mantenere la tua chiave API sicura e fuori dal codice sorgente, configurala come una variabile d'ambiente. Segui questi passi:\n\n### Su Linux/MacOS:\n\n```bash\nexport WEATHER_API_KEY=la-tua-api-key\n```\n\n### Su Windows (nel terminale PowerShell):\n\n```powershell\n$env:WEATHER_API_KEY=\"la-tua-api-key\"\n```\n\nAssicurati che la variabile d'ambiente `WEATHER_API_KEY` sia impostata correttamente prima di procedere.\n\n## 3. Build del Docker Compose\n\nAssicurati di avere Docker installato e di avere accesso al file `docker-compose.yml`:\n\n- Posizionati nella directory che contiene `docker-compose.yml`\n\n## 4. Opzionale - Configurazione di Twilio\n\nSe desideri inviare avvisi tramite Twilio, segui i seguenti passi per creare un account su Twilio e configurare le variabili d'ambiente:\n\nConsulta: [Twilio WhatsApp Quickstart (Go)](https://www.twilio.com/docs/whatsapp/quickstart/go)\n\nConfigurare le seguenti variabili d'ambiente:\n\n```bash\nexport TWILIO_ACCOUNT_SID=il-tuo-account-sid\nexport TWILIO_AUTH_TOKEN=il-tuo-auth-token\nexport TWILIO_PHONE_NUMBER=il-tuo-numero-di-telefono\nexport ALERT_PHONE_NUMBER=il-numero-di-telefono-per-gli-avvisi\n```\n\n## 5. Eseguire il Server\n\nUna volta configurata la chiave API, puoi avviare il server:\n\n1. Naviga alla directory `temperature_grpc_server`:\n\n    ```bash\n    cd temperature_grpc_server/cmd/server\n    ```\n\n2. Esegui il server:\n\n    ```bash\n    go run main.go\n    ```\n\nIl server inizierà ad ascoltare le richieste gRPC.\n\n## 6. Eseguire il Client\n\nCon il server in esecuzione, ora puoi avviare il client per inviare richieste al server:\n\n1. Apri un nuovo terminale e naviga alla directory `temperature_grpc_client`:\n\n    ```bash\n    cd temperature_grpc_client/cmd/client\n    ```\n\n2. Esegui il client:\n\n    ```bash\n    go run main.go\n    ```\n\nIl client invierà una richiesta gRPC al server e riceverà una risposta con i dati di temperatura.\n\n## Grafico della Temperatura\n\nOgni volta che arresti l'applicazione, in particolare il client, vedrai disegnato un grafico che mostrerà la variazione della temperatura.\n\n![Grafico della Temperatura](extra/img/temp_graph.png)\n\n## Per il dettaglio del client e del server\n\n- temperature_grpc_client/client.md\n- temperature_grpc_server/server.md\n\n## Approfondimenti sulla tecnologia scelta\n\ngRPC può essere considerato un successore di RPC, ed è leggero in termini di peso. Google lo ha sviluppato per la comunicazione tra microservizi e altri sistemi che necessitano di interagire. Ci sono diversi vantaggi nell'usare gRPC.\n\n## Vantaggi di gRPC\n\n- **Utilizza Protocol Buffers (Protobuf)** invece del JSON.\n- **Costruito su HTTP/2** invece che su HTTP 1.1.\n- **Generazione di codice incorporata**.\n- **Alte prestazioni**.\n- **Sicurezza SSL**.\n\nOltre ai vantaggi chiave menzionati sopra, gRPC promuove un design migliore per la tua applicazione. gRPC è orientato all'API, a differenza di REST che è orientato alle risorse. È anche asincrono per impostazione predefinita, il che significa che non blocca il thread su richiesta e può servire milioni di richieste in parallelo, garantendo un'alta scalabilità.\n\n## Vantaggi di gRPC rispetto a REST\n\ngRPC è circa sette volte più veloce di REST nel ricevere dati e circa dieci volte più veloce di REST nel trasmettere dati per un payload specifico. Questo è principalmente dovuto al pacchettamento compatto dei Protocol Buffers e all'uso di HTTP/2 da parte di gRPC.\n\n\n## Autore\n\nAndreaCavallo\n\n\n-------------------------------------------------------------------------------------------------------------------\n\n# English Version\n\n# Super cool Go with GRPC\n\n\u003cimg src=\"./extra/img/GRPC.png\" height=\"300\" width=\"300\"\u003e\n\n# Project Execution\n\n## 1. Prerequisites\n\nBefore running the project, you need to obtain an API key to use the WeatherAPI service. This service is completely free, and you can get your API key by following these steps:\n\n1. Visit the [WeatherAPI](https://www.weatherapi.com/) website.\n2. Sign up and follow the instructions to get your API key.\n3. Once obtained, save the API key in a safe place.\n\n## 2. Configure the API Key as an Environment Variable\n\nTo keep your API key secure and out of the source code, configure it as an environment variable. Follow these steps:\n\n### On Linux/MacOS:\n\n```bash\nexport WEATHER_API_KEY=your-api-key\n```\n\n### On Windows (in PowerShell):\n\n```powershell\n$env:WEATHER_API_KEY=\"your-api-key\"\n```\n\nEnsure the `WEATHER_API_KEY` environment variable is set correctly before proceeding.\n\n## 3. Docker Compose Build\n\nEnsure you have Docker installed and access to the `docker-compose.yml` file:\n\n- Navigate to the directory that contains `docker-compose.yml`.\n\n## 4. Optional - Twilio Configuration\n\nIf you wish to send alerts via Twilio, follow these steps to create a Twilio account and set up the environment variables:\n\nConsult: [Twilio WhatsApp Quickstart (Go)](https://www.twilio.com/docs/whatsapp/quickstart/go)\n\nSet the following environment variables:\n\n```bash\nexport TWILIO_ACCOUNT_SID=your-account-sid\nexport TWILIO_AUTH_TOKEN=your-auth-token\nexport TWILIO_PHONE_NUMBER=your-phone-number\nexport ALERT_PHONE_NUMBER=alert-phone-number\n```\n\n## 5. Running the Server\n\nOnce the API key is configured, you can start the server:\n\n1. Navigate to the `temperature_grpc_server` directory:\n\n    ```bash\n    cd temperature_grpc_server/cmd/server\n    ```\n\n2. Start the server:\n\n    ```bash\n    go run main.go\n    ```\n\nThe server will start listening for gRPC requests.\n\n## 6. Running the Client\n\nWith the server running, you can now start the client to send requests to the server:\n\n1. Open a new terminal and navigate to the `temperature_grpc_client` directory:\n\n    ```bash\n    cd temperature_grpc_client/cmd/client\n    ```\n\n2. Start the client:\n\n    ```bash\n    go run main.go\n    ```\n\nThe client will send a gRPC request to the server and receive a response with the temperature data.\n\n## Temperature Graph\n\nWhenever you shut down the application, especially the client, you will see a graph showing the temperature variation.\n\n![Temperature Graph](extra/img/temp_graph.png)\n\n## Detailed Client and Server Documentation\n\n- temperature_grpc_client/client.md\n- temperature_grpc_server/server.md\n\n## Insights into the Chosen Technology\n\ngRPC can be considered a successor to RPC and is lightweight. Google developed it for communication between microservices and other systems that need to interact. There are several advantages to using gRPC.\n\n## Advantages of gRPC\n\n- **Uses Protocol Buffers (Protobuf)** instead of JSON.\n- **Built on HTTP/2** instead of HTTP 1.1.\n- **Built-in Code Generation**.\n- **High Performance**.\n- **SSL Security**.\n\nIn addition to the key advantages mentioned above, gRPC promotes better design for your application. gRPC is API-oriented, unlike REST, which is resource-oriented. It is also asynchronous by default, meaning it does not block the thread on request and can serve millions of requests in parallel, ensuring high scalability.\n\n## Advantages of gRPC over REST\n\ngRPC is about seven times faster than REST in receiving data and about ten times faster than REST in transmitting data for a specific payload. This is primarily due to the compact packing of Protocol Buffers and the use of HTTP/2 by gRPC.\n\n\n## Author\nAndrea Cavallo\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrea-cavallo%2Fgo_grpc_temperature_monitoring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrea-cavallo%2Fgo_grpc_temperature_monitoring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrea-cavallo%2Fgo_grpc_temperature_monitoring/lists"}