Skip to content
This repository has been archived by the owner on Jan 11, 2025. It is now read-only.

Elytra Plugin API #24

Draft
wants to merge 18 commits into
base: mcs/devel
Choose a base branch
from
Draft

Elytra Plugin API #24

wants to merge 18 commits into from

Conversation

Kiwifuit
Copy link
Owner

@Kiwifuit Kiwifuit commented Jan 9, 2025

Summary by Sourcery

Introduce a plugin API for Elytra, enabling external providers to be loaded dynamically at runtime.

New Features:

  • Add a plugin API to allow extending Elytra with custom server providers.

Tests:

  • Add tests for the plugin API.

@Kiwifuit Kiwifuit added enhancement New feature or request t-elytra Issues relating to the Elytra Backend labels Jan 9, 2025
Copy link

sourcery-ai bot commented Jan 9, 2025

Reviewer's Guide by Sourcery

This pull request introduces a plugin API for Elytra, allowing developers to extend its functionality by creating custom plugins. The API is designed around a ServerProvider trait, which plugins must implement to integrate with Elytra. The changes include adding new modules, updating dependencies, and modifying the server build process to accommodate plugins.

Sequence diagram for plugin loading process

sequenceDiagram
    participant C as Client
    participant P as Plugin
    participant L as Library Loader
    participant SP as ServerProvider

    C->>P: load(path)
    activate P
    P->>L: Library::new(path)
    L-->>P: Library
    P->>L: get_symbol('init')
    L-->>P: PluginInit symbol
    P->>SP: plugin_init()
    SP-->>P: Box<dyn ServerProvider>
    P-->>C: Plugin instance
    deactivate P
Loading

Class diagram for the new Plugin API structure

classDiagram
    class ServerProvider {
      <<interface>>
      +id() str
      +name() str
      +version() str
      +execute()
    }

    class Plugin {
      -plugin: Box<dyn ServerProvider>
      +load(path) Result<Plugin, PluginError>
    }

    class PluginError {
      <<enumeration>>
      Load(Error)
    }

    Plugin *-- ServerProvider : contains
    Plugin ..> PluginError : uses
Loading

File-Level Changes

Change Details Files
Introduce the plugin API
  • Added new modules for plugin functionality.
  • Defined the ServerProvider trait.
  • Implemented plugin loading and management.
  • Updated Cargo dependencies to include necessary crates for plugin support.
  • Added a feature flag to enable plugin functionality
elytra/src/lib.rs
elytra/src/plugin/mod.rs
elytra/src/plugin/provider.rs
elytra/src/utils/mod.rs
elytra/src/utils/plugin/mod.rs
elytra/Cargo.toml
Modify server build process
  • Commented out the existing server build logic.
  • Prepared for integration with the new plugin API
dms-backend/src/worker.rs
Update dependencies and features
  • Updated dependencies to support plugin functionality.
  • Added new features for plugin-related utilities.
  • Modified the server run arguments.
  • Updated the Maven artifact builder.
  • Improved error handling in the shell module
elytra/Cargo.toml
denji/examples/install-server.rs
mar/src/lib.rs
mar/src/types.rs
denji/src/shell.rs
Cargo.lock

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request t-elytra Issues relating to the Elytra Backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant