-
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.
- Loading branch information
Showing
3 changed files
with
80 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using Microsoft.Extensions.Logging; | ||
using PicoProfiler.Logging; | ||
|
||
namespace PicoSampleApp; | ||
|
||
internal class AlmostRealLifeService | ||
{ | ||
private readonly ILogger<AlmostRealLifeService> _logger; | ||
|
||
public AlmostRealLifeService(ILogger<AlmostRealLifeService> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public async Task HandleMessage() | ||
{ | ||
var data = await FetchHelperData(); | ||
await ProcessRules(data); | ||
} | ||
|
||
private async Task<object[]> FetchHelperData() | ||
{ | ||
using var _ = _logger.StartProfiler(); | ||
await Task.Delay(283); // fair roll dice, as you know it. | ||
|
||
var results = Enumerable.Range(0, 3).Cast<object>().ToArray(); | ||
_logger.LogInformation("Returning {HelperDataCount} results", results.Length); | ||
return results; | ||
} | ||
|
||
private async Task ProcessRules(object[] objects) | ||
{ | ||
using var _ = _logger.StartProfiler(); | ||
|
||
foreach (var o in objects) | ||
{ | ||
using (_logger.StartProfiler($"Processing rule {o}", logLevel: LogLevel.Trace)) | ||
{ | ||
await Task.Delay(15); | ||
} | ||
} | ||
} | ||
} |
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