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.