NyaruDocumentStream
public struct NyaruDocumentStream<T> : AsyncSequence, Sendable where T : Decodable, T : Encodable, T : Sendable
A pull-based AsyncSequence that yields documents one by one without
materialising the entire collection in memory.
The iterator fetches documents in bounded batches from the storage engine.
Each batch is decoded lazily as the consumer calls next(). When the
batch is exhausted, the next batch is fetched from the collection actor.
Memory usage is bounded by one batch (batchSize documents).
Note
This replaces the earlierAsyncThrowingStream-based approach
whose unbounded buffer allowed a fast producer to materialise the whole
collection behind a slow consumer, defeating the purpose of streaming.
-
Declaration
Swift
public typealias Element = T -
The pull-based iterator that fetches documents in bounded batches.
See moreDeclaration
Swift
public struct Iterator : AsyncIteratorProtocol
View on GitHub