Skip to content

Conversation

tobyhede
Copy link
Contributor

@tobyhede tobyhede commented Sep 12, 2025

  • 🚀 Cleaner Architecture:
    Context is now the primary interface for handler operations
  • 🔒 Encapsulation: All handler dependencies now flow through Context

Work remains:

  • context is now too big
  • functions in frontend still need to be extracted.

Further work will be pushed in separate PRs

…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
@tobyhede tobyhede force-pushed the refactor-frontend-context branch 2 times, most recently from 58e1d62 to ef25adb Compare September 12, 2025 05:48
- 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.
@tobyhede tobyhede force-pushed the refactor-frontend-context branch from ef25adb to a35b9f0 Compare September 12, 2025 05:50
@tobyhede tobyhede force-pushed the refactor-frontend-context branch from dc7eed3 to bc1aa6b Compare September 15, 2025 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant