feat: implement builder-based connection API with TLS support (v0.3.0)#40
Merged
feat: implement builder-based connection API with TLS support (v0.3.0)#40
Conversation
Add comprehensive builder pattern for connections and pools with full TLS configuration options. This is a breaking change release (v0.3.0) that removes deprecated parameters and dead code. Breaking Changes: - Remove deprecated statement_cache_size parameter from async connect() - Remove TypedConnection<S> (unused internal typestate implementation) New Features: - Add TlsConfig class with factory methods: - from_directory(path) - load certificates from directory - from_environment(env_var) - load from environment variable - from_certificate(pem_content) - use PEM string directly - with_system_roots() - use system root certificates - insecure() - disable verification (development only) - Add ConnectionBuilder for programmatic connection configuration - Add AsyncConnectionBuilder for async connections - Add ConnectionPoolBuilder for pool configuration with TLS - Automatic TLS detection for hdbsqls:// URL scheme - Register all builder classes in PyModule - Add comprehensive Python type stubs in _core.pyi - Update README with TLS configuration examples Implementation Details: - PyConnectionBuilder/PyAsyncConnectionBuilder use runtime validation - PyConnectionPoolBuilder supports TLS configuration - Internal builder.rs typestate pattern retained for Rust code safety - Python-facing builders provide ergonomic fluent API - Security: no credential leaks in __repr__ or error messages - All clippy checks pass with strict mode - Code formatted with cargo +nightly fmt Documentation: - Add v0.3.0 section to CHANGELOG.md - Document breaking changes and migration paths - Add TLS/SSL Connections section to README - Complete type stubs for IDE support Phase 7 implementation complete.
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #40 +/- ##
==========================================
+ Coverage 72.24% 72.27% +0.03%
==========================================
Files 38 38
Lines 6117 6114 -3
==========================================
Hits 4419 4419
+ Misses 1698 1695 -3
🚀 New features to boost your workflow:
|
Remove check_connection_valid helper function from async_support/common.rs that was defined but never called. The is_valid() methods in AsyncPyConnection and PooledConnection implement validation inline instead. Impact: - Removed ~20 lines (function + docs + test) - No functional changes - function was never used - All checks pass (cargo check, clippy)
4cf7d80 to
2952140
Compare
Phase 8 critical improvements based on connection API completeness audit: ## Bug Fixes - **Fix database field ignored in typestate builder** (builder.rs:233-241) Previously self.database was stored but never passed to hdbconnect builder, causing database selection to fail silently in internal Rust API. ## New Features ### CursorHoldability Enum - Add CursorHoldability for transaction control (NEW: cursor_holdability.rs) - Variants: None, Commit, Rollback, CommitAndRollback - Controls result set behavior across transaction boundaries - Critical for applications reading results after committing other changes - Integrated with: - ConnectionBuilder.cursor_holdability() - AsyncConnectionBuilder.cursor_holdability() - Python type stubs ### Network Group Parameter - Add network_group for HANA Scale-Out and HA deployments - Essential for multi-node routing and load balancing - Integrated with: - ConnectionBuilder.network_group(group) - AsyncConnectionBuilder.network_group(group) - ConnectionPoolBuilder.network_group(group) - HanaConnectionManager for pool support ## Documentation - Update CHANGELOG.md v0.3.0 section - Add README sections: - Cursor Holdability usage with examples - High Availability configuration with network groups - Complete Python type stubs (_core.pyi): - CursorHoldability enum - ConnectionPoolBuilder class (was missing) - All new builder methods ## Tests - Update Python tests to use new features - All validation passed: - cargo +nightly fmt --check ✓ - cargo clippy --workspace --all-features -- -D warnings ✓ - cargo check --workspace --all-features ✓ - cargo deny check ✓ - ruff check/format ✓ ## Files Changed New: - crates/hdbconnect-py/src/cursor_holdability.rs (148 lines) Modified: - crates/hdbconnect-py/src/connection/builder.rs - crates/hdbconnect-py/src/connection/py_builder.rs - crates/hdbconnect-py/src/async_support/pool.rs - crates/hdbconnect-py/src/lib.rs - python/pyhdb_rs/_core.pyi - CHANGELOG.md - README.md - Python tests (4 files) Audit sources: - .local/analysis/hdb-connection-completeness-audit.md - .local/analysis/pool-over-engineering-analysis.md All changes are additive - no new breaking changes beyond v0.3.0 already planned.
736f29f to
8ddfcba
Compare
Complete documentation update for v0.3.0 release with all new features and refactored README using collapsible sections for better readability. ## Version Updates - Bump version: 0.2.4 → 0.3.0 - Cargo.toml workspace version - python/pyproject.toml ## README.md Enhancements (995 → 1031 lines, ~50% visual reduction) **New sections:** - Builder API (basic, TLS, URL overrides, async) - TLS/SSL Connections (all 5 factory methods) - Cursor Holdability (transaction control) - High Availability & Scale-Out (network groups) - Migration Guide (v0.2.x → v0.3.0) - API Patterns & Best Practices **Refactored with collapsible sections:** Made 11 advanced sections collapsible using <details><summary> tags: - Builder API advanced examples - Polars integration - TLS/SSL configuration - Cursor holdability - HA & Scale-Out - Async support - Migration guide - API patterns - Error handling - Connection URL format - Arrow ecosystem **Kept visible:** - Project description + badges - Features list - Installation - Quick start (DB-API, Builder basics) - Bottom sections (MSRV, Contributing, License) Result: More scannable README while maintaining full content accessibility ## Python Examples (7 new files in examples/python/) 1. builder_basic.py - Basic ConnectionBuilder usage 2. builder_tls.py - All 5 TlsConfig methods 3. builder_async.py - AsyncConnectionBuilder 4. pool_builder.py - ConnectionPoolBuilder 5. cursor_holdability.py - All 4 CursorHoldability variants 6. ha_network_group.py - HA/Scale-Out configurations 7. migration_guide.py - v0.2.x → v0.3.0 migration 8. README.md - Examples overview ## Jupyter Notebooks **Updated existing:** - 01_quickstart.ipynb - Added Builder API section (5 new cells) **Created new (4 notebooks):** - 05_builder_api.ipynb - Comprehensive builder guide - 06_tls_configuration.ipynb - All TLS methods + best practices - 07_connection_pooling.ipynb - ConnectionPoolBuilder usage - 08_advanced_features.ipynb - CursorHoldability + network groups **Updated:** - examples/notebooks/README.md - Complete rewrite for v0.3.0 ## Documentation Quality - All documentation in English - Professional, expert tone - Proper GitHub callouts ([!TIP], [!WARNING], [!IMPORTANT]) - Comprehensive code examples - Production-ready patterns - Mobile-friendly collapsible sections ## Files Summary Modified (7): - Cargo.toml, Cargo.lock - README.md - python/pyproject.toml, python/uv.lock - examples/notebooks/01_quickstart.ipynb - examples/notebooks/README.md Added (12): - 4 Jupyter notebooks (05-08) - 7 Python examples - examples/python/README.md All examples tested and working. Documentation ready for v0.3.0 release.
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.
Summary
Implements Phase 7 of the builder-based connection API with comprehensive TLS/SSL support. This is a breaking change release (v0.3.0) that removes deprecated code and adds a modern builder pattern for connections and pools.
New Features
TlsConfig Class
Factory-based configuration for SSL/TLS connections:
TlsConfig.from_directory(path)- Load certificates from directoryTlsConfig.from_environment(env_var)- Load from environment variableTlsConfig.from_certificate(pem_content)- Use PEM string directlyTlsConfig.with_system_roots()- Use system root certificatesTlsConfig.insecure()- Disable verification (development only)Builder API
hdbsqls://URL schemePython Integration
_core.pyifor IDE autocompletepyhdb_rsandpyhdb_rs.aiopackages__repr__or error messagesBreaking Changes
statement_cache_sizeparameter fromasync connect()(deprecated since v0.2.x)TypedConnection<S>internal typestate implementation (unused, 270 lines)Migration Guide
See CHANGELOG.md for complete migration details.
Implementation Details
builder.rs- Typestate pattern for compile-time safetypy_builder.rs- Runtime validation for Python APIcargo +nightly fmtDocumentation
Verification
Files Changed
crates/hdbconnect-py/src/tls.rs(332 lines)crates/hdbconnect-py/src/connection/py_builder.rs(790 lines)crates/hdbconnect-py/src/connection/state.rs(270 lines)Stats: 14 files changed, 2359 insertions(+), 314 deletions(-)
Phase 7 Status
All acceptance criteria met:
Related
.local/plan/phase-7-builder-connection-api.md.local/analysis/hdbconnect-py-bloat-analysis.md.local/review/phase-7-code-review.md