diff --git a/build.sbt b/build.sbt index 21b6b027..eda98608 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ import Dependencies._ import sbtversionpolicy.Compatibility.None val commonSettings = Seq( - scalacOptions ++= Seq("-Xfatal-warnings"), + scalacOptions ++= Seq("-Xfatal-warnings", "-Xlint:unused"), addCompilerPlugin("org.typelevel" % "kind-projector" % "0.13.2" cross CrossVersion.full), wartremoverExcluded += sourceManaged.value, Compile / compile / wartremoverErrors ++= Warts diff --git a/core/src/main/scala/endless/core/interpret/EntityT.scala b/core/src/main/scala/endless/core/interpret/EntityT.scala index db22e3a9..c0e90056 100644 --- a/core/src/main/scala/endless/core/interpret/EntityT.scala +++ b/core/src/main/scala/endless/core/interpret/EntityT.scala @@ -2,12 +2,11 @@ package endless.core.interpret import cats.conversions.all._ import cats.data.{Chain, NonEmptyChain} -import cats.effect.kernel.{Clock, Unique} +import cats.effect.kernel.Clock import cats.syntax.applicative._ import cats.syntax.either._ import cats.syntax.flatMap._ import cats.syntax.functor._ -import cats.tagless.FunctorK import cats.{Applicative, Functor, Monad, ~>} import endless.core.data.{EventsFolder, Folded} import endless.core.entity.Entity diff --git a/core/src/test/scala/endless/core/interpret/EffectorTSuite.scala b/core/src/test/scala/endless/core/interpret/EffectorTSuite.scala index 73e0b8bd..71c716ee 100644 --- a/core/src/test/scala/endless/core/interpret/EffectorTSuite.scala +++ b/core/src/test/scala/endless/core/interpret/EffectorTSuite.scala @@ -1,11 +1,9 @@ package endless.core.interpret -import cats.data.Chain -import cats.effect.{Clock, Concurrent, GenSpawn, GenTemporal, IO, MonadCancel, Sync, Temporal} +import cats.effect.{Clock, GenSpawn, GenTemporal, IO, MonadCancel, Sync} import cats.effect.laws.AsyncTests import cats.laws.discipline.arbitrary._ import cats.laws.discipline.{MiniInt, MonadTests} -import cats.laws.discipline.eq._ import cats.syntax.all._ import cats.derived.auto.eq._ import cats.derived.auto.order._ diff --git a/example/src/main/scala/endless/example/ExampleApp.scala b/example/src/main/scala/endless/example/ExampleApp.scala index db733749..fbe57b94 100644 --- a/example/src/main/scala/endless/example/ExampleApp.scala +++ b/example/src/main/scala/endless/example/ExampleApp.scala @@ -1,17 +1,14 @@ package endless.example import akka.actor.typed.ActorSystem -import akka.cluster.sharding.typed.scaladsl.ClusterSharding import akka.util.Timeout import cats.Monad import cats.effect._ import cats.syntax.applicative._ import cats.syntax.either._ import cats.syntax.flatMap._ -import cats.syntax.functor._ import cats.syntax.show._ import endless.core.entity.EntityNameProvider -import endless.core.interpret.EffectorT import endless.core.protocol.EntityIDCodec import endless.example.adapter.VehicleStateAdapter import endless.example.algebra._ diff --git a/example/src/main/scala/endless/example/logic/VehicleEffector.scala b/example/src/main/scala/endless/example/logic/VehicleEffector.scala index 9256a776..ec55cbc2 100644 --- a/example/src/main/scala/endless/example/logic/VehicleEffector.scala +++ b/example/src/main/scala/endless/example/logic/VehicleEffector.scala @@ -2,7 +2,6 @@ package endless.example.logic import cats.effect.Ref import cats.effect.kernel.Sync -import cats.syntax.flatMap._ import cats.syntax.functor._ import cats.{Applicative, Monad} import endless.core.entity.Effector diff --git a/protobuf/src/test/scala/endless/protobuf/ProtobufCommandProtocolSuite.scala b/protobuf/src/test/scala/endless/protobuf/ProtobufCommandProtocolSuite.scala index 49ca856d..e8022b3f 100644 --- a/protobuf/src/test/scala/endless/protobuf/ProtobufCommandProtocolSuite.scala +++ b/protobuf/src/test/scala/endless/protobuf/ProtobufCommandProtocolSuite.scala @@ -1,9 +1,9 @@ package endless.protobuf -import cats.{Functor, Id} +import cats.Id +import cats.syntax.functor._ import endless.core.protocol.{Decoder, IncomingCommand, OutgoingCommand} import endless.protobuf.test.proto.dummy.{DummyCommand, DummyReply} import org.scalacheck.Prop.forAll -import cats.syntax.functor._ class ProtobufCommandProtocolSuite extends munit.ScalaCheckSuite { test("protobuf command protocol") { diff --git a/runtime/src/main/scala/endless/runtime/akka/EntityPassivator.scala b/runtime/src/main/scala/endless/runtime/akka/EntityPassivator.scala index c32a92ff..9ac845a7 100644 --- a/runtime/src/main/scala/endless/runtime/akka/EntityPassivator.scala +++ b/runtime/src/main/scala/endless/runtime/akka/EntityPassivator.scala @@ -30,7 +30,7 @@ private[akka] class EntityPassivator[F[_]: Sync](upcomingPassivation: Ref[F, Opt case PassivationState.Unchanged => Applicative[F].unit } - private def enablePassivation(after: FiniteDuration = Duration.Zero) = + private def enablePassivation(after: FiniteDuration) = if (after === Duration.Zero) passivate else schedulePassivation(after) private def schedulePassivation(after: FiniteDuration) = diff --git a/runtime/src/main/scala/endless/runtime/akka/ShardingCommandRouter.scala b/runtime/src/main/scala/endless/runtime/akka/ShardingCommandRouter.scala index 20cd27ca..e341d9ee 100644 --- a/runtime/src/main/scala/endless/runtime/akka/ShardingCommandRouter.scala +++ b/runtime/src/main/scala/endless/runtime/akka/ShardingCommandRouter.scala @@ -1,6 +1,5 @@ package endless.runtime.akka -import akka.actor.typed.ActorSystem import akka.cluster.sharding.typed.scaladsl.{ClusterSharding, EntityTypeKey} import akka.util.Timeout import cats.effect.kernel.Async @@ -18,8 +17,6 @@ import org.typelevel.log4cats.Logger * Retrieves the entity ref and asks the command, then decodes the reply and lifts it into `F` * @param sharding * Akka cluster sharding extension - * @param actorSystem - * actor system * @param askTimeout * Akka ask timeout * @param idEncoder @@ -33,7 +30,6 @@ import org.typelevel.log4cats.Logger */ private[akka] final class ShardingCommandRouter[F[_]: Logger, ID](implicit sharding: ClusterSharding, - actorSystem: ActorSystem[_], askTimeout: Timeout, idEncoder: EntityIDEncoder[ID], nameProvider: EntityNameProvider[ID], @@ -65,7 +61,6 @@ private[akka] final class ShardingCommandRouter[F[_]: Logger, ID](implicit object ShardingCommandRouter { implicit def apply[F[_]: Logger, ID](implicit sharding: ClusterSharding, - actorSystem: ActorSystem[_], askTimeout: Timeout, idEncoder: EntityIDEncoder[ID], nameProvider: EntityNameProvider[ID], diff --git a/runtime/src/main/scala/endless/runtime/akka/deploy/Deployer.scala b/runtime/src/main/scala/endless/runtime/akka/deploy/Deployer.scala index a0f47e08..93681d66 100644 --- a/runtime/src/main/scala/endless/runtime/akka/deploy/Deployer.scala +++ b/runtime/src/main/scala/endless/runtime/akka/deploy/Deployer.scala @@ -1,21 +1,18 @@ package endless.runtime.akka.deploy -import akka.actor.typed.{ActorRef, ActorSystem, Behavior} +import akka.actor.typed.{ActorRef, Behavior} import akka.cluster.sharding.typed.ShardingEnvelope -import akka.cluster.sharding.typed.scaladsl.{ClusterSharding, EntityContext} +import akka.cluster.sharding.typed.scaladsl.EntityContext import akka.persistence.typed.scaladsl.EventSourcedBehavior import akka.util.Timeout import cats.effect.kernel.{Async, Resource} import cats.syntax.applicative._ -import cats.syntax.flatMap._ -import cats.syntax.functor._ import cats.tagless.FunctorK import endless.core.entity._ import endless.core.event.EventApplier import endless.core.interpret.EffectorT._ import endless.core.interpret._ -import endless.core.protocol.{CommandProtocol, CommandRouter, EntityIDCodec} -import endless.runtime.akka.ShardingCommandRouter +import endless.core.protocol.{CommandProtocol, EntityIDCodec} import endless.runtime.akka.data._ import endless.runtime.akka.deploy.Deployer.EffectorParameters import endless.runtime.akka.deploy.internal.EventSourcedShardedEntityDeployer @@ -173,13 +170,10 @@ trait Deployer { customizeBehavior: ( EntityContext[Command], EventSourcedBehavior[Command, E, Option[S]] - ) => Behavior[Command] = - (_: EntityContext[Command], behavior: EventSourcedBehavior[Command, E, Option[S]]) => - behavior, + ) => Behavior[Command], customizeEntity: akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[ Command - ]] => akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[Command]] = - identity + ]] => akka.cluster.sharding.typed.scaladsl.Entity[Command, ShardingEnvelope[Command]] )(implicit akkaCluster: AkkaCluster, nameProvider: EntityNameProvider[ID], diff --git a/runtime/src/main/scala/endless/runtime/akka/deploy/DurableDeployer.scala b/runtime/src/main/scala/endless/runtime/akka/deploy/DurableDeployer.scala index 722a433a..dbd738d0 100644 --- a/runtime/src/main/scala/endless/runtime/akka/deploy/DurableDeployer.scala +++ b/runtime/src/main/scala/endless/runtime/akka/deploy/DurableDeployer.scala @@ -1,8 +1,8 @@ package endless.runtime.akka.deploy -import akka.actor.typed.{ActorRef, ActorSystem, Behavior} +import akka.actor.typed.{ActorRef, Behavior} import akka.cluster.sharding.typed.ShardingEnvelope -import akka.cluster.sharding.typed.scaladsl.{ClusterSharding, EntityContext} +import akka.cluster.sharding.typed.scaladsl.EntityContext import akka.persistence.typed.state.scaladsl.DurableStateBehavior import akka.util.Timeout import cats.effect.kernel.{Async, Resource} diff --git a/runtime/src/main/scala/endless/runtime/akka/deploy/internal/DurableShardedEntityDeployer.scala b/runtime/src/main/scala/endless/runtime/akka/deploy/internal/DurableShardedEntityDeployer.scala index f0a26f6b..c083623c 100644 --- a/runtime/src/main/scala/endless/runtime/akka/deploy/internal/DurableShardedEntityDeployer.scala +++ b/runtime/src/main/scala/endless/runtime/akka/deploy/internal/DurableShardedEntityDeployer.scala @@ -1,14 +1,12 @@ package endless.runtime.akka.deploy.internal -import akka.actor.typed.scaladsl.{ActorContext, Behaviors} -import akka.actor.typed.{ActorRef, ActorSystem, Behavior} -import akka.cluster.sharding.typed.ShardingEnvelope -import akka.cluster.sharding.typed.scaladsl.{ClusterSharding, EntityContext, EntityTypeKey} +import akka.actor.typed.Behavior +import akka.actor.typed.scaladsl.ActorContext +import akka.cluster.sharding.typed.scaladsl.EntityContext import akka.persistence.typed.PersistenceId import akka.persistence.typed.state.scaladsl.{DurableStateBehavior, Effect} import akka.persistence.typed.state.{RecoveryCompleted, RecoveryFailed} -import akka.util.Timeout -import cats.effect.kernel.{Async, Resource} +import cats.effect.kernel.Async import cats.effect.std.Dispatcher import cats.syntax.applicative._ import cats.syntax.flatMap._ diff --git a/runtime/src/main/scala/endless/runtime/akka/deploy/internal/EventSourcedShardedEntityDeployer.scala b/runtime/src/main/scala/endless/runtime/akka/deploy/internal/EventSourcedShardedEntityDeployer.scala index b563714c..13c3b97b 100644 --- a/runtime/src/main/scala/endless/runtime/akka/deploy/internal/EventSourcedShardedEntityDeployer.scala +++ b/runtime/src/main/scala/endless/runtime/akka/deploy/internal/EventSourcedShardedEntityDeployer.scala @@ -1,12 +1,10 @@ package endless.runtime.akka.deploy.internal +import akka.actor.typed.Behavior import akka.actor.typed.scaladsl.ActorContext -import akka.actor.typed.{ActorSystem, Behavior} -import akka.cluster.sharding.typed.ShardingEnvelope -import akka.cluster.sharding.typed.scaladsl.{ClusterSharding, EntityContext} +import akka.cluster.sharding.typed.scaladsl.EntityContext import akka.persistence.typed.scaladsl.{Effect, EventSourcedBehavior} import akka.persistence.typed.{PersistenceId, RecoveryCompleted, RecoveryFailed} -import akka.util.Timeout import cats.effect.kernel.Async import cats.effect.std.Dispatcher import cats.syntax.applicative._ diff --git a/runtime/src/main/scala/endless/runtime/akka/deploy/internal/ShardedRepositoryDeployer.scala b/runtime/src/main/scala/endless/runtime/akka/deploy/internal/ShardedRepositoryDeployer.scala index 6f9fad27..481e4c7a 100644 --- a/runtime/src/main/scala/endless/runtime/akka/deploy/internal/ShardedRepositoryDeployer.scala +++ b/runtime/src/main/scala/endless/runtime/akka/deploy/internal/ShardedRepositoryDeployer.scala @@ -1,7 +1,7 @@ package endless.runtime.akka.deploy.internal import akka.actor.typed.scaladsl.{ActorContext, Behaviors} -import akka.actor.typed.{ActorRef, ActorSystem, Behavior} +import akka.actor.typed.{ActorRef, Behavior} import akka.cluster.sharding.typed.ShardingEnvelope import akka.cluster.sharding.typed.scaladsl.{ClusterSharding, EntityContext, EntityTypeKey} import akka.util.Timeout @@ -34,7 +34,6 @@ trait ShardedRepositoryDeployer[F[_], RepositoryAlg[_[_]], Alg[_[_]], ID] { commandProtocol: CommandProtocol[Alg], functorK: FunctorK[Alg] ): Resource[F, (RepositoryAlg[F], ActorRef[ShardingEnvelope[Command]])] = { - implicit val system: ActorSystem[_] = akkaCluster.system implicit val clusterSharding: ClusterSharding = akkaCluster.sharding implicit val commandRouter: CommandRouter[F, ID] = ShardingCommandRouter.apply val repositoryT = RepositoryT.apply[F, ID, Alg]