Skip to content

Commit 6c9670f

Browse files
author
liguoliang
committed
版本升级and代码升级
1 parent 323a41c commit 6c9670f

11 files changed

Lines changed: 30 additions & 225 deletions

File tree

demo/ApiGatewayDemo/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
},
99
"AllowedHosts": "*",
1010
"nacos": {
11-
"ServerAddresses": [ "http://192.168.219.1:8848" ],
11+
"ServerAddresses": [ "http://127.0.0.1:8848" ],
1212
"ServiceName": "apigateway",
1313
"DefaultTimeOut": 15000,
1414
//×Ô¶¨ÒåNamespaceµÄId
15-
"Namespace": "2ae308e2-7e8a-4602-9d1c-56508a3e263c",
15+
"Namespace": "01761089-727d-49cb-9abe-fbe647f83927",
1616
"GroupName": "DEFAULT_GROUP",
1717
"ClusterName": "DEFAULT",
1818
"ListenInterval": 1000,

demo/ProductApi/ProductApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.1" />
1313
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
14-
<PackageReference Include="nacos-sdk-csharp.AspNetCore" Version="1.1.0-alpha20210426120755" />
14+
<PackageReference Include="nacos-sdk-csharp.AspNetCore" Version="1.2.2" />
1515
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
1616
</ItemGroup>
1717
<ItemGroup>

demo/ProductApi/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
},
99
"AllowedHosts": "*",
1010
"nacos": {
11-
"ServerAddresses": [ "http://192.168.219.1:8848" ],
11+
"ServerAddresses": [ "http://127.0.0.1:8848" ],
1212
"ServiceName": "productservice",
1313
"DefaultTimeOut": 15000,
1414
//×Ô¶¨ÒåNamespaceµÄId
15-
"Namespace": "2ae308e2-7e8a-4602-9d1c-56508a3e263c",
15+
"Namespace": "01761089-727d-49cb-9abe-fbe647f83927",
1616
"GroupName": "DEFAULT_GROUP",
1717
"ClusterName": "DEFAULT",
1818
"ListenInterval": 1000,

src/Ocelot.Provider.Nacos/NacosClient/LoadBalance/ILBStrategy.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Ocelot.Provider.Nacos/NacosClient/LoadBalance/LBStrategyName.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Ocelot.Provider.Nacos/NacosClient/LoadBalance/LbKv.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/Ocelot.Provider.Nacos/NacosClient/LoadBalance/WeightRandomLBStrategy.cs

Lines changed: 0 additions & 73 deletions
This file was deleted.

src/Ocelot.Provider.Nacos/NacosClient/LoadBalance/WeightRoundRobinLBStrategy.cs

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/Ocelot.Provider.Nacos/NacosClient/V2/NacosAspNetOptions.cs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,23 @@ public class NacosAspNetOptions : NacosSdkOptions
6868
/// </summary>
6969
public bool Secure { get; set; } = false;
7070

71-
/// <summary>
72-
/// Load Balance Strategy
73-
/// </summary>
74-
public string LBStrategy { get; set; } = LBStrategyName.WeightRandom.ToString();
75-
76-
public NacosSdkOptions BuildSdkOptions()
71+
public System.Action<NacosSdkOptions> BuildSdkOptions()
7772
{
78-
return new NacosSdkOptions
73+
return x =>
7974
{
80-
AccessKey = this.AccessKey,
81-
ConfigUseRpc = this.ConfigUseRpc,
82-
ContextPath = this.ContextPath,
83-
DefaultTimeOut = this.DefaultTimeOut,
84-
EndPoint = this.EndPoint,
85-
ListenInterval = this.ListenInterval,
86-
Namespace = this.Namespace,
87-
NamingLoadCacheAtStart = this.NamingLoadCacheAtStart,
88-
NamingUseRpc = this.NamingUseRpc,
89-
Password = this.Password,
90-
SecretKey = this.SecretKey,
91-
ServerAddresses = this.ServerAddresses,
92-
UserName = this.UserName,
75+
x.AccessKey = this.AccessKey;
76+
x.ConfigUseRpc = this.ConfigUseRpc;
77+
x.ContextPath = this.ContextPath;
78+
x.DefaultTimeOut = this.DefaultTimeOut;
79+
x.EndPoint = this.EndPoint;
80+
x.ListenInterval = this.ListenInterval;
81+
x.Namespace = this.Namespace;
82+
x.NamingLoadCacheAtStart = this.NamingLoadCacheAtStart;
83+
x.NamingUseRpc = this.NamingUseRpc;
84+
x.Password = this.Password;
85+
x.SecretKey = this.SecretKey;
86+
x.ServerAddresses = this.ServerAddresses;
87+
x.UserName = this.UserName;
9388
};
9489
}
9590
}

src/Ocelot.Provider.Nacos/NacosClient/V2/ServiceCollectionExtensions.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ public static class ServiceCollectionExtensions
1616
/// </summary>
1717
/// <param name="services">services.</param>
1818
/// <param name="configuration">configuration</param>
19+
/// <param name="section">section, default is nacos</param>
1920
/// <returns>IServiceCollection</returns>
20-
public static IServiceCollection AddNacosAspNet(this IServiceCollection services, IConfiguration configuration)
21+
public static IServiceCollection AddNacosAspNet(this IServiceCollection services, IConfiguration configuration, string section = "nacos")
2122
{
22-
services.Configure<NacosAspNetOptions>(configuration.GetSection("nacos"));
23+
services.Configure<NacosAspNetOptions>(configuration.GetSection(section));
2324
services.AddNacosV2Naming(configuration);
2425
services.AddSingleton<RegSvcBgTask>();
2526

@@ -39,7 +40,9 @@ public static IServiceCollection AddNacosAspNet(this IServiceCollection services
3940

4041
var options = new NacosAspNetOptions();
4142
optionsAccs.Invoke(options);
42-
services.AddNacosV2Naming(x => options.BuildSdkOptions());
43+
44+
services.AddNacosV2Naming(options.BuildSdkOptions());
45+
4346
services.AddSingleton<RegSvcBgTask>();
4447

4548
return services;

0 commit comments

Comments
 (0)