Skip to content

Commit

Permalink
Merge branch 'master' into update/circe-core-0.14.6
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-steward committed Oct 24, 2023
2 parents 9e6b321 + 26d2389 commit 9976d76
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 44 deletions.
3 changes: 1 addition & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ pull_request_rules:
conditions:
- author=scala-steward
- "body~=(labels: library-update, early-semver-minor)|(labels: library-update, early-semver-patch)|(labels: sbt-plugin-update, early-semver-minor)|(labels: sbt-plugin-update, early-semver-patch)|(labels: test-library-update)"
- "check-success=Java8"
- "check-success=Java11"
- "check-success=ci"
actions:
merge:
method: squash
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.7.12"
version = "3.7.14"
runner.dialect = scala213
maxColumn = 120
align.preset = more
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<div align="center"><img src="logo.png"></div>

# zim

[![Project stage](https://img.shields.io/badge/Project%20Stage-Concept-orange.svg)](https://github.com/bitlap/bitlap/wiki/Project-Stages)
[![Build](https://github.com/bitlap/zim/actions/workflows/ScalaCI.yml/badge.svg?branch=master)](https://github.com/bitlap/zim/actions/workflows/ScalaCI.yml)
[![codecov](https://codecov.io/gh/bitlap/zim/branch/master/graph/badge.svg?token=V95ZMWUUCE)](https://codecov.io/gh/bitlap/zim)
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/liguobin/zim?label=docker-image)](https://hub.docker.com/r/liguobin/zim/tags)
Expand Down
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ object CatsRedisServiceLive {
redis <- Redis[IO].fromClient(client, stringCodec)
} yield redis

lazy val live: ULayer[CRedis] = ZLayer.succeed(new CatsRedisServiceLive(resource))
lazy val live: ULayer[Redis] = ZLayer.succeed(new CatsRedisServiceLive(resource))
}

final case class CatsRedisServiceLive(redis: Resource[IO, RedisCommands[IO, String, String]])(implicit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ import cats.effect.IO
* @version 1.0,2023/3/26
*/
package object redis4cats {
type CRedis = RedisService[IO]
type Redis = RedisService[IO]
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,23 @@ import zio._
*/
final class InfrastructureConfiguration {

ConnectionPool.add(
Symbol(mysqlConfigurationProperties.databaseName),
mysqlConfigurationProperties.url,
mysqlConfigurationProperties.user,
mysqlConfigurationProperties.password,
ConnectionPoolSettings(
initialSize = mysqlConfigurationProperties.initialSize,
maxSize = mysqlConfigurationProperties.maxSize,
connectionTimeoutMillis = mysqlConfigurationProperties.connectionTimeoutMillis,
validationQuery = mysqlConfigurationProperties.validationQuery,
driverName = mysqlConfigurationProperties.driverName
)
)
def initPool(): URIO[Any, Unit] = {
ZIO.attempt {
ConnectionPool.add(
Symbol(mysqlConfigurationProperties.databaseName),
mysqlConfigurationProperties.url,
mysqlConfigurationProperties.user,
mysqlConfigurationProperties.password,
ConnectionPoolSettings(
initialSize = mysqlConfigurationProperties.initialSize,
maxSize = mysqlConfigurationProperties.maxSize,
connectionTimeoutMillis = mysqlConfigurationProperties.connectionTimeoutMillis,
validationQuery = mysqlConfigurationProperties.validationQuery,
driverName = mysqlConfigurationProperties.driverName
)
)
}.orDie
}

lazy val mysqlConfigurationProperties: MysqlConfigurationProperties = MysqlConfigurationProperties()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ object ZimServer extends zio.ZIOAppDefault {
| ./__; .' | | '.'|| | |`-'
| ; | .' ; : ;| ;/
| `---' | , / '---'""".stripMargin)
_ <- ZIO.environmentWithZIO[AkkaHttpModule](_.get.httpServer())
_ <- ZIO.serviceWithZIO[InfrastructureConfiguration](_.initPool()) // init pool
_ <- ZIO.serviceWithZIO[AkkaHttpModule](_.httpServer())
_ <- ZIO.never
} yield ()).provide(
AkkaModule.live,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ object AkkaModule {
lazy val live: ZLayer[Any with Any with Scope, Throwable, ActorSystem[Nothing]] =
ZLayer.fromZIO(ZIO.acquireRelease(ZIO.attempt(akkaActorSystem))(a => ZIO.attempt(a.terminate()).ignore))

lazy val wslive: ZLayer[Any, Throwable, ActorSystem[Nothing]] =
private lazy val actorSystemLive: ZLayer[Any, Throwable, ActorSystem[Nothing]] =
ZLayer.fromZIO(ZIO.attempt(wsAkkaActorSystem))

def make: ZIO[Any, Throwable, ActorSystem[Nothing]] = Scope.global.use {
ZIO.service[ActorSystem[Nothing]].provideLayer(wslive)
ZIO.service[ActorSystem[Nothing]].provideLayer(actorSystemLive)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object MailServiceImpl {
)

def sendHtmlMail(to: String, subject: String, content: String): URIO[MailServiceImpl, Any] =
ZIO.environmentWithZIO(_.get.sendHtmlMail(to, subject, content))
ZIO.serviceWithZIO(_.sendHtmlMail(to, subject, content))

lazy val live: URLayer[MailConfigurationProperties, MailServiceImpl] = ZLayer(
ZIO.service[MailConfigurationProperties].map(MailServiceImpl.apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.bitlap.zim.server.service

import org.bitlap.zim.cache.redis4cats.{CatsRedisServiceLive, CRedis}
import org.bitlap.zim.cache.redis4cats.{CatsRedisServiceLive, Redis}
import org.bitlap.zim.cache.redis4zio._
import org.bitlap.zim.server.CacheType
import org.bitlap.zim.server.CacheType._
Expand All @@ -34,15 +34,15 @@ object RedisCache {
def getSets(k: String)(implicit cacheType: CacheType): Task[List[String]] = cacheType match {
case ZioCache => ZIO.serviceWithZIO[ZRedis](_.getSets(k)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.getSets(k))).provideLayer(CatsRedisServiceLive.live)
ZIO.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.getSets(k))).provideLayer(CatsRedisServiceLive.live)
}

def removeSetValue(k: String, m: String)(implicit cacheType: CacheType): Task[Long] = cacheType match {
case ZioCache =>
ZIO.serviceWithZIO[ZRedis](_.removeSetValue(k, m)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO
.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.removeSetValue(k, m)))
.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.removeSetValue(k, m)))
.provideLayer(CatsRedisServiceLive.live)
}

Expand All @@ -51,7 +51,7 @@ object RedisCache {
case ZioCache => ZIO.serviceWithZIO[ZRedis](_.setSet(k, m)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO
.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.setSet(k, m)))
.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.setSet(k, m)))
.provideLayer(CatsRedisServiceLive.live)
}

Expand All @@ -64,7 +64,7 @@ object RedisCache {
ZIO.serviceWithZIO[ZRedis](_.set[T](key, value)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO
.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.set(key, value)))
.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.set(key, value)))
.provideLayer(CatsRedisServiceLive.live)
}

Expand All @@ -76,20 +76,20 @@ object RedisCache {
case ZioCache =>
ZIO.serviceWithZIO[ZRedis](_.get[T](key)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.get(key))).provideLayer(CatsRedisServiceLive.live)
ZIO.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.get(key))).provideLayer(CatsRedisServiceLive.live)
}

def exists(key: String)(implicit cacheType: CacheType): Task[Boolean] = cacheType match {
case ZioCache =>
ZIO.serviceWithZIO[ZRedis](_.exists(key)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.exists(key))).provideLayer(CatsRedisServiceLive.live)
ZIO.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.exists(key))).provideLayer(CatsRedisServiceLive.live)
}

def del(key: String)(implicit cacheType: CacheType): Task[Boolean] = cacheType match {
case ZioCache =>
ZIO.serviceWithZIO[ZRedis](_.del(key)).provideLayer(ZioRedisServiceLive.live)
case CatsCache =>
ZIO.serviceWithZIO[CRedis](c => LiftIO.liftK[Task].apply(c.del(key))).provideLayer(CatsRedisServiceLive.live)
ZIO.serviceWithZIO[Redis](c => LiftIO.liftK[Task].apply(c.del(key))).provideLayer(CatsRedisServiceLive.live)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ import zio.actors.akka._
*/
object WsService {

private lazy val wsLayer =
InfrastructureConfiguration.live >>> UserServiceImpl.live >>> WsServiceLive.live
private lazy val wsLayer: ZLayer[Any, Throwable, WsServiceLive] = {
ZLayer.make[WsServiceLive](InfrastructureConfiguration.live, UserServiceImpl.live, WsServiceLive.live)
}

final lazy val actorRefSessions: ConcurrentHashMap[Integer, ActorRef] = new ConcurrentHashMap[Integer, ActorRef]

private val customDispatcher = DispatcherSelector.fromConfig("custom-dispatcher")
private val customDispatcher: DispatcherSelector = DispatcherSelector.fromConfig("custom-dispatcher")

// 非最佳实践,为了使用unsafeRun,不能把environment传递到最外层,这里直接provideLayer
def sendMessage(message: IMMessage): Task[Unit] =
Expand Down
14 changes: 7 additions & 7 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import sbt._
object Dependencies {

object Version {
val zio = "2.0.16"
val zio = "2.0.18"
val `zio-logging` = "2.1.14"
val tapir = "1.7.0"
val `akka-http` = "10.5.0"
val akka = "2.8.0"
val circe = "0.14.3"
val scalikejdbc = "4.0.0"
val scalikejdbc = "4.1.0"
val logback = "1.4.11"
val config = "1.4.2"
val config = "1.4.3"
val `zio-interop-reactiveStreams` = "2.0.2"
val mysql = "8.0.32"
val `simple-java-mail` = "7.5.0"
val h2 = "2.2.220"
val scalaTest = "3.2.15"
val h2 = "2.2.224"
val scalaTest = "3.2.17"
val `zio-actors` = "0.1.0"
val refined = "0.10.3"
val `zio-schema` = "0.4.13"
val `sttp-apispec` = "0.6.0"
val `zio-schema` = "0.4.14"
val `sttp-apispec` = "0.6.3"
val redis4cats = "1.4.1"
val `zio-interop-cats` = "23.0.03"
val `log4cats-slf4j` = "2.5.0"
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.9.4
sbt.version = 1.9.6
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.8")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
//addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.1")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0")
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.6.3"
ThisBuild / version := "0.6.4"

0 comments on commit 9976d76

Please sign in to comment.