Skip to content

Commit

Permalink
Features/blob storage (#99)
Browse files Browse the repository at this point in the history
* Save messages to storage.
Better Cancellation support

* Add Corvus.Retry to deal with TCP disconnection errors.
  • Loading branch information
HowardvanRooijen authored Mar 13, 2021
1 parent fda5e98 commit 74d4c5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Solutions/Ais.Net.Models.Specs/Ais.Net.Models.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Corvus.Testing.SpecFlow.NUnit" Version="1.3.1" />
<PackageReference Include="Corvus.Testing.SpecFlow.NUnit" Version="1.3.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ais.Net.Models\Ais.Net.Models.csproj" />
Expand Down
1 change: 1 addition & 0 deletions Solutions/Ais.Net.Receiver/Ais.Net.Receiver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Corvus.Retry" Version="1.0.1" />
<PackageReference Include="Endjin.RecommendedPractices" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
16 changes: 15 additions & 1 deletion Solutions/Ais.Net.Receiver/Receiver/ReceiverHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ namespace Ais.Net.Receiver.Receiver
using Ais.Net.Receiver.Configuration;
using Ais.Net.Receiver.Parser;

using Corvus.Retry;
using Corvus.Retry.Policies;
using Corvus.Retry.Strategies;

public class ReceiverHost
{
private readonly AisConfig configuration;
Expand All @@ -37,7 +41,17 @@ public ReceiverHost(AisConfig configuration)

public IObservable<IAisMessage> Messages => this.messages;

public async Task StartAsync(CancellationToken cancellationToken = default)
public Task StartAsync(CancellationToken cancellationToken = default)
{
return Retriable.RetryAsync(() =>
this.StartAsyncInternal(cancellationToken),
cancellationToken,
new Backoff(maxTries: 100, deltaBackoff: TimeSpan.FromSeconds(5)),
new AnyExceptionPolicy(),
false);
}

private async Task StartAsyncInternal(CancellationToken cancellationToken = default)
{
var processor = new NmeaToAisMessageTypeProcessor();
var adapter = new NmeaLineToAisStreamAdapter(processor);
Expand Down

0 comments on commit 74d4c5e

Please sign in to comment.