-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from pfpack/feature/async-pipeline-options
Feature/async pipeline options
- Loading branch information
Showing
25 changed files
with
182 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.Result/Configure/Configure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace System; | ||
|
||
partial struct AsyncPipeline<TSuccess, TFailure> | ||
{ | ||
public AsyncPipeline<TSuccess, TFailure> Configure([AllowNull] AsyncPipelineOptions options) | ||
=> | ||
new( | ||
pipeline.Configure(options)); | ||
} |
28 changes: 28 additions & 0 deletions
28
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.Result/Fold.Result/Fold.Task.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<TSuccess, TFailure> | ||
{ | ||
public AsyncPipeline<TResultSuccess, TResultFailure> Fold<TResultSuccess, TResultFailure>( | ||
Func<TSuccess, CancellationToken, Task<Result<TResultSuccess, TResultFailure>>> mapSuccessAsync, | ||
Func<TFailure, CancellationToken, Task<Result<TResultSuccess, TResultFailure>>> mapFailureAsync) | ||
where TResultFailure : struct | ||
=> | ||
InnerFold( | ||
mapSuccessAsync ?? throw new ArgumentNullException(nameof(mapSuccessAsync)), | ||
mapFailureAsync ?? throw new ArgumentNullException(nameof(mapFailureAsync))); | ||
|
||
private AsyncPipeline<TResultSuccess, TResultFailure> InnerFold<TResultSuccess, TResultFailure>( | ||
Func<TSuccess, CancellationToken, Task<Result<TResultSuccess, TResultFailure>>> mapSuccessAsync, | ||
Func<TFailure, CancellationToken, Task<Result<TResultSuccess, TResultFailure>>> mapFailureAsync) | ||
where TResultFailure : struct | ||
=> | ||
new( | ||
pipeline.InternalPipe( | ||
(r, t) => r.FoldAsync( | ||
s => mapSuccessAsync.Invoke(s, t), | ||
f => mapFailureAsync.Invoke(f, t)))); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.Result/Fold.Result/Fold.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace System | ||
{ | ||
partial struct AsyncPipeline<TSuccess, TFailure> | ||
{ | ||
public AsyncPipeline<TResultSuccess, TResultFailure> Fold<TResultSuccess, TResultFailure>( | ||
Func<TSuccess, Result<TResultSuccess, TResultFailure>> mapSuccess, | ||
Func<TFailure, Result<TResultSuccess, TResultFailure>> mapFailure) | ||
where TResultFailure : struct | ||
=> | ||
InnerFold( | ||
mapSuccess ?? throw new ArgumentNullException(nameof(mapSuccess)), | ||
mapFailure ?? throw new ArgumentNullException(nameof(mapFailure))); | ||
|
||
private AsyncPipeline<TResultSuccess, TResultFailure> InnerFold<TResultSuccess, TResultFailure>( | ||
Func<TSuccess, Result<TResultSuccess, TResultFailure>> mapSuccess, | ||
Func<TFailure, Result<TResultSuccess, TResultFailure>> mapFailure) | ||
where TResultFailure : struct | ||
=> | ||
new( | ||
pipeline.InternalPipe( | ||
r => r.Fold(mapSuccess, mapFailure))); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.Result/Fold.Result/FoldValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System | ||
{ | ||
partial struct AsyncPipeline<TSuccess, TFailure> | ||
{ | ||
public AsyncPipeline<TResultSuccess, TResultFailure> FoldValue<TResultSuccess, TResultFailure>( | ||
Func<TSuccess, CancellationToken, ValueTask<Result<TResultSuccess, TResultFailure>>> mapSuccessAsync, | ||
Func<TFailure, CancellationToken, ValueTask<Result<TResultSuccess, TResultFailure>>> mapFailureAsync) | ||
where TResultFailure : struct | ||
=> | ||
InnerFoldValue( | ||
mapSuccessAsync ?? throw new ArgumentNullException(nameof(mapSuccessAsync)), | ||
mapFailureAsync ?? throw new ArgumentNullException(nameof(mapFailureAsync))); | ||
|
||
private AsyncPipeline<TResultSuccess, TResultFailure> InnerFoldValue<TResultSuccess, TResultFailure>( | ||
Func<TSuccess, CancellationToken, ValueTask<Result<TResultSuccess, TResultFailure>>> mapSuccessAsync, | ||
Func<TFailure, CancellationToken, ValueTask<Result<TResultSuccess, TResultFailure>>> mapFailureAsync) | ||
where TResultFailure : struct | ||
=> | ||
new( | ||
pipeline.InternalPipeValue( | ||
(r, t) => r.FoldValueAsync( | ||
s => mapSuccessAsync.Invoke(s, t), | ||
f => mapFailureAsync.Invoke(f, t)))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/core-asyncpipeline/AsyncPipeline/AsyncPipeline.T/Configure/Configure.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace System; | ||
|
||
partial struct AsyncPipeline<T> | ||
{ | ||
public AsyncPipeline<T> Configure([AllowNull] AsyncPipelineOptions options) | ||
=> | ||
isStopped is false | ||
? new(valueTask, options, cancellationToken) | ||
: new(default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.