-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename Discovery Client/Extension Packages as they're no longer the b…
…ase (#393) - Rename Discovery Client/Extension Packages as they're no longer the base - split DiscoveryClientCore into two packages to isolate ASP.NET code
- Loading branch information
Showing
174 changed files
with
368 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Extensions.Hosting; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Steeltoe.Discovery.Client | ||
{ | ||
internal class DiscoveryClientService : IHostedService | ||
{ | ||
private readonly IDiscoveryLifecycle _applicationLifetime; | ||
|
||
internal DiscoveryClientService(IDiscoveryLifecycle applicationLifetime) | ||
{ | ||
_applicationLifetime = applicationLifetime; | ||
} | ||
|
||
public Task StartAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Discovery/src/ClientBase/DiscoveryHostBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Steeltoe.Connector; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace Steeltoe.Discovery.Client | ||
{ | ||
public static class DiscoveryHostBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Adds service discovery to your application. This method can be used in place of configuration via your Startup class.<para /> | ||
/// If <paramref name="optionsAction"/> is not provided, a <see cref="NoOpDiscoveryClient"/> will be configured | ||
/// </summary> | ||
/// <param name="hostBuilder">Your HostBuilder</param> | ||
/// <param name="optionsAction">Select the discovery client implementation</param> | ||
/// <remarks>Also configures named HttpClients "DiscoveryRandom" and "DiscoveryRoundRobin" for automatic injection</remarks> | ||
/// <exception cref="AmbiguousMatchException">Thrown if multiple IDiscoveryClient implementations are configured</exception> | ||
/// <exception cref="ConnectorException">Thrown if no service info with expected name or type are found or when multiple service infos are found and a single was expected</exception> | ||
public static IHostBuilder AddServiceDiscovery(this IHostBuilder hostBuilder, Action<DiscoveryClientBuilder> optionsAction) | ||
{ | ||
return hostBuilder.ConfigureServices((context, collection) => AddServices(collection, optionsAction)); | ||
} | ||
|
||
private static void AddServices(IServiceCollection collection, Action<DiscoveryClientBuilder> optionsAction) | ||
{ | ||
collection.AddServiceDiscovery(optionsAction); | ||
collection.AddHostedService(services => new DiscoveryClientService(services.GetRequiredService<IDiscoveryLifecycle>())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Steeltoe.Discovery.ClientBase.Test")] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions
25
src/Discovery/src/ClientBase/Steeltoe.Discovery.ClientBase.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netcoreapp3.1</TargetFrameworks> | ||
<Description>Base package for using Steeltoe Service Discovery</Description> | ||
<PackageTags>service discovery;service registry;Spring Cloud;eureka;consul;kubernetes</PackageTags> | ||
<RootNamespace>Steeltoe.Discovery.Client</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<Import Project="..\..\..\..\versions.props" /> | ||
<Import Project="..\..\..\..\sharedproject.props" /> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(ExtensionsVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(ExtensionsVersion)" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\Common\src\Common.Http\Steeltoe.Common.Http.csproj" /> | ||
<ProjectReference Include="..\..\..\Connectors\src\ConnectorBase\Steeltoe.Connector.ConnectorBase.csproj" /> | ||
<ProjectReference Include="..\Abstractions\Steeltoe.Discovery.Abstractions.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.