forked from Manuel/meeting-assistant
feat(macos): enable meeting integrations
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MeetingAssistant.MeetingNotes;
|
||||
|
||||
internal static class MeetingMetadataDiagnosticRunner
|
||||
{
|
||||
public static async Task<MeetingMetadataDiagnosticResult> RunAsync(
|
||||
string provider,
|
||||
DateTimeOffset startedAt,
|
||||
TimeSpan timeout,
|
||||
Func<CancellationToken, Task<MeetingMetadata?>> lookupAsync,
|
||||
string noMatchError,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
try
|
||||
{
|
||||
var lookup = lookupAsync(cancellationToken);
|
||||
var metadata = timeout > TimeSpan.Zero
|
||||
? await lookup.WaitAsync(timeout, cancellationToken)
|
||||
: await lookup.WaitAsync(cancellationToken);
|
||||
return new MeetingMetadataDiagnosticResult(
|
||||
provider,
|
||||
startedAt,
|
||||
metadata is not null,
|
||||
false,
|
||||
stopwatch.ElapsedMilliseconds,
|
||||
metadata,
|
||||
metadata is null ? noMatchError : null);
|
||||
}
|
||||
catch (TimeoutException exception)
|
||||
{
|
||||
return new MeetingMetadataDiagnosticResult(
|
||||
provider,
|
||||
startedAt,
|
||||
false,
|
||||
true,
|
||||
stopwatch.ElapsedMilliseconds,
|
||||
null,
|
||||
exception.Message);
|
||||
}
|
||||
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
return new MeetingMetadataDiagnosticResult(
|
||||
provider,
|
||||
startedAt,
|
||||
false,
|
||||
false,
|
||||
stopwatch.ElapsedMilliseconds,
|
||||
null,
|
||||
exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user