Nacos.ConfigFilter.Reference
1.0.5
dotnet add package Nacos.ConfigFilter.Reference --version 1.0.5
NuGet\Install-Package Nacos.ConfigFilter.Reference -Version 1.0.5
<PackageReference Include="Nacos.ConfigFilter.Reference" Version="1.0.5" />
paket add Nacos.ConfigFilter.Reference --version 1.0.5
#r "nuget: Nacos.ConfigFilter.Reference, 1.0.5"
// Install Nacos.ConfigFilter.Reference as a Cake Addin
#addin nuget:?package=Nacos.ConfigFilter.Reference&version=1.0.5
// Install Nacos.ConfigFilter.Reference as a Cake Tool
#tool nuget:?package=Nacos.ConfigFilter.Reference&version=1.0.5
nacos-sdk-csharp Extension
An extension for charp(dotnet core) to use nacos for configuration refrence just like below:
There is a base config
{
"Database" {
"Host": "192.168.0.100",
"Port": 3306,
"User": "dbuser",
"Password": "dbpass"
}
}
Another configuration reference to this config like this:
{
"ConnectionStrings": {
"DefaultConnection": "server=${Database.Host};port=${Database.Port};user id=${Database.User};password=${Database.Password};database=somedb;CharSet=utf8mb4;SslMode=none"
}
}
Installation
Install via nuget
dotnet add Nacos.ConfigFilter.Reference --version 1.0.5
Usage
Configuration
Put below in your appsettings.json
{
"NacosConfig": {
"Listeners": [
{...}
],
"Namespace": "your nacos namespace id",
"ServerAddresses": [ "http://yourNacosServer:8848" ],
"ConfigFilterAssemblies": [ "Nacos.ConfigFilter.Reference" ],
"ConfigFilterExtInfo": "{}"
}
}
The only change to your NacosConfig it to add this assembly name "Nacos.ConfigFilter.Reference" to "ConfigFilterAssemblies"
Attention Base config listener must be placed from top to bottom.
Attention If a referenced key is not found, the application will exit!
Code
builder.WebHost.ConfigureAppConfiguration((context, builder) =>
{
var c = builder.Build();
// set the parser which is default to JsonParser
NacosReferenceConfigHandler.SetParser(Nacos.YamlParser.YamlConfigurationStringParser.Instance);
// set the groups can be used as base config can be referenced to .
NacosReferenceConfigHandler.SetBaseGroupList("DEFAULT_GROUP", "COMMON_GROUP");
// set the groups can be used as base config can be referenced by other configs.
NacosReferenceConfigHandler.SetBaseDataIdList("middleware");
// The process order is group first
// These two options can be ignored, but if you have a lot of DataIds, it is recommended to set there two options to decrease memory use.
builder.AddNacosV2Configuration(c.GetSection("NacosConfig"),
parser: Nacos.YamlParser.YamlConfigurationStringParser.Instance,
logAction: null);
});
Contact
If you have any questions, you can leave an issue here.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- nacos-sdk-csharp (>= 1.3.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.5 | 257 | 12/19/2022 |