Skip to content

Commit 64c1ed8

Browse files
committed
update PersistenceGuardian to initialize schema provider
1 parent 7d9b2df commit 64c1ed8

File tree

7 files changed

+45
-25
lines changed

7 files changed

+45
-25
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ jobs:
4444
flags: unittests
4545
fail_ci_if_error: true
4646
verbose: true
47-
# - name: Publish
48-
# run: sbt publish
47+
- name: Publish
48+
run: sbt publish
4949

5050
lint:
5151
runs-on: ubuntu-latest

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ThisBuild / organization := "app.softnetwork"
3030

3131
name := "generic-persistence-api"
3232

33-
ThisBuild / version := "0.3.0.1"
33+
ThisBuild / version := "0.3.0.2"
3434

3535
ThisBuild / scalaVersion := "2.12.11"
3636

core/src/main/scala/app/softnetwork/persistence/launch/PersistenceGuardian.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import scala.language.implicitConversions
2323

2424
/** Created by smanciot on 15/05/2020.
2525
*/
26-
trait PersistenceGuardian extends ClusterDomainEventHandler { _: SchemaProvider =>
26+
trait PersistenceGuardian extends ClusterDomainEventHandler {
2727

2828
def config: Config
2929

@@ -50,6 +50,8 @@ trait PersistenceGuardian extends ClusterDomainEventHandler { _: SchemaProvider
5050

5151
def startSystem: ActorSystem[_] => Unit = _ => ()
5252

53+
def schemaProvider: ActorSystem[_] => SchemaProvider
54+
5355
def banner: String =
5456
"""
5557
| ____ __ _ _ _
@@ -62,11 +64,12 @@ trait PersistenceGuardian extends ClusterDomainEventHandler { _: SchemaProvider
6264

6365
def setup(): Behavior[ClusterDomainEvent] = {
6466
Behaviors.setup[ClusterDomainEvent] { context =>
65-
// initialize schema
66-
initSchema()
6767

6868
val system = context.system
6969

70+
// initialize schema
71+
schemaProvider(system).initSchema()
72+
7073
val cluster: Cluster = Cluster(system)
7174

7275
context.log.info("Starting up cluster listener...")

core/src/main/scala/app/softnetwork/persistence/launch/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import app.softnetwork.persistence.typed.EntityBehavior
99

1010
package object launch {
1111

12-
trait ClusterDomainEventHandler { _: SchemaProvider =>
12+
trait ClusterDomainEventHandler {
1313
def handleEvent(event: ClusterDomainEvent)(implicit system: ActorSystem[_]): Unit = ()
1414
}
1515

core/testkit/src/main/scala/app/softnetwork/persistence/scalatest/PersistenceTestKit.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ trait PersistenceTestKit
160160
implicit val patience: PatienceConfig =
161161
PatienceConfig(Settings.DefaultTimeout, Span(100, org.scalatest.time.Millis))
162162

163+
override def schemaProvider: ActorSystem[_] => SchemaProvider = _ => this
164+
163165
override def beforeAll(): Unit = {
164166
initAndJoinCluster()
165167
}

docs/diagrams/out/Patterns.svg

Lines changed: 26 additions & 17 deletions
Loading

docs/diagrams/src/Patterns.plantuml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ package app.softnetwork {
1414
abstract class CommandTypeKey <C: Command> <<(T,orchid) trait >> {
1515
+def TypeKey(implicit c: ClassTag[C]): EntityTypeKey[C]
1616
}
17-
note left of CommandTypeKey::TypeKey
17+
note right of CommandTypeKey::TypeKey
1818
A key that uniquely identifies
1919
the type of entity in the cluster
2020
end note
@@ -46,5 +46,11 @@ package app.softnetwork {
4646
EntityPattern +-- RecipientPattern: <<implicit>>
4747
}
4848
}
49+
package persistence.service {
50+
abstract Service <C: Command, R: CommandResult> <<(T,orchid) trait>>{
51+
+def run(entityId: String, command: C): Future[R]
52+
}
53+
Patterns <|.. Service: <<self>>
54+
}
4955
}
5056
@enduml

0 commit comments

Comments
 (0)