pkg/db/db.go #31

Closed
opened 2026-03-28 04:20:37 +00:00 by mfreeman451 · 0 comments
Owner

Imported from GitHub.

Original GitHub issue: #68
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/68
Original created: 2025-01-20T03:36:10Z


  • Error Handling: The error handling could be improved by providing more context in error messages. For example, instead of just returning errFailedToQuery, it could return fmt.Errorf("failed to query nodes: %w", err).
  • Transaction Management: The UpdateNodeStatus() function could be made more robust by ensuring that either all operations succeed or none of them do (atomicity).
  • Code Duplication: The rollbackOnError() function is only used once and could be inlined.
  • Database Schema: The database schema could be improved by adding indexes to frequently queried columns.
  • The createTablesSQL constant could be broken down into separate constants for each table and index.
  • The errFailedToEnableWAL error could be removed, as it is handled in errFailedOpenDB.
  • The database schema has two tables named service_status and service_history which could be confusing.
  • The NodeHistory type is defined in this file but not used within it.
  • The GetNodeHistory() function and GetNodeHistoryPoints() both query node history but return different types. This could be simplified.
  • The comments for the IsNodeOffline() function are incorrect.
Imported from GitHub. Original GitHub issue: #68 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/issues/68 Original created: 2025-01-20T03:36:10Z --- - [ ] Error Handling: The error handling could be improved by providing more context in error messages. For example, instead of just returning errFailedToQuery, it could return fmt.Errorf("failed to query nodes: %w", err). - [ ] Transaction Management: The UpdateNodeStatus() function could be made more robust by ensuring that either all operations succeed or none of them do (atomicity). - [ ] Code Duplication: The rollbackOnError() function is only used once and could be inlined. - [ ] Database Schema: The database schema could be improved by adding indexes to frequently queried columns. - [ ] The createTablesSQL constant could be broken down into separate constants for each table and index. - [ ] The errFailedToEnableWAL error could be removed, as it is handled in errFailedOpenDB. - [ ] The database schema has two tables named service_status and service_history which could be confusing. - [ ] The NodeHistory type is defined in this file but not used within it. - [ ] The GetNodeHistory() function and GetNodeHistoryPoints() both query node history but return different types. This could be simplified. - [ ] The comments for the IsNodeOffline() function are incorrect.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar#31
No description provided.