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

    • Silky Framework Source Code Analysis
    • Host Construction
    • Service Engine
    • Module System
    • Service & Service Entry Resolution
    • Service Registration
    • Dependency Injection Conventions
    • RPC Service Proxy
  • Runtime

    • Endpoints & Routing
    • Executor Dispatch System
    • Local Executor & Server-Side Filters
    • Remote Executor & RPC Call Chain
    • RPC Server Message Handling
    • Service Governance
    • Cache Interceptor
    • Distributed Transactions (TCC)
    • HTTP Gateway Pipeline
    • Filter Pipeline
    • Polly Resilience Pipeline
    • Endpoint Health Monitor

Concepts

Service (Application Service)

In Silky, a service refers to an interface that exposes capabilities to the outside world — analogous to a controller in traditional MVC. An interface is declared as an application service by adding the [ServiceRoute] attribute:

[ServiceRoute]
public interface IOrderAppService
{
    Task<GetOrderOutput> GetAsync(long id);
    Task<PagedList<GetOrderOutput>> GetPageAsync(PagedRequestDto input);
}

Key service properties:

PropertyDescription
IdGenerated from the interface's fully qualified name
ServiceDescriptorMetadata registered to the service registry
IsLocalWhether this service has a local implementation in this host
ServiceTypeThe Type object of the interface
ServiceProtocolThe protocol (Rpc / Http / WebSocket)
ServiceEntriesAll service entries (methods) this service exposes

Service Entry

A service entry corresponds to a single method on an application service — analogous to an Action in MVC. Each method generates one or more service entries depending on its HTTP verb and route configuration.

Key service entry properties:

PropertyDescription
IdFully qualified method name + parameter names + HTTP method name
ServiceIdId of the parent service
IsLocalWhether this entry executes locally
MethodExecutorObjectMethodExecutor for the method (handles sync/async/ValueTask)
RouterHTTP route template, HTTP method, path, and path parameter extractors
ParameterDescriptorsDescribes each method parameter (name, binding source, type)
GovernanceOptionsTimeout, retry, circuit breaker, load balancing config for this entry
ClientFiltersClient-side filters applied when calling this entry remotely
ServerFiltersServer-side filters applied when executing this entry locally
ServiceEntryDescriptorSerializable descriptor registered to the service registry

Application Service Resolution

Service Manager

DefaultServiceManager (singleton) is responsible for resolving and caching all services. It is constructed by injecting all IServiceProvider implementations (not to be confused with .NET's IServiceProvider):

public class DefaultServiceManager : IServiceManager
{
    private IEnumerable<Service> m_localServices;
    private IEnumerable<Service> m_allServices;

    public DefaultServiceManager(IEnumerable<IServiceProvider> providers)
    {
        UpdateServices(providers);
    }

    private void UpdateServices(IEnumerable<IServiceProvider> providers)
    {
        var allServices = new List<Service>();
        foreach (var provider in providers)
        {
            var services = provider.GetServices();
            allServices.AddRange(services);
        }
        m_allServices = allServices;
        m_localServices = allServices.Where(p => p.IsLocal).ToList();
    }
}

The default DefaultServiceProvider scans all assemblies for interfaces annotated with [ServiceRoute]. Custom providers can be added by implementing IServiceProvider (Silky's own interface).

Route Template Generation

Route templates follow this pattern by default (when Governance:ApiIsRESTfulStyle is true):

{HttpMethod} /{ServiceRouteTemplate}/{appservice}/{ActionName}
  • ServiceRouteTemplate: from [ServiceRoute(template: "api/order")]
  • {appservice}: injected from the template variable (defaults to the application name)
  • ActionName: method name with leading HTTP verb stripped (e.g., GetAsync → info)

HTTP verb inference from method name prefix:

PrefixHTTP Method
Get, Query, Search, FindGET
Create, Add, PostPOST
Update, Edit, PutPUT
Delete, RemoveDELETE
PatchPATCH

ServiceKey

When multiple implementations of the same interface exist (multi-tenancy, plugin scenarios), services are differentiated using [ServiceKey]. The caller specifies which implementation to target by setting RpcContext.Attachments["ServiceKey"].

Service Entry Manager

After all services and entries are resolved, they are stored in IServiceEntryManager (singleton), which provides fast lookups by:

  • Service entry Id
  • HTTP method + path (for gateway routing)
  • ServiceKey
Edit this page
Prev
Module System
Next
Service Registration