-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
40 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,26 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Sample; | ||
|
||
|
||
// [RegisterMiddleware] | ||
public class MyRequestMiddleware : IRequestMiddleware<MyMessageRequest, MyMessageResponse> | ||
public class MyRequestMiddleware(AppSqliteConnection conn) : IRequestMiddleware<MyMessageRequest, MyMessageResponse> | ||
{ | ||
public async Task<MyMessageResponse> Process(MyMessageRequest request, Func<Task<MyMessageResponse>> next, CancellationToken cancellationToken) | ||
{ | ||
// BEFORE - If connected - pull from API after save to cache ELSE pull from cache | ||
var result = await next(); | ||
// AFTER = cache | ||
var sw = new Stopwatch(); | ||
sw.Start(); | ||
var result = await next().ConfigureAwait(false); | ||
sw.Stop(); | ||
|
||
await conn.Log( | ||
nameof(MyRequestMiddleware), | ||
new MyMessageEvent( | ||
request.Arg, | ||
request.FireAndForgetEvents | ||
), | ||
sw.ElapsedMilliseconds | ||
); | ||
return result; | ||
} | ||
} | ||
|
||
public class CatchAllRequestMiddleware : IRequestMiddleware<IRequest<object>, object> | ||
{ | ||
public Task<object> Process(IRequest<object> request, Func<Task<object>> next, CancellationToken cancellationToken) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
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