Skip to content

Commit 8ebbcd9

Browse files
Rename the internal "feed" types to "source" (#313)
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. This renames them; internal only, no behavior change. - `IFeed<T>` is now `IPumpSource<T>`. The plainer `IRowSource<T>` is already an internal interface in Core that the Channel and Dataflow packages can see, so that name would have clashed (the owner approved `IPumpSource`). - `ChunkFeed<T>` is now `ChunkSource<T>`, and `RowFeed<T>` is now `RowSource<T>`. - 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", in the two pumps, the call sites and five test comments. Uses of "feed" that mean something else (a column feeds a property, a package feed) are unchanged. Every renamed type and member is internal; the public API files have no diff, and grep finds no `IFeed`, `ChunkFeed`, `RowFeed` or `TFeed` left. Verification: solution Release and Debug (VS MSBuild) 0 warnings, 0 errors; Core.Tests 16154 passed with the generator on, 16133 passed and 16 skipped with it off; 267 sample checks; style and analyzer checks 0 findings on all 14 projects; docfx 0 warnings; style scan clean. Reviews: a lens that compared every changed line for pure renames, collisions and left-over names (no defect). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent c6ba27b commit 8ebbcd9

11 files changed

Lines changed: 49 additions & 49 deletions

File tree

‎Source/Channel/ChannelPump.cs‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ namespace Open.Database.Extensions;
55

66
// One frame for every member of the package: the guards run at the
77
// call (the members are not async), then this frame waits for room,
8-
// runs the feed, counts and completes.
9-
// A feed is the only part that differs: where the rows come from.
8+
// runs the source, counts and completes.
9+
// A source is the only part that differs: where the rows come from.
1010
internal static class ChannelPump
1111
{
1212
/// <summary>
13-
/// Writes the rows of a feed to a channel.
13+
/// Writes the rows of a source to a channel.
1414
/// </summary>
15-
/// <param name="feed">Where the rows come from.</param>
15+
/// <param name="source">Where the rows come from.</param>
1616
/// <param name="writer">Where the rows are written.</param>
1717
/// <param name="complete">
1818
/// <see langword="true"/> to complete the writer when the pass ends,
1919
/// with the exception that ended it if there was one.
2020
/// </param>
2121
/// <include file="../Core/Mapped.docs.xml" path="docs/members[@name='token-pass']/*" />
2222
/// <returns>The number of rows handed to the writer.</returns>
23-
public static async ValueTask<long> Run<T, TFeed>(
24-
TFeed feed,
23+
public static async ValueTask<long> Run<T, TSource>(
24+
TSource source,
2525
ChannelWriter<T> writer,
2626
bool complete,
2727
CancellationToken cancellationToken)
28-
where TFeed : struct, IFeed<T>
28+
where TSource : struct, IPumpSource<T>
2929
{
3030
Debug.Assert(writer is not null);
3131

@@ -34,9 +34,9 @@ public static async ValueTask<long> Run<T, TFeed>(
3434
Exception? error = null;
3535
try
3636
{
37-
// Reached at the call: the feed takes the stream's enumerator
37+
// Reached at the call: the source takes the stream's enumerator
3838
// before its first await, then waits for room (ChannelPump.Open).
39-
return await feed
39+
return await source
4040
.WriteAsync(writer, cancellationToken)
4141
.ConfigureAwait(false);
4242
}
@@ -53,7 +53,7 @@ public static async ValueTask<long> Run<T, TFeed>(
5353
}
5454

5555
/// <summary>
56-
/// Takes the enumerator of a feed's stream, then waits for room.
56+
/// Takes the enumerator of a source's stream, then waits for room.
5757
/// </summary>
5858
/// <remarks>
5959
/// The enumerator is taken first, synchronously, so a stream that fills
@@ -144,7 +144,7 @@ public static int TryWriteFrom<T>(
144144
/// <summary>
145145
/// Where the rows of one pass come from.
146146
/// </summary>
147-
internal interface IFeed<T>
147+
internal interface IPumpSource<T>
148148
{
149149
/// <summary>
150150
/// Writes every row to the writer.
@@ -156,16 +156,16 @@ ValueTask<long> WriteAsync(
156156
}
157157

158158
/// <summary>
159-
/// The buffered feed: Core's chunk stream, read at full speed.
159+
/// The buffered source: Core's chunk stream, read at full speed.
160160
/// </summary>
161161
/// <remarks>
162162
/// The connection is closed when the read ends, however slowly the
163163
/// writer takes the rows. A full target stalls only this loop:
164164
/// the rows wait in the stream's queue.
165165
/// </remarks>
166-
internal readonly struct ChunkFeed<T>(
166+
internal readonly struct ChunkSource<T>(
167167
IAsyncEnumerable<ReadOnlyMemory<T>> chunks)
168-
: IFeed<T>
168+
: IPumpSource<T>
169169
{
170170
public async ValueTask<long> WriteAsync(
171171
ChannelWriter<T> writer,
@@ -209,16 +209,16 @@ public async ValueTask<long> WriteAsync(
209209
}
210210

211211
/// <summary>
212-
/// The streaming feed: Core's <c>StreamBuffered</c> with a channel of one row.
212+
/// The streaming source: Core's <c>StreamBuffered</c> with a channel of one row.
213213
/// </summary>
214214
/// <remarks>
215215
/// The next row is pulled only after the current one was written, so a
216216
/// full target holds the reader and the connection open.
217217
/// </remarks>
218-
internal readonly struct RowFeed<T>(IAsyncEnumerable<T> rows)
219-
: IFeed<T>
218+
internal readonly struct RowSource<T>(IAsyncEnumerable<T> rows)
219+
: IPumpSource<T>
220220
{
221-
// The stall timeout is Core's: this feed only learns of an expiry
221+
// The stall timeout is Core's: this source only learns of an expiry
222222
// while it waits for room, because a loop that is not pulling cannot
223223
// see it in MoveNextAsync.
224224
public async ValueTask<long> WriteAsync(

‎Source/Channel/ToChannel.Produce.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ IAsyncEnumerable<ReadOnlyMemory<T>> chunks
227227
// fault is read so that a caller who drops the count never has it
228228
// reported as unobserved. A caller who awaits it still sees it.
229229
readCount = ChannelPump
230-
.Run<T, ChunkFeed<T>>(
230+
.Run<T, ChunkSource<T>>(
231231
new(chunks),
232232
channel.Writer,
233233
complete: true,

‎Source/Channel/ToChannel.Streaming.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static ValueTask<long> ToChannelHoldingConnection<T>(
128128
Contract.EndContractBlock();
129129

130130
cancellationToken.ThrowIfCancellationRequested();
131-
return ChannelPump.Run<T, RowFeed<T>>(
131+
return ChannelPump.Run<T, RowSource<T>>(
132132
new(source.StreamBuffered(stallTimeout, 1, cancellationToken)),
133133
writer,
134134
complete,

‎Source/Channel/ToChannel.Target.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public static ValueTask<long> ToChannel<T>(
118118
Contract.EndContractBlock();
119119

120120
cancellationToken.ThrowIfCancellationRequested();
121-
return ChannelPump.Run<T, ChunkFeed<T>>(
121+
return ChannelPump.Run<T, ChunkSource<T>>(
122122
new(source.ToPooledBufferStream(cancellationToken)),
123123
writer,
124124
complete,

‎Source/Dataflow/BlockPump.cs‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ namespace Open.Database.Extensions;
55

66
// One frame for every member of the package: the guards run at the
77
// call (the members are not async), then this frame checks the target,
8-
// runs the feed, and completes or faults the target.
9-
// A feed is the only part that differs: where the rows come from.
8+
// runs the source, and completes or faults the target.
9+
// A source is the only part that differs: where the rows come from.
1010
internal static class BlockPump
1111
{
1212
/// <summary>
13-
/// Writes the rows of a feed to a block.
13+
/// Writes the rows of a source to a block.
1414
/// </summary>
1515
/// <typeparam name="T">The type of each row.</typeparam>
16-
/// <typeparam name="TFeed">The feed that supplies the rows.</typeparam>
17-
/// <param name="feed">Where the rows come from.</param>
16+
/// <typeparam name="TSource">The source that supplies the rows.</typeparam>
17+
/// <param name="source">Where the rows come from.</param>
1818
/// <param name="target">Where the rows are sent.</param>
1919
/// <param name="complete">
2020
/// <see langword="true"/> to complete the target when the pass ends,
2121
/// or to fault it with the exception that ended the pass.
2222
/// </param>
2323
/// <include file="../Core/Mapped.docs.xml" path="docs/members[@name='token-pass']/*" />
2424
/// <returns>The number of rows the target accepted.</returns>
25-
public static async ValueTask<long> Run<T, TFeed>(
26-
TFeed feed,
25+
public static async ValueTask<long> Run<T, TSource>(
26+
TSource source,
2727
ITargetBlock<T> target,
2828
bool complete,
2929
CancellationToken cancellationToken)
30-
where TFeed : struct, IFeed<T>
30+
where TSource : struct, IPumpSource<T>
3131
{
3232
Debug.Assert(target is not null);
3333

@@ -36,9 +36,9 @@ public static async ValueTask<long> Run<T, TFeed>(
3636
Exception? error = null;
3737
try
3838
{
39-
// Reached at the call: the feed takes the stream's enumerator
39+
// Reached at the call: the source takes the stream's enumerator
4040
// before its first await, then checks the block (Open).
41-
return await feed
41+
return await source
4242
.WriteAsync(target, cancellationToken)
4343
.ConfigureAwait(false);
4444
}
@@ -58,7 +58,7 @@ public static async ValueTask<long> Run<T, TFeed>(
5858
}
5959

6060
/// <summary>
61-
/// Takes the enumerator of a feed's stream, then checks the block.
61+
/// Takes the enumerator of a source's stream, then checks the block.
6262
/// </summary>
6363
/// <remarks>
6464
/// The enumerator is taken first, synchronously, so a stream that fills
@@ -89,7 +89,7 @@ IAsyncEnumerator<TItem> rows
8989
/// <summary>
9090
/// Where the rows of one pass come from.
9191
/// </summary>
92-
internal interface IFeed<T>
92+
internal interface IPumpSource<T>
9393
{
9494
/// <summary>
9595
/// Sends every row to the target.
@@ -101,16 +101,16 @@ ValueTask<long> WriteAsync(
101101
}
102102

103103
/// <summary>
104-
/// The buffered feed: Core's chunk stream, read at full speed.
104+
/// The buffered source: Core's chunk stream, read at full speed.
105105
/// </summary>
106106
/// <remarks>
107107
/// The connection is closed when the read ends, however slowly the
108108
/// target takes the rows. A full target stalls only this loop:
109109
/// the rows wait in the stream's queue.
110110
/// </remarks>
111-
internal readonly struct ChunkFeed<T>(
111+
internal readonly struct ChunkSource<T>(
112112
IAsyncEnumerable<ReadOnlyMemory<T>> chunks)
113-
: IFeed<T>
113+
: IPumpSource<T>
114114
{
115115
public async ValueTask<long> WriteAsync(
116116
ITargetBlock<T> target,
@@ -151,17 +151,17 @@ public async ValueTask<long> WriteAsync(
151151
}
152152
}
153153

154-
// The stall timeout is Core's: this feed only learns of an expiry while it waits for the target,
154+
// The stall timeout is Core's: this source only learns of an expiry while it waits for the target,
155155
// because a loop that is not pulling cannot see it in MoveNextAsync.
156156
/// <summary>
157-
/// The streaming feed: Core's <c>StreamBuffered</c> with a channel of one row.
157+
/// The streaming source: Core's <c>StreamBuffered</c> with a channel of one row.
158158
/// </summary>
159159
/// <remarks>
160160
/// The next row is pulled only after the current one was accepted, so a
161161
/// full target holds the reader and the connection open.
162162
/// </remarks>
163-
internal readonly struct RowFeed<T>(IAsyncEnumerable<T> rows)
164-
: IFeed<T>
163+
internal readonly struct RowSource<T>(IAsyncEnumerable<T> rows)
164+
: IPumpSource<T>
165165
{
166166
public async ValueTask<long> WriteAsync(
167167
ITargetBlock<T> target,

‎Source/Dataflow/DataflowExtensions.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ IAsyncEnumerable<ReadOnlyMemory<T>> chunks
8989
// A failure reaches the block through Fault: the task's own fault is
9090
// read so that it is never reported as unobserved.
9191
_ = BlockPump
92-
.Run<T, ChunkFeed<T>>(
92+
.Run<T, ChunkSource<T>>(
9393
new(chunks),
9494
block,
9595
complete: true,
@@ -186,7 +186,7 @@ public static ValueTask<long> ToTargetBlock<T>(
186186
Contract.EndContractBlock();
187187

188188
cancellationToken.ThrowIfCancellationRequested();
189-
return BlockPump.Run<T, ChunkFeed<T>>(
189+
return BlockPump.Run<T, ChunkSource<T>>(
190190
new(source.ToPooledBufferStream(cancellationToken)),
191191
target,
192192
complete,
@@ -283,7 +283,7 @@ public static ValueTask<long> ToTargetBlockHoldingConnection<T>(
283283
Contract.EndContractBlock();
284284

285285
cancellationToken.ThrowIfCancellationRequested();
286-
return BlockPump.Run<T, RowFeed<T>>(
286+
return BlockPump.Run<T, RowSource<T>>(
287287
new(source.StreamBuffered(stallTimeout, 1, cancellationToken)),
288288
target,
289289
complete,

‎Tests/Open.Database.Extensions.Core.Tests/CaptureStreamTests.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public static async Task AFullChannel_HoldsTheRun_WithTheCaptureArmed()
411411
Assert.Equal(9, await total);
412412
}
413413

414-
// A cancel while the feed waits for room: nothing ran, and the capture
414+
// A cancel while the source waits for room: nothing ran, and the capture
415415
// is canceled with the call.
416416
[Fact]
417417
public static async Task AFullChannel_CanceledWhileItWaits_CancelsIt()
@@ -490,7 +490,7 @@ public IAsyncEnumerable<Row> StreamBuffered(
490490
=> throw new NotSupportedException();
491491
}
492492

493-
// A target that closes after the first row: the feed stops and disposes
493+
// A target that closes after the first row: the source stops and disposes
494494
// the stream, and the captured run stops at its next chunk and delivers.
495495
[Theory]
496496
[InlineData(true)]

‎Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelFixtures.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static async Task<List<int>> Drain(
7878
}
7979

8080
/// <summary>
81-
/// A source that is not ours: the feeds work on any implementation of
81+
/// A source that is not ours: the pump sources work on any implementation of
8282
/// the interface.
8383
/// </summary>
8484
public sealed class FakeSource(

‎Tests/Open.Database.Extensions.Core.Tests/TestHelpers/ChannelTestSupport.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static async Task<ChannelRow> ReceiveRow(ISourceBlock<ChannelRow> block,
175175
when (ex.CancellationToken == cts.Token && !Ct.IsCancellationRequested)
176176
{
177177
// The wait here ran out: that is a failure of the test,
178-
// not a cancel the feed reported.
178+
// not a cancel the source reported.
179179
throw new TimeoutException("the channel never ended", ex);
180180
}
181181
catch (Exception ex)

‎Tests/Open.Database.Extensions.Core.Tests/ToChannelStreamingTests.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public static void TheGuards_ThrowAtTheCall()
367367
.ToChannelHoldingConnection(Unbounded(), Long, Ct)));
368368
}
369369

370-
// The feed adds no timing of its own: the timeout and the token
370+
// The source adds no timing of its own: the timeout and the token
371371
// reach Stream untouched, on a source that is not ours.
372372
[Theory]
373373
[InlineData(false)]

0 commit comments

Comments
 (0)