Use TimeToLive (TimeSpan?) instead of TtlMs (long?) in public APIs (#1644)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com> Co-authored-by: halter73 <54385+halter73@users.noreply.github.com> Co-authored-by: Pranav Senthilnathan <pranas@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
9ba1f47d77
commit
3368bb7349
3 changed files with 30 additions and 85 deletions
|
|
@ -32,9 +32,9 @@ public class InMemoryMcpTaskStore : IMcpTaskStore
|
|||
public long DefaultPollIntervalMs { get; set; } = 1000;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default time-to-live in milliseconds for new tasks, or <see langword="null"/> for unlimited.
|
||||
/// Gets or sets the default time-to-live for new tasks, or <see langword="null"/> for unlimited.
|
||||
/// </summary>
|
||||
public long? DefaultTtlMs { get; set; }
|
||||
public TimeSpan? DefaultTimeToLive { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Task<McpTaskInfo> CreateTaskAsync(CancellationToken cancellationToken = default)
|
||||
|
|
@ -42,7 +42,7 @@ public class InMemoryMcpTaskStore : IMcpTaskStore
|
|||
var taskId = Guid.NewGuid().ToString("N");
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
|
||||
var info = new McpTaskInfo(taskId, McpTaskStatus.Working, now, now, DefaultTtlMs, DefaultPollIntervalMs);
|
||||
var info = new McpTaskInfo(taskId, McpTaskStatus.Working, now, now, DefaultTimeToLive, DefaultPollIntervalMs);
|
||||
_tasks[taskId] = info;
|
||||
|
||||
return Task.FromResult(info);
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
Status = info.Status,
|
||||
CreatedAt = info.CreatedAt,
|
||||
LastUpdatedAt = info.LastUpdatedAt,
|
||||
TtlMs = info.TtlMs,
|
||||
TimeToLive = info.TimeToLive,
|
||||
PollIntervalMs = info.PollIntervalMs,
|
||||
StatusMessage = info.StatusMessage,
|
||||
ResultType = "task",
|
||||
|
|
@ -1036,7 +1036,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
TaskId = info.TaskId,
|
||||
CreatedAt = info.CreatedAt,
|
||||
LastUpdatedAt = info.LastUpdatedAt,
|
||||
TtlMs = info.TtlMs,
|
||||
TimeToLive = info.TimeToLive,
|
||||
PollIntervalMs = info.PollIntervalMs,
|
||||
StatusMessage = info.StatusMessage,
|
||||
ResultType = "complete",
|
||||
|
|
@ -1046,7 +1046,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
TaskId = info.TaskId,
|
||||
CreatedAt = info.CreatedAt,
|
||||
LastUpdatedAt = info.LastUpdatedAt,
|
||||
TtlMs = info.TtlMs,
|
||||
TimeToLive = info.TimeToLive,
|
||||
PollIntervalMs = info.PollIntervalMs,
|
||||
StatusMessage = info.StatusMessage,
|
||||
Result = info.Result ?? throw new InvalidOperationException($"Task '{info.TaskId}' is completed but has no result."),
|
||||
|
|
@ -1057,7 +1057,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
TaskId = info.TaskId,
|
||||
CreatedAt = info.CreatedAt,
|
||||
LastUpdatedAt = info.LastUpdatedAt,
|
||||
TtlMs = info.TtlMs,
|
||||
TimeToLive = info.TimeToLive,
|
||||
PollIntervalMs = info.PollIntervalMs,
|
||||
StatusMessage = info.StatusMessage,
|
||||
Error = info.Error ?? throw new InvalidOperationException($"Task '{info.TaskId}' is failed but has no error."),
|
||||
|
|
@ -1068,7 +1068,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
TaskId = info.TaskId,
|
||||
CreatedAt = info.CreatedAt,
|
||||
LastUpdatedAt = info.LastUpdatedAt,
|
||||
TtlMs = info.TtlMs,
|
||||
TimeToLive = info.TimeToLive,
|
||||
PollIntervalMs = info.PollIntervalMs,
|
||||
StatusMessage = info.StatusMessage,
|
||||
ResultType = "complete",
|
||||
|
|
@ -1078,7 +1078,7 @@ internal sealed partial class McpServerImpl : McpServer
|
|||
TaskId = info.TaskId,
|
||||
CreatedAt = info.CreatedAt,
|
||||
LastUpdatedAt = info.LastUpdatedAt,
|
||||
TtlMs = info.TtlMs,
|
||||
TimeToLive = info.TimeToLive,
|
||||
PollIntervalMs = info.PollIntervalMs,
|
||||
StatusMessage = info.StatusMessage,
|
||||
// McpTaskInfo.InputRequests is IReadOnlyDictionary (covers immutable store
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public sealed record McpTaskInfo(
|
|||
McpTaskStatus Status,
|
||||
DateTimeOffset CreatedAt,
|
||||
DateTimeOffset LastUpdatedAt,
|
||||
long? TtlMs = null,
|
||||
TimeSpan? TimeToLive = null,
|
||||
long? PollIntervalMs = null,
|
||||
string? StatusMessage = null,
|
||||
JsonElement? Result = null,
|
||||
|
|
|
|||
Loading…
Reference in a new issue