Skip to content

Commit 3547f03

Browse files
committed
PollingInterval -> StreamReaderPollingInterval
1 parent 55d9ac0 commit 3547f03

4 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/ModelContextProtocol/Server/DistributedCacheEventStreamStore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ public DistributedCacheEventStreamReader(
351351
}
352352

353353
// Wait before polling again for new events
354-
LogWaitingForNewEvents(SessionId, StreamId, _options.PollingInterval);
355-
await Task.Delay(_options.PollingInterval, cancellationToken).ConfigureAwait(false);
354+
LogWaitingForNewEvents(SessionId, StreamId, _options.StreamReaderPollingInterval);
355+
await Task.Delay(_options.StreamReaderPollingInterval, cancellationToken).ConfigureAwait(false);
356356

357357
// Refresh metadata to get the latest sequence and completion status
358358
var metadataKey = CacheKeys.StreamMetadata(SessionId, StreamId);

src/ModelContextProtocol/Server/DistributedCacheEventStreamStoreOptions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public sealed class DistributedCacheEventStreamStoreOptions
4040
public TimeSpan? MetadataAbsoluteExpiration { get; set; } = TimeSpan.FromHours(4);
4141

4242
/// <summary>
43-
/// Gets or sets the interval between polling attempts when a reader is waiting for new events
43+
/// Gets or sets the interval between polling attempts when a stream reader is waiting for new events
4444
/// in the default <see cref="SseEventStreamMode.Streaming"/> mode.
4545
/// </summary>
4646
/// <remarks>
47-
/// This only affects readers. A shorter interval provides lower latency for new events
47+
/// This only affects stream readers. A shorter interval provides lower latency for new events
4848
/// but increases cache access frequency.
4949
/// </remarks>
50-
public TimeSpan PollingInterval { get; set; } = TimeSpan.FromMilliseconds(100);
50+
public TimeSpan StreamReaderPollingInterval { get; set; } = TimeSpan.FromSeconds(1);
5151
}

tests/ModelContextProtocol.AspNetCore.Tests/DistributedCacheResumabilityIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected override ValueTask<ISseEventStreamStore> CreateEventStreamStoreAsync()
3434
var options = new DistributedCacheEventStreamStoreOptions
3535
{
3636
// Use shorter polling interval for faster test execution
37-
PollingInterval = TimeSpan.FromMilliseconds(50),
37+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50),
3838

3939
// Use shorter expiration times for tests
4040
EventSlidingExpiration = TimeSpan.FromMinutes(5),

tests/ModelContextProtocol.Tests/Server/DistributedCacheEventStreamStoreTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public async Task SetModeAsync_ModeChangeReflectedInReader()
352352
var cache = CreateMemoryCache();
353353
var customOptions = new DistributedCacheEventStreamStoreOptions
354354
{
355-
PollingInterval = TimeSpan.FromMilliseconds(10)
355+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(10)
356356
};
357357
var store = new DistributedCacheEventStreamStore(cache, customOptions);
358358
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
@@ -814,7 +814,7 @@ public async Task ReadEventsAsync_InStreamingMode_WaitsForNewEvents()
814814
var cache = CreateMemoryCache();
815815
var store = new DistributedCacheEventStreamStore(cache, new DistributedCacheEventStreamStoreOptions
816816
{
817-
PollingInterval = TimeSpan.FromMilliseconds(50)
817+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50)
818818
});
819819
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
820820
{
@@ -871,7 +871,7 @@ public async Task ReadEventsAsync_InStreamingMode_YieldsNewlyWrittenEvents()
871871
var cache = CreateMemoryCache();
872872
var store = new DistributedCacheEventStreamStore(cache, new DistributedCacheEventStreamStoreOptions
873873
{
874-
PollingInterval = TimeSpan.FromMilliseconds(50)
874+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50)
875875
});
876876
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
877877
{
@@ -929,7 +929,7 @@ public async Task ReadEventsAsync_InStreamingMode_CompletesWhenStreamIsDisposed(
929929
var cache = CreateMemoryCache();
930930
var store = new DistributedCacheEventStreamStore(cache, new DistributedCacheEventStreamStoreOptions
931931
{
932-
PollingInterval = TimeSpan.FromMilliseconds(50)
932+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50)
933933
});
934934
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
935935
{
@@ -967,7 +967,7 @@ public async Task ReadEventsAsync_InStreamingMode_RespectsCancellation()
967967
var cache = CreateMemoryCache();
968968
var store = new DistributedCacheEventStreamStore(cache, new DistributedCacheEventStreamStoreOptions
969969
{
970-
PollingInterval = TimeSpan.FromMilliseconds(50)
970+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50)
971971
});
972972
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
973973
{
@@ -1031,7 +1031,7 @@ public async Task ReadEventsAsync_RespectsModeSwitchFromStreamingToPolling()
10311031
var cache = CreateMemoryCache();
10321032
var store = new DistributedCacheEventStreamStore(cache, new DistributedCacheEventStreamStoreOptions
10331033
{
1034-
PollingInterval = TimeSpan.FromMilliseconds(50)
1034+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50)
10351035
});
10361036
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
10371037
{
@@ -1076,7 +1076,7 @@ public async Task ReadEventsAsync_PollingModeReturnsEventsThenCompletes()
10761076
var cache = CreateMemoryCache();
10771077
var store = new DistributedCacheEventStreamStore(cache, new DistributedCacheEventStreamStoreOptions
10781078
{
1079-
PollingInterval = TimeSpan.FromMilliseconds(50)
1079+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(50)
10801080
});
10811081
var writer = await store.CreateStreamAsync(new SseEventStreamOptions
10821082
{
@@ -1350,7 +1350,7 @@ public void DefaultOptions_HaveReasonableDefaults()
13501350
var options = new DistributedCacheEventStreamStoreOptions();
13511351

13521352
// Assert - Check that defaults are set reasonably
1353-
Assert.True(options.PollingInterval >= TimeSpan.FromMilliseconds(50), "Polling interval should be at least 50ms");
1353+
Assert.True(options.StreamReaderPollingInterval >= TimeSpan.FromMilliseconds(50), "Polling interval should be at least 50ms");
13541354
Assert.True(options.EventSlidingExpiration > TimeSpan.Zero, "Event sliding expiration should be positive");
13551355
Assert.True(options.EventAbsoluteExpiration > TimeSpan.Zero, "Event absolute expiration should be positive");
13561356
Assert.True(options.MetadataSlidingExpiration > TimeSpan.Zero, "Metadata sliding expiration should be positive");
@@ -1364,7 +1364,7 @@ public async Task ReadEventsAsync_ThrowsMcpException_WhenMetadataExpires()
13641364
var trackingCache = new TestDistributedCache();
13651365
var customOptions = new DistributedCacheEventStreamStoreOptions
13661366
{
1367-
PollingInterval = TimeSpan.FromMilliseconds(10) // Fast polling to detect the bug quickly
1367+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(10) // Fast polling to detect the bug quickly
13681368
};
13691369
var store = new DistributedCacheEventStreamStore(trackingCache, customOptions);
13701370

@@ -1448,7 +1448,7 @@ public async Task ReadEventsAsync_DoesNotReadMetadata_InPollingMode()
14481448
var trackingCache = new TestDistributedCache();
14491449
var customOptions = new DistributedCacheEventStreamStoreOptions
14501450
{
1451-
PollingInterval = TimeSpan.FromMilliseconds(10)
1451+
StreamReaderPollingInterval = TimeSpan.FromMilliseconds(10)
14521452
};
14531453
var store = new DistributedCacheEventStreamStore(trackingCache, customOptions);
14541454

0 commit comments

Comments
 (0)