48.1 Extensibility Spectrum
Less Flexible More Flexible
├──────────┼──────────────┼─────────────────┼──────────────┤
│ Config │ Scripting │ Plugin System │ Full SDK + │
│ Files │ (Webhooks, │ (Interfaces, │ Marketplace │
│ │ Templates) │ Lifecycle Mgmt)│ │
Enterprise platforms need extensibility without core-code modification for every third-party integration, customer customization, or new capability — a well-designed plugin architecture enables faster feature delivery and, at the far end of the spectrum, ecosystem growth through external contributions.
48.2 Registry-Based Discovery
┌──────────────┐ ┌────────────────┐ ┌─────────────┐
│ Plugin Store │────▶│ Plugin Registry│◀────│ Platform │
│ (Upload/ │ │ (Metadata, │ │ Core │
│ Publish) │ │ Versions, │ │ (Discovery │
│ │ │ Capabilities) │ │ at startup)│
└──────────────┘ └────────────────┘ └─────────────┘
A central database/service stores plugin metadata; the platform queries the registry at startup or on-demand. Metadata includes name, version, capabilities, dependencies, health status. Examples of this pattern: extension marketplaces, operator hubs.
48.3 Convention-Based Discovery
Plugins are placed in a well-known directory (e.g., /plugins/); the platform scans that directory at startup; each plugin is identified by a manifest file (plugin.json, manifest.yaml). Simple, works well for self-hosted/on-prem deployments without a network-accessible registry.
48.4 Service-Based Discovery
Plugins register as services (via Consul, Eureka, Kubernetes service discovery); the platform discovers them via service mesh/DNS; health checks determine availability. Natural fit when plugins are already deployed as independent microservices.
48.5 Annotation/Decorator-Based Discovery
@plugin(name="notification-connector", version="1.0", capabilities=["notification"])
class NotificationConnectorPlugin(NotificationPlugin):
def send(self, message: str, channel: str) -> bool:
...
Runtime scanning of annotated classes auto-registers plugins based on decorators/annotations. Common in Python (pluggy-style systems), Java (SPI), .NET (MEF).
Section 48 — Interview Q&A
Q1: How do you choose between registry-based and convention-based plugin discovery for a new platform? Registry-based suits multi-tenant, cloud/SaaS platforms where plugins are published and versioned centrally, need remote discoverability, and benefit from centralized health/version tracking. Convention-based suits self-hosted or single-tenant deployments where plugins live alongside the platform install and a network-accessible registry is unnecessary overhead. A hybrid is common: convention-based for local/dev plugin loading, backed by a registry for production/marketplace-style distribution.
Q2: What are the trade-offs of annotation/decorator-based discovery vs. explicit manifest files? Annotations keep the plugin’s metadata co-located with its implementation, reducing the chance of drift between code and manifest, and they auto-register with less boilerplate. Manifest files (JSON/YAML) are language-agnostic, can be validated/linted independently of running any code, and are easier to inspect or generate tooling around (e.g., a marketplace UI reading manifests without importing the plugin’s code). For a platform that must support plugins written in multiple languages, manifest-based discovery is generally the safer default; annotation-based is a good ergonomic choice within a single-language ecosystem.