From d16cd958001f4c9474a2bd511fb3b40a4d7c7daf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 16 Dec 2024 18:12:07 -0600 Subject: consolidate I/SearchService --- src/slskd/Search/ISearchService.cs | 71 -------------------------------------- src/slskd/Search/SearchService.cs | 56 +++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 72 deletions(-) delete mode 100644 src/slskd/Search/ISearchService.cs (limited to 'src') diff --git a/src/slskd/Search/ISearchService.cs b/src/slskd/Search/ISearchService.cs deleted file mode 100644 index 097e23de..00000000 --- a/src/slskd/Search/ISearchService.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// 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/. -// - -namespace slskd.Search -{ - using System; - using System.Collections.Generic; - using System.Linq.Expressions; - using System.Threading.Tasks; - using Soulseek; - - /// - /// Handles the lifecycle and persistence of searches. - /// - public interface ISearchService - { - /// - /// Deletes the specified search. - /// - /// The search to delete. - /// The operation context. - Task DeleteAsync(Search search); - - /// - /// Finds a single search matching the specified . - /// - /// The expression to use to match searches. - /// A value indicating whether to include search responses in the result. - /// The found search, or default if not found. - /// Thrown when an expression is not supplied. - Task FindAsync(Expression> expression, bool includeResponses = false); - - /// - /// Returns a list of all completed and in-progress searches, with responses omitted, matching the optional . - /// - /// An optional expression used to match searches. - /// The list of searches matching the specified expression, or all searches if no expression is specified. - Task> ListAsync(Expression> expression = null); - - /// - /// Performs a search for the specified and . - /// - /// A unique identifier for the search. - /// The search query. - /// The search scope. - /// Search options. - /// The completed search. - Task StartAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null); - - /// - /// Cancels the search matching the specified , if it is in progress. - /// - /// The unique identifier for the search. - /// A value indicating whether the search was successfully cancelled. - bool TryCancel(Guid id); - } -} \ No newline at end of file diff --git a/src/slskd/Search/SearchService.cs b/src/slskd/Search/SearchService.cs index 3d2e2750..ed661b1f 100644 --- a/src/slskd/Search/SearchService.cs +++ b/src/slskd/Search/SearchService.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -36,6 +36,60 @@ namespace slskd.Search using SearchScope = Soulseek.SearchScope; using SearchStates = Soulseek.SearchStates; + /// + /// Handles the lifecycle and persistence of searches. + /// + public interface ISearchService + { + /// + /// Deletes the specified search. + /// + /// The search to delete. + /// The operation context. + Task DeleteAsync(Search search); + + /// + /// Finds a single search matching the specified . + /// + /// The expression to use to match searches. + /// A value indicating whether to include search responses in the result. + /// The found search, or default if not found. + /// Thrown when an expression is not supplied. + Task FindAsync(Expression> expression, bool includeResponses = false); + + /// + /// Returns a list of all completed and in-progress searches, with responses omitted, matching the optional . + /// + /// An optional expression used to match searches. + /// The list of searches matching the specified expression, or all searches if no expression is specified. + Task> ListAsync(Expression> expression = null); + + /// + /// Performs a search for the specified and . + /// + /// A unique identifier for the search. + /// The search query. + /// The search scope. + /// Search options. + /// The completed search. + Task StartAsync(Guid id, SearchQuery query, SearchScope scope, SearchOptions options = null); + + /// + /// Cancels the search matching the specified , if it is in progress. + /// + /// The unique identifier for the search. + /// A value indicating whether the search was successfully cancelled. + bool TryCancel(Guid id); + + /// + /// Removes searches older than the specified . + /// + /// The age after which records are eligible for pruning, in minutes. + /// An optional, additional state by which records are filtered for pruning. + /// The number of pruned records. + int Prune(int age, SearchStates state = SearchStates.Completed); + } + /// /// Handles the lifecycle and persistence of searches. /// -- cgit v1.2.3