Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
67f9e30b
Commit
67f9e30b
authored
Jun 18, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove polly dependency #458 ?
parent
863ddc93
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
24 deletions
+21
-24
RetryPolicy.cs
Titanium.Web.Proxy/Network/RetryPolicy.cs
+21
-21
Titanium.Web.Proxy.csproj
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
+0
-1
Titanium.Web.Proxy.nuspec
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
+0
-1
packages.config
Titanium.Web.Proxy/packages.config
+0
-1
No files found.
Titanium.Web.Proxy/Network/RetryPolicy.cs
View file @
67f9e30b
using
Polly
;
using
System
;
using
System
;
using
System.Threading.Tasks
;
using
Titanium.Web.Proxy.Network.Tcp
;
...
...
@@ -11,14 +10,11 @@ namespace Titanium.Web.Proxy.Network
private
readonly
TcpConnectionFactory
tcpConnectionFactory
;
private
TcpServerConnection
currentConnection
;
private
Policy
policy
;
internal
RetryPolicy
(
int
retries
,
TcpConnectionFactory
tcpConnectionFactory
)
{
this
.
retries
=
retries
;
this
.
tcpConnectionFactory
=
tcpConnectionFactory
;
policy
=
getRetryPolicy
();
}
/// <summary>
...
...
@@ -32,14 +28,14 @@ namespace Titanium.Web.Proxy.Network
Func
<
Task
<
TcpServerConnection
>>
generator
,
TcpServerConnection
initialConnection
)
{
currentConnection
=
initialConnection
;
Exception
exception
=
null
;
bool
@continue
=
true
;
Exception
exception
=
null
;
try
var
attempts
=
retries
;
while
(
attempts
>=
0
)
{
//retry on error with polly policy
//do not use polly context to store connection; it does not save states b/w attempts
await
policy
.
ExecuteAsync
(
async
()
=>
try
{
//setup connection
currentConnection
=
currentConnection
as
TcpServerConnection
??
...
...
@@ -47,23 +43,27 @@ namespace Titanium.Web.Proxy.Network
//try
@continue
=
await
action
(
currentConnection
);
});
}
catch
(
T
ex
)
{
exception
=
ex
;
await
onRetry
(
ex
);
}
if
(
exception
==
null
)
{
break
;
}
exception
=
null
;
attempts
--;
}
catch
(
Exception
e
)
{
exception
=
e
;
}
return
new
RetryResult
(
currentConnection
,
exception
,
@continue
);
}
//get the policy
private
Policy
getRetryPolicy
()
{
return
Policy
.
Handle
<
T
>()
.
RetryAsync
(
retries
,
onRetryAsync
:
onRetry
);
}
//before retry clear connection
private
async
Task
onRetry
(
Exception
ex
,
int
attempt
)
private
async
Task
onRetry
(
Exception
ex
)
{
if
(
currentConnection
!=
null
)
{
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.csproj
View file @
67f9e30b
...
...
@@ -12,7 +12,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Polly" Version="6.0.1" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.2" />
<PackageReference Include="StreamExtended" Version="1.0.179" />
</ItemGroup>
...
...
Titanium.Web.Proxy/Titanium.Web.Proxy.nuspec
View file @
67f9e30b
...
...
@@ -16,7 +16,6 @@
<dependencies>
<dependency
id=
"StreamExtended"
version=
"1.0.179"
/>
<dependency
id=
"Portable.BouncyCastle"
version=
"1.8.2"
/>
<dependency
id=
"Polly"
version=
"6.0.1"
/>
</dependencies>
</metadata>
<files>
...
...
Titanium.Web.Proxy/packages.config
View file @
67f9e30b
...
...
@@ -3,5 +3,4 @@
<
packages
>
<
package
id
=
"Portable.BouncyCastle"
version
=
"1.8.2"
targetFramework
=
"net45"
/>
<
package
id
=
"StreamExtended"
version
=
"1.0.179"
targetFramework
=
"net45"
/>
<
package
id
=
"Polly"
version
=
"6.0.1"
targetFramework
=
"net45"
/>
</
packages
>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment