diff options
author | vnugent <public@vaughnnugent.com> | 2023-08-01 18:39:13 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-08-01 18:39:13 -0400 |
commit | 5f76434c98ab0e45447e947c4489ec644f93439a (patch) | |
tree | 2cfab192627e4e61f573e3f0425d36763af2ee9d /lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs | |
parent | 3fbd6e9c483503419cdfe76544090d89397e35de (diff) |
Latest updates, build configurations, and native compression
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs')
-rw-r--r-- | lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs b/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs index 4e2d682..1c8174c 100644 --- a/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs +++ b/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins.Extensions.Data @@ -23,11 +23,13 @@ */ using System; +using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using VNLib.Utils; + namespace VNLib.Plugins.Extensions.Data.Abstractions { /// <summary> @@ -40,20 +42,23 @@ namespace VNLib.Plugins.Extensions.Data.Abstractions /// <summary> /// Gets the total number of records in the current store /// </summary> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task that resolves the number of records in the store</returns> - Task<long> GetCountAsync(); + Task<long> GetCountAsync(CancellationToken cancellation = default); /// <summary> /// Gets the number of records that belong to the specified constraint /// </summary> /// <param name="specifier">A specifier to constrain the reults</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>The number of records that belong to the specifier</returns> - Task<long> GetCountAsync(string specifier); + Task<long> GetCountAsync(string specifier, CancellationToken cancellation = default); /// <summary> /// Gets a record from its key /// </summary> /// <param name="key">The key identifying the unique record</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A promise that resolves the record identified by the specified key</returns> - Task<T?> GetSingleAsync(string key); + Task<T?> GetSingleAsync(string key, CancellationToken cancellation = default); /// <summary> /// Gets a record from its key /// </summary> @@ -64,16 +69,18 @@ namespace VNLib.Plugins.Extensions.Data.Abstractions /// Gets a record from the store with a partial model, intended to complete the model /// </summary> /// <param name="record">The partial model used to query the store</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task the resolves the completed data-model</returns> - Task<T?> GetSingleAsync(T record); + Task<T?> GetSingleAsync(T record, CancellationToken cancellation = default); /// <summary> /// Fills a collection with enires retireved from the store using the specifer /// </summary> /// <param name="collection">The collection to add entires to</param> /// <param name="specifier">A specifier argument to constrain results</param> /// <param name="limit">The maximum number of elements to retrieve</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A Task the resolves to the number of items added to the collection</returns> - Task<ERRNO> GetCollectionAsync(ICollection<T> collection, string specifier, int limit); + Task<ERRNO> GetCollectionAsync(ICollection<T> collection, string specifier, int limit, CancellationToken cancellation = default); /// <summary> /// Fills a collection with enires retireved from the store using a variable length specifier /// parameter @@ -87,26 +94,30 @@ namespace VNLib.Plugins.Extensions.Data.Abstractions /// Updates an entry in the store with the specified record /// </summary> /// <param name="record">The record to update</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task the resolves an error code (should evaluate to false on failure, and true on success)</returns> - Task<ERRNO> UpdateAsync(T record); + Task<ERRNO> UpdateAsync(T record, CancellationToken cancellation = default); /// <summary> /// Creates a new entry in the store representing the specified record /// </summary> /// <param name="record">The record to add to the store</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task the resolves an error code (should evaluate to false on failure, and true on success)</returns> - Task<ERRNO> CreateAsync(T record); + Task<ERRNO> CreateAsync(T record, CancellationToken cancellation = default); /// <summary> /// Deletes one or more entrires from the store matching the specified record /// </summary> /// <param name="record">The record to remove from the store</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task the resolves the number of records removed(should evaluate to false on failure, and deleted count on success)</returns> - Task<ERRNO> DeleteAsync(T record); + Task<ERRNO> DeleteAsync(T record, CancellationToken cancellation = default); /// <summary> /// Deletes one or more entires from the store matching the specified unique key /// </summary> /// <param name="key">The unique key that identifies the record</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task the resolves the number of records removed(should evaluate to false on failure, and deleted count on success)</returns> - Task<ERRNO> DeleteAsync(string key); + Task<ERRNO> DeleteAsync(string key, CancellationToken cancellation = default); /// <summary> /// Deletes one or more entires from the store matching the supplied specifiers /// </summary> @@ -117,7 +128,8 @@ namespace VNLib.Plugins.Extensions.Data.Abstractions /// Updates an entry in the store if it exists, or creates a new entry if one does not already exist /// </summary> /// <param name="record">The record to add to the store</param> + /// <param name="cancellation">A cancellation token to cancel the operation</param> /// <returns>A task the resolves the result of the operation</returns> - Task<ERRNO> AddOrUpdateAsync(T record); + Task<ERRNO> AddOrUpdateAsync(T record, CancellationToken cancellation = default); } } |