diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-02-18 07:05:03 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-18 07:05:03 -0600 |
| commit | fccc9c6440af11fd400f3d1dee243d2d18ea1651 (patch) | |
| tree | 0ba68479205c192e630c985f5025c67d2ca4c715 /src/slskd/Transfers/TransferService.cs | |
| parent | dee1b7315ff56194f7868803b876cabe4ab165d7 (diff) | |
| parent | 58e865993eb507e31dca3771fac0ea3829880d02 (diff) | |
| download | slskd-fccc9c6440af11fd400f3d1dee243d2d18ea1651.tar.gz | |
Merge pull request #346 from slskd/groups
Add upload slot and bandwidth limiting for user groups
Diffstat (limited to 'src/slskd/Transfers/TransferService.cs')
| -rw-r--r-- | src/slskd/Transfers/TransferService.cs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/slskd/Transfers/TransferService.cs b/src/slskd/Transfers/TransferService.cs new file mode 100644 index 00000000..714d85be --- /dev/null +++ b/src/slskd/Transfers/TransferService.cs @@ -0,0 +1,70 @@ +// <copyright file="TransferService.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +using Microsoft.Extensions.Options; + +namespace slskd.Transfers +{ + using slskd.Transfers.Uploads; + using slskd.Users; + + /// <summary> + /// Manages transfers. + /// </summary> + public interface ITransferService + { + /// <summary> + /// Gets the upload service. + /// </summary> + IUploadService Uploads { get; } + } + + /// <summary> + /// Manages transfers. + /// </summary> + public class TransferService : ITransferService + { + /// <summary> + /// Initializes a new instance of the <see cref="TransferService"/> class. + /// </summary> + /// <param name="userService">The UserService instance to use.</param> + /// <param name="optionsMonitor">The OptionsMonitor instance to use.</param> + /// <param name="uploadService">The optional UploadService instance to use.</param> + public TransferService( + IUserService userService, + IOptionsMonitor<Options> optionsMonitor, + IUploadService uploadService = null) + { + Users = userService; + OptionsMonitor = optionsMonitor; + + Uploads = uploadService ?? new UploadService() + { + Governor = new UploadGovernor(userService: Users, optionsMonitor: OptionsMonitor), + Queue = new UploadQueue(userService: Users, optionsMonitor: OptionsMonitor), + }; + } + + /// <summary> + /// Gets the upload service. + /// </summary> + public IUploadService Uploads { get; init; } + + private IOptionsMonitor<Options> OptionsMonitor { get; init; } + private IUserService Users { get; init; } + } +}
\ No newline at end of file |
