aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2022-01-30 21:10:45 -0600
committerJP Dillingham <jpdillingham@gmail.com>2022-01-30 21:10:45 -0600
commitd592695e40b23e4bffbea2651313c2f674a19ec3 (patch)
tree9f13ee2424b07721bcd136dfe33c40407321b7f6 /src/slskd/Application.cs
parentee21f4514305fb1ff213aae016817b7ff25d628d (diff)
downloadslskd-d592695e40b23e4bffbea2651313c2f674a19ec3.tar.gz
stub Governor
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index f2d81471..1d3d1b33 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -68,6 +68,7 @@ namespace slskd
IRoomService roomService,
ISharedFileCache sharedFileCache,
IPushbulletService pushbulletService,
+ IGovernor governor,
IHubContext<ApplicationHub> applicationHub,
IHubContext<LogsHub> logHub)
{
@@ -89,6 +90,8 @@ namespace slskd
ConversationTracker = conversationTracker;
Pushbullet = pushbulletService;
+ Governor = governor;
+
RoomService = roomService;
ApplicationHub = applicationHub;
@@ -125,6 +128,7 @@ namespace slskd
private IRoomService RoomService { get; set; }
private IBrowseTracker BrowseTracker { get; set; }
private IConversationTracker ConversationTracker { get; set; }
+ private IGovernor Governor { get; set; }
private ILogger Log { get; set; } = Serilog.Log.ForContext<Application>();
private ConcurrentDictionary<string, ILogger> Loggers { get; } = new ConcurrentDictionary<string, ILogger>();
private Options Options => OptionsMonitor.CurrentValue;
@@ -547,7 +551,11 @@ namespace slskd
// create a new cancellation token source so that we can cancel the upload from the UI.
var cts = new CancellationTokenSource();
- var topts = new TransferOptions(stateChanged: (e) => tracker.AddOrUpdate(e, cts), progressUpdated: (e) => tracker.AddOrUpdate(e, cts));
+ var topts = new TransferOptions(
+ stateChanged: (e) => tracker.AddOrUpdate(e, cts),
+ progressUpdated: (e) => tracker.AddOrUpdate(e, cts),
+ governor: (tx, req, ct) => Governor.GetBytes(tx, req, ct),
+ reporter: (tx, att, grant, act) => Governor.ReturnBytes(tx, att, grant, act));
// accept all download requests, and begin the upload immediately. normally there would be an internal queue, and
// uploads would be handled separately.