Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit f4e6fe1

Browse files
Merge pull request #464 from justcoding121/master
Remove polly
2 parents 94e57f7 + 67f9e30 commit f4e6fe1

File tree

46 files changed

+82
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+82
-85
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Install by [nuget](https://www.nuget.org/packages/Titanium.Web.Proxy)
3636

3737
For beta releases on [beta branch](https://github.com/justcoding121/Titanium-Web-Proxy/tree/beta)
3838

39-
Install-Package Titanium.Web.Proxy -Pre
39+
Install-Package Titanium.Web.Proxy
4040

4141
For stable releases on [stable branch](https://github.com/justcoding121/Titanium-Web-Proxy/tree/stable)
4242

Titanium.Web.Proxy/Network/RetryPolicy.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Polly;
2-
using System;
1+
using System;
32
using System.Threading.Tasks;
43
using Titanium.Web.Proxy.Network.Tcp;
54

@@ -11,14 +10,11 @@ internal class RetryPolicy<T> where T : Exception
1110
private readonly TcpConnectionFactory tcpConnectionFactory;
1211

1312
private TcpServerConnection currentConnection;
14-
private Policy policy;
1513

1614
internal RetryPolicy(int retries, TcpConnectionFactory tcpConnectionFactory)
1715
{
1816
this.retries = retries;
1917
this.tcpConnectionFactory = tcpConnectionFactory;
20-
21-
policy = getRetryPolicy();
2218
}
2319

2420
/// <summary>
@@ -32,38 +28,42 @@ internal async Task<RetryResult> ExecuteAsync(Func<TcpServerConnection, Task<boo
3228
Func<Task<TcpServerConnection>> generator, TcpServerConnection initialConnection)
3329
{
3430
currentConnection = initialConnection;
35-
Exception exception = null;
3631
bool @continue = true;
32+
Exception exception = null;
3733

38-
try
34+
var attempts = retries;
35+
while (attempts >= 0)
3936
{
40-
//retry on error with polly policy
41-
//do not use polly context to store connection; it does not save states b/w attempts
42-
await policy.ExecuteAsync(async () =>
37+
38+
try
4339
{
4440
//setup connection
4541
currentConnection = currentConnection as TcpServerConnection ??
4642
await generator();
4743
//try
4844
@continue = await action(currentConnection);
4945

50-
});
46+
}
47+
catch (T ex)
48+
{
49+
exception = ex;
50+
await onRetry(ex);
51+
}
52+
53+
if(exception == null)
54+
{
55+
break;
56+
}
57+
58+
exception = null;
59+
attempts--;
5160
}
52-
catch (Exception e) { exception = e; }
5361

5462
return new RetryResult(currentConnection, exception, @continue);
5563
}
5664

57-
//get the policy
58-
private Policy getRetryPolicy()
59-
{
60-
return Policy.Handle<T>()
61-
.RetryAsync(retries,
62-
onRetryAsync: onRetry);
63-
}
64-
6565
//before retry clear connection
66-
private async Task onRetry(Exception ex, int attempt)
66+
private async Task onRetry(Exception ex)
6767
{
6868
if (currentConnection != null)
6969
{

Titanium.Web.Proxy/ResponseHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Titanium.Web.Proxy
1212
public partial class ProxyServer
1313
{
1414
/// <summary>
15-
/// Called asynchronously when a request was successfully and we received the response.
15+
/// Called asynchronously when a request was successfull and we received the response.
1616
/// </summary>
1717
/// <param name="args">The session event arguments.</param>
1818
/// <returns> The task.</returns>

Titanium.Web.Proxy/Titanium.Web.Proxy.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Polly" Version="6.0.1" />
1615
<PackageReference Include="Portable.BouncyCastle" Version="1.8.2" />
1716
<PackageReference Include="StreamExtended" Version="1.0.179" />
1817
</ItemGroup>

Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<dependencies>
1717
<dependency id="StreamExtended" version="1.0.179" />
1818
<dependency id="Portable.BouncyCastle" version="1.8.2" />
19-
<dependency id="Polly" version="6.0.1"/>
2019
</dependencies>
2120
</metadata>
2221
<files>

Titanium.Web.Proxy/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
<packages>
44
<package id="Portable.BouncyCastle" version="1.8.2" targetFramework="net45" />
55
<package id="StreamExtended" version="1.0.179" targetFramework="net45" />
6-
<package id="Polly" version="6.0.1" targetFramework="net45" />
76
</packages>

docs/api/Titanium.Web.Proxy.EventArguments.AsyncEventHandler-1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta name="viewport" content="width=device-width">
1111
<meta name="title" content="Delegate AsyncEventHandler&lt;TEventArgs&gt;
1212
| Titanium Web Proxy ">
13-
<meta name="generator" content="docfx 2.36.1.0">
13+
<meta name="generator" content="docfx 2.36.2.0">
1414

1515
<link rel="shortcut icon" href="../favicon.ico">
1616
<link rel="stylesheet" href="../styles/docfx.vendor.css">

docs/api/Titanium.Web.Proxy.EventArguments.BeforeSslAuthenticateEventArgs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta name="viewport" content="width=device-width">
1111
<meta name="title" content="Class BeforeSslAuthenticateEventArgs
1212
| Titanium Web Proxy ">
13-
<meta name="generator" content="docfx 2.36.1.0">
13+
<meta name="generator" content="docfx 2.36.2.0">
1414

1515
<link rel="shortcut icon" href="../favicon.ico">
1616
<link rel="stylesheet" href="../styles/docfx.vendor.css">

docs/api/Titanium.Web.Proxy.EventArguments.CertificateSelectionEventArgs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta name="viewport" content="width=device-width">
1111
<meta name="title" content="Class CertificateSelectionEventArgs
1212
| Titanium Web Proxy ">
13-
<meta name="generator" content="docfx 2.36.1.0">
13+
<meta name="generator" content="docfx 2.36.2.0">
1414

1515
<link rel="shortcut icon" href="../favicon.ico">
1616
<link rel="stylesheet" href="../styles/docfx.vendor.css">

docs/api/Titanium.Web.Proxy.EventArguments.CertificateValidationEventArgs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta name="viewport" content="width=device-width">
1111
<meta name="title" content="Class CertificateValidationEventArgs
1212
| Titanium Web Proxy ">
13-
<meta name="generator" content="docfx 2.36.1.0">
13+
<meta name="generator" content="docfx 2.36.2.0">
1414

1515
<link rel="shortcut icon" href="../favicon.ico">
1616
<link rel="stylesheet" href="../styles/docfx.vendor.css">

0 commit comments

Comments
 (0)