Skip to content

Commit

Permalink
Merge branch 'nacos-group:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ZUOXIANGE authored Sep 22, 2024
2 parents f2a24b7 + ded6426 commit 32a6870
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
run: |
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos/Nacos.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos.AspNetCore/Nacos.AspNetCore.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos.Microsoft.Extensions.ServiceDiscovery/Nacos.Microsoft.Extensions.ServiceDiscovery.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos.Microsoft.Extensions.Configuration/Nacos.Microsoft.Extensions.Configuration.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json parsers/Nacos.IniParser/Nacos.IniParser.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json parsers/Nacos.YamlParser/Nacos.YamlParser.csproj
Expand All @@ -32,6 +33,7 @@ jobs:
ver=alpha`date +%Y%m%d%H%M%S`
dotnet pack src/Nacos/Nacos.csproj --version-suffix $ver -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack src/Nacos.AspNetCore/Nacos.AspNetCore.csproj --version-suffix $ver -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack src/Nacos.Microsoft.Extensions.ServiceDiscovery/Nacos.Microsoft.Extensions.ServiceDiscovery.csproj --version-suffix $ver -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack src/Nacos.Microsoft.Extensions.Configuration/Nacos.Microsoft.Extensions.Configuration.csproj --version-suffix $ver -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack parsers/Nacos.IniParser/Nacos.IniParser.csproj --version-suffix $ver -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack parsers/Nacos.YamlParser/Nacos.YamlParser.csproj --version-suffix $ver -o /home/runner/work/nugetpkgs -c Release --no-build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release_stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
run: |
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos/Nacos.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos.AspNetCore/Nacos.AspNetCore.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos.Microsoft.Extensions.ServiceDiscovery/Nacos.Microsoft.Extensions.ServiceDiscovery.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json src/Nacos.Microsoft.Extensions.Configuration/Nacos.Microsoft.Extensions.Configuration.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json parsers/Nacos.IniParser/Nacos.IniParser.csproj
dotnet build --configuration Release --source https://api.nuget.org/v3/index.json parsers/Nacos.YamlParser/Nacos.YamlParser.csproj
Expand All @@ -31,6 +32,7 @@ jobs:
run: |
dotnet pack src/Nacos/Nacos.csproj -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack src/Nacos.AspNetCore/Nacos.AspNetCore.csproj -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack src/Nacos.Microsoft.Extensions.ServiceDiscovery/Nacos.Microsoft.Extensions.ServiceDiscovery.csproj -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack src/Nacos.Microsoft.Extensions.Configuration/Nacos.Microsoft.Extensions.Configuration.csproj -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack parsers/Nacos.IniParser/Nacos.IniParser.csproj -o /home/runner/work/nugetpkgs -c Release --no-build
dotnet pack parsers/Nacos.YamlParser/Nacos.YamlParser.csproj -o /home/runner/work/nugetpkgs -c Release --no-build
Expand Down
17 changes: 17 additions & 0 deletions src/Nacos.Microsoft.Extensions.ServiceDiscovery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# nacos-sdk-csharp.Extensions.ServiceDiscovery

nacos-sdk-csharp.Extensions.ServiceDiscovery provides service registration and discovery With Microsoft.Extensions.ServiceDiscovery.

```csharp
builder.Services.AddServiceDiscovery(o =>
{
o.RefreshPeriod = TimeSpan.FromSeconds(60);
})
.AddConfigurationServiceEndpointProvider()
.AddNacosSrvServiceEndpointProvider();
```

## Links

* [Documentation](https://nacos-sdk-csharp.readthedocs.io/en/latest/)
* [nacos-sdk-csharp GitHub](https://github.com/nacos-group/nacos-sdk-csharp)
12 changes: 10 additions & 2 deletions src/Nacos/V2/Naming/Remote/Grpc/Redo/NamingGrpcRedoService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void InstanceDeregister(string serviceName, string groupName)
if (_registeredInstances.TryGetValue(key, out var data))
{
data.Unregistering = true;
data.ExpectedRegistered = false;
}
}

Expand All @@ -125,7 +126,10 @@ public void RemoveInstanceForRedo(string serviceName, string groupName)
{
string key = NamingUtils.GetGroupedName(serviceName, groupName);

_registeredInstances.TryRemove(key, out _);
if (_registeredInstances.TryGetValue(key, out var data) && data != null && !data.ExpectedRegistered)
{
_registeredInstances.TryRemove(key, out _);
}
}

/// <summary>
Expand Down Expand Up @@ -190,6 +194,7 @@ public void SubscriberDeregister(string serviceName, string groupName, string cl
if (_subscribes.TryGetValue(key, out var data))
{
data.Unregistering = true;
data.ExpectedRegistered = false;
}
}

Expand All @@ -203,7 +208,10 @@ public void RemoveSubscriberForRedo(string serviceName, string groupName, string
{
string key = ServiceInfo.GetKey(NamingUtils.GetGroupedName(serviceName, groupName), cluster);

_subscribes.TryRemove(key, out _);
if (_subscribes.TryGetValue(key, out var data) && data != null && !data.ExpectedRegistered)
{
_subscribes.TryRemove(key, out _);
}
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Nacos/V2/Naming/Remote/Grpc/Redo/RedoData{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ protected RedoData(string serviceName, string groupName)
{
this.ServiceName = serviceName;
this.GroupName = groupName;
this.ExpectedRegistered = true;
}

public string ServiceName { get; private set; }

public string GroupName { get; private set; }

public bool ExpectedRegistered { get; set; }

public T Data { get; set; }

public bool Registered { get; set; }
Expand Down
5 changes: 5 additions & 0 deletions src/Nacos/V2/Naming/Remote/Grpc/Redo/RedoScheduledTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ private async Task RedoForInstance(InstanceRedoData redoData)
case RedoType.REGISTER:
if (IsClientDisabled()) return;

if (redoData is BatchInstanceRedoData batchInstanceRedoData)
{
await _clientProxy.BatchRegisterServiceAsync(serviceName, groupName, batchInstanceRedoData.Instances).ConfigureAwait(false);
}

await _clientProxy.DoRegisterService(serviceName, groupName, redoData.Data).ConfigureAwait(false);
break;
case RedoType.UNREGISTER:
Expand Down

0 comments on commit 32a6870

Please sign in to comment.