chore(keystone): standardize pagination, improve timestamps, and cleanup dead code#26
Merged
shark0F0497 merged 13 commits intomainfrom Apr 9, 2026
Merged
chore(keystone): standardize pagination, improve timestamps, and cleanup dead code#26shark0F0497 merged 13 commits intomainfrom
shark0F0497 merged 13 commits intomainfrom
Conversation
…ming and transaction management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
Please ensure your PR meets the following requirements:
Summary
This PR performs a comprehensive code cleanup of the keystone backend, consolidating WebSocket connection management, removing unused code, and adding pagination support to list endpoints.
Motivation
The codebase had accumulated technical debt through:
RecorderHubandTransferHubTaskManagerservice andmodels.gopackage that were never utilizedThis refactoring improves maintainability and prepares the codebase for future scalability.
Changes
Modified Files
PaginationParams,ListResponse,ParsePagination(), andPaginationErrortypes; removed unusedformatDBTimeToRFC3339ListOrders, joinedscene_name, changed timestamp fields tosql.NullTimeListBatches, refactored timestamp handlingsql.NullTimeAdded Files
Hub[T Connection]type that consolidates WebSocket connection management with duplicate connection rejectionDeleted Files
Key Technical Changes
Generic Hub Type (
internal/services/hub.go):Connectioninterface withGetDeviceID(),GetWSConn(),GetConnectedAt()Hub[T Connection]provides thread-safe connection registry withconnect(),disconnect(),get(),list()methodsPagination Infrastructure (
internal/api/handlers/common.go):ParsePagination(c *gin.Context)- validates and extractslimit/offsetquery params (default 50, max 100)ListResponsestruct provides consistent response format withtotal,limit,offset,hasNext,hasPrevTimestamp Standardization:
formatDBTimeToRFC3339functionsql.NullTimewith proper JSON marshalingType of Change
Impact Analysis
Breaking Changes
None. The internal refactoring maintains API compatibility. Note that:
GET /api/v1/ordersresponse format changed from{orders: [...]}to{items: [...], total, limit, offset, hasNext, hasPrev}Backward Compatibility
API responses now include additional fields (
total,limit,offset,hasNext,hasPrev) but existing fields remain compatible. Clients should handle unknown fields gracefully.Testing
Test Environment
Go 1.24 with
go test -raceTest Cases
go test -cover -race ./...)Manual Testing Steps
Verified WebSocket connection management:
Test Coverage
Screenshots / Recordings
N/A - Backend-only changes
Performance Impact
Documentation
Related Issues
Additional Notes
Hub[T Connection]pattern follows Go best practices for eliminating code duplicationtask_manager.goandmodels.gowere identified as dead code via static analysisReviewers
@kilo-code-bot
Notes for Reviewers
Hub[T]type design ininternal/services/hub.goConnectioninterface boundaryRecorderHubandTransferHubcorrectly implement theConnectioninterfaceChecklist for Reviewers