mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-08 14:57:54 +00:00
Reuse a singleton HttpClient for proxying
This commit is contained in:
parent
c70556f5f9
commit
05282fd167
3 changed files with 5 additions and 14 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Discord;
|
||||
|
|
@ -21,7 +20,7 @@ namespace PluralKit.Bot
|
|||
public string InnerText;
|
||||
}
|
||||
|
||||
class ProxyService: IDisposable {
|
||||
class ProxyService {
|
||||
private IDiscordClient _client;
|
||||
private LogChannelService _logChannel;
|
||||
private IDataStore _data;
|
||||
|
|
@ -29,9 +28,7 @@ namespace PluralKit.Bot
|
|||
private ILogger _logger;
|
||||
private WebhookExecutorService _webhookExecutor;
|
||||
private ProxyCacheService _cache;
|
||||
|
||||
private HttpClient _httpClient;
|
||||
|
||||
|
||||
public ProxyService(IDiscordClient client, LogChannelService logChannel, IDataStore data, EmbedService embeds, ILogger logger, ProxyCacheService cache, WebhookExecutorService webhookExecutor)
|
||||
{
|
||||
_client = client;
|
||||
|
|
@ -41,8 +38,6 @@ namespace PluralKit.Bot
|
|||
_cache = cache;
|
||||
_webhookExecutor = webhookExecutor;
|
||||
_logger = logger.ForContext<ProxyService>();
|
||||
|
||||
_httpClient = new HttpClient();
|
||||
}
|
||||
|
||||
private ProxyMatch GetProxyTagMatch(string message, IEnumerable<ProxyCacheService.ProxyDatabaseResult> potentialMembers)
|
||||
|
|
@ -272,10 +267,5 @@ namespace PluralKit.Bot
|
|||
_logger.Information("Bulk deleting {Count} messages in channel {Channel}", messages.Count, channel.Id);
|
||||
await _data.DeleteMessagesBulk(messages.Select(m => m.Id).ToList());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_httpClient.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue