IAsyncEnumerable usage and its default `limit` argument
See original GitHub issueEvery occurrence of something like
IAsyncEnumerable<IReadOnlyCollection<IMessage>> GetMessagesAsync
enforces a limit. This is not limited to GetMessagesAsync
but perhaps audit log entries as well, etc… Let’s continue talking about GetMessagesAsync
as an example though.
This method takes a mandatory argument limit
with default value of MaxMessagesPerBatch
(=100) which isn’t in line with IAsyncEnumerable
and how that would normally be used. Such limit should default to no limit (or in other words int.MaxValue
?)
Correct consumption of IAsyncEnumerable would be to execute api calls until complex conditions are satisfied. To get around this one has to hack it up by passing an int.MaxValue
instead of leaving it “unlimited,” with its default value (which isn’t “unlimited.”) Simply, leaving “limit” empty implies no limit, it does not imply 100
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
It’s not reckless, it’s correct. If the user of the library is an idiot, it’s not your problem. And I never mentioned (I’ve never used any) other libraries.
But hey, take it or leave it
¯\_(ツ)_/¯
The meta around Discord’s API is not favorable to infinite paging, and making that the default seems like a reckless decision, especially only in the name of “consistency with other libraries” which has never been a design goal of this one.