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

Support for Multiple Instances and Modularity in Ksoup #78

Open
itboy87 opened this issue Sep 14, 2024 · 0 comments
Open

Support for Multiple Instances and Modularity in Ksoup #78

itboy87 opened this issue Sep 14, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@itboy87
Copy link
Collaborator

itboy87 commented Sep 14, 2024

Currently, Ksoup operates with a single global instance, which causes issues for users who want to run multiple engines in a single project (see issue #68) or have more than one Ksoup instance with different configurations. To address this, the proposal is to create a modular structure for Ksoup that allows users to extend functionality through additional modules. This will also enable us to create a separate module for Charset Decoder and improve the overall structure of library modules.

Proposed Changes:

  1. Core Module (ksoup-core):
    Ksoup will have a core module that handles the base functionality without any built-in engines or external dependencies.

  2. Extension Modules:
    Users can add specific extensions to Ksoup for I/O and networking by choosing the following modules:

    • I/O Extensions: kotlinx-io, okio, korlibs-io
    • Network Extensions: ktor2, ktor3, korlibs-network
    • Charset Decoder Extension

    These extensions will be built on top of ksoup-core, making it flexible and customizable for various needs.

  3. Breaking Changes:

    • Single Instance Usage:
      Users can still use ksoup-core without any external dependencies, which will work similarly to the current single-instance setup (Ksoup.*). However, to add more functionality, users must explicitly initialize it with extensions, e.g., Ksoup.addExtension(KotlinxIoExtension()). This will install the extension for the global Ksoup.* instance and add extension functions for the specified library (e.g., kotlinx-io).

    • Multiple Instances Support:
      For users who need multiple instances of Ksoup with different configurations, a separate class will be introduced, allowing for more flexibility. (Details of this implementation are still to be planned.)

Benefits:

  • Decoupling Engines:
    This approach will remove the dependency of the ksoup-core module on specific engines, allowing users to opt-in for the engines they need.

  • Future-Proofing:
    The modular design will make Ksoup more scalable and easier to maintain, providing users with more control over the library's functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant