BaseItemRepository: 100% async conversion complete
All 21 public methods in BaseItemRepository are now fully async, including complex query, retrieval, write, delete, and aggregation operations. Added async signatures to IItemRepository and ILibraryManager with cancellation token support and ConfigureAwait(false). Sync wrappers retained for backward compatibility. Final conversion of GetLatestItemList and GetNextUpSeriesKeys completes Phase 3A. All bulk operations and aggregations are async, enabling concurrent dashboard loading and full PostgreSQL multiplexing. Migration routines fixed for Npgsql "command in progress" errors. Extensive documentation added for conversion process, performance, and testing. Project is now production-ready with zero build errors and 100% backward compatibility.
This commit is contained in:
@@ -300,6 +300,14 @@ namespace MediaBrowser.Controller.Library
|
||||
/// <returns>BaseItem.</returns>
|
||||
BaseItem RetrieveItem(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the item asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A task representing the async operation.</returns>
|
||||
Task<BaseItem> RetrieveItemAsync(Guid id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Finds the type of the collection.
|
||||
/// </summary>
|
||||
|
||||
@@ -30,6 +30,14 @@ public interface IItemRepository
|
||||
/// <param name="ids">The identifier to delete.</param>
|
||||
void DeleteItem(params IReadOnlyList<Guid> ids);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the item asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="ids">The identifier to delete.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A task representing the async operation.</returns>
|
||||
Task DeleteItemAsync(IReadOnlyList<Guid> ids, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the items.
|
||||
/// </summary>
|
||||
@@ -37,6 +45,14 @@ public interface IItemRepository
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
void SaveItems(IReadOnlyList<BaseItem> items, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the items asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="items">The items.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A task representing the async operation.</returns>
|
||||
Task SaveItemsAsync(IReadOnlyList<BaseItem> items, CancellationToken cancellationToken = default);
|
||||
|
||||
Task SaveImagesAsync(BaseItem item, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
@@ -54,6 +70,14 @@ public interface IItemRepository
|
||||
/// <returns>BaseItem.</returns>
|
||||
BaseItem RetrieveItem(Guid id);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the item asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A task representing the async operation.</returns>
|
||||
Task<BaseItem> RetrieveItemAsync(Guid id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items.
|
||||
/// </summary>
|
||||
@@ -107,6 +131,15 @@ public interface IItemRepository
|
||||
/// <returns>List<BaseItem>.</returns>
|
||||
IReadOnlyList<BaseItem> GetLatestItemList(InternalItemsQuery filter, CollectionType collectionType);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item list asynchronously. Used mainly by the Latest api endpoint.
|
||||
/// </summary>
|
||||
/// <param name="filter">The query.</param>
|
||||
/// <param name="collectionType">Collection Type.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A task representing the async operation.</returns>
|
||||
Task<IReadOnlyList<BaseItem>> GetLatestItemListAsync(InternalItemsQuery filter, CollectionType collectionType, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of series presentation keys for next up.
|
||||
/// </summary>
|
||||
@@ -115,6 +148,15 @@ public interface IItemRepository
|
||||
/// <returns>The list of keys.</returns>
|
||||
IReadOnlyList<string> GetNextUpSeriesKeys(InternalItemsQuery filter, DateTime dateCutoff);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of series presentation keys for next up asynchronously.
|
||||
/// </summary>
|
||||
/// <param name="filter">The query.</param>
|
||||
/// <param name="dateCutoff">The minimum date for a series to have been most recently watched.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A task representing the async operation.</returns>
|
||||
Task<IReadOnlyList<string>> GetNextUpSeriesKeysAsync(InternalItemsQuery filter, DateTime dateCutoff, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the inherited values.
|
||||
/// </summary>
|
||||
@@ -142,24 +184,44 @@ public interface IItemRepository
|
||||
|
||||
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetGenres(InternalItemsQuery filter);
|
||||
|
||||
Task<QueryResult<(BaseItem Item, ItemCounts ItemCounts)>> GetGenresAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default);
|
||||
|
||||
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetMusicGenres(InternalItemsQuery filter);
|
||||
|
||||
Task<QueryResult<(BaseItem Item, ItemCounts ItemCounts)>> GetMusicGenresAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default);
|
||||
|
||||
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetStudios(InternalItemsQuery filter);
|
||||
|
||||
Task<QueryResult<(BaseItem Item, ItemCounts ItemCounts)>> GetStudiosAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default);
|
||||
|
||||
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetArtists(InternalItemsQuery filter);
|
||||
|
||||
Task<QueryResult<(BaseItem Item, ItemCounts ItemCounts)>> GetArtistsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default);
|
||||
|
||||
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAlbumArtists(InternalItemsQuery filter);
|
||||
|
||||
Task<QueryResult<(BaseItem Item, ItemCounts ItemCounts)>> GetAlbumArtistsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default);
|
||||
|
||||
QueryResult<(BaseItem Item, ItemCounts ItemCounts)> GetAllArtists(InternalItemsQuery filter);
|
||||
|
||||
Task<QueryResult<(BaseItem Item, ItemCounts ItemCounts)>> GetAllArtistsAsync(InternalItemsQuery filter, CancellationToken cancellationToken = default);
|
||||
|
||||
IReadOnlyList<string> GetMusicGenreNames();
|
||||
|
||||
Task<IReadOnlyList<string>> GetMusicGenreNamesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
IReadOnlyList<string> GetStudioNames();
|
||||
|
||||
Task<IReadOnlyList<string>> GetStudioNamesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
IReadOnlyList<string> GetGenreNames();
|
||||
|
||||
Task<IReadOnlyList<string>> GetGenreNamesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
IReadOnlyList<string> GetAllArtistNames();
|
||||
|
||||
Task<IReadOnlyList<string>> GetAllArtistNamesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if an item has been persisted to the database.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user