You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the session pool is passed to the methods implementing the query/command logic. After doing some reading in the skunk Discord channel I found a few discussions mentioning that this would be more efficient:
object Main extends ResourceApp.Forever {
override def run(args: List[String]): Resource[IO, Unit] = {
for {
sessionPool <- Session.pooled[IO](
host = host,
port = port,
user = user,
database = db,
password = password,
max = max
)
databaseAccessLayer = sessionPool.map(new DBAccessLayerIO)
service = new MyServiceIO
server <- BlazeServerBuilder[IO]
.withHttpApp(service.orNotFound)
.bindHttp(host = "0.0.0.0", port = 8080)
.resource
.void
} yield server
From what I understand this would mean "using" the dbAccessLayer on each request inside the route, so I comes down to what is more costly, inefficient session reuse or repeatedly allocating new objects? I'm not sure which one would be the better tradeoff to make in a "typical" web backend.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently the session pool is passed to the methods implementing the query/command logic. After doing some reading in the skunk Discord channel I found a few discussions mentioning that this would be more efficient:
From what I understand this would mean "using" the dbAccessLayer on each request inside the route, so I comes down to what is more costly, inefficient session reuse or repeatedly allocating new objects? I'm not sure which one would be the better tradeoff to make in a "typical" web backend.
https://discord.com/channels/632277896739946517/839844929877704785/955838009872384020
Beta Was this translation helpful? Give feedback.
All reactions