Skip to content

Commit 23d07de

Browse files
committed
Add PollyTest
1 parent 089ef8b commit 23d07de

12 files changed

Lines changed: 218 additions & 0 deletions

src/Example.CSharp.sln

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRedisStackTest", "plugins\
269269
EndProject
270270
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerilogTest", "plugins\SerilogTest\SerilogTest.csproj", "{5C904F2C-2E56-49B7-9BC0-9F61A435B6BF}"
271271
EndProject
272+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Polly", "Polly", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
273+
EndProject
274+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebPollyTest", "plugins\WebPollyTest\WebPollyTest.csproj", "{F4FAEA96-D8F1-4C3D-83EF-A121BAFD2EA1}"
275+
EndProject
276+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsolePollyTest", "plugins\ConsolePollyTest\ConsolePollyTest.csproj", "{7F0AA476-83A6-49C7-9064-6D13EF4811B9}"
277+
EndProject
272278
Global
273279
GlobalSection(SolutionConfigurationPlatforms) = preSolution
274280
Debug|Any CPU = Debug|Any CPU
@@ -655,6 +661,14 @@ Global
655661
{5C904F2C-2E56-49B7-9BC0-9F61A435B6BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
656662
{5C904F2C-2E56-49B7-9BC0-9F61A435B6BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
657663
{5C904F2C-2E56-49B7-9BC0-9F61A435B6BF}.Release|Any CPU.Build.0 = Release|Any CPU
664+
{F4FAEA96-D8F1-4C3D-83EF-A121BAFD2EA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
665+
{F4FAEA96-D8F1-4C3D-83EF-A121BAFD2EA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
666+
{F4FAEA96-D8F1-4C3D-83EF-A121BAFD2EA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
667+
{F4FAEA96-D8F1-4C3D-83EF-A121BAFD2EA1}.Release|Any CPU.Build.0 = Release|Any CPU
668+
{7F0AA476-83A6-49C7-9064-6D13EF4811B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
669+
{7F0AA476-83A6-49C7-9064-6D13EF4811B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
670+
{7F0AA476-83A6-49C7-9064-6D13EF4811B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
671+
{7F0AA476-83A6-49C7-9064-6D13EF4811B9}.Release|Any CPU.Build.0 = Release|Any CPU
658672
EndGlobalSection
659673
GlobalSection(SolutionProperties) = preSolution
660674
HideSolutionNode = FALSE
@@ -767,6 +781,9 @@ Global
767781
{BB9D0A15-F03D-4000-BAD3-CFF79A168E3C} = {3EAB4251-F872-4E23-AFEE-C55FEC5856DD}
768782
{805752FF-E206-49FA-8959-AE79DDA1DBEA} = {630114C3-1AE7-468E-8ADD-1CDE3E9EEF26}
769783
{5C904F2C-2E56-49B7-9BC0-9F61A435B6BF} = {630114C3-1AE7-468E-8ADD-1CDE3E9EEF26}
784+
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {630114C3-1AE7-468E-8ADD-1CDE3E9EEF26}
785+
{F4FAEA96-D8F1-4C3D-83EF-A121BAFD2EA1} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
786+
{7F0AA476-83A6-49C7-9064-6D13EF4811B9} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
770787
EndGlobalSection
771788
GlobalSection(ExtensibilityGlobals) = postSolution
772789
SolutionGuid = {CBE0CD6C-2E47-4D9F-B072-C138AA4A6D5A}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Polly.Core" Version="8.6.1" />
12+
<PackageReference Include="Polly.Extensions" Version="8.6.1" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Polly;
2+
3+
namespace ConsolePollyTest;
4+
5+
public static class PollyTest
6+
{
7+
8+
#region Constants & Statics
9+
10+
public static void MethodName()
11+
{
12+
var builder = new ResiliencePipelineBuilder().;
13+
}
14+
15+
#endregion
16+
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace ConsolePollyTest;
2+
3+
internal static class Program
4+
{
5+
6+
#region Constants & Statics
7+
8+
private static void Main(string[] args)
9+
{
10+
}
11+
12+
#endregion
13+
14+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace WebPollyTest.Controllers;
4+
5+
[ApiController]
6+
[Route("[controller]")]
7+
public class WeatherForecastController : ControllerBase
8+
{
9+
10+
#region Constants & Statics
11+
12+
private static readonly string[] Summaries = new[]
13+
{
14+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
15+
};
16+
17+
#endregion
18+
19+
private readonly ILogger<WeatherForecastController> _logger;
20+
21+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
22+
{
23+
_logger = logger;
24+
}
25+
26+
#region Methods
27+
28+
[HttpGet(Name = "GetWeatherForecast")]
29+
public IEnumerable<WeatherForecast> Get()
30+
{
31+
return Enumerable.Range(1, 5)
32+
.Select(
33+
index =>
34+
new WeatherForecast
35+
{
36+
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
37+
TemperatureC = Random.Shared.Next(-20, 55),
38+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
39+
})
40+
.ToArray();
41+
}
42+
43+
#endregion
44+
45+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace WebPollyTest;
2+
3+
internal static class Program
4+
{
5+
6+
#region Constants & Statics
7+
8+
private static void Main(string[] args)
9+
{
10+
var builder = WebApplication.CreateBuilder(args);
11+
12+
// Add services to the container.
13+
14+
_ = builder.Services.AddControllers();
15+
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
16+
_ = builder.Services.AddOpenApi();
17+
18+
var app = builder.Build();
19+
20+
// Configure the HTTP request pipeline.
21+
if (app.Environment.IsDevelopment())
22+
{
23+
_ = app.MapOpenApi();
24+
}
25+
26+
_ = app.UseHttpsRedirection();
27+
28+
_ = app.UseAuthorization();
29+
30+
_ = app.MapControllers();
31+
32+
app.Run();
33+
}
34+
35+
#endregion
36+
37+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": false,
8+
"applicationUrl": "http://localhost:5222",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": false,
17+
"applicationUrl": "https://localhost:7140;http://localhost:5222",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace WebPollyTest;
2+
3+
public class WeatherForecast
4+
{
5+
public DateOnly Date { get; set; }
6+
7+
public int TemperatureC { get; set; }
8+
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10+
11+
public string? Summary { get; set; }
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.6" />
11+
<PackageReference Include="Polly.Core" Version="8.6.1" />
12+
<PackageReference Include="Polly.Extensions" Version="8.6.1" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@WebPollyTest_HostAddress = http://localhost:5222
2+
3+
GET {{WebPollyTest_HostAddress}}/weatherforecast/
4+
Accept: application/json
5+
6+
###

0 commit comments

Comments
 (0)