question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Queue: take for more than one record

See original GitHub issue

FS2 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:closed
  • Created 2 years ago
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

4reactions
vasilmkdcommented, Dec 12, 2021

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.

3reactions
SystemFwcommented, Dec 12, 2021

cats-effect-std was put together haphazardly and without much thought.

I disagree with this and I think you’re being far too harsh (including to yourself).

It has a lot of growing up to do

Potentially, yes. The discussions in this wave of feature requests are good.

Also think about how Resource is going to evolve

If Resource is going to evolve. The importance of having stable std is far greater than relaxing constraints here and there.

I dislike std, it was an afterthought.

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 a std module, but not providing one is very defeatist (lots of precedent in all directions from stdlib in any language)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found