Slick 3.0 non-db computations in transaction

164 views
Skip to first unread message

Laurynas Tretjakovas

unread,
Feb 20, 2015, 7:25:47 AM2/20/15
to scala...@googlegroups.com
Let's say I want:
  1. Select a row from a database
  2. Do some processing with it
  3. insert/update some rows according to the computation
I want to do this in a single transaction. I can flatmap/map all the actions and apply the .transactionally combinator and then db.run() on the final action and it would work.
However, I want non-database computations to run in another execution context so I do not use the thread pool used for DB operations. Please suggest your solutions.

Christopher Vogt

unread,
Feb 20, 2015, 12:56:51 PM2/20/15
to scala...@googlegroups.com, Stefan Zeiger
Slicks DBIO is tuned for exactly that and does it out of the box. Have
the implicit execution context in scope you want to run computations on.
Slick will use it. For blocking queries Slick uses a separate one Slick
manages.

@szeiger may want to elaborate more on the details.

On 20.02.15 07:25, Laurynas Tretjakovas wrote:
> Let's say I want:
>
> 1. Select a row from a database
> 2. Do some processing with it
> 3. insert/update some rows according to the computation
>
> I want to do this in a single transaction. I can flatmap/map all the
> actions and apply the .transactionally combinator and then db.run() on
> the final action and it would work.
> However, I want non-database computations to run in another execution
> context so I do not use the thread pool used for DB operations. Please
> suggest your solutions.
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Slick / ScalaQuery" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to scalaquery+...@googlegroups.com
> <mailto:scalaquery+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scalaquery/13dc9fe5-563d-493c-854e-1dbaaae099b6%40googlegroups.com
> <https://groups.google.com/d/msgid/scalaquery/13dc9fe5-563d-493c-854e-1dbaaae099b6%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages