terrymanu opened a new issue, #37037:
URL: https://github.com/apache/shardingsphere/issues/37037

   Feature Description
   
     Currently, ShardingSphereDriver supports two URL loading methods: 
classpath: and absolutepath:. This feature request aims to add support for 
distributed configuration centers by implementing two new
     ShardingSphereURLLoader implementations:
     - ZooKeeper URL Loader: Load configuration from ZooKeeper
     - etcd URL Loader: Load configuration from etcd
   
     Proposed URL Formats
   
     ZooKeeper URL Format
   ```
     
jdbc:shardingsphere:zookeeper:127.0.0.1:2181?namespace=shardingsphere&timeout=5000&sessionTimeout=60000&connectionTimeout=15000
   ```
     etcd URL Format
   ```
     
jdbc:shardingsphere:etcd:127.0.0.1:2379?namespace=shardingsphere&timeout=5000&retryTimes=3&keepaliveTime=30
   ```
     Authentication Support
   
     Both loaders will support standard JDBC authentication using user/password 
parameters:
   
   ```java
     // Connection without authentication
     Connection conn1 = DriverManager.getConnection(
         
"jdbc:shardingsphere:zookeeper:127.0.0.1:2181?namespace=shardingsphere");
   ```
   
   ```java
     // Connection with username/password authentication
     Connection conn2 = DriverManager.getConnection(
         
"jdbc:shardingsphere:zookeeper:127.0.0.1:2181?namespace=shardingsphere",
         "admin", "password123");
   ```
   
     Data Storage Logic
   
     - ZooKeeper: Store/retrieve configuration at path /{namespace}/config
     - etcd: Store/retrieve configuration at key {namespace}/config
     - Default namespace: default if not specified in URL parameters
   
     Technical Implementation
   
     Module Structure
   
   ```
     infra/url/type/
     ├── zookeeper/
     │   ├── pom.xml
     │   ├── 
src/main/java/org/apache/shardingsphere/infra/url/zookeeper/ZooKeeperURLLoader.java
     │   ├── 
src/main/resources/META-INF/services/org.apache.shardingsphere.infra.url.spi.ShardingSphereURLLoader
     │   └── 
src/test/java/org/apache/shardingsphere/infra/url/zookeeper/ZooKeeperURLLoaderTest.java
     └── etcd/
         ├── pom.xml
         ├── 
src/main/java/org/apache/shardingsphere/infra/url/etcd/EtcdURLLoader.java
         ├── 
src/main/resources/META-INF/services/org.apache.shardingsphere.infra.url.spi.ShardingSphereURLLoader
         └── 
src/test/java/org/apache/shardingsphere/infra/url/etcd/EtcdURLLoaderTest.java
   ```
   
     Dependencies
   
     - ZooKeeper: Use existing Apache Curator (5.7.0) and ZooKeeper (3.9.4)
     - etcd: Use existing jetcd-core (0.7.7)
     - Common: shardingsphere-infra-url-spi
   
     Supported Parameters
   
     ZooKeeper Parameters:
     - namespace: Namespace for configuration isolation (required)
     - timeout: Connection timeout in milliseconds
     - sessionTimeout: Session timeout in milliseconds
     - connectionTimeout: Connection timeout in milliseconds
   
     etcd Parameters:
     - namespace: Namespace for configuration isolation (required)
     - timeout: Connection timeout in milliseconds
     - retryTimes: Number of retry attempts
     - keepaliveTime: Keepalive time in seconds
   
     Implementation Requirements
   
     Core Features
   
     - Implement ZooKeeperURLLoader with Apache Curator
     - Implement EtcdURLLoader with jetcd-core
     - Support namespace-based configuration isolation
     - Support username/password authentication
     - Support configurable connection parameters
     - Proper resource cleanup with try-with-resources
   
     Integration
   
     - Modify DriverDataSourceCache to pass authentication credentials
     - Register loaders via META-INF/services
     - Update parent module pom.xml dependencies
     - Ensure seamless integration with existing URL loading system
   
     Testing
   
     - Unit tests for all core functionality
     - Authentication tests (username/password)
     - Parameter parsing tests
     - Exception handling tests (connection failures, timeouts, missing data)
     - Integration tests with mock servers
     - 100% line and branch coverage
   
     Quality Standards
   
     - Follow existing ShardingSphere coding patterns
     - Use @SneakyThrows for exception handling
     - UTF-8 encoding consistency
     - Proper error messages without sensitive data leakage
     - Comprehensive logging
   
     Use Cases
   
     Multi-environment Configuration Management
   
   ```java
     // Development environment
     Connection devConn = DriverManager.getConnection(
         "jdbc:shardingsphere:zookeeper:zk-dev:2181?namespace=dev");
   ```
   
   ```
     // Production environment  
     Connection prodConn = DriverManager.getConnection(
         "jdbc:shardingsphere:zookeeper:zk-prod:2181?namespace=prod",
         "prod_user", "prod_password");
   ```
   
     Distributed Configuration Sharing
   
     Multiple applications can share the same ZooKeeper/etcd cluster while 
maintaining configuration isolation through namespaces.
   
     Benefits
   
     1. Centralized Configuration: Manage ShardingSphere configurations in 
distributed systems
     2. Dynamic Updates: Support for configuration changes without application 
restarts
     3. Multi-tenancy: Namespace-based configuration isolation
     4. Enterprise Integration: Integration with existing ZooKeeper/etcd 
infrastructure
     5. Standard Authentication: Leverage JDBC's standard authentication 
mechanism
   
     Security Considerations
   
     - Support for authentication in distributed environments
     - Secure credential handling via JDBC standard
     - No sensitive data in error messages or logs
     - Connection security (TLS/SSL) can be added in future iterations
   
     Compatibility
   
     - Backward compatible with existing classpath: and absolutepath: loaders
     - No breaking changes to existing API
     - Follows established ShardingSphere patterns and conventions
   
     Acceptance Criteria
   
     - Both ZooKeeper and etcd URLs can be parsed and loaded correctly
     - Authentication functionality works as expected
     - All URL parameters are processed correctly
     - 100% test coverage achieved
     - Integration with existing system is seamless
     - Performance meets requirements for configuration loading
     - Error handling covers all exception scenarios
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to