Skip to content

Commit

Permalink
Merge f01fdce into 784010e
Browse files Browse the repository at this point in the history
  • Loading branch information
i-surkov committed Nov 21, 2022
2 parents 784010e + f01fdce commit fd292a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.evolutiongaming.akkaeffect.cluster.sharding


import akka.actor.{Actor, ActorRef, Props}
import akka.cluster.sharding.ShardCoordinator.LeastShardAllocationStrategy
import akka.cluster.sharding.ShardRegion.ShardState
import akka.cluster.sharding.ShardCoordinator.ShardAllocationStrategy
import akka.cluster.sharding.ShardRegion.{ShardId, ShardState}
import akka.cluster.sharding.{ClusterShardingSettings, ShardRegion}
import cats.effect.IO
import com.evolutiongaming.akkaeffect.IOSuite._
Expand All @@ -14,7 +14,9 @@ import com.evolutiongaming.catshelper.CatsHelper._
import org.scalatest.funsuite.AsyncFunSuite
import org.scalatest.matchers.should.Matchers

import scala.concurrent.Future
import scala.concurrent.duration._
import scala.collection.immutable.IndexedSeq


class ClusterShardingLocalTest extends AsyncFunSuite with ActorSuite with Matchers {
Expand Down Expand Up @@ -42,6 +44,22 @@ class ClusterShardingLocalTest extends AsyncFunSuite with ActorSuite with Matche
}
}

// Allocation strategy that doesn't use ActorSystem and Cluster extension (as opposed to Akka built-in strategies)
val noopAllocationStrategy = new ShardAllocationStrategy {
override def allocateShard(
requester: ActorRef,
shardId: ShardId,
currentShardAllocations: Map[ActorRef, IndexedSeq[ShardId]]
): Future[ActorRef] =
Future.successful(requester)

override def rebalance(
currentShardAllocations: Map[ActorRef, IndexedSeq[ShardId]],
rebalanceInProgress: Set[ShardId]
): Future[Set[ShardId]] =
Future.successful(Set.empty)
}

val result = for {
probe <- Probe.of(actorRefOf)
actor = () => new Actor {
Expand All @@ -62,7 +80,7 @@ class ClusterShardingLocalTest extends AsyncFunSuite with ActorSuite with Matche
clusterShardingSettings,
extractEntityId,
uniform(2),
new LeastShardAllocationStrategy(1, 1),
noopAllocationStrategy,
HandOffStopMsg)

actorEffect = ActorEffect.fromActor[IO](actorRef)
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Dependencies {
}

object Akka {
private val version = "2.6.8"
private val version = "2.6.20"
val actor = "com.typesafe.akka" %% "akka-actor" % version
val testkit = "com.typesafe.akka" %% "akka-testkit" % version
val stream = "com.typesafe.akka" %% "akka-stream" % version
Expand Down

0 comments on commit fd292a3

Please sign in to comment.