Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 198d8ed

Browse files
author
li.shuai
committed
optimization httpclient
1 parent a86c380 commit 198d8ed

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/HttpReports.Dashboard/Services/AlarmService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ public class AlarmService : IAlarmService
2727

2828
private readonly JsonSerializerOptions _jsonSetting;
2929

30+
private readonly IHttpClientFactory _factory;
31+
3032
private Localize lang => _localizeService.Current;
3133

32-
public AlarmService(IOptions<DashboardOptions> options, JsonSerializerOptions jsonSetting, ILogger<AlarmService> logger, ILocalizeService localizeService, IHttpReportsStorage storage)
34+
public AlarmService(IOptions<DashboardOptions> options, JsonSerializerOptions jsonSetting, ILogger<AlarmService> logger, ILocalizeService localizeService, IHttpReportsStorage storage, IHttpClientFactory factory)
3335
{
3436
Options = options.Value;
3537
Logger = logger;
3638
_localizeService = localizeService;
3739
_storage = storage;
3840
_jsonSetting = jsonSetting;
41+
_factory = factory;
3942
}
4043

4144
private async Task SendMessageAsync(MimeMessage message)
@@ -85,7 +88,7 @@ private async Task NotifyWebHookAsync(AlarmOption option)
8588
return;
8689
}
8790

88-
using (var httpClient = new HttpClient())
91+
using (var httpClient = _factory.CreateClient())
8992
{
9093
string Title = $"HttpReports - {lang.Warning_Title}";
9194

0 commit comments

Comments
 (0)