Middleware Performance Benchmarks & External Plugin System#434
Merged
A6dulmalik merged 3 commits intoMindBlockLabs:mainfrom Mar 28, 2026
Merged
Middleware Performance Benchmarks & External Plugin System#434A6dulmalik merged 3 commits intoMindBlockLabs:mainfrom
A6dulmalik merged 3 commits intoMindBlockLabs:mainfrom
Conversation
- Implement automated benchmarking system to measure latency overhead of each middleware individually - Create benchmark.ts script with load testing client for realistic performance measurement - Support benchmarking of JWT Auth, RBAC, Security Headers, Timeout, Circuit Breaker, and Correlation ID middleware - Add npm scripts: 'benchmark' and 'benchmark:ci' for running performance tests - Update PERFORMANCE.md with comprehensive benchmarking documentation and usage guide - Add benchmark integration tests to verify middleware initialization - Update package.json with autocannon (load testing) and ts-node dependencies - Update README.md with performance benchmarking section - Update tsconfig.json to include scripts directory - Export security middleware components for benchmarking All implementation confined to middleware repository as required.
PLUGIN SYSTEM IMPLEMENTATION
============================
Core Components:
- PluginInterface: Standard interface all plugins must implement
- PluginLoader: Low-level plugin discovery, loading, and lifecycle management
- PluginRegistry: High-level service for plugin management and orchestration
Key Features:
✓ Dynamic discovery of plugins from npm packages
✓ Plugin lifecycle management (load, init, activate, deactivate, unload, reload)
✓ Configuration validation with JSON Schema support
✓ Semantic version compatibility checking
✓ Dependency resolution between plugins
✓ Plugin priority-based execution ordering
✓ Plugin registry with search and filter capabilities
✓ Plugin context for access to shared services
✓ Comprehensive error handling with specific error types
✓ Plugin middleware export and utility export
✓ Plugin statistics and monitoring
Error Types:
- PluginNotFoundError
- PluginLoadError
- PluginAlreadyLoadedError
- PluginConfigError
- PluginDependencyError
- PluginVersionError
- PluginInitError
- PluginInactiveError
- InvalidPluginPackageError
- PluginResolutionError
Files Added:
- src/common/interfaces/plugin.interface.ts: Core plugin types and metadata
- src/common/interfaces/plugin.errors.ts: Custom error classes
- src/common/utils/plugin-loader.ts: PluginLoader service implementation
- src/common/utils/plugin-registry.ts: PluginRegistry service implementation
- src/plugins/example.plugin.ts: Example plugin template
- tests/integration/plugin-system.integration.spec.ts: Plugin system tests
- docs/PLUGINS.md: Complete plugin system documentation
- docs/PLUGIN_QUICKSTART.md: Quick start guide for plugin developers
Files Modified:
- package.json: Added semver, @types/semver dependencies
- src/index.ts: Export plugin system components
- src/common/interfaces/index.ts: Plugin interface exports
- src/common/utils/index.ts: Plugin utility exports
- README.md: Added plugin system overview and links
USAGE EXAMPLE:
==============
const registry = new PluginRegistry({ autoLoadEnabled: true });
await registry.init();
const plugin = await registry.load('@yourorg/plugin-example');
await registry.initialize(plugin.metadata.id);
await registry.activate(plugin.metadata.id);
PLUGIN DEVELOPMENT:
===================
1. Implement PluginInterface with metadata
2. Create package.json with mindblockPlugin configuration
3. Export plugin class/instance from main entry point
4. Publish to npm with scoped name (@yourorg/plugin-name)
5. Users can discover, load, and activate via PluginRegistry
All implementation confined to middleware repository as required.
|
@OthmanImam Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds two major features to the
@mindblock/middlewarepackage:All implementation is confined to the middleware repository with no backend modifications.
Features
Performance Benchmarks (#369)
npm run benchmarkandnpm run benchmark:ciFiles:
scripts/benchmark.ts- Load testing implementationdocs/PERFORMANCE.md- Benchmarking documentation (updated)tests/integration/benchmark.integration.spec.ts- Test coverageExternal Plugin Loader System
onLoad,onInit,onActivate,onDeactivate,onUnload,onReloadFiles:
src/common/interfaces/plugin.interface.ts- Plugin types and metadatasrc/common/interfaces/plugin.errors.ts- Error classessrc/common/utils/plugin-loader.ts- Loader service (650+ lines)src/common/utils/plugin-registry.ts- Registry service (400+ lines)src/plugins/example.plugin.ts- Template plugin for developersdocs/PLUGINS.md- Complete plugin documentation (750+ lines)docs/PLUGIN_QUICKSTART.md- Quick start guide for plugin developers (600+ lines)tests/integration/plugin-system.integration.spec.ts- Integration testsUsage
Performance Benchmarking
Outputs comprehensive latency overhead comparison for each middleware.
Loading Plugins
Creating Plugins
Developers can create plugins by implementing
PluginInterface:Publish to npm with scoped name (
@yourorg/plugin-name) and users can discover and load automatically.Testing
Run tests:
npm testDependencies Added
autocannon@^7.15.0- Load testing library (already installed, fallback to simple HTTP client)semver@^7.6.0- Semantic version validation@types/semver@^7.5.8- TypeScript definitionsts-node@^10.9.2- TypeScript executionDocumentation
Breaking Changes
None. All additions are backward compatible.
Commits
4f83f97- feat: feat(streak): build streak screen, calendar component, and exclude sidenav from full-screen pages #369 add per-middleware performance benchmarks1e04e8f- feat: External Plugin Loader for npm packagesReady for review and merge into main after testing!