Flow[Seq[Session => Unit]].map { msg =>
Try {
db.withSession { session =>
msg.foreach(_(session))
}
}
I am trying to adapt a project of mine that uses already Akka streams to Slick 3.0; my problem is that in my current solution I create a stream of sequences of functions that cause some side-effect to the database.
Flow[Seq[Session => Unit]].map { msg =>
Try {
db.withSession { session =>
msg.foreach(_(session))
}
}
I already replaced the code generating the flow of `Session => Unit` to generate instead a flow of `DBIO[Int]`; ideally I would now like to use `DBIO.sequence` to fuse the `Seq[DBIO[Int]]` in a `DBIO[Seq[Int]]` and then run those sequentially and get in the end a `Flow[Seq[Int]]`.
Thanks for the answer Stefan, I will give it a try. One thing that I don't fully understand is whether or not I will be guaranteed that the actions will be executed at the database level in order using mapAsync or if I have to worry about this detail as some of my actions could be dependent on each other. Could you advice on this please?