Skip to content

Commit

Permalink
Merge pull request #81 from nacos-group/dev
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
catcherwong authored Mar 20, 2021
2 parents 1645598 + 4de9106 commit e503ad7
Show file tree
Hide file tree
Showing 48 changed files with 439 additions and 433 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build_With_Stable
name: Build_With_Stable_1x

on:
push:
Expand Down Expand Up @@ -37,14 +37,23 @@ jobs:
run: dotnet --version
- name: Show java Version
run: java -version
- name: Setup Stable Nacos Server
- name: Setup Stable 1.x Nacos Server
run: |
wget https://github.com/alibaba/nacos/releases/download/1.4.1/nacos-server-1.4.1.tar.gz
tar -xvf nacos-server-1.4.1.tar.gz
cd nacos/bin
# sed -i 's/nacos.core.auth.enabled=false/nacos.core.auth.enabled=true/g' ../conf/application.properties
chmod 755 startup.sh
nohup ./startup.sh -m standalone 2>&1 &
sleep 30
curl "127.0.0.1:8848/nacos/v1/ns/operator/metrics"
- name: Build with dotnet
run: dotnet build --configuration Release
run: dotnet build --configuration Release
- name: Test with dotnet
run: dotnet test --filter "Category=all|Category=1x"
- name: Upload Nacos logs
if: always()
uses: actions/upload-artifact@v2
with:
name: nacos-logs
path: /home/runner/work/nacos-sdk-csharp/nacos-sdk-csharp/nacos/logs
59 changes: 59 additions & 0 deletions .github/workflows/build_Stable_2x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build_With_Stable_2x

on:
push:
branches: [ dev, master ]
pull_request:
branches: [ dev, master ]

jobs:
windows:
name: build on windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Build with dotnet
run: dotnet build --configuration Release

linux:
name: build on linux
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Setup up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Show dotnet Version
run: dotnet --version
- name: Show java Version
run: java -version
- name: Setup Stable 2.x Nacos Server
run: |
wget https://github.com/alibaba/nacos/releases/download/2.0.0/nacos-server-2.0.0.tar.gz
tar -xvf nacos-server-2.0.0.tar.gz
cd nacos/bin
# sed -i 's/nacos.core.auth.enabled=false/nacos.core.auth.enabled=true/g' ../conf/application.properties
chmod 755 startup.sh
nohup ./startup.sh -m standalone 2>&1 &
sleep 30
curl "127.0.0.1:8848/nacos/v1/ns/operator/metrics"
- name: Build with dotnet
run: dotnet build --configuration Release
- name: Test with dotnet
run: dotnet test --filter "Category=all|Category=1x|Category=2x"
- name: Upload Nacos logs
if: always()
uses: actions/upload-artifact@v2
with:
name: nacos-logs
path: /home/runner/work/nacos-sdk-csharp/nacos-sdk-csharp/nacos/logs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build_With_Alpha
name: Build_With_Unstable

on:
push:
Expand Down Expand Up @@ -26,11 +26,12 @@ jobs:
run: dotnet --version
- name: Show java Version
run: java -version
- name: Setup Alpha Nacos Server
- name: Setup Unstable Nacos Server
run: |
wget https://github.com/alibaba/nacos/releases/download/2.0.0-BETA/nacos-server-2.0.0-BETA.tar.gz
tar -xvf nacos-server-2.0.0-BETA.tar.gz
wget https://github.com/alibaba/nacos/releases/download/2.0.0/nacos-server-2.0.0.tar.gz
tar -xvf nacos-server-2.0.0.tar.gz
cd nacos/bin
# sed -i 's/nacos.core.auth.enabled=false/nacos.core.auth.enabled=true/g' ../conf/application.properties
sed -i 's/Xms512m/Xms1024m/g' startup.sh
sed -i 's/Xmx512m/Xmx1024m/g' startup.sh
sed -i 's/Xmn256m/Xmn512m/g' startup.sh
Expand All @@ -41,7 +42,7 @@ jobs:
- name: Build with dotnet
run: dotnet build
- name: Test with dotnet
run: dotnet test
run: dotnet test --filter "Category=all|Category=1x|Category=2x"
- name: Upload Nacos logs
if: always()
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Release_Unstable

on:
push:
Expand Down
2 changes: 2 additions & 0 deletions src/Nacos.AspNetCore/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class ServiceCollectionExtensions
/// <param name="services">services.</param>
/// <param name="configuration">configuration</param>
/// <returns>IServiceCollection</returns>
[Obsolete("This method is obsolete and will be removed in a future version. Use AddNacosAspNet instead.")]
public static IServiceCollection AddNacosAspNetCore(
this IServiceCollection services,
IConfiguration configuration)
Expand Down Expand Up @@ -53,6 +54,7 @@ public static IServiceCollection AddNacosAspNetCore(
/// <param name="nacosAspNetCoreOptions">nacosAspNetCoreOptions.</param>
/// <param name="nacosOptions">nacosOptions</param>
/// <returns>IServiceCollection</returns>
[Obsolete("This method is obsolete and will be removed in a future version. Use AddNacosAspNet instead.")]
public static IServiceCollection AddNacosAspNetCore(
this IServiceCollection services,
Action<NacosAspNetCoreOptions> nacosAspNetCoreOptions,
Expand Down
1 change: 0 additions & 1 deletion src/Nacos.AspNetCore/V2/RegSvcBgTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public async Task StartAsync(CancellationToken cancellationToken)

if (_options.Secure) metadata[MetadataSecure] = "true";


foreach (var item in _options.Metadata)
{
if (!metadata.ContainsKey(item.Key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public MsConfigServerHttpAgent(NacosOptions options)
_namespaceId = _options.Namespace;

_serverListMgr = new ServerListManager(_options);
_securityProxy = new Security.SecurityProxy(_options);
_securityProxy = new Security.SecurityProxy(_options, null);

_securityProxy.LoginAsync(_serverListMgr.GetServerUrls()).ConfigureAwait(false).GetAwaiter().GetResult();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public static IConfigurationBuilder AddNacosConfiguration(
return builder.Add(source);
}

/// <summary>
/// Add Nacos Configuration that integrate with Microsoft.Extensions.Configuration
/// </summary>
/// <param name="builder">IConfigurationBuilder</param>
/// <param name="action">setup NacosConfigurationSource</param>
/// <returns>IConfigurationBuilder</returns>
public static IConfigurationBuilder AddNacosV2Configuration(
this IConfigurationBuilder builder, Action<NacosV2ConfigurationSource> action)
{
Expand All @@ -85,6 +91,13 @@ public static IConfigurationBuilder AddNacosV2Configuration(
return builder.Add(source);
}

/// <summary>
/// Add Nacos Configuration that integrate with Microsoft.Extensions.Configuration
/// </summary>
/// <param name="builder">IConfigurationBuilder</param>
/// <param name="configuration">Configuration binding nacos configuration source</param>
/// <param name="parser">The parser.</param>
/// <returns>IConfigurationBuilder</returns>
public static IConfigurationBuilder AddNacosV2Configuration(
this IConfigurationBuilder builder,
IConfiguration configuration,
Expand Down
32 changes: 16 additions & 16 deletions src/Nacos/Config/AbstNacosConfigClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task<string> GetConfigAsync(GetConfigRequest request)

if (!string.IsNullOrWhiteSpace(config))
{
_logger.LogInformation($"[get-config] get failover ok, envname={GetAgent().GetName()}, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, config ={config}");
_logger?.LogInformation($"[get-config] get failover ok, envname={GetAgent().GetName()}, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, config ={config}");
return config;
}

Expand All @@ -54,12 +54,12 @@ public async Task<string> GetConfigAsync(GetConfigRequest request)
}
catch (Exception ex)
{
_logger.LogWarning($"[get-config] get from server error, envname={GetAgent().GetName()}, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, msg={ex.Message}");
_logger?.LogWarning($"[get-config] get from server error, envname={GetAgent().GetName()}, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, msg={ex.Message}");
}

if (!string.IsNullOrWhiteSpace(config))
{
_logger.LogInformation($"[get-config] content from server {config}, envname={GetAgent().GetName()}, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
_logger?.LogInformation($"[get-config] content from server {config}, envname={GetAgent().GetName()}, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
await GetProcessor().SaveSnapshotAsync(GetAgent().GetName(), request.DataId, request.Group, request.Tenant, config);
return config;
}
Expand Down Expand Up @@ -102,14 +102,14 @@ public async Task<bool> PublishConfigAsync(PublishConfigRequest request)
switch (responseMessage.StatusCode)
{
case System.Net.HttpStatusCode.OK:
_logger.LogInformation($"[publish-single] ok, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, config={request.Content}");
_logger?.LogInformation($"[publish-single] ok, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, config={request.Content}");
var result = await responseMessage.Content.ReadAsStringAsync();
return result.Equals("true", StringComparison.OrdinalIgnoreCase);
case System.Net.HttpStatusCode.Forbidden:
_logger.LogWarning($"[publish-single] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
_logger?.LogWarning($"[publish-single] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
throw new NacosException(NacosException.NO_RIGHT, $"Insufficient privilege.");
default:
_logger.LogWarning($"[publish-single] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
_logger?.LogWarning($"[publish-single] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
return false;
}
}
Expand All @@ -128,14 +128,14 @@ public async Task<bool> RemoveConfigAsync(RemoveConfigRequest request)
switch (responseMessage.StatusCode)
{
case System.Net.HttpStatusCode.OK:
_logger.LogInformation($"[remove] ok, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
_logger?.LogInformation($"[remove] ok, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
var result = await responseMessage.Content.ReadAsStringAsync();
return result.Equals("true", StringComparison.OrdinalIgnoreCase);
case System.Net.HttpStatusCode.Forbidden:
_logger.LogWarning($"[remove] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
_logger?.LogWarning($"[remove] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
throw new NacosException(NacosException.NO_RIGHT, $"Insufficient privilege.");
default:
_logger.LogWarning($"[remove] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
_logger?.LogWarning($"[remove] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
return false;
}
}
Expand All @@ -153,7 +153,7 @@ public Task AddListenerAsync(AddListenerRequest request)

if (listeners.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
{
_logger.LogWarning($"[add-listener] error, {name} has been added.");
_logger?.LogWarning($"[add-listener] error, {name} has been added.");
return Task.CompletedTask;
}

Expand Down Expand Up @@ -185,7 +185,7 @@ public Task RemoveListenerAsync(RemoveListenerRequest request)

if (!listeners.Any(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
{
_logger.LogWarning($"[remove-listener] error, {name} was not added.");
_logger?.LogWarning($"[remove-listener] error, {name} was not added.");
return Task.CompletedTask;
}

Expand All @@ -209,7 +209,7 @@ public Task RemoveListenerAsync(RemoveListenerRequest request)
}
catch (Exception ex)
{
_logger.LogError(ex, $"[remove-listener] call back throw exception, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
_logger?.LogError(ex, $"[remove-listener] call back throw exception, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
}
}

Expand Down Expand Up @@ -247,18 +247,18 @@ private async Task PollingAsync(object requestInfo)
break;
case System.Net.HttpStatusCode.Forbidden:
SetHealthServer(false);
_logger.LogWarning($"[listener] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
_logger?.LogWarning($"[listener] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
throw new NacosException(NacosException.NO_RIGHT, $"Insufficient privilege.");
default:
SetHealthServer(false);
_logger.LogWarning($"[listener] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
_logger?.LogWarning($"[listener] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}, code={(int)responseMessage.StatusCode} msg={responseMessage.StatusCode.ToString()}");
throw new NacosException((int)responseMessage.StatusCode, responseMessage.StatusCode.ToString());
}
}
catch (Exception ex)
{
SetHealthServer(false);
_logger.LogError(ex, $"[listener] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
_logger?.LogError(ex, $"[listener] error, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
}
}

Expand Down Expand Up @@ -286,7 +286,7 @@ private async Task ConfigChangeAsync(string content, AddListenerRequest request)
}
catch (Exception ex)
{
_logger.LogError(ex, $"[listener] call back throw exception, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
_logger?.LogError(ex, $"[listener] call back throw exception, dataId={request.DataId}, group={request.Group}, tenant={request.Tenant}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Nacos/Config/Http/ServerHttpAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ServerHttpAgent(
_namespaceId = _options.Namespace;

_serverListMgr = new ServerListManager(_options);
_securityProxy = new Security.SecurityProxy(_options);
_securityProxy = new Security.SecurityProxy(_options, _logger);

_securityProxy.LoginAsync(_serverListMgr.GetServerUrls()).ConfigureAwait(false).GetAwaiter().GetResult();

Expand Down Expand Up @@ -87,7 +87,7 @@ public override async Task<HttpResponseMessage> ReqApiAsync(HttpMethod httpMetho
|| responseMessage.StatusCode == System.Net.HttpStatusCode.BadGateway
|| responseMessage.StatusCode == System.Net.HttpStatusCode.ServiceUnavailable)
{
_logger.LogError("[NACOS ConnectException] currentServerAddr: {0}, httpCode: {1}", _serverListMgr.GetCurrentServerAddr(), responseMessage.StatusCode);
_logger?.LogError("[NACOS ConnectException] currentServerAddr: {0}, httpCode: {1}", _serverListMgr.GetCurrentServerAddr(), responseMessage.StatusCode);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/Nacos/Nacos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<PackageReference Include="Google.Protobuf" Version="3.14.0" />
<PackageReference Include="Grpc.Core" Version="2.34.0" />
<!--<PackageReference Include="Grpc.Net.Client" Version="2.33.1" />-->
<!--<Protobuf Include="protos\nacos_grpc_service.proto" GrpcServices="Client" />-->
<!--<PackageReference Include="Grpc.Tools" Version="2.33.1" PrivateAssets="All" />-->
<!--<Protobuf Include="V2\protos\nacos_grpc_service.proto" GrpcServices="Client" />-->
<!--<PackageReference Include="Grpc.Tools" Version="2.36.1" PrivateAssets="All" />-->
</ItemGroup>

</Project>
Loading

0 comments on commit e503ad7

Please sign in to comment.