Skip to content
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

feat: add Extensions Manager #68

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft

Conversation

pavelnikonorov
Copy link
Collaborator

@pavelnikonorov pavelnikonorov commented Nov 7, 2024

Summary by Sourcery

Add an Extensions Manager to manage extensions within the application, including new CLI commands for extension management. Enhance the Configuration and Transport structs to support extensions and TLS verification. Update dependencies to support these new features.

New Features:

  • Introduce an Extensions Manager to handle the loading, enabling, and management of extensions within the application.
  • Add new CLI subcommands for managing extensions, including listing, adding, removing, and enabling extensions.

Enhancements:

  • Enhance the Configuration struct to support extensions and integrate with the new Extensions Manager.
  • Improve the Transport struct to support TLS verification using extensions.

Build:

  • Add new dependencies for handling extensions, including libloading and base64.

@pavelnikonorov pavelnikonorov linked an issue Nov 7, 2024 that may be closed by this pull request
Copy link
Contributor

sourcery-ai bot commented Nov 7, 2024

Reviewer's Guide by Sourcery

This PR introduces an Extensions Manager system that enables dynamic loading and management of extensions in the GA4GH SDK. The implementation includes configuration handling, extension loading/unloading, and TLS verification capabilities. The changes primarily affect the configuration and transport layers, with additional CLI commands for extension management.

Sequence diagram for loading extensions

sequenceDiagram
    participant CLI
    participant Configuration
    participant ExtensionManager
    participant Extension
    CLI->>Configuration: from_file()
    Configuration->>ExtensionManager: new(installed_extensions, service_config)
    ExtensionManager->>Extension: new(config)
    Extension->>Extension: load(service_config)
    ExtensionManager-->>Configuration: ExtensionManager instance
    Configuration-->>CLI: Configuration instance
Loading

Class diagram for the new Extensions Manager

classDiagram
    class Configuration {
        +String base_path
        +Option<String> user_agent
        +Option<BasicAuth> basic_auth
        +Option<String> oauth_access_token
        +Option<String> bearer_access_token
        +Option<ApiKey> api_key
        +Option<ServiceExtensionsConfiguration> extensions
        +ExtensionManager extensions_manager
        +from_file(service_type: Option<ServiceType>, service_config_path: &String, extensions_config_path: &String) Result<Self, Box<dyn std::error::Error>>
    }

    class ExtensionManager {
        +Vec<Extension> extensions
        +new(installed_extensions: InstalledExtensions, service_config: Option<ServiceExtensionsConfiguration>) Result<Self, Box<dyn Error>>
        +get_extensions() &Vec<Extension>
        +lookup_extension_methods(unified_method_name: &str) Vec<&ExtensionMethod>
    }

    class Extension {
        +String name
        +String version
        +Option<String> path
        +Option<String> description
        +bool enabled
        +bool loaded
        +Option<Library> library
        +HashMap<String, Vec<ExtensionMethod>> methods
        +new(config: InstalledExtension) Result<Self, Box<dyn Error>>
        +load(service_config: Value)
    }

    class Transport {
        +Configuration config
        +reqwest::Client client
        +new(config: &Configuration) Result<Self, Box<dyn Error>>
    }

    Configuration --> ExtensionManager
    ExtensionManager --> Extension
    Transport --> Configuration
Loading

File-Level Changes

Change Details Files
Implemented an Extension Manager system for dynamic extension loading
  • Added ExtensionManager struct to handle extension lifecycle
  • Created Extension struct to represent individual extensions
  • Implemented methods for loading, enabling, and unloading extensions
  • Added support for extension method lookup and invocation
lib/src/utils/extension_manager.rs
lib/src/utils/extension.rs
Enhanced Configuration struct to support extensions
  • Added extension-related fields to Configuration struct
  • Implemented serialization/deserialization for Configuration
  • Added support for installed extensions configuration
  • Created new structs for extension configuration
lib/src/utils/configuration.rs
Updated Transport layer to support TLS verification through extensions
  • Added TLS verification support using extension methods
  • Implemented certificate handling for secure connections
  • Added security mode support (enforce/permissive)
  • Enhanced error handling and logging
lib/src/utils/transport.rs
Added CLI commands for extension management
  • Added extension subcommands (list, add, remove, enable)
  • Updated main CLI structure to include extension commands
  • Enhanced CLI documentation and help messages
cli/src/main.rs

Possibly linked issues

  • Deploy Funnel #1: The PR implements the Extensions Manager, addressing the issue's requirement for extension support.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pavelnikonorov pavelnikonorov force-pushed the feat/extension-manager branch 2 times, most recently from ec638d5 to 2e78004 Compare November 25, 2024 13:52
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.

feat: add Extensions Manager
1 participant