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

Introduction

Silky supports configuration via json or yml files. appsettings.yml is recommended as the base configuration, combined with appsettings.{Environment}.yml for environment-specific overrides.

Configuration priority (low → high):

  1. appsettings.yml — base configuration
  2. appsettings.{Environment}.yml — environment overrides
  3. Environment variables
  4. Command-line arguments

RPC Communication (Rpc)

Config section: Rpc. Applies to all hosts that provide or consume RPC services (General Host, Web Host, WebSocket Host).

PropertyDescriptionDefaultNotes
HostListening IP0.0.0.00.0.0.0 auto-detects host IP
CidrCIDR filter—Selects NIC when server has multiple network interfaces
PortRPC listening port2200
UseLibuvEnable Libuv transporttrue
IsSslEnable SSLfalse
SslCertificateNameSSL certificate filename—Effective when IsSsl is true
SslCertificatePasswordSSL certificate password—Effective when IsSsl is true
SoBacklogDotNetty SoBacklog1024
TokenRPC auth token—Required; all services in the same cluster must share the same token
ConnectTimeoutConnection timeout300ms
RegisterFailureRetryCountRegistration failure retry count10
TransportClientPoolNumberTransport client pool size50
UseTransportClientPoolEnable connection pooltrue
EnableMonitorEnable RPC call monitoringtrue
CollectMonitorInfoIntervalSecondsMonitor data collection interval30s
EnableHeartbeatEnable heartbeattrueKeeps DotNetty long-lived connections alive
HeartbeatWatchIntervalSecondsHeartbeat interval300s; minimum 60s (auto-corrected if lower)
MinThreadPoolSizeMin thread pool sizeCPU cores × 4
MaxThreadPoolSizeMax thread pool sizeCPU cores × 10

Example (YAML):

Rpc:
  Token: "your-rpc-token"
  Port: 2200
  Host: "0.0.0.0"
  ConnectTimeout: 300
  EnableHeartbeat: true
  HeartbeatWatchIntervalSeconds: 300

Service Governance (Governance)

Config section: Governance. Controls load balancing, timeout, circuit breaking, and retry for RPC calls. Can be overridden at method level with the [Governance] attribute.

PropertyDescriptionDefaultNotes
ShuntStrategyLoad balancing strategyPollingOptions: Polling, Random, HashAlgorithm
TimeoutMillSecondsRPC call timeout5000ms; triggers circuit break on timeout
EnableCachingInterceptorEnable cache interceptiontrueWhen false, all caching intercept attributes are ignored
EnableCircuitBreakerEnable circuit breakertrueBusiness exceptions do not trigger the breaker
ExceptionsAllowedBeforeBreakingConsecutive failures before opening circuit3
BreakerSecondsCircuit open duration60s; endpoint refuses new requests while open
AddressFuseSleepDurationSecondsEndpoint sleep duration after communication failure60s
UnHealthAddressTimesAllowedBeforeRemovingMax sleeps before endpoint is removed3
RetryTimesFailover retry count3
RetryIntervalMillSecondsFailover retry interval50ms
MaxConcurrentHandlingCountMax concurrent requests per instance50Throws when exceeded
ApiIsRESTfulStyleUse RESTful-style routestrueAffects service entry route template generation

Example (YAML):

Governance:
  ShuntStrategy: Polling
  TimeoutMillSeconds: 5000
  EnableCircuitBreaker: true
  ExceptionsAllowedBeforeBreaking: 3
  BreakerSeconds: 60
  RetryTimes: 3
  RetryIntervalMillSeconds: 50
  MaxConcurrentHandlingCount: 50

Service Registry (RegistryCenter)

Config section: RegistryCenter. Three registry types selected by the Type field.

Zookeeper

NuGet: Silky.RegistryCenter.Zookeeper

PropertyDescriptionDefaultNotes
TypeRegistry typeZookeeperFixed value
ConnectionStringsZookeeper connection string—Required; comma-separated nodes per cluster, semicolon-separated clusters
ConnectionTimeoutConnection timeout2000ms
SessionTimeoutSession timeout8000ms
OperatingTimeoutOperation timeout15000ms
HeartBeatIntervalSecondHeartbeat interval10s
EnableHeartBeatEnable heartbeattrue
FuseTimesCircuit trips before connection fuse10
SchemeACL auth schemeWorldOptions: World, Auth, Digest, Ip
AuthACL auth infoanyone
RoutePathService metadata storage path/silky/server
SwaggerDocPathSwagger doc storage path/silky/swagger
RegisterSwaggerDocSync Swagger docs to registrytrue

Example (YAML):

RegistryCenter:
  Type: Zookeeper
  ConnectionStrings: "127.0.0.1:2181"
  ConnectionTimeout: 2000
  SessionTimeout: 8000
  OperatingTimeout: 15000

Nacos

NuGet: Silky.RegistryCenter.Nacos

PropertyDescriptionDefaultNotes
TypeRegistry typeNacosFixed value
ServerAddressesNacos server addresses—Required
NamespaceNacos namespace—
UserNameAuth username—
PasswordAuth password—
ServerGroupNameService group nameSILKYGROUPGroup used when registering Silky services
RegisterSwaggerDocSync Swagger docs to registrytrue
NamingUseRpcUse gRPC mode with Nacos—

Example (YAML):

RegistryCenter:
  Type: Nacos
  ServerAddresses:
    - "http://127.0.0.1:8848"
  Namespace: ""
  UserName: "nacos"
  Password: "nacos"
  ServerGroupName: SILKYGROUP

Consul

NuGet: Silky.RegistryCenter.Consul

PropertyDescriptionDefaultNotes
TypeRegistry typeConsulFixed value
AddressConsul Agent address—Required; e.g. http://127.0.0.1:8500
TokenConsul ACL token—
HeartBeatIntervalSecondHeartbeat / renewal interval15s
HealthCheckIntervalSecondHealth check interval10s
HealthCheckTimeoutSecondHealth check timeout1s
HealthCheckEnable health checktrue
RoutePathService metadata KV pathsilky/services
SwaggerDocPathSwagger doc KV pathsilky/swagger
RegisterSwaggerDocSync Swagger docs to registrytrue

Example (YAML):

RegistryCenter:
  Type: Consul
  Address: "http://127.0.0.1:8500"
  HeartBeatIntervalSecond: 15
  HealthCheck: true

Distributed Cache (DistributedCache)

Config section: DistributedCache. NuGet: Silky.Caching (Redis requires Silky.Caching.StackExchangeRedis).

PropertyDescriptionDefaultNotes
HideErrorsHide cache errorstrue
KeyPrefixGlobal cache key prefix""Empty = no prefix

Redis sub-section:

PropertyDescriptionDefaultNotes
IsEnabledEnable Redis backendfalseReplaces memory cache when true
ConfigurationRedis connection string""StackExchange.Redis format

GlobalCacheEntryOptions sub-section:

PropertyDescriptionDefaultNotes
AbsoluteExpirationAbsolute expiry (timestamp)—ISO 8601
AbsoluteExpirationRelativeToNowAbsolute expiry relative to now—Format: HH:mm:ss
SlidingExpirationSliding expiry (reset on access)00:20:00Cannot exceed absolute expiry

Example (YAML):

DistributedCache:
  HideErrors: true
  KeyPrefix: "myapp:"
  Redis:
    IsEnabled: true
    Configuration: "127.0.0.1:6379,password=yourpassword"
  GlobalCacheEntryOptions:
    SlidingExpiration: "00:20:00"

JWT Authentication (JwtSettings)

Config section: JwtSettings. NuGet: Silky.Jwt.

PropertyDescriptionDefaultNotes
SecretJWT signing key—Required; same key for issuer and validator
AlgorithmSigning algorithmHS256Options: HS256, HS384, HS512, RS256
IssuerToken issuerhttp://silky.com/issuer
AudienceToken audiencehttp://silky.com/audience
ExpiredTimeToken validity duration24hours

Example (YAML):

JwtSettings:
  Secret: "your-jwt-secret-key-at-least-16-chars"
  Algorithm: HS256
  Issuer: "https://your-domain.com/issuer"
  Audience: "https://your-domain.com/audience"
  ExpiredTime: 24

Gateway (Gateway)

Config section: Gateway.

Warning

This section is only effective in a Gateway Host (Silky.Http.Core). Configuring it in a business microservice has no effect.

PropertyDescriptionDefaultNotes
JwtSecretJWT key used by the gateway for parsing tokens—Must match JwtSettings:Secret of the issuing service
ResponseContentTypeHTTP response Content-Type—Auto-determined if not set
IgnoreWrapperPathPatternsPaths excluded from unified response wrappingStatic assets + health pathsArray; supports regex

Example (YAML):

Gateway:
  JwtSecret: "your-jwt-secret-key-at-least-16-chars"
  IgnoreWrapperPathPatterns:
    - "\\/.*\\.(js|css|html)"
    - "\\/(healthchecks|healthz)"
    - "\\/api\\/file\\/.*"

CORS (CorsAccessor)

Config section: CorsAccessor. NuGet: Silky.Http.CorsAccessor.

PropertyDescriptionDefaultNotes
PolicyNameCORS policy nameApp.CorsAccessor.Policy
WithOriginsAllowed origins[]Empty = allow any origin
WithHeadersAllowed request headers—All headers allowed if not set
WithExposedHeadersResponse headers exposed to browser—
WithMethodsAllowed HTTP methods—All methods allowed if not set
AllowCredentialsAllow credentials (cookies/auth headers)true
SetPreflightMaxAgePreflight (OPTIONS) cache duration—s

Example (YAML):

CorsAccessor:
  WithOrigins:
    - "https://your-frontend.com"
  AllowCredentials: true
  WithHeaders:
    - "Authorization"
    - "Content-Type"

Audit Logging (Auditing)

Config section: Auditing. NuGet: Silky.Http.Auditing.

PropertyDescriptionDefaultNotes
IsEnabledEnable audit loggingtrue
IsEnabledForAnonymousUsersLog anonymous requeststrue
IsEnabledForGetRequestsLog GET requestsfalseGET is read-only; disabled by default
HideErrorsHide audit write errorstrue
AlwaysLogOnExceptionForce logging when an exception occurstrue

Example (YAML):

Auditing:
  IsEnabled: true
  IsEnabledForAnonymousUsers: true
  IsEnabledForGetRequests: false
  AlwaysLogOnException: true

WebSocket (WebSocket)

Config section: WebSocket. NuGet: Silky.WebSocket. WebSocket Host only.

PropertyDescriptionDefaultNotes
PortWebSocket listening port3000
IsSslEnable SSL/WSSfalse
SslCertificateNameSSL certificate filename—Effective when IsSsl is true
SslCertificatePasswordSSL certificate password—Effective when IsSsl is true
WaitTimeWebSocket handshake wait time1s
KeepCleanClean up resources after session endsfalse
TokenWebSocket connection tokenwebsocket

Example (YAML):

WebSocket:
  Port: 3000
  IsSsl: false
  Token: "websocket"

Swagger Documentation (SwaggerDocument)

Config section: SwaggerDocument. NuGet: Silky.Http.Swagger.

PropertyDescriptionDefaultNotes
TitleSwagger UI titleSwagger UI
DescriptionAPI descriptionSwagger Document
VersionAPI versionv1.0.0
RoutePrefixSwagger UI route prefix""Empty = serve at /
OrganizationModeDocument grouping modeAllAndGroupNoGroup / Group / AllAndGroup
ShowModeService entry display modeAllAll / Interface / RegisterCenter
EnableMultipleServiceKeyShow multiple ServiceKey entriestrue
EnableHashRouteHeaderEnable hash routing via request headertrue
EnableAuthorizedEnable Swagger Bearer authtrue
FormatAsV2Output as OpenAPI v2 formattruefalse = OpenAPI v3
DocExpansionStateDefault doc expansion stateListList / Full / None
ShowDashboardServiceShow Dashboard internal APIs in Swaggerfalse
XmlCommentsXML comment file paths to load—Array
GroupsCustom service group config[]Each: ApplicationInterface, Title, Description, Version

Example (YAML):

SwaggerDocument:
  Title: "My Service API"
  Version: "v1.0.0"
  OrganizationMode: AllAndGroup
  EnableAuthorized: true
  RoutePrefix: ""
  XmlComments:
    - "MyService.Application.Contracts.xml"

Console Dashboard (Dashboard)

Config section: Dashboard. NuGet: Silky.Http.Dashboard. Gateway Host only.

PropertyDescriptionDefaultNotes
StatsPollingIntervalDashboard stats polling interval2000ms
UseAuthEnable login verificationtrue
UseTenantSupport tenant logintrue
DashboardLoginApiDashboard login endpoint/api/account/login
UserNameFiledNameUsername field name in login requestUserName
PasswordFiledNamePassword field name in login requestPassword
TenantNameFiledNameTenant field name in login requestTenantName
WrapperResponseWrap login response in unified formattrue
DisplayWebApiInSwaggerShow Dashboard APIs in Swaggerfalse
PathBaseDashboard base path (reverse proxy)—
ExternalLinksExternal links in Dashboard[]Each: Title, Path, Icon

Example (YAML):

Dashboard:
  UseAuth: true
  UseTenant: false
  DashboardLoginApi: "/api/account/login"
  StatsPollingInterval: 2000

Distributed Transactions (DistributedTransaction)

Config section: DistributedTransaction. NuGet: Silky.Transaction.Tcc.

PropertyDescriptionDefaultNotes
TransactionTypeTransaction typeTccOnly TCC is currently supported
ScheduledInitDelayRecovery task startup delay20s
ScheduledRecoveryDelayRecovery task execution interval30s
ScheduledCleanDelayCleanup task execution interval120s
RecoverDelayTimeTrigger recovery after this duration259200s (3 days)
CleanDelayTimeTrigger cleanup after this duration86400s (1 day)
LimitMax records per recovery/cleanup run100
RetryMaxMax recovery retry attempts10
PhyDeletedPhysically delete completed transaction recordstruefalse = soft delete
StoreDaysMax transaction record retention3days

Example (YAML):

DistributedTransaction:
  TransactionType: Tcc
  ScheduledRecoveryDelay: 30
  RetryMax: 10
  PhyDeleted: true
  StoreDays: 3

HTTP Rate Limiting (RateLimiting)

Config section: RateLimiting. NuGet: Silky.Http.RateLimit. Based on AspNetCoreRateLimit.

IP Rate Limiting

RateLimiting:
  Ip:
    EnableEndpointRateLimiting: true
    StackBlockedRequests: false
    RealIpHeader: X-Real-IP
    GeneralRules:
      - Endpoint: "*"
        Period: "1s"
        Limit: 100

Client ID Rate Limiting

RateLimiting:
  Client:
    EnableEndpointRateLimiting: true
    ClientIdHeader: X-ClientId
    GeneralRules:
      - Endpoint: "*"
        Period: "1m"
        Limit: 1000

Tips

For the full AspNetCoreRateLimit configuration reference, see the AspNetCoreRateLimit documentation.

Edit this page