Skip to content

Commit

Permalink
Merge pull request #1153 from eikek/update-deps
Browse files Browse the repository at this point in the history
Update deps
  • Loading branch information
mergify[bot] authored Aug 3, 2023
2 parents 1f057b5 + 1e740c4 commit 851179e
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 52 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val scalafixSettings = Seq(

val sharedSettings = Seq(
organization := "com.github.eikek",
scalaVersion := "2.13.10",
scalaVersion := "2.13.11",
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sharry.backend
import scala.concurrent.ExecutionContext

import cats.effect._
import fs2.io.file.Files

import sharry.backend.account._
import sharry.backend.alias.OAlias
Expand Down Expand Up @@ -55,7 +56,7 @@ object BackendApp {
val files: OFiles[F] = filesImpl
}

def apply[F[_]: Async](
def apply[F[_]: Async: Files](
cfg: Config,
connectEC: ExecutionContext
): Resource[F, BackendApp[F]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import sharry.backend.share.{Queries => ShareQueries}
import sharry.common._
import sharry.store.AddResult
import sharry.store.Store
import sharry.store.doobie.DoobieMeta
import sharry.store.records._

import doobie._
Expand Down Expand Up @@ -128,7 +127,7 @@ object OAccount {
} yield u

def insert(user: RAccount): ConnectionIO[Int] =
RAccount.insert(user)(DoobieMeta.TraceLogging.handler)
RAccount.insert(user, "trace")

def accountExists: ConnectionIO[Boolean] =
RAccount.existsByLogin(acc.login)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class QueriesTest extends FunSuite with StoreFixture {
)

for {
_ <- store.transact(RAccount.insert(account))
_ <- store.transact(RAccount.insert(account, "warn"))
e <- store.transact(Queries.getEmail(accountId))
_ <- IO(assertEquals(e, Some(MailAddress(Some("jdoe"), "test@test.com"))))
} yield ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import scala.concurrent.ExecutionContext

import cats.effect._
import cats.implicits._
import fs2.io.file.Files

import sharry.backend.BackendApp
import sharry.restserver.config.Config
Expand All @@ -28,7 +29,7 @@ final class RestAppImpl[F[_]: Sync](val config: Config, val backend: BackendApp[

object RestAppImpl {

def create[F[_]: Async](
def create[F[_]: Async: Files](
cfg: Config,
connectEC: ExecutionContext
): Resource[F, RestApp[F]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package sharry.restserver
import cats.data.{Kleisli, OptionT}
import cats.effect._
import cats.syntax.all._
import fs2.io.file.Files
import fs2.io.net.Network
import fs2.{Pure, Stream}

import sharry.backend.auth.AuthToken
Expand All @@ -23,7 +25,10 @@ import org.http4s.server.Router
import org.http4s.server.middleware.{Logger => Http4sLogger}

object RestServer {
def stream[F[_]: Async](cfg: Config, pools: Pools): Stream[F, Nothing] = {
def stream[F[_]: Async: Files: Network](
cfg: Config,
pools: Pools
): Stream[F, Nothing] = {
implicit val logger = sharry.logging.getLogger[F]

val server = httpApp(cfg, pools).flatMap(httpServer(cfg, _))
Expand All @@ -33,7 +38,7 @@ object RestServer {
.flatMap(_ => Stream.never)
}

def httpServer[F[_]: Async: Logger](cfg: Config, app: HttpApp[F]) =
def httpServer[F[_]: Async: Network: Logger](cfg: Config, app: HttpApp[F]) =
EmberServerBuilder
.default[F]
.withHost(cfg.bind.address)
Expand All @@ -46,7 +51,10 @@ object RestServer {
.withHttpApp(app)
.build

def httpApp[F[_]: Async: Logger](cfg: Config, pools: Pools): Resource[F, HttpApp[F]] = {
def httpApp[F[_]: Async: Files: Network: Logger](
cfg: Config,
pools: Pools
): Resource[F, HttpApp[F]] = {
val templates = TemplateRoutes[F](cfg)
for {
restApp <- RestAppImpl.create[F](cfg, pools.connectEC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object TemplateRoutes {
def serviceWorker: HttpRoutes[F]
}

def apply[F[_]: Async](cfg: Config): InnerRoutes[F] = {
def apply[F[_]: Async: Files](cfg: Config): InnerRoutes[F] = {
implicit val logger = sharry.logging.getLogger[F]
val indexTemplate = memo(
loadResource("/index.html").flatMap(loadTemplate(_))
Expand Down
3 changes: 2 additions & 1 deletion modules/store/src/main/scala/sharry/store/FileStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import cats.data.OptionT
import cats.effect._
import cats.implicits._
import fs2.Chunk
import fs2.io.file.Files

import sharry.common._
import sharry.store.doobie.AttributeStore
Expand Down Expand Up @@ -39,7 +40,7 @@ trait FileStore[F[_]] {

object FileStore {

def apply[F[_]: Async](
def apply[F[_]: Async: Files](
ds: DataSource,
xa: Transactor[F],
chunkSize: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import javax.sql.DataSource

import cats.effect.Async
import cats.syntax.all._
import fs2.io.file.Path
import fs2.io.file.{Files, Path}

import binny.ChunkedBinaryStore
import binny.fs.{
Expand Down Expand Up @@ -47,7 +47,7 @@ object FileStoreConfig {
s"S3(enabled=$enabled, endpoint=$endpoint, bucket=$bucket, accessKey=$accessKey, secretKey=***)"
}

def createBinaryStore[F[_]: Async](ds: DataSource, chunkSize: Int)(
def createBinaryStore[F[_]: Async: Files](ds: DataSource, chunkSize: Int)(
config: FileStoreConfig
): F[ChunkedBinaryStore[F]] = {
implicit val logger: binny.util.Logger[F] = SharryLogger(sharry.logging.getLogger[F])
Expand Down
22 changes: 20 additions & 2 deletions modules/store/src/main/scala/sharry/store/Store.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import scala.concurrent.ExecutionContext

import cats.effect._
import fs2._
import fs2.io.file.Files

import sharry.common.ByteSize
import sharry.store.doobie.StoreImpl

import _root_.doobie._
import _root_.doobie.hikari.HikariTransactor
import _root_.doobie.util.log.{LogEvent, Success}
import com.zaxxer.hikari.HikariDataSource

trait Store[F[_]] {
Expand All @@ -25,7 +27,21 @@ trait Store[F[_]] {

object Store {

def create[F[_]: Async](
private object DefaultLogging {
implicit def handler[F[_]: Sync]: LogHandler[F] =
new LogHandler[F] {
val logger = sharry.logging.getLogger[F]("DoobieMeta")
def run(e: LogEvent) = e match {
case e @ Success(_, _, _, _, _) =>
logger.trace("SQL success: " + e)
case e =>
if (e.label == "trace") logger.trace(s"SQL failure: $e")
else logger.warn(s"SQL failure: $e")
}
}
}

def create[F[_]: Async: Files](
jdbc: JdbcConfig,
chunkSize: ByteSize,
computeChecksumConfig: ComputeChecksumConfig,
Expand All @@ -43,7 +59,9 @@ object Store {
ds.setPassword(jdbc.password)
ds.setDriverClassName(jdbc.driverClass)
}
xa <- Resource.pure(HikariTransactor[F](ds, connectEC))
xa <- Resource.pure(
HikariTransactor[F](ds, connectEC, Some(DefaultLogging.handler[F]))
)
fs <- Resource.eval(
FileStore[F](ds, xa, chunkSize.bytes.toInt, computeChecksumConfig, fileStoreCfg)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ import sharry.common.syntax.all._

import doobie._
import doobie.implicits.legacy.instant._
import doobie.util.log.Success
import io.circe.{Decoder, Encoder}
import scodec.bits.ByteVector

trait DoobieMeta {

implicit val sqlLogging = DoobieMeta.DefaultLogging.handler

def jsonMeta[A](implicit d: Decoder[A], e: Encoder[A]): Meta[A] =
Meta[String].imap(str => str.parseJsonAs[A].fold(ex => throw ex, identity))(a =>
e.apply(a).noSpaces
Expand Down Expand Up @@ -52,26 +49,4 @@ trait DoobieMeta {
Meta[String].timap(s => ByteVector.fromValidHex(s))(_.toHex)
}

object DoobieMeta extends DoobieMeta {
private[this] val logger = sharry.logging.unsafeLogger("DoobieMeta")

object TraceLogging {
implicit val handler =
LogHandler {
case e @ Success(_, _, _, _) =>
logger.trace("SQL success: " + e)
case e =>
logger.trace(s"SQL failure: $e")
}
}

object DefaultLogging {
implicit val handler =
LogHandler {
case e @ Success(_, _, _, _) =>
logger.trace("SQL success: " + e)
case e =>
logger.warn(s"SQL failure: $e")
}
}
}
object DoobieMeta extends DoobieMeta
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ object RAccount {

import Columns._

def insert(
v: RAccount
)(implicit LH: LogHandler = DoobieMeta.sqlLogging): ConnectionIO[Int] = {
def insert(v: RAccount, label: String): ConnectionIO[Int] = {
val sql = Sql.insertRow(
table,
all,
fr"${v.id},${v.login},${v.source},${v.state},${v.password},${v.email},${v.admin},${v.loginCount},${v.lastLogin},${v.created}"
)
sql.updateWithLogHandler(LH).run
sql.updateWithLabel(label).run
}

def update(aid: Ident, v: ModAccount): ConnectionIO[Int] = {
Expand Down
3 changes: 2 additions & 1 deletion modules/store/src/test/scala/sharry/store/StoreFixture.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import scala.util.Random

import cats.effect._
import cats.effect.unsafe.implicits.global
import fs2.io.file.Files

import sharry.common._
import sharry.store.doobie._
Expand All @@ -23,7 +24,7 @@ trait StoreFixture {
object StoreFixture {
private[this] val logger = sharry.logging.unsafeLogger("StoreFixture")

def makeStore[F[_]: Async]: Resource[F, Store[F]] = {
def makeStore[F[_]: Async: Files]: Resource[F, Store[F]] = {
def dataSource(jdbc: JdbcConfig): Resource[F, JdbcConnectionPool] = {
def jdbcConnPool =
JdbcConnectionPool.create(jdbc.url.asString, jdbc.user, jdbc.password)
Expand Down
12 changes: 6 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ object Dependencies {

val BcryptVersion = "0.4"
val BetterMonadicForVersion = "0.3.1"
val BinnyVersion = "0.9.1"
val BinnyVersion = "0.10.0"
val CirceVersion = "0.14.5"
val ClipboardJsVersion = "2.0.11"
val DoobieVersion = "1.0.0-RC2"
val EmilVersion = "0.13.0"
val DoobieVersion = "1.0.0-RC4"
val EmilVersion = "0.14.0"
val FlywayVersion = "9.21.1"
val Fs2Version = "3.6.1"
val Fs2Version = "3.8.0"
val H2Version = "2.2.220"
val Http4sVersion = "0.23.18"
val Http4sVersion = "0.23.23"
val JQueryVersion = "3.5.1"
val KindProjectorVersion = "0.10.3"
val MariaDbVersion = "3.1.4"
Expand All @@ -21,7 +21,7 @@ object Dependencies {
val OrganizeImportsVersion = "0.6.0"
val PostgresVersion = "42.6.0"
val PureConfigVersion = "0.17.4"
val ScribeVersion = "3.11.8"
val ScribeVersion = "3.11.9"
val SourcecodeVersion = "0.3.0"
val SwaggerVersion = "5.2.0"
val TikaVersion = "2.8.0"
Expand Down

0 comments on commit 851179e

Please sign in to comment.