Files
AI-Studio/app/MindWork AI Studio/Tools/Services/Indexing/IIndexedSourceIndexer.cs
T
Thorsten Sommer c4400c0ff6
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Added mailboxes as local data sources (#1022)
2026-10-04 12:26:26 +02:00

63 lines
3.1 KiB
C#

using AIStudio.Settings;
namespace AIStudio.Tools.Services.Indexing;
/// <summary>
/// Indexes one kind of data source: knows how to find its documents and how to read them.
/// </summary>
/// <remarks>
/// Everything else is the same for every kind and stays out of here: the embedding service queues
/// the runs, prepares each one in an IndexedRunContext and reports the progress, and the context
/// embeds and stores the documents. A new kind of data source needs nothing but an indexer of its
/// own, and tables of its own for whatever it has to remember beyond its documents.
///
/// What an indexer does bring is how it notices that a data source changed. Files are watched by
/// the file system; another kind may have to look again at an interval. Whether anything is tracked
/// at all is not the indexer's to decide: the embedding service starts and stops the tracking.
/// </remarks>
internal interface IIndexedSourceIndexer : IDisposable
{
/// <summary>
/// Whether this indexer reads the documents of a data source.
/// </summary>
/// <param name="dataSource">The data source.</param>
/// <returns>True when this indexer is the one for it.</returns>
public bool Supports(IDataSourceBase dataSource);
/// <summary>
/// Works through the documents of the data source of a run, from finding them to completing the run.
/// </summary>
/// <remarks>
/// A run may stop after its share of the work and leave the rest to another one, so a data source
/// which takes hours does not hold up all others for that long. Whether and when that run comes
/// is the embedding service's to decide.
/// </remarks>
/// <param name="context">The prepared run, whose data source this indexer supports.</param>
/// <param name="refreshMode">Why the run was started.</param>
/// <param name="token">The cancellation token.</param>
/// <returns>Whether another run has to carry on.</returns>
public Task<IndexedRunOutcome> ProcessAsync(IndexedRunContext context, DataSourceEmbeddingRefreshMode refreshMode, CancellationToken token);
/// <summary>
/// Keeps track of changes to the given data sources, and of nothing else.
/// </summary>
/// <remarks>
/// Called whenever the configured data sources may have changed, always with all of those this
/// indexer supports. A data source which was tracked before and is missing now is no longer
/// tracked.
/// </remarks>
/// <param name="dataSources">The data sources to track.</param>
/// <param name="requestRun">Asks the embedding service for a run of the data source with the given id.</param>
public void TrackChanges(IReadOnlyCollection<IIndexedDataSource> dataSources, Func<string, DataSourceEmbeddingRefreshMode, Task> requestRun);
/// <summary>
/// Stops tracking changes to one data source, and drops what was about to be reported for it.
/// </summary>
/// <param name="dataSourceId">The id of the data source.</param>
public void StopTracking(string dataSourceId);
/// <summary>
/// Stops tracking changes to any data source.
/// </summary>
public void StopTrackingAll();
}