Skip to content

Commit c4459b5

Browse files
committed
update README
1 parent 9113597 commit c4459b5

File tree

9 files changed

+335
-142
lines changed

9 files changed

+335
-142
lines changed

README.md

Lines changed: 197 additions & 43 deletions
Large diffs are not rendered by default.

core/src/main/scala/app/softnetwork/persistence/typed/EntityBehavior.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ trait EntityBehavior[C <: Command, S <: State, E <: Event, R <: CommandResult]
7979
/** @return
8080
* number of events before saving a snapshot of the current actor entity state. If multiple
8181
* events are persisted with a single Effect the snapshot will happen after all of the events
82-
* are persisted rather than precisely every `numberOfEvents`
82+
* are persisted rather than precisely every `snapshotInterval`
8383
*/
8484
def snapshotInterval: Int = 10
8585

@@ -89,9 +89,8 @@ trait EntityBehavior[C <: Command, S <: State, E <: Event, R <: CommandResult]
8989
def numberOfSnapshots: Int = 2
9090

9191
/** @return
92-
* the key used to define the Entity Type Key of this actor that uniquely identifies the type
93-
* of entity in this cluster and is then used to retrieve an EntityRef for a given entity
94-
* identifier
92+
* the key used to define the Entity Type Key of this entity actor that uniquely identifies the type
93+
* of entity in the cluster
9594
*/
9695
def persistenceId: String
9796

@@ -112,7 +111,7 @@ trait EntityBehavior[C <: Command, S <: State, E <: Event, R <: CommandResult]
112111
* - actor system
113112
* @param maybeRole
114113
* - an optional node role required to start this entity
115-
* @param c
114+
* @param c - runtime class of C
116115
* -
117116
* @return
118117
*/

docs/diagrams/out/Command.svg

Lines changed: 20 additions & 12 deletions
Loading

docs/diagrams/out/EntityBehavior.svg

Lines changed: 16 additions & 16 deletions
Loading

docs/diagrams/out/EventSourcing.svg

Lines changed: 5 additions & 5 deletions
Loading

docs/diagrams/out/Patterns.svg

Lines changed: 49 additions & 33 deletions
Loading

docs/diagrams/src/Command.plantuml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ hide empty members
55
package app.softnetwork.persistence.message {
66
abstract CommandResult << (T,orchid) trait >>
77
abstract Command << (T,orchid) trait >>
8+
abstract EntityCommand << (T,orchid) trait >> extends Command{
9+
+def id: String
10+
}
11+
note right of EntityCommand::id
12+
the entity identifier
13+
end note
814
abstract CommandWithReply <R: CommandResult> <<(T,orchid) trait >>{
915
+replyTo: ActorRef[R]
1016
}
11-
note right: a command which includes \na reference to the actor identity \nto whom a response has to be sent
17+
note right of CommandWithReply: a command which includes \na reference to the actor identity \nto whom a response has to be sent
1218
Command <|-- CommandWithReply
1319

1420
abstract CommandWrapper <C: Command, R: CommandResult> <<(T,orchid) trait >> extends CommandWithReply {

docs/diagrams/src/EventSourcing.plantuml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ skinparam BoxPadding 10
55
skinparam sequenceMessageAlign center
66
skinparam monochrome true
77

8-
participant Consumer as c
8+
participant Sender as s
99
control "Entity Pattern" as ep
1010
participant "Cluster Sharding" as cs
1111
entity "Entity Behavior" as eb
1212
database Journal as j
1313

14-
c -> ep++: ? (**entityId**: String, **cmd**: Command)
14+
s -> ep++: ? (**entityId**: String, **cmd**: Command)
1515
ep -> ep : ref(**entityId**)
16-
ep -> cs++: entityRefFor(**entityId**)
17-
return recipient
16+
ep -> cs++: entityRefFor(entityTypeKey, **entityId**)
17+
return entity reference
1818
ep -> eb++: ? **cmd**
1919

2020
opt recovering from latest saved snapshot

docs/diagrams/src/Patterns.plantuml

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,41 @@ package app.softnetwork {
1010
+<<recursive>>retry(n: Int)(fn: => Future[T]): Future[T]
1111
}
1212
}
13-
package persistence.typed.scaladsl {
14-
abstract Patterns <C: Command, R: CommandResult> <<(T,orchid) trait>>{
15-
<<type>> Recipient
16-
<<implicit>> command2Request(command: C): ActorRef[R] => C
17-
timeout: Timeout
18-
-recipientRef(recipient: Recipient): akka.actor.typed.RecipientRef[C]
19-
+?(recipient: Recipient, command: C): Future[R] = recipientRef(recipient) ? command
20-
+!(recipient: Recipient, command: C): Unit = recipientRef(recipient) ! command
21-
<<implicit>> key2Recipient[T](key: T): Recipient
22-
#lookup[T](key: T): Future[Option[Recipient]]
23-
+??[T](key: T, command: C): Future[R]
24-
+?![T](key: T, command: C): Unit
25-
+*?[T](keys: List[T], command: C): Future[List[R]]
26-
+*![T](keys: List[T], command: C): Unit
13+
package persistence.typed {
14+
abstract class CommandTypeKey <C: Command> <<(T,orchid) trait >> {
15+
+def TypeKey(implicit c: ClassTag[C]): EntityTypeKey[C]
2716
}
28-
Retryable <|-- Patterns: <<bind>> <R -> T>
29-
abstract EntityPattern <C: Command, R: CommandResult> <<(T,orchid) trait>> extends Patterns{
30-
<<type>> Recipient = String
17+
note left of CommandTypeKey::TypeKey
18+
A key that uniquely identifies
19+
the type of entity in the cluster
20+
end note
21+
package scaladsl {
22+
abstract Patterns <C: Command, R: CommandResult> <<(T,orchid) trait>>{
23+
<<type>> Recipient
24+
<<implicit>> command2Request(command: C): ActorRef[R] => C
25+
timeout: Timeout
26+
-recipientRef(recipient: Recipient): akka.actor.typed.RecipientRef[C]
27+
+?(recipient: Recipient, command: C): Future[R] = recipientRef(recipient) ? command
28+
+!(recipient: Recipient, command: C): Unit = recipientRef(recipient) ! command
29+
<<implicit>> key2Recipient[T](key: T): Recipient
30+
#lookup[T](key: T): Future[Option[Recipient]]
31+
+??[T](key: T, command: C): Future[R]
32+
+?![T](key: T, command: C): Unit
33+
+*?[T](keys: List[T], command: C): Future[List[R]]
34+
+*![T](keys: List[T], command: C): Unit
35+
}
36+
Retryable <|-- Patterns: <<bind>> <R -> T>
37+
abstract EntityPattern <C: Command, R: CommandResult> <<(T,orchid) trait>> extends Patterns{
38+
<<type>> Recipient = String
39+
}
40+
CommandTypeKey <|.. EntityPattern : <<self>>
41+
abstract SingletonPattern <C: Command, R: CommandResult> <<(T,orchid) trait>> extends Patterns
42+
class RecipientPattern {
43+
entityId: String
44+
ref(): EntityRef[C]
45+
}
46+
EntityPattern +-- RecipientPattern: <<implicit>>
3147
}
32-
abstract SingletonPattern <C: Command, R: CommandResult> <<(T,orchid) trait>> extends Patterns
33-
class RecipientPattern {
34-
entityId: String
35-
ref(): EntityRef[C]
36-
}
37-
EntityPattern +-- RecipientPattern: <<implicit>>
3848
}
3949
}
4050
@enduml

0 commit comments

Comments
 (0)