-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor frontend context #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobyhede
wants to merge
7
commits into
main
Choose a base branch
from
refactor-frontend-context
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
…rontend - Create service traits for encryption and schema operations in services/mod.rs - Refactor Context to use service trait objects instead of direct Proxy dependency - Remove proxy field from Frontend, making it focus solely on PostgreSQL message handling - Context now serves as central coordinator with service delegation methods - Add backward compatibility with new_with_proxy() helper method - Implement service traits on Proxy for seamless migration - Add comprehensive test infrastructure with mock services - Maintain all existing functionality while improving separation of concerns This architectural change makes the frontend more focused, testable, and follows proper dependency injection patterns while preserving backward compatibility.
…per service - Create ColumnMapper service to handle column mapping and encryption configuration - Move get_projection_columns, get_param_columns, get_literal_columns from Frontend - Remove ~150 lines of column processing logic from Frontend - Add Context delegation methods for column processing operations - Remove unused imports (Identifier, TableColumn, Type) from Frontend - Fix test configuration with proper CRN format and required environment variables This refactoring achieves clear separation of concerns: - Frontend focuses solely on PostgreSQL message handling - ColumnMapper handles column mapping and encryption configuration - Context serves as coordinator with clean delegation methods - Maintains all existing functionality while improving code organization
- Extract Statement struct and impl into context/statement.rs (44 lines) - Extract Portal enum and impl into context/portal.rs (68 lines) - Remove ~110 lines from context/mod.rs main file - Add public re-exports for backward compatibility - Clean up unused imports and formatting This modular organization improves: - Code maintainability with focused single-responsibility modules - Context module readability by reducing main file complexity - Developer experience with logical separation of concerns - Architecture consistency following established patterns All existing functionality preserved with proper import handling.
- Move encryption configuration files from proxy/config/ to proxy/encrypt_config/ - Rename EncryptConfig to ColumnEncryptionConfig for clarity - Create new EncryptConfig wrapper struct in manager for better encapsulation - Update module structure and imports throughout codebase
…ation - Add TandemConfig::for_testing() for environment-independent unit tests - Add DatabaseConfig::for_testing() to handle private password field - Update Context::new_for_test() to use new testing constructors - Update Context::new_with_proxy() to extract schema and config from Proxy - Rename Proxy fields: encrypt_config → encrypt_config_manager, schema → schema_manager - Remove environment variable dependency from Context tests - Add integration test for schema reload with mapping disabled
58e1d62
to
ef25adb
Compare
- Replace handler function signature to accept Context<ZeroKms> instead of Proxy + client_id - Add config access methods to Context for database, TLS, and other settings - Convert EncryptionService trait from impl Future to async_trait for cleaner syntax - Update ZeroKms implementation to use async_trait - Modify startup functions to work with Context instead of Proxy - Remove services module as functionality is now integrated into Context - Fix type annotation errors by using concrete Context<ZeroKms> type This refactoring simplifies the architecture by making Context the primary interface for handler operations, avoiding dyn trait objects while maintaining strong typing.
ef25adb
to
a35b9f0
Compare
dc7eed3
to
bc1aa6b
Compare
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.
Context is now the primary interface for handler operations
Work remains:
Further work will be pushed in separate PRs