From 4a2aff7d8c9b9a3eea997bd5a58fd060ac6722a9 Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Thu, 3 Dec 2026 14:20:40 -0800 Subject: [PATCH] Rename the internal "feed" types to "source" The Channel and Dataflow pumps each have an internal interface and two structs that say where the rows of one pass come from. They were named with "feed", while the rest of the package says "source" for where rows come from. - IFeed is now IPumpSource. The plainer IRowSource is already an internal interface in Core that the Channel and Dataflow packages can see, so that name would have clashed. - ChunkFeed is now ChunkSource, and RowFeed is now RowSource. - The type parameter TFeed is now TSource and the parameter feed is now source, in ChannelPump.Run and BlockPump.Run (no other name in those scopes is called source). - Comments and doc comments that mean these types now say "source". Uses of "feed" that mean something else (a column feeds a property, a package feed) are unchanged. A rename only: no logic, no behavior and no public member changes. Every renamed type and member is internal, and the public API files have no diff. No run-time cost. Co-Authored-By: Claude Sonnet 5.5 --- Source/Channel/ChannelPump.cs | 36 +++++++++--------- Source/Channel/ToChannel.Produce.cs | 2 +- Source/Channel/ToChannel.Streaming.cs | 2 +- Source/Channel/ToChannel.Target.cs | 2 +- Source/Dataflow/BlockPump.cs | 38 +++++++++---------- Source/Dataflow/DataflowExtensions.cs | 6 +-- .../CaptureStreamTests.cs | 4 +- .../TestHelpers/ChannelFixtures.cs | 2 +- .../TestHelpers/ChannelTestSupport.cs | 2 +- .../ToChannelStreamingTests.cs | 2 +- .../ToTargetBlockStreamingTests.cs | 2 +- 11 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Source/Channel/ChannelPump.cs b/Source/Channel/ChannelPump.cs index 3f379f34..cc75cb98 100644 --- a/Source/Channel/ChannelPump.cs +++ b/Source/Channel/ChannelPump.cs @@ -5,14 +5,14 @@ namespace Open.Database.Extensions; // One frame for every member of the package: the guards run at the // call (the members are not async), then this frame waits for room, -// runs the feed, counts and completes. -// A feed is the only part that differs: where the rows come from. +// runs the source, counts and completes. +// A source is the only part that differs: where the rows come from. internal static class ChannelPump { /// - /// Writes the rows of a feed to a channel. + /// Writes the rows of a source to a channel. /// - /// Where the rows come from. + /// Where the rows come from. /// Where the rows are written. /// /// to complete the writer when the pass ends, @@ -20,12 +20,12 @@ internal static class ChannelPump /// /// /// The number of rows handed to the writer. - public static async ValueTask Run( - TFeed feed, + public static async ValueTask Run( + TSource source, ChannelWriter writer, bool complete, CancellationToken cancellationToken) - where TFeed : struct, IFeed + where TSource : struct, IPumpSource { Debug.Assert(writer is not null); @@ -34,9 +34,9 @@ public static async ValueTask Run( Exception? error = null; try { - // Reached at the call: the feed takes the stream's enumerator + // Reached at the call: the source takes the stream's enumerator // before its first await, then waits for room (ChannelPump.Open). - return await feed + return await source .WriteAsync(writer, cancellationToken) .ConfigureAwait(false); } @@ -53,7 +53,7 @@ public static async ValueTask Run( } /// - /// Takes the enumerator of a feed's stream, then waits for room. + /// Takes the enumerator of a source's stream, then waits for room. /// /// /// The enumerator is taken first, synchronously, so a stream that fills @@ -144,7 +144,7 @@ public static int TryWriteFrom( /// /// Where the rows of one pass come from. /// -internal interface IFeed +internal interface IPumpSource { /// /// Writes every row to the writer. @@ -156,16 +156,16 @@ ValueTask WriteAsync( } /// -/// The buffered feed: Core's chunk stream, read at full speed. +/// The buffered source: Core's chunk stream, read at full speed. /// /// /// The connection is closed when the read ends, however slowly the /// writer takes the rows. A full target stalls only this loop: /// the rows wait in the stream's queue. /// -internal readonly struct ChunkFeed( +internal readonly struct ChunkSource( IAsyncEnumerable> chunks) - : IFeed + : IPumpSource { public async ValueTask WriteAsync( ChannelWriter writer, @@ -209,16 +209,16 @@ public async ValueTask WriteAsync( } /// -/// The streaming feed: Core's StreamBuffered with a channel of one row. +/// The streaming source: Core's StreamBuffered with a channel of one row. /// /// /// The next row is pulled only after the current one was written, so a /// full target holds the reader and the connection open. /// -internal readonly struct RowFeed(IAsyncEnumerable rows) - : IFeed +internal readonly struct RowSource(IAsyncEnumerable rows) + : IPumpSource { - // The stall timeout is Core's: this feed only learns of an expiry + // The stall timeout is Core's: this source only learns of an expiry // while it waits for room, because a loop that is not pulling cannot // see it in MoveNextAsync. public async ValueTask WriteAsync( diff --git a/Source/Channel/ToChannel.Produce.cs b/Source/Channel/ToChannel.Produce.cs index 9e51dab3..03064709 100644 --- a/Source/Channel/ToChannel.Produce.cs +++ b/Source/Channel/ToChannel.Produce.cs @@ -227,7 +227,7 @@ IAsyncEnumerable> chunks // fault is read so that a caller who drops the count never has it // reported as unobserved. A caller who awaits it still sees it. readCount = ChannelPump - .Run>( + .Run>( new(chunks), channel.Writer, complete: true, diff --git a/Source/Channel/ToChannel.Streaming.cs b/Source/Channel/ToChannel.Streaming.cs index 25296dcb..fed6b85e 100644 --- a/Source/Channel/ToChannel.Streaming.cs +++ b/Source/Channel/ToChannel.Streaming.cs @@ -128,7 +128,7 @@ public static ValueTask ToChannelHoldingConnection( Contract.EndContractBlock(); cancellationToken.ThrowIfCancellationRequested(); - return ChannelPump.Run>( + return ChannelPump.Run>( new(source.StreamBuffered(stallTimeout, 1, cancellationToken)), writer, complete, diff --git a/Source/Channel/ToChannel.Target.cs b/Source/Channel/ToChannel.Target.cs index 52f614be..aa384574 100644 --- a/Source/Channel/ToChannel.Target.cs +++ b/Source/Channel/ToChannel.Target.cs @@ -118,7 +118,7 @@ public static ValueTask ToChannel( Contract.EndContractBlock(); cancellationToken.ThrowIfCancellationRequested(); - return ChannelPump.Run>( + return ChannelPump.Run>( new(source.ToPooledBufferStream(cancellationToken)), writer, complete, diff --git a/Source/Dataflow/BlockPump.cs b/Source/Dataflow/BlockPump.cs index 71b6f2a9..b542e571 100644 --- a/Source/Dataflow/BlockPump.cs +++ b/Source/Dataflow/BlockPump.cs @@ -5,16 +5,16 @@ namespace Open.Database.Extensions; // One frame for every member of the package: the guards run at the // call (the members are not async), then this frame checks the target, -// runs the feed, and completes or faults the target. -// A feed is the only part that differs: where the rows come from. +// runs the source, and completes or faults the target. +// A source is the only part that differs: where the rows come from. internal static class BlockPump { /// - /// Writes the rows of a feed to a block. + /// Writes the rows of a source to a block. /// /// The type of each row. - /// The feed that supplies the rows. - /// Where the rows come from. + /// The source that supplies the rows. + /// Where the rows come from. /// Where the rows are sent. /// /// to complete the target when the pass ends, @@ -22,12 +22,12 @@ internal static class BlockPump /// /// /// The number of rows the target accepted. - public static async ValueTask Run( - TFeed feed, + public static async ValueTask Run( + TSource source, ITargetBlock target, bool complete, CancellationToken cancellationToken) - where TFeed : struct, IFeed + where TSource : struct, IPumpSource { Debug.Assert(target is not null); @@ -36,9 +36,9 @@ public static async ValueTask Run( Exception? error = null; try { - // Reached at the call: the feed takes the stream's enumerator + // Reached at the call: the source takes the stream's enumerator // before its first await, then checks the block (Open). - return await feed + return await source .WriteAsync(target, cancellationToken) .ConfigureAwait(false); } @@ -58,7 +58,7 @@ public static async ValueTask Run( } /// - /// Takes the enumerator of a feed's stream, then checks the block. + /// Takes the enumerator of a source's stream, then checks the block. /// /// /// The enumerator is taken first, synchronously, so a stream that fills @@ -89,7 +89,7 @@ IAsyncEnumerator rows /// /// Where the rows of one pass come from. /// -internal interface IFeed +internal interface IPumpSource { /// /// Sends every row to the target. @@ -101,16 +101,16 @@ ValueTask WriteAsync( } /// -/// The buffered feed: Core's chunk stream, read at full speed. +/// The buffered source: Core's chunk stream, read at full speed. /// /// /// The connection is closed when the read ends, however slowly the /// target takes the rows. A full target stalls only this loop: /// the rows wait in the stream's queue. /// -internal readonly struct ChunkFeed( +internal readonly struct ChunkSource( IAsyncEnumerable> chunks) - : IFeed + : IPumpSource { public async ValueTask WriteAsync( ITargetBlock target, @@ -151,17 +151,17 @@ public async ValueTask WriteAsync( } } -// The stall timeout is Core's: this feed only learns of an expiry while it waits for the target, +// The stall timeout is Core's: this source only learns of an expiry while it waits for the target, // because a loop that is not pulling cannot see it in MoveNextAsync. /// -/// The streaming feed: Core's StreamBuffered with a channel of one row. +/// The streaming source: Core's StreamBuffered with a channel of one row. /// /// /// The next row is pulled only after the current one was accepted, so a /// full target holds the reader and the connection open. /// -internal readonly struct RowFeed(IAsyncEnumerable rows) - : IFeed +internal readonly struct RowSource(IAsyncEnumerable rows) + : IPumpSource { public async ValueTask WriteAsync( ITargetBlock target, diff --git a/Source/Dataflow/DataflowExtensions.cs b/Source/Dataflow/DataflowExtensions.cs index 481b17b3..bb37c381 100644 --- a/Source/Dataflow/DataflowExtensions.cs +++ b/Source/Dataflow/DataflowExtensions.cs @@ -89,7 +89,7 @@ IAsyncEnumerable> chunks // A failure reaches the block through Fault: the task's own fault is // read so that it is never reported as unobserved. _ = BlockPump - .Run>( + .Run>( new(chunks), block, complete: true, @@ -186,7 +186,7 @@ public static ValueTask ToTargetBlock( Contract.EndContractBlock(); cancellationToken.ThrowIfCancellationRequested(); - return BlockPump.Run>( + return BlockPump.Run>( new(source.ToPooledBufferStream(cancellationToken)), target, complete, @@ -283,7 +283,7 @@ public static ValueTask ToTargetBlockHoldingConnection( Contract.EndContractBlock(); cancellationToken.ThrowIfCancellationRequested(); - return BlockPump.Run>( + return BlockPump.Run>( new(source.StreamBuffered(stallTimeout, 1, cancellationToken)), target, complete, diff --git a/Tests/Open.Database.Extensions.Core.Tests/CaptureStreamTests.cs b/Tests/Open.Database.Extensions.Core.Tests/CaptureStreamTests.cs index 9c3eaa50..4d646ec3 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/CaptureStreamTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/CaptureStreamTests.cs @@ -411,7 +411,7 @@ public static async Task AFullChannel_HoldsTheRun_WithTheCaptureArmed() Assert.Equal(9, await total); } - // A cancel while the feed waits for room: nothing ran, and the capture + // A cancel while the source waits for room: nothing ran, and the capture // is canceled with the call. [Fact] public static async Task AFullChannel_CanceledWhileItWaits_CancelsIt() @@ -490,7 +490,7 @@ public IAsyncEnumerable StreamBuffered( => throw new NotSupportedException(); } - // A target that closes after the first row: the feed stops and disposes + // A target that closes after the first row: the source stops and disposes // the stream, and the captured run stops at its next chunk and delivers. [Theory] [InlineData(true)] diff --git a/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelFixtures.cs b/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelFixtures.cs index a30c7ea5..ef366363 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelFixtures.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelFixtures.cs @@ -78,7 +78,7 @@ public static async Task> Drain( } /// - /// A source that is not ours: the feeds work on any implementation of + /// A source that is not ours: the pump sources work on any implementation of /// the interface. /// public sealed class FakeSource( diff --git a/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelTestSupport.cs b/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelTestSupport.cs index cd2d3ea2..c35007cc 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelTestSupport.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelTestSupport.cs @@ -175,7 +175,7 @@ public static async Task ReceiveRow(ISourceBlock block, when (ex.CancellationToken == cts.Token && !Ct.IsCancellationRequested) { // The wait here ran out: that is a failure of the test, - // not a cancel the feed reported. + // not a cancel the source reported. throw new TimeoutException("the channel never ended", ex); } catch (Exception ex) diff --git a/Tests/Open.Database.Extensions.Core.Tests/ToChannelStreamingTests.cs b/Tests/Open.Database.Extensions.Core.Tests/ToChannelStreamingTests.cs index 9338f5bd..a3d38d04 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/ToChannelStreamingTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/ToChannelStreamingTests.cs @@ -367,7 +367,7 @@ public static void TheGuards_ThrowAtTheCall() .ToChannelHoldingConnection(Unbounded(), Long, Ct))); } - // The feed adds no timing of its own: the timeout and the token + // The source adds no timing of its own: the timeout and the token // reach Stream untouched, on a source that is not ours. [Theory] [InlineData(false)] diff --git a/Tests/Open.Database.Extensions.Core.Tests/ToTargetBlockStreamingTests.cs b/Tests/Open.Database.Extensions.Core.Tests/ToTargetBlockStreamingTests.cs index a193d7d1..813742de 100644 --- a/Tests/Open.Database.Extensions.Core.Tests/ToTargetBlockStreamingTests.cs +++ b/Tests/Open.Database.Extensions.Core.Tests/ToTargetBlockStreamingTests.cs @@ -362,7 +362,7 @@ public static void TheGuards_ThrowAtTheCall() .ToTargetBlockHoldingConnection(NewBlock(), Long, Ct))); } - // The feed adds no timing of its own: the timeout and the token + // The source adds no timing of its own: the timeout and the token // reach Stream untouched, on a source that is not ours. [Theory] [InlineData(false)]