Queue: take for more than one record
See original GitHub issueFS2 Queue’s had methods that would allow you to take a chunk of records, which were really convenient. The behavior would be that we would run the tryTake
method until N was hit, or None was returned. I would like to see the same in the Cats Effect queue. Something like this:
def tryTakeChunk(
maxN: Int
)(implicit A: Async[F]
): F[List[A]] = {
A.tailRecM[(List[A], Int), List[A]](
(List.empty, 0)
) { case (list, i) =>
if (list.size === maxN) list.reverse.asRight.pure[F]
else {
queue.tryTake.map {
case None => Right(list.reverse)
case Some(x) => Left((list.prepend(x), i + 1))
}
}
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (17 by maintainers)
Top Results From Across the Web
Everything You Need to Know About Salesforce Queues
Queues in Salesforce act like a user record; instead of a user being the record owner, the queue is the record owner while...
Read more >queuing solution to process a record through multiple processes
Simplest solution is all the processes runs every 10 minutes and queries the table for the records with the respective status. There are ......
Read more >How to Add to Queue with multiple lines of data for a single ...
Put all information into one cell, use Chr(10) as a row divider. Excel would perfectly show that. When reading, use Split with same...
Read more >5 Things You Should Know About Salesforce Queues - PhoneIQ
1. Queues are an excellent way to handle team-based work & backup responsibilities ... If you have a scenario where more than one...
Read more >Sequencing and Queuing Cache for Multiple-Record Writes
PowerExchange uses this cache to queue data from nonrelational sources with multiple record types in the correct sequence before sending it to the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @SystemFw and sorry. To everyone offended by my previous comment, I apologize. I don’t think
std
is bad as an idea or that it shouldn’t exist. I feel that not enough care was put in (starting from me, I have written a lot of code for it) to make the implementation more flexible in terms of evolution. I see it as a personal failure and every feature request that I read reminds me of it.I disagree with this and I think you’re being far too harsh (including to yourself).
Potentially, yes. The discussions in this wave of feature requests are good.
If Resource is going to evolve. The importance of having stable
std
is far greater than relaxing constraints here and there.It certainly wasn’t an afterthought, we debated both the general strategy of a
std
module and the specific components for quite a long time in CE2. I think the current situation with a richer std is miles better for end users than the scattered approach we used to take. It’s always hard to figure out what to include in astd
module, but not providing one is very defeatist (lots of precedent in all directions from stdlib in any language)