Skip to content

Conversation

jsonbailey
Copy link
Contributor

@jsonbailey jsonbailey commented Jun 30, 2025

feat: Add experimental plugin support

Summary

This PR implements experimental plugin support for the Ruby Server SDK following the LaunchDarkly plugin specifications. The implementation adds a new Plugin interface that allows external integrations to register hooks and perform initialization tasks during SDK startup.

Key Changes:

  • Added Interfaces::Plugins module with Plugin mixin and metadata classes (SdkMetadata, ApplicationMetadata, EnvironmentMetadata, PluginMetadata)
  • Extended Config class to accept and validate plugins parameter
  • Modified LDClient to collect plugin hooks during initialization and register plugins after data source setup
  • Added comprehensive test suite covering plugin configuration, hook collection, registration, and error handling
  • Added MockPlugin test utility following existing patterns

Implementation Details:

  • Plugin hooks are collected before client initialization and appended after config hooks
  • Plugins are registered in the order they were added to the configuration
  • Error handling wraps plugin operations with logging to prevent SDK initialization failures
  • Environment metadata provides plugins with SDK version, application info, and SDK key access

Review & Testing Checklist for Human

  • Run the test suite - I was unable to run tests due to bundle install permission issues, so this needs verification that all tests pass
  • Test plugin registration flow end-to-end - Create a simple plugin and verify it gets registered and its hooks are called correctly
  • Verify no regression in existing functionality - Run existing hook tests to ensure plugin integration doesn't break current behavior
  • Test error handling - Verify that plugin errors during get_hooks() and register() are caught and logged without breaking SDK initialization
  • Validate against plugin specs - Double-check the implementation matches the plugin specification requirements exactly

Recommended Test Plan:

  1. Create a minimal plugin that implements the Plugin mixin and registers a simple hook
  2. Initialize the SDK with this plugin and verify the hook is executed
  3. Test with a plugin that throws errors during registration to ensure graceful handling
  4. Run existing test suite to ensure no regressions

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    Config["lib/ldclient-rb/config.rb"]:::major-edit --> LDClient["lib/ldclient-rb/ldclient.rb"]:::major-edit
    Interfaces["lib/ldclient-rb/interfaces.rb"]:::major-edit --> Config
    Interfaces --> LDClient
    LDClient --> DataSource["Data Source"]:::context
    LDClient --> Hooks["Hook System"]:::context
    
    TestSpec["spec/ldclient_plugins_spec.rb"]:::major-edit --> MockComponents["spec/mock_components.rb"]:::minor-edit
    TestSpec --> Interfaces
    
    Config --> |plugins parameter| PluginValidation["Plugin Validation"]:::context
    LDClient --> |get_plugin_hooks| PluginHooks["Plugin Hook Collection"]:::context
    LDClient --> |register_plugins| PluginRegistration["Plugin Registration"]:::context
    
    subgraph Legend
        L1["Major Edit"]:::major-edit
        L2["Minor Edit"]:::minor-edit  
        L3["Context/No Edit"]:::context
    end

    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

  • Environment Issue: Bundle install failed due to permission errors, preventing test execution during development
  • Implementation follows existing patterns: Used same error handling, logging, and validation patterns as existing hook system
  • Plugin execution order: Config hooks execute first, then plugin hooks, then plugins are registered
  • Session: Requested by @jsonbailey - Link to Devin run: https://app.devin.ai/sessions/6cac75e94159428e9e2e518957628365

- Add Plugin interface and metadata classes following plugin specs
- Extend Config class to accept plugins parameter
- Modify LDClient to register plugins and collect their hooks
- Add comprehensive tests for plugin functionality
- Follow existing Ruby SDK patterns and conventions

Co-Authored-By: jbailey@launchdarkly.com <accounts@sidewaysgravity.com>
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@jsonbailey jsonbailey marked this pull request as ready for review July 11, 2025 21:01
@jsonbailey jsonbailey requested a review from a team as a code owner July 11, 2025 21:01
Copy link

Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it.

@jsonbailey jsonbailey merged commit 1bdcf01 into main Jul 15, 2025
5 checks passed
@jsonbailey jsonbailey deleted the devin/sdk-1323/experimental-plugin-support branch July 15, 2025 15:27
jsonbailey pushed a commit that referenced this pull request Jul 15, 2025
🤖 I have created a release *beep* *boop*
---


##
[8.11.0](8.10.2...8.11.0)
(2025-07-15)


### Features

* Add experimental plugin support
([#327](#327))
([1bdcf01](1bdcf01))


### Bug Fixes

* Bump eventsource to 2.2.6
([#331](#331))
([33feb9b](33feb9b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants