Grégory Coutant
Sep 4, 2018 · 1 min read

This doesn’t look like streaming to me because every applicant is loaded in memory.

You should have something like this to stream data from db :

def getApplicants(): fs2.Stream[IO, Applicant] = {
sql"select * from applicants"
.query[List[Applicant]]
.stream
.transact(xa)
}

And convert the Stream to a Source directly. You can use streamz for that : https://github.com/krasserm/streamz/blob/master/streamz-converter/README.md#conversions-from-fs2-to-akka-stream

And then you will properly stream data from your db and support stuffs like back pressure.

    Grégory Coutant

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade