Created
December 1, 2020 12:29
-
-
Save fomkin/35ffbd05aeb0a71baa6e0f13ee58cb5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait MyService[F[_], S[_]] { | |
def getItem(id: Long): F[Item] | |
def getItemsByGroup(groupId): F[S[Item]] | |
} | |
class MyServiceImpl[F[_], S[_]](xa: Transactor[F]) extends MyService { | |
def getItemsByGroup(groupId): S[Item] = { | |
val stream = sql"select * from items where group = $groupId" | |
.query[Item] | |
.stream | |
.transact(xa) | |
// Convers fs2.Stream[F, Item] to S[_] in both of them have `tofu.streams` instances. | |
StreamAdapter(stream) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment