Silky Microservice FrameworkSilky Microservice Framework
Home
Docs
Config
Source
github
gitee
  • 简体中文
  • English
Home
Docs
Config
Source
github
gitee
  • 简体中文
  • English
  • Introduction

    • Silky Framework Overview
  • Getting Started

    • Glossary
    • Quick Start
    • Project Template
    • Microservice Architecture
    • Sample Projects
  • Host & Module

    • Host Types
    • Gateway Configuration
    • Module System
    • Plugin System
  • Gateway & HTTP

    • Swagger / OpenAPI
    • MiniProfiler
    • CORS
    • Audit Logging
  • Service & RPC

    • App Services & Service Entries
    • RPC Communication
    • WebSocket
    • Service Registry
    • Service Governance
  • Data & Cache

    • EFCore Data Access
    • Caching
    • Distributed Lock
  • Security & Auth

    • Identity & Authentication
    • Distributed Transactions
  • Infrastructure

    • Dependency Injection
    • Object Mapping
    • Validation
    • Link Tracking (SkyAPM)
    • Logging (Serilog)
    • Health Checks
    • Message Bus (MassTransit)
    • Unit & Integration Testing

Overview

Silky's plugin system allows you to load additional modules from external assemblies at runtime, without compiling them into the main host project. This enables:

  • Hot-loadable extension packs
  • Optional feature modules
  • Separation of concerns in large codebases
  • Third-party extensions

Plugin Configuration

Specify plugin directories in appsettings.json:

{
  "plugin": {
    "path": "plugins",
    "enable": true
  }
}

At startup, Silky scans the specified directory for plugin assemblies and loads all valid SilkyModule subclasses found.

Creating a Plugin

1. Create a Class Library

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Silky.Core" Version="3.9.2" />
  </ItemGroup>
</Project>

2. Define the Plugin Module

using Silky.Core.Modularity;

public class AnalyticsPluginModule : SilkyModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddSingleton<IAnalyticsService, DefaultAnalyticsService>();
        context.Services.AddHostedService<AnalyticsBackgroundService>();
    }
}

3. Implement Plugin Services

public class DefaultAnalyticsService : IAnalyticsService, ISingletonDependency
{
    public void TrackEvent(string eventName, IDictionary<string, object> properties)
    {
        // ...
    }
}

Deploying a Plugin

  1. Build the plugin project:

    dotnet publish -c Release -o ./publish/plugins/Analytics
    
  2. Copy the output to the host's plugin directory:

    {host-root}/
      plugins/
        Analytics/
          AnalyticsPlugin.dll
          AnalyticsPlugin.deps.json
    
  3. Restart the host — the plugin is picked up automatically.

Plugin Dependencies

Plugin assemblies are loaded in isolation. If a plugin depends on packages already loaded by the host, those are shared. If a dependency is unique to the plugin, it must be included in the plugin directory.

Use Cases

ScenarioImplementation
Feature toggleLoad module only when feature flag is enabled
Multi-tenant customizationPer-tenant plugin with custom business rules
Third-party integrationsDeliver as a plugin package (NuGet → unzip to plugins/)
Hot reload (limited)Restart the host to reload updated plugins

Tips

Plugin hot reload (without process restart) is not currently supported. Plugins are loaded once at startup.

Edit this page
Prev
Module System