added job parallel lock, file structure, diagnostics

This commit is contained in:
andy 2022-02-25 23:58:01 +00:00
parent bf55f7222e
commit 35c24ad0ef
7 changed files with 13 additions and 1 deletions

View File

@ -12,6 +12,7 @@ using System.Threading.Tasks;
namespace Selector.CLI.Jobs
{
[DisallowConcurrentExecution]
public class ScrobbleWatcherJob : IJob
{
private readonly ILogger<ScrobbleWatcherJob> logger;

View File

@ -125,11 +125,11 @@ namespace Selector.Web
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseHttpsRedirection();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHttpsRedirection();
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
//app.UseHsts();
}

View File

@ -2,6 +2,7 @@
using Selector.Operations;
using SpotifyAPI.Web;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace Selector
@ -40,9 +41,13 @@ namespace Selector
{
logger.LogInformation("Mapping Last.fm {} ({}) to Spotify", Query, QueryType);
var netTime = Stopwatch.StartNew();
currentTask = searchClient.Item(new (QueryType, Query));
currentTask.ContinueWith(async t =>
{
netTime.Stop();
logger.LogTrace("Network request took {:n} ms", netTime.ElapsedMilliseconds);
if (t.IsCompletedSuccessfully)
{
HandleResponse(t);

View File

@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging;
using Selector.Operations;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
@ -50,9 +51,14 @@ namespace Selector
public Task Execute()
{
logger.LogInformation("Scrobble request #{} for {} by {} from {} to {}", pageNumber, username, pageSize, from, to);
var netTime = Stopwatch.StartNew();
currentTask = userClient.GetRecentScrobbles(username, pagenumber: pageNumber, count: pageSize, from: from, to: to);
currentTask.ContinueWith(async t =>
{
netTime.Stop();
logger.LogTrace("Network request took {:n} ms", netTime.ElapsedMilliseconds);
if (t.IsCompletedSuccessfully)
{
var result = t.Result;