Permalink
Browse files

Runtime overhaul and modularization (#17)

  • Loading branch information...
notxcain committed Aug 7, 2017
1 parent 207353d commit 13f991ab291700eacf534806a300d093858eed30
Showing with 4,254 additions and 2,276 deletions.
  1. +2 −2 .travis.yml
  2. +63 −63 README.md
  3. +58 −0 aecor-akka-generic/src/main/scala/aecor/runtime/akkageneric/GenericAkkaRuntime.scala
  4. +84 −0 aecor-akka-generic/src/main/scala/aecor/runtime/akkageneric/GenericAkkaRuntimeActor.scala
  5. +8 −8 ...la → aecor-akka-generic/src/main/scala/aecor/runtime/akkageneric/GenericAkkaRuntimeSettings.scala
  6. +101 −0 aecor-akka-persistence/src/main/scala/aecor/runtime/akkapersistence/AkkaPersistenceRuntime.scala
  7. +117 −68 ...r-akka-persistence/src/main/scala/aecor/runtime/akkapersistence/AkkaPersistenceRuntimeActor.scala
  8. +34 −0 ...kka-persistence/src/main/scala/aecor/runtime/akkapersistence/AkkaPersistenceRuntimeSettings.scala
  9. +72 −0 aecor-akka-persistence/src/main/scala/aecor/runtime/akkapersistence/CassandraEventJournalQuery.scala
  10. +33 −23 ...→ aecor-akka-persistence/src/main/scala/aecor/runtime/akkapersistence}/CassandraOffsetStore.scala
  11. +52 −0 ...-akka-persistence/src/main/scala/aecor/runtime/akkapersistence/CommittableEventJournalQuery.scala
  12. +21 −0 aecor-akka-persistence/src/main/scala/aecor/runtime/akkapersistence/EventJournalQuery.scala
  13. +1 −1 ... → aecor-akka-persistence/src/main/scala/aecor/runtime/akkapersistence}/serialization/Codec.scala
  14. +36 −0 ...ka-persistence/src/main/scala/aecor/runtime/akkapersistence/serialization/PersistentDecoder.scala
  15. +6 −5 ...a-persistence/src/main/scala/aecor/runtime/akkapersistence}/serialization/PersistentEncoder.scala
  16. +3 −1 ...akka-persistence/src/main/scala/aecor/runtime/akkapersistence}/serialization/PersistentRepr.scala
  17. 0 ...ka-persistence}/src/main/scala/akka/persistence/cassandra/CassandraSessionInitSerialization.scala
  18. +36 −0 aecor-fs2/src/main/scala/aecor/effect/fs2/Fs2TaskInstances.scala
  19. +3 −0 aecor-fs2/src/main/scala/aecor/effect/fs2/package.scala
  20. +35 −0 aecor-monix/src/main/scala/aecor/effect/monix/MonixTaskInstances.scala
  21. +3 −0 aecor-monix/src/main/scala/aecor/effect/monix/package.scala
  22. +101 −0 aecor-test-kit/src/main/scala/aecor/testkit/E2eSupport.scala
  23. +10 −0 aecor-test-kit/src/main/scala/aecor/testkit/EventJournal.scala
  24. +108 −0 aecor-test-kit/src/main/scala/aecor/testkit/Eventsourced.scala
  25. +30 −0 aecor-test-kit/src/main/scala/aecor/testkit/StateClock.scala
  26. +112 −0 aecor-test-kit/src/main/scala/aecor/testkit/StateEventJournal.scala
  27. +29 −0 aecor-test-kit/src/main/scala/aecor/testkit/StateKeyValueStore.scala
  28. +62 −0 aecor-test-kit/src/main/scala/aecor/testkit/StateRuntime.scala
  29. +147 −30 build.sbt
  30. +3 −3 core/src/main/resources/reference.conf
  31. +0 −66 core/src/main/scala/aecor/aggregate/AkkaRuntime.scala
  32. +0 −18 core/src/main/scala/aecor/aggregate/Folder.scala
  33. +0 −51 core/src/main/scala/aecor/aggregate/StateRuntime.scala
  34. +0 −44 core/src/main/scala/aecor/aggregate/Tagging.scala
  35. +0 −20 core/src/main/scala/aecor/aggregate/package.scala
  36. +0 −35 core/src/main/scala/aecor/aggregate/serialization/PersistentDecoder.scala
  37. +43 −0 core/src/main/scala/aecor/data/Behavior.scala
  38. +55 −0 core/src/main/scala/aecor/data/Committable.scala
  39. +5 −0 core/src/main/scala/aecor/data/ConsumerId.scala
  40. +16 −0 core/src/main/scala/aecor/data/Correlation.scala
  41. +1 −1 core/src/main/scala/aecor/data/EventTag.scala
  42. +8 −0 core/src/main/scala/aecor/data/EventsourcedBehavior.scala
  43. +4 −0 core/src/main/scala/aecor/data/Folded.scala
  44. +29 −0 core/src/main/scala/aecor/data/Folder.scala
  45. +15 −4 core/src/main/scala/aecor/data/Handler.scala
  46. +6 −0 core/src/main/scala/aecor/data/Reducer.scala
  47. +39 −0 core/src/main/scala/aecor/data/Tagging.scala
  48. +11 −0 core/src/main/scala/aecor/data/package.scala
  49. +70 −0 core/src/main/scala/aecor/effect/Async.scala
  50. +23 −0 core/src/main/scala/aecor/effect/Capture.scala
  51. +28 −0 core/src/main/scala/aecor/effect/CaptureFuture.scala
  52. +0 −63 core/src/main/scala/aecor/streaming/AggregateJournal.scala
  53. +0 −81 core/src/main/scala/aecor/streaming/CassandraAggregateJournal.scala
  54. +0 −41 core/src/main/scala/aecor/streaming/Committable.scala
  55. +0 −10 core/src/main/scala/aecor/streaming/OffsetStore.scala
  56. +0 −52 core/src/main/scala/aecor/streaming/StreamSupervisor.scala
  57. +0 −51 core/src/main/scala/aecor/streaming/StreamSupervisorActor.scala
  58. +16 −0 core/src/main/scala/aecor/util/Clock.scala
  59. +15 −0 core/src/main/scala/aecor/util/JavaTimeClock.scala
  60. +22 −0 core/src/main/scala/aecor/util/KeyValueStore.scala
  61. +16 −0 core/src/main/scala/aecor/util/NoopKeyValueStore.scala
  62. +11 −0 distributed-processing/src/main/protobuf/DistributedProcessing.proto
  63. +13 −0 distributed-processing/src/main/resources/reference.conf
  64. +28 −0 distributed-processing/src/main/scala/aecor/distributedprocessing/AkkaStreamProcess.scala
  65. +82 −0 distributed-processing/src/main/scala/aecor/distributedprocessing/DistributedProcessing.scala
  66. +60 −0 ...buted-processing/src/main/scala/aecor/distributedprocessing/DistributedProcessingSupervisor.scala
  67. +54 −0 distributed-processing/src/main/scala/aecor/distributedprocessing/DistributedProcessingWorker.scala
  68. +6 −0 distributed-processing/src/main/scala/aecor/distributedprocessing/serialization/Message.scala
  69. +27 −0 ...buted-processing/src/main/scala/aecor/distributedprocessing/serialization/MessageSerializer.scala
  70. +0 −36 example/src/main/protobuf/Account.proto
  71. +16 −5 example/src/main/resources/application.conf
  72. +1 −1 example/src/main/resources/logback.xml
  73. +0 −9 example/src/main/resources/requests/AuthorizePayment.json
  74. +0 −7 example/src/main/resources/requests/CreditAccount.json
  75. +0 −5 example/src/main/resources/requests/OpenAccount.json
  76. +0 −74 example/src/main/scala/aecor/example/AccountAPI.scala
  77. +44 −0 example/src/main/scala/aecor/example/AccountEndpoint.scala
  78. +26 −0 example/src/main/scala/aecor/example/AnyValCirceEncoding.scala
  79. +126 −3 example/src/main/scala/aecor/example/App.scala
  80. +0 −121 example/src/main/scala/aecor/example/AppActor.scala
  81. +0 −118 example/src/main/scala/aecor/example/AuthorizePaymentAPI.scala
  82. +0 −109 example/src/main/scala/aecor/example/EventStream.scala
  83. +22 −0 example/src/main/scala/aecor/example/MonixSupport.scala
  84. +75 −44 example/src/main/scala/aecor/example/ScheduleApp.scala
  85. +126 −0 example/src/main/scala/aecor/example/TransactionEndpoint.scala
  86. +0 −138 example/src/main/scala/aecor/example/domain/AccountAggregate.scala
  87. +0 −34 example/src/main/scala/aecor/example/domain/AccountAggregateEvent.scala
  88. +0 −49 example/src/main/scala/aecor/example/domain/AccountAggregateOp.scala
  89. +6 −1 example/src/main/scala/aecor/example/domain/Amount.scala
  90. +0 −72 example/src/main/scala/aecor/example/domain/AuthorizationProcess.scala
  91. +0 −138 example/src/main/scala/aecor/example/domain/CardAuthorizationAggregate.scala
  92. +0 −27 example/src/main/scala/aecor/example/domain/CardAuthorizationAggregateEvent.scala
  93. +0 −36 example/src/main/scala/aecor/example/domain/CardAuthorizationAggregateOp.scala
  94. +74 −0 example/src/main/scala/aecor/example/domain/TransactionProcess.scala
  95. +52 −0 example/src/main/scala/aecor/example/domain/account/AccountAggregate.scala
  96. +34 −0 example/src/main/scala/aecor/example/domain/account/AccountEvent.scala
  97. +3 −0 example/src/main/scala/aecor/example/domain/account/AccountId.scala
  98. +107 −0 example/src/main/scala/aecor/example/domain/account/EventsourcedAccountAggregate.scala
  99. +153 −0 example/src/main/scala/aecor/example/domain/transaction/EventsourcedTransactionAggregate.scala
  100. +30 −0 example/src/main/scala/aecor/example/domain/transaction/TransactionAggregate.scala
  101. +36 −0 example/src/main/scala/aecor/example/domain/transaction/TransactionEvent.scala
  102. +2 −1 example/src/main/scala/aecor/example/persistentEncoderUtil.scala
  103. +1 −1 project/build.properties
  104. +3 −4 project/plugins.sbt
  105. +67 −48 schedule/src/main/scala/aecor/schedule/CassandraScheduleEntryRepository.scala
  106. +37 −27 schedule/src/main/scala/aecor/schedule/DefaultSchedule.scala
  107. +150 −0 schedule/src/main/scala/aecor/schedule/DefaultScheduleAggregate.scala
  108. +83 −78 schedule/src/main/scala/aecor/schedule/Schedule.scala
  109. +12 −150 schedule/src/main/scala/aecor/schedule/ScheduleAggregate.scala
  110. +6 −8 schedule/src/main/scala/aecor/schedule/ScheduleEntryRepository.scala
  111. +0 −141 schedule/src/main/scala/aecor/schedule/ScheduleProcess.scala
  112. +43 −0 schedule/src/main/scala/aecor/schedule/process/DefaultScheduleEventJournal.scala
  113. +43 −0 schedule/src/main/scala/aecor/schedule/process/PeriodicProcessRuntime.scala
  114. +7 −0 schedule/src/main/scala/aecor/schedule/process/ScheduleEventJournal.scala
  115. +64 −0 schedule/src/main/scala/aecor/schedule/process/ScheduleProcess.scala
  116. +3 −2 schedule/src/main/scala/aecor/schedule/protobuf/ScheduleEventCodec.scala
  117. +1 −1 schedule/src/main/scala/aecor/schedule/protobuf/ScheduleEventSerializer.scala
  118. +66 −0 tests/src/test/scala/aecor/tests/AkkaPersistenceRuntimeSpec.scala
  119. +1 −1 tests/src/test/scala/aecor/tests/CompositeCorrelationIdSpec.scala
  120. +37 −0 tests/src/test/scala/aecor/tests/DistributedSourceWorkerSpec.scala
  121. +207 −0 tests/src/test/scala/aecor/tests/EndToEndTest.scala
  122. +30 −0 tests/src/test/scala/aecor/tests/PersistentEncoderCirce.scala
  123. +3 −2 tests/src/test/scala/aecor/tests/ScheduleAggregateSpec.scala
  124. +2 −2 tests/src/test/scala/aecor/tests/ScheduleEventCodecSpec.scala
  125. +67 −0 tests/src/test/scala/aecor/tests/ShardedRuntimeSpec.scala
  126. +13 −42 tests/src/test/scala/aecor/tests/StateRuntimeSpec.scala
  127. +69 −0 tests/src/test/scala/aecor/tests/e2e/CounterOp.scala
  128. +21 −0 tests/src/test/scala/aecor/tests/e2e/CounterViewProcess.scala
  129. +37 −0 tests/src/test/scala/aecor/tests/e2e/CounterViewRepository.scala
  130. +39 −0 tests/src/test/scala/aecor/tests/e2e/NotificationProcess.scala
  131. +78 −0 tests/src/test/scala/aecor/tests/e2e/TestScheduleEntryRepository.scala
  132. +58 −0 tests/src/test/scala/aecor/tests/e2e/notification.scala
View
@@ -1,7 +1,7 @@
language: scala
scala:
- 2.11.8
- 2.12.0
- 2.11.11-bin-typelevel-4
- 2.12.2-bin-typelevel-4
jdk:
- oraclejdk8
View
126 README.md
@@ -26,26 +26,9 @@ scalacOptions += "-Ypartial-unification"
### Defining and running behavior
Let's start with entity operations:
Let's start with defining domain events:
```scala
sealed trait SubscriptionOp[A] {
def subscriptionId: String
}
object SubscriptionOp {
case class CreateSubscription(subscriptionId: String, userId: String, productId: String, planId: String) extends SubscriptionOp[Unit]
case class PauseSubscription(subscriptionId: String) extends SubscriptionOp[Unit]
case class ResumeSubscription(subscriptionId: String) extends SubscriptionOp[Unit]
case class CancelSubscription(subscriptionId: String) extends SubscriptionOp[Unit]
}
```
Entity events with persistent encoder and decoder:
```scala
import aecor.data.Folded.syntax._
import cats.syntax.option._
sealed trait SubscriptionEvent
object SubscriptionEvent {
case class SubscriptionCreated(subscriptionId: String, userId: String, productId: String, planId: String) extends SubscriptionEvent
@@ -58,10 +41,12 @@ object SubscriptionEvent {
}
```
Then we define how this events affect aggregate state:
`Folder[F, E, S]` instance represents the ability to fold `E`s into `S`, with effect `F` on each step.
Aecor runtime uses `Folded[A]` data type, with two possible states:
`Next(a)` - says that a should be used as a state for next folding step
`Impossible` - says that folding should be aborted (underlying runtime actor throws `IllegalStateException`)
`Next(a)` - says that `a` should be used as a state for next folding step
`Impossible` - says that folding should be aborted (e.g. underlying runtime actor throws `IllegalStateException`)
```scala
sealed trait SubscriptionStatus
@@ -71,89 +56,104 @@ object SubscriptionStatus {
case object Cancelled extends SubscriptionStatus
}
case class Subscription(status: SubscriptionStatus)
case class Subscription(status: SubscriptionStatus) {
def applyEvent(e: SubscriptionEvent): Folded[Subscription] = e match {
case e: SubscriptionCreated =>
impossible
case e: SubscriptionPaused =>
subscription.copy(status = Paused).next
case e: SubscriptionResumed =>
subscription.copy(status = Active).next
case e: SubscriptionCancelled =>
subscription.copy(status = Cancelled).next
}
}
object Subscription {
import SubscriptionStatus._
implicit def folder: Folder[Folded, SubscriptionEvent, Option[Subscription]] =
Folder.instance(Option.empty[Subscription]) {
case Some(subscription) => {
case e: SubscriptionCreated =>
impossible
case e: SubscriptionPaused =>
subscription.copy(status = Paused).some.next
case e: SubscriptionResumed =>
subscription.copy(status = Active).some.next
case e: SubscriptionCancelled =>
subscription.copy(status = Cancelled).some.next
}
case None => {
case SubscriptionCreated(subscriptionId, userId, productId, planId) =>
Subscription(Active).some.next
case _ =>
impossible
}
}
def init(e: SubscriptionEvent): Folded[Subscription] = e match {
case SubscriptionCreated(subscriptionId, userId, productId, planId) =>
Subscription(Active).next
case _ => impossible
}
def folder: Folder[Folded, SubscriptionEvent, Option[Subscription]] =
Folder.optionInstance(init)(_.applyEvent)
}
```
Now let's define a behavior that converts operation to its handler.
A `Handler[State, Event, Reply]` is just a wrapper around `State => (Seq[Event], Reply)`,
A `Handler[F, State, Event, Reply]` is just a wrapper around `State => (Seq[Event], Reply)`,
you can think of it as `Kleisli[(Seq[Event], ?), State, Reply]`
i.e. a side-effecting function with a side effect being a sequence of events representing state change caused by operation.
```scala
val behavior = Lambda[SubscriptionOp ~> Handler[Option[Subscription], SubscriptionEvent, ?]] {
sealed trait SubscriptionOp[A] {
def subscriptionId: String
}
object SubscriptionOp {
case class CreateSubscription(subscriptionId: String, userId: String, productId: String, planId: String) extends SubscriptionOp[Unit]
case class PauseSubscription(subscriptionId: String) extends SubscriptionOp[Unit]
case class ResumeSubscription(subscriptionId: String) extends SubscriptionOp[Unit]
case class CancelSubscription(subscriptionId: String) extends SubscriptionOp[Unit]
}
def handler[F[_]](implicit F: Applicative[F]) = Lambda[SubscriptionOp ~> Handler[F, Option[Subscription], SubscriptionEvent, ?]] {
case CreateSubscription(subscriptionId, userId, productId, planId) => {
case Some(subscription) =>
// Do nothing reply with ()
Seq.empty -> ()
F.pure(Seq.empty -> ())
case None =>
// Produce event and reply with ()
Seq(SubscriptionCreated(subscriptionId, userId, productId, planId)) -> ()
F.pure(Seq(SubscriptionCreated(subscriptionId, userId, productId, planId)) -> ())
}
case PauseSubscription(subscriptionId) => {
case Some(subscription) if subscription.status == Active =>
Seq(SubscriptionPaused(subscriptionId)) -> ()
F.pure(Seq(SubscriptionPaused(subscriptionId)) -> ())
case _ =>
Seq.empty -> ()
F.pure(Seq.empty -> ())
}
case ResumeSubscription(subscriptionId) => {
case Some(subscription) if subscription.status == Paused =>
Seq(SubscriptionResumed(subscriptionId)) -> ()
F.pure(Seq(SubscriptionResumed(subscriptionId)) -> ())
case _ =>
Seq.empty -> ()
F.pure(Seq.empty -> ())
}
case CancelSubscription(subscriptionId) => {
case Some(subscription) =>
Seq(SubscriptionCancelled(subscriptionId)) -> ()
F.pure(Seq(SubscriptionCancelled(subscriptionId)) -> ())
case _ =>
Seq.empty -> ()
F.pure(Seq.empty -> ())
}
}
```
Then you define a correlation function, entity name and a value provided by correlation function form unique primary key for aggregate.
It should not be changed in the future, at least without prior event migration.
It should not be changed between releases, at least without prior event migration.
```scala
def correlation: Correlation[SubscriptionOp] = {
def mk[A](op: SubscriptionOp[A]): CorrelationF[A] = op.subscriptionId
FunctionK.lift(mk _)
}
def correlation: Correlation[SubscriptionOp] = _.subscriptionId
```
After that we are ready to launch.
```scala
implicit val system = ActorSystem("foo")
import monix.cats._
import monix.eval.Task
import aecor.effect.monix._
import aecor.runtime.akkapersistence.AkkaPersistenceRuntime
val system = ActorSystem("foo")
val subscriptions: SubscriptionOp ~> Future =
AkkaRuntime(system).start(
entityName = "Subscription",
behavior,
val subscriptions: SubscriptionOp ~> Task =
AkkaPersistenceRuntime(
system,
"Subscription",
correlation,
Tagging(EventTag("Payment")
EventsourcedBehavior(
handler,
Subscription.folder
),
Tagging.const[SubscriptionEvent](EventTag("Payment"))
)
```
@@ -0,0 +1,58 @@
package aecor.runtime.akkageneric
import aecor.data.{ Behavior, Correlation }
import aecor.effect.{ Async, Capture, CaptureFuture }
import aecor.runtime.akkageneric.GenericAkkaRuntime.CorrelatedCommand
import akka.actor.ActorSystem
import akka.cluster.sharding.{ ClusterSharding, ShardRegion }
import akka.pattern._
import akka.util.Timeout
import cats.~>
import scala.concurrent.Future
object GenericAkkaRuntime {
def apply[F[_]: Async: CaptureFuture: Capture](system: ActorSystem): GenericAkkaRuntime[F] =
new GenericAkkaRuntime(system)
private final case class CorrelatedCommand[A](entityId: String, command: A)
}
class GenericAkkaRuntime[F[_]: Async: CaptureFuture: Capture](system: ActorSystem) {
def start[Op[_]](typeName: String,
correlation: Correlation[Op],
behavior: Behavior[F, Op],
settings: GenericAkkaRuntimeSettings =
GenericAkkaRuntimeSettings.default(system)): F[Op ~> F] =
Capture[F]
.capture {
val numberOfShards = settings.numberOfShards
val extractEntityId: ShardRegion.ExtractEntityId = {
case CorrelatedCommand(entityId, c) =>
(entityId, GenericAkkaRuntimeActor.PerformOp(c.asInstanceOf[Op[_]]))
}
val extractShardId: ShardRegion.ExtractShardId = {
case CorrelatedCommand(entityId, _) =>
(scala.math.abs(entityId.hashCode) % numberOfShards).toString
case other => throw new IllegalArgumentException(s"Unexpected message [$other]")
}
val props = GenericAkkaRuntimeActor.props(behavior, settings.idleTimeout)
val shardRegionRef = ClusterSharding(system).start(
typeName = typeName,
entityProps = props,
settings = settings.clusterShardingSettings,
extractEntityId = extractEntityId,
extractShardId = extractShardId
)
implicit val timeout = Timeout(settings.askTimeout)
new (Op ~> F) {
override def apply[A](fa: Op[A]): F[A] = CaptureFuture[F].captureFuture {
(shardRegionRef ? CorrelatedCommand(correlation(fa), fa)).asInstanceOf[Future[A]]
}
}
}
}
@@ -0,0 +1,84 @@
package aecor.runtime.akkageneric
import java.util.UUID
import aecor.data.Behavior
import aecor.effect.Async
import aecor.effect.Async.ops._
import aecor.runtime.akkageneric.GenericAkkaRuntimeActor.PerformOp
import akka.actor.{ Actor, ActorLogging, Props, ReceiveTimeout, Stash, Status }
import akka.cluster.sharding.ShardRegion
import akka.pattern.pipe
import scala.concurrent.duration.FiniteDuration
import scala.util.control.NonFatal
import scala.util.{ Failure, Success, Try }
object GenericAkkaRuntimeActor {
def props[F[_]: Async, Op[_]](behavior: Behavior[F, Op], idleTimeout: FiniteDuration): Props =
Props(new GenericAkkaRuntimeActor(behavior, idleTimeout))
final case class PerformOp[Op[_], A](op: Op[A])
case object Stop
}
private[aecor] final class GenericAkkaRuntimeActor[F[_]: Async, Op[_]](behavior: Behavior[F, Op],
idleTimeout: FiniteDuration)
extends Actor
with Stash
with ActorLogging {
import context._
private case class Result(id: UUID, value: Try[(Behavior[F, Op], Any)])
setIdleTimeout()
override def receive: Receive = withBehavior(behavior)
private def withBehavior(behavior: Behavior[F, Op]): Receive = {
case PerformOp(op) =>
val opId = UUID.randomUUID()
behavior
.run(op.asInstanceOf[Op[Any]])
.unsafeRun
.map(x => Result(opId, Success(x)))
.recover {
case NonFatal(e) => Result(opId, Failure(e))
}
.pipeTo(self)(sender)
become {
case Result(`opId`, value) =>
value match {
case Success((newBehavior, reply)) =>
sender() ! reply
become(withBehavior(newBehavior))
case Failure(cause) =>
sender() ! Status.Failure(cause)
throw cause
}
unstashAll()
case _ =>
stash()
}
case ReceiveTimeout =>
passivate()
case GenericAkkaRuntimeActor.Stop =>
context.stop(self)
case Result(_, _) =>
log.debug(
"Ignoring result of another operation. Probably targeted previous instance of actor."
)
}
private def passivate(): Unit = {
log.debug("Passivating...")
context.parent ! ShardRegion.Passivate(GenericAkkaRuntimeActor.Stop)
}
private def setIdleTimeout(): Unit = {
log.debug("Setting idle timeout to [{}]", idleTimeout)
context.setReceiveTimeout(idleTimeout)
}
}
@@ -1,4 +1,4 @@
package aecor.aggregate
package aecor.runtime.akkageneric
import java.util.concurrent.TimeUnit
@@ -7,24 +7,24 @@ import akka.cluster.sharding.ClusterShardingSettings
import scala.concurrent.duration._
final case class AkkaRuntimeSettings(numberOfShards: Int,
idleTimeout: FiniteDuration,
askTimeout: FiniteDuration,
clusterShardingSettings: ClusterShardingSettings)
final case class GenericAkkaRuntimeSettings(numberOfShards: Int,
idleTimeout: FiniteDuration,
askTimeout: FiniteDuration,
clusterShardingSettings: ClusterShardingSettings)
object AkkaRuntimeSettings {
object GenericAkkaRuntimeSettings {
/**
* Reads config from `aecor.akka-runtime`, see reference.conf for details
* @param system Actor system to get config from
* @return default settings
*/
def default(system: ActorSystem): AkkaRuntimeSettings = {
def default(system: ActorSystem): GenericAkkaRuntimeSettings = {
val config = system.settings.config.getConfig("aecor.akka-runtime")
def getMillisDuration(path: String): FiniteDuration =
Duration(config.getDuration(path, TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
AkkaRuntimeSettings(
GenericAkkaRuntimeSettings(
config.getInt("number-of-shards"),
getMillisDuration("idle-timeout"),
getMillisDuration("ask-timeout"),
Oops, something went wrong.

0 comments on commit 13f991a

Please sign in to comment.