Skip to content

Latest commit

 

History

History
213 lines (163 loc) · 5.99 KB

File metadata and controls

213 lines (163 loc) · 5.99 KB

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Changelog - Connection Configuration Library

Version 0.4.0 (2025-05-01)

Breaking Changes

  1. Connection Type Access Changed

    • Before: connection_kind.config_class() (method call)
    • After: connection_kind.config_class (property access)

    Migration:

    # Before
    config_class = ConnectionKind.ARANGO.config_class()
    
    # After
    config_class = ConnectionKind.ARANGO.config_class
  2. Connection Configuration Creation

    • Before: Direct class instantiation with hosts parameter
    • After: Use url parameter or factory with more flexible options

    Migration:

    # Before
    config = ArangoConnectionConfig(hosts="http://localhost:8529", cred_name="root", cred_pass="password")
    
    # After
    config = ArangoConnectionConfig(url="http://localhost:8529", username="root", password="password")
    # Or using factory
    config = ConfigFactory.create_config({
        "db_type": "arango",
        "url": "http://localhost:8529",
        "username": "root",
        "password": "password"
    })
  3. Renamed Credential Parameters

    • Before: cred_name, cred_pass
    • After: username, password (with backward compatibility)

    Migration:

    # Before
    config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password")
    
    # After (preferred)
    config = Neo4jConnectionConfig(username="neo4j", password="password")
    # Old params still work but are deprecated
    config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password")  # Still works
    • Before: ip_addr

    • After: hostname

    • Before: WSGIConfig.host

    • After: WSGIConfig.listen_addr

    Migration:

    # Before
    config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password")
    
    # After (preferred)
    config = Neo4jConnectionConfig(username="neo4j", password="password")
    # Old params still work but are deprecated
    config = Neo4jConnectionConfig(cred_name="neo4j", cred_pass="password")  # Still works
  4. URL Parsing Changes

    • Before: Custom parsing with string operations
    • After: Standard library urlparse for robust URL handling

    Migration:

    # Before - URL components were extracted with custom string operations
    # After - Just use the url parameter and components are automatically extracted
    config = WSGIConfig(url="http://localhost:5000/api/v1")
    print(config.protocol)  # "http"
    print(config.ip_addr)   # "localhost"
    print(config.port)      # "5000"
    print(config.path)      # "/api/v1"
  5. Changed hosts Parameter to url

    • Before: Primary URL parameter was named hosts
    • After: Primary URL parameter is named url

    Migration:

    # Before
    config = ProtoConnectionConfig(hosts="http://localhost:8080")
    
    # After
    config = ProtoConnectionConfig(url="http://localhost:8080")

New Features

  1. Direct URL-based Configuration

    # Create config with just a URL
    config = ConfigFactory.create_config(url="neo4j://neo4j:password@localhost:7687/mydb")
  2. Improved Factory with Type Inference

    # Factory now tries to infer connection type from URL
    config = ConfigFactory.create_config(url="http://localhost:8529/_db/mydb")  # Will infer ArangoDB if "arango" is in URL
  3. Expanded File Handling

    # Load configuration from JSON or YAML
    config = ConfigFactory.create_config(path="config.json")
    config = ConfigFactory.create_config(path="config.yaml")
    
    # Save configuration
    from suthing import FileHandle
    FileHandle.save(config.__dict__, "config.json")
  4. First-Class Support for Connection Base Class

    # Use the factory with automatic type detection
    from suthing import ConnectionConfig
    config_dict = {"db_type": "neo4j", "url": "neo4j://localhost:7687"}
    config = ConnectionConfig.from_dict(config_dict)

Other Improvements

  1. Better Type Annotations

    from typing import Dict, Optional
    
    # Types are now properly annotated
    def process_config(config: ConnectionConfig) -> Dict[str, Optional[str]]:
        return {
            "type": config.connection_type.value if config.connection_type else None,
            "url": config.url,
            "database": getattr(config, "database", None)
        }
  2. Enhanced Error Handling

    # More specific error messages
    try:
        config = ConnectionConfig.from_dict({"db_type": "unknown"})
    except ValueError as e:
        print(e)  # "Connection type 'unknown' not supported. Should be one of: ['arango', 'neo4j', 'wsgi']"

Migration Guide

Step 2: Update URL Parameters

# Before
config = Neo4jConnectionConfig(hosts="http://localhost:7687", cred_name="neo4j", cred_pass="pass")

# After
config = Neo4jConnectionConfig(url="http://localhost:7687", username="neo4j", password="pass")

Step 3: Update Factory Usage

# Before
config = ConfigFactory.create_config(dict_like={"db_type": "arango", "hosts": "http://localhost:8529"})

# After
config = ConfigFactory.create_config(dict_like={"db_type": "arango", "url": "http://localhost:8529"})
# Or more directly
config = ConfigFactory.create_config(url="http://localhost:8529")

Step 4: Update Connection Type Access

# Before
config_class = db_type.config_class()

# After
config_class = db_type.config_class

[0.3.0] - 2025-01-15

  • published on pypi

[0.2.4] - 2023-09-01

  • FileHandle
    • added support for reading .env files and pushing them to environment

[0.2.3] - 2023-08-30

  • switched to python 3.10
  • FileHandle
    • added support for reading txt files by default
    • if a single argument to FileHandle.load() is not named it is interpreted as filepath