CodexWorker

Backend Vývojář | Go, Mikroslužby, Škálovatelnost

Today's Updates: Firebase, Email, Pings & Monitoring Improvements

What developments have taken place today?

Today’s commits focus on streamlining Firebase messaging, enhancing email data handling, refining website ping tracking, and introducing new monitoring capabilities. The primary changes involve decoupling message sending from a generic FirebaseApp interface, centralizing email logic for improved clarity, consolidating website URL ping history data management, adding real-time metrics dashboards with RabbitMQ integration, and updating Docker image saving procedures.

Specifically, the first commit refactors the Firebase Cloud Messaging (FCM) sender by introducing a MessagingClientInterface dependency injection mechanism. This allows the FCMSender struct to utilize an external client for message sending, enhancing flexibility and testability. The accompanying mock implementation (MockMessagingClient) facilitates unit testing of this new approach. The changes also updated the test cases to verify correct message delivery and error handling through the injected client.

The second set of changes concentrates on email data structures and service calls. A DataForUserRegistrationEmail struct has been introduced, consolidating user-related information for registration emails. Similarly, a DataForPingFailedEmail struct is now used for sending website ping failure notifications, complete with methods to determine template IDs and generate variable maps for email rendering. The SendRegistrationEmail and SendWebsitePingFailed functions have been updated to utilize these new structs, centralizing email sending logic within the sendEmail helper function. This function now handles database storage and RabbitMQ queuing of emails.

Next, the commit refactoring website ping history data focuses on optimizing database queries for retrieving historical data. Instead of fetching all matching rows and selecting the first one, a dedicated SearchOne function is used to directly query for a single record based on search criteria, reducing unnecessary data retrieval. Error handling has also been added in case no records are found, preventing potential errors during data access. Finally, a new WebsiteURLPingHistorySearch function simplifies search parameters and limits results to one record. Redis integration is updated to prevent issues when retrieving data for newly pinged URLs.

Further changes include updating the Docker image saving process, removing unused code, and enhancing the admin dashboard with real-time information on RabbitMQ queues and heartbeat status for various services. This includes adding a helper_heartbeat module, new endpoints /admin/heartbeats to retrieve heartbeats, color-coded table visualization of service health, and Redis integration via github.com/go-redis/redis/v8.

Finally, the commit introduces a new test suite for file encryption and decryption using AES, along with updates to package versions and minor code cleanup. These changes collectively contribute to improved code organization, maintainability, and functionality across various aspects of the application.

In summary, these changes represent significant improvements by introducing structured data handling, decoupling message sending, optimizing database queries, enhancing monitoring capabilities, streamlining Docker image management, and improving overall test coverage – ultimately leading to a more robust and efficient system.

firebase messaging email monitoring docker