2026-02-03 13:32:17 +00:00
|
|
|
|
using AIStudio.Tools.Rust;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Tools.Services;
|
|
|
|
|
|
|
|
|
|
|
|
public sealed partial class RustService
|
|
|
|
|
|
{
|
2026-05-19 06:24:22 +00:00
|
|
|
|
public async Task<QdrantInfo> GetQdrantInfo(CancellationToken cancellationToken = default)
|
2026-02-03 13:32:17 +00:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-05-19 06:24:22 +00:00
|
|
|
|
using var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
|
|
|
|
|
|
cts.CancelAfter(TimeSpan.FromSeconds(45));
|
|
|
|
|
|
|
|
|
|
|
|
return await this.http.GetFromJsonAsync<QdrantInfo>("/system/qdrant/info", this.jsonRustSerializerOptions, cts.Token);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(this.logger is not null)
|
|
|
|
|
|
this.logger.LogWarning("Fetching Qdrant info from Rust service was cancelled by caller.");
|
|
|
|
|
|
else
|
|
|
|
|
|
Console.WriteLine("Fetching Qdrant info from Rust service was cancelled by caller.");
|
|
|
|
|
|
|
|
|
|
|
|
return new QdrantInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
Status = QdrantStatus.UNAVAILABLE,
|
|
|
|
|
|
UnavailableReason = "Operation cancelled by caller."
|
|
|
|
|
|
};
|
2026-02-03 13:32:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(this.logger is not null)
|
|
|
|
|
|
this.logger.LogError(e, "Error while fetching Qdrant info from Rust service.");
|
|
|
|
|
|
else
|
|
|
|
|
|
Console.WriteLine($"Error while fetching Qdrant info from Rust service: '{e}'.");
|
|
|
|
|
|
|
2026-05-19 06:24:22 +00:00
|
|
|
|
return new QdrantInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
Status = QdrantStatus.UNAVAILABLE,
|
|
|
|
|
|
UnavailableReason = e.Message
|
|
|
|
|
|
};
|
2026-02-03 13:32:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|