Enable quick switch between eureka and consul in discovery sample

This commit is contained in:
Tim Hess 2020-08-17 13:44:36 -04:00
Родитель bac42983e7
Коммит 3b34d80456
13 изменённых файлов: 29 добавлений и 42 удалений

Просмотреть файл

@ -19,7 +19,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Common.Hosting" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.ClientBase" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.Consul" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.Eureka" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="$(SteeltoeVersion)" />

Просмотреть файл

@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Steeltoe.Common.Hosting;
using Steeltoe.Discovery.Client;
using Steeltoe.Discovery.Eureka;
using Steeltoe.Extensions.Configuration.CloudFoundry;
using Steeltoe.Extensions.Configuration.Placeholder;
@ -17,13 +16,15 @@ namespace FortuneTellerService
public static IHost BuildHost(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(host => host.UseStartup<Startup>())
.ConfigureWebHostDefaults(host =>
{
host.UseStartup<Startup>();
})
.AddCloudFoundryConfiguration()
.AddDiscoveryClient()
.AddPlaceholderResolver()
.AddServiceDiscovery(options => options.UseEureka())
.UseCloudHosting(5000)
.Build();
}
}

Просмотреть файл

@ -24,7 +24,7 @@
"Fortune-Teller-Service-Consul": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Consul"
"ASPNETCORE_ENVIRONMENT": "consul"
}
}
}

Просмотреть файл

@ -3,8 +3,7 @@
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Debug",
"Steeltoe": "Debug"
"Steeltoe.Discovery": "Trace"
}
},
"eureka": {

Просмотреть файл

@ -3,8 +3,7 @@
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Information",
"Steeltoe": "Information"
"Steeltoe.Discovery": "Trace"
},
"Console": {
"DisableColors": true

Просмотреть файл

@ -2,9 +2,7 @@
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Information",
"Steeltoe": "Information"
"Default": "Information"
},
"Console": {
"DisableColors": true
@ -21,21 +19,6 @@
// "registrationMethod" : "direct"
// }
// }
},
"eureka": {
"client": {
"serviceUrl": "http://localhost:8761/eureka/",
"shouldFetchRegistry": false,
"ValidateCertificates": false
},
"instance": {
"port": 5000,
"appName": "fortuneService", // this shouldn't be needed, there's probably a bug in 3.0 preventing spring:application:name from being used here
"instanceId": "${spring:application:name}"
// Remove comments to enable SSL requests
// More changes in Program.cs are required if using direct C2C communications
//,"securePortEnabled": true
}
}
}

Просмотреть файл

@ -10,6 +10,7 @@
<PackageReference Include="Steeltoe.Common.Hosting" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.Consul" Version="$(SteeltoeVersion)" />
<PackageReference Include="Steeltoe.Discovery.Eureka" Version="$(SteeltoeVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -20,6 +20,12 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Fortune-Teller-UI-Consul": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "consul"
}
}
}
}

Просмотреть файл

@ -25,7 +25,7 @@ namespace Fortune_Teller_UI
{
c.BaseAddress = new Uri("http://fortuneService/api/fortunes/");
})
.AddHttpMessageHandler<DiscoveryHttpMessageHandler>()
.AddServiceDiscovery()
.AddTypedClient<IFortuneService, FortuneService>();
// Add framework services.

Просмотреть файл

@ -3,8 +3,14 @@
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Debug",
"Steeltoe": "Debug"
"Steeltoe.Discovery": "Trace"
}
},
"eureka": {
"client": {
"serviceUrl": "http://localhost:8761/eureka/",
"shouldRegisterWithEureka": false,
"ValidateCertificates": false
}
}
}

Просмотреть файл

@ -3,8 +3,7 @@
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Information",
"Steeltoe": "Information"
"Steeltoe.Discovery": "Trace"
},
"Console": {
"DisableColors": true

Просмотреть файл

@ -3,7 +3,6 @@
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Information",
"Steeltoe": "Information"
},
"Console": {
@ -14,13 +13,6 @@
"application": {
"name": "fortuneUI"
}
},
"eureka": {
"client": {
"serviceUrl": "http://localhost:8761/eureka/",
"shouldRegisterWithEureka": false,
"ValidateCertificates": false
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<SteeltoeVersion>3.0.0-3432</SteeltoeVersion>
<SteeltoeVersion>3.0.0-3468</SteeltoeVersion>
</PropertyGroup>
<PropertyGroup>
<GitInfoVersion>2.0.20</GitInfoVersion>