Skip to content

Commit

Permalink
🔨refactor: Add ClusterReplicationSettings.create (for internal use) i…
Browse files Browse the repository at this point in the history
…nstead of deprecated apply method
  • Loading branch information
negokaz committed Jul 15, 2021
1 parent f563b43 commit 4674603
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import scala.concurrent.duration.FiniteDuration

object ClusterReplicationSettings {

def apply(system: ActorSystem): ClusterReplicationSettings = {
@deprecated("Use typed.ClusterReplicationSettings instead", since = "2.0.0")
def apply(system: ActorSystem): ClusterReplicationSettings = create(system)

// for internal use
private[entityreplication] def create(system: ActorSystem): ClusterReplicationSettings = {
val cluster = Cluster(system)
ClusterReplicationSettingsImpl(system.settings.config, cluster.settings.Roles)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait ReplicationActor[StateData] extends Actor with Stash with akka.lerna.Stash

private val instanceId = ReplicationActor.generateInstanceId()

private[this] val settings = ClusterReplicationSettings(context.system)
private[this] val settings = ClusterReplicationSettings.create(context.system)

private[this] val log = Logging(context.system, this)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private[entityreplication] class ClusterReplicationImpl(system: ActorSystem[_])

private[this] def internalInit[M, E](entity: ReplicatedEntity[M, E]): ActorRef[E] = {
val classicSystem = system.toClassic
val settings = entity.settings.getOrElse(untyped.ClusterReplicationSettings(classicSystem))
val settings = entity.settings.getOrElse(untyped.ClusterReplicationSettings.create(classicSystem))
val extractEntityId: untyped.ReplicationRegion.ExtractEntityId = {
case ReplicationEnvelope(entityId, message) => (entityId, message)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private[entityreplication] final case class ReplicatedEntityBehaviorImpl[Command

override def apply(ctx: TypedActorContext[Command]): Behavior[Command] = {
try {
val settings = ClusterReplicationSettings(ctx.asScala.system.toClassic)
val settings = ClusterReplicationSettings.create(ctx.asScala.system.toClassic)
Behaviors.intercept(() => interceptor)(createBehavior(entityContext.shard, settings)).narrow
} catch {
case NonFatal(e) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConsistencyTestNormal extends MultiNodeSpec(ConsistencyTestBaseConfig) wit
clusterReplication = ClusterReplication(system).start(
typeName = "sample",
entityProps = Props[ConsistencyTestReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = ConsistencyTestReplicationActor.extractEntityId,
extractShardId = ConsistencyTestReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class RaftActorCompactionSpec extends MultiNodeSpec(RaftActorCompactionSpecConfi
ClusterReplication(system).start(
typeName = typeName,
entityProps = DummyReplicationActor.props(),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = DummyReplicationActor.extractEntityId,
extractShardId = DummyReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class RaftEventSourcedSpec extends MultiNodeSpec(RaftEventSourcedSpecConfig) wit
ClusterReplication(system).start(
typeName,
entityProps = DummyReplicationActor.props(),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
DummyReplicationActor.extractEntityId,
DummyReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "ping-pong-sample",
entityProps = Props[PingPongReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = PingPongReplicationActor.extractEntityId,
extractShardId = PingPongReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -285,7 +285,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "ping-pong-sample-2",
entityProps = Props[PingPongReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = PingPongReplicationActor.extractEntityId,
extractShardId = PingPongReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -319,7 +319,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "lock-sample",
entityProps = Props[LockReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = LockReplicationActor.extractEntityId,
extractShardId = LockReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -356,7 +356,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "passivate-sample",
entityProps = Props[EphemeralReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = EphemeralReplicationActor.extractEntityId,
extractShardId = EphemeralReplicationActor.extractShardId,
)
Expand Down Expand Up @@ -396,7 +396,7 @@ class ReplicationActorMultiNodeSpec extends MultiNodeSpec(ReplicationActorSpecCo
ClusterReplication(system).start(
typeName = "recovery-sample",
entityProps = Props[EphemeralReplicationActor](),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = EphemeralReplicationActor.extractEntityId,
extractShardId = EphemeralReplicationActor.extractShardId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ReplicationRegionSpec extends MultiNodeSpec(ReplicationRegionSpecConfig) w
ClusterReplication(system).start(
typeName = typeName,
entityProps = DummyReplicationActor.props(entityProbe),
settings = ClusterReplicationSettings(system),
settings = ClusterReplicationSettings.create(system),
extractEntityId = DummyReplicationActor.extractEntityId,
extractShardId = DummyReplicationActor.extractShardId,
)
Expand All @@ -197,7 +197,7 @@ class ReplicationRegionSpec extends MultiNodeSpec(ReplicationRegionSpecConfig) w
new ReplicationRegion(
typeName = typeName,
_ => DummyReplicationActor.props(entityProbe),
ClusterReplicationSettings(system),
ClusterReplicationSettings.create(system),
DummyReplicationActor.extractEntityId,
DummyReplicationActor.extractShardId,
maybeCommitLogStore = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ class RaftActorMultiNodeSpec extends MultiNodeSpec(RaftActorSpecConfig) with STM
new ReplicationRegion(
typeName = typeName,
_ => replicationActorProps,
ClusterReplicationSettings(system),
ClusterReplicationSettings.create(system),
extractEntityId,
extractShardId,
maybeCommitLogStore = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class RaftActorLeaderSpec extends TestKit(ActorSystem()) with RaftActorSpecBase
}
}

private[this] val settings = ClusterReplicationSettings(system)
private[this] val settings = ClusterReplicationSettings.create(system)

private[this] val eventStore = system.actorOf(EventStore.props(settings), "eventStore")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger

class SnapshotSyncManagerSpec extends TestKit(ActorSystem()) with ActorSpec with BeforeAndAfterEach {

private[this] val settings = ClusterReplicationSettings(system)
private[this] val settings = ClusterReplicationSettings.create(system)

private[this] val shardId = NormalizedShardId("test-shard")

Expand Down

0 comments on commit 4674603

Please sign in to comment.