@@ -42,12 +42,20 @@ sealed trait ResourceBehavior
4242 */
4343 override protected def tagEvent (entityId : String , event : ResourceEvent ): Set [String ] = {
4444 event match {
45+ case _ : SessionResourceEvent =>
46+ Set (
47+ s " ${persistenceId.toLowerCase}-to-session "
48+ )
4549 case _ =>
4650 Set (
4751 persistenceId,
4852 s " ${persistenceId.toLowerCase}-to-localfilesystem " ,
4953 s " ${persistenceId.toLowerCase}-to-s3 " ,
50- s " ${persistenceId.toLowerCase}-to-gcs "
54+ s " ${persistenceId.toLowerCase}-to-gcs " ,
55+ s " ${persistenceId.toLowerCase}-to-azure " ,
56+ s " ${persistenceId.toLowerCase}-to-minio " ,
57+ s " ${persistenceId.toLowerCase}-to-db " , // database storage (Cassandra, Postgres, MySQL...)
58+ s " ${persistenceId.toLowerCase}-to-redis " // redis storage
5159 )
5260 }
5361 }
@@ -77,13 +85,20 @@ sealed trait ResourceBehavior
7785 case cmd : CreateResource =>
7886 import cmd ._
7987 val createdDate = Instant .now()
88+ val sessionId = if (uuid.contains('#' )) uuid.split('#' ).headOption else None
89+ val sessionEvent = sessionId.map(sid =>
90+ SessionResourceCreatedEvent .defaultInstance
91+ .withUuid(uuid)
92+ .withSessionId(sid)
93+ .copy(uri = uri)
94+ )
8095 Effect
8196 .persist(
8297 ResourceCreatedEvent (
8398 asResource(uuid, bytes, uri)
8499 .withCreatedDate(createdDate)
85100 .withLastUpdated(createdDate)
86- )
101+ ) +: sessionEvent.toList
87102 )
88103 .thenRun(_ => { ResourceCreated ~> replyTo })
89104
@@ -96,13 +111,20 @@ sealed trait ResourceBehavior
96111 case None => Instant .now()
97112 }
98113 }
114+ val sessionId = if (uuid.contains('#' )) uuid.split('#' ).headOption else None
115+ val sessionEvent = sessionId.map(sid =>
116+ SessionResourceUpdatedEvent .defaultInstance
117+ .withUuid(uuid)
118+ .withSessionId(sid)
119+ .copy(uri = uri)
120+ )
99121 Effect
100122 .persist(
101123 ResourceUpdatedEvent (
102124 asResource(uuid, bytes, uri)
103125 .withCreatedDate(createdDate)
104126 .withLastUpdated(lastUpdated)
105- )
127+ ) +: sessionEvent.toList
106128 )
107129 .thenRun(_ => { ResourceUpdated ~> replyTo })
108130
@@ -120,11 +142,15 @@ sealed trait ResourceBehavior
120142 case Some (uri) => s " $uri/ $entityId"
121143 case _ => entityId
122144 }
145+ val sessionId = if (uuid.contains('#' )) uuid.split('#' ).headOption else None
146+ val sessionEvent = sessionId.map(sid =>
147+ SessionResourceDeletedEvent .defaultInstance.withUuid(uuid).withSessionId(sid)
148+ )
123149 Effect
124150 .persist[ResourceEvent , Option [Resource ]](
125151 ResourceDeletedEvent (
126152 uuid
127- )
153+ ) +: sessionEvent.toList
128154 )
129155 .thenRun(_ => {
130156 ResourceDeleted ~> replyTo
0 commit comments