-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supporting #withTagger() of typed persistence.
- Loading branch information
1 parent
9427c33
commit 529ad05
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
api/src/main/scala/org/nullvector/TaggedEventAdapter.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.nullvector | ||
|
||
import akka.persistence.journal.Tagged | ||
import reactivemongo.api.bson.BSONDocument | ||
|
||
import scala.reflect.ClassTag | ||
|
||
class TaggedEventAdapter[E](adapter: EventAdapter[E], tags: Set[String]) | ||
(implicit ev: ClassTag[E]) extends EventAdapter[E] { | ||
|
||
override val manifest: String = adapter.manifest | ||
|
||
override def tags(payload: E): Set[String] = tags | ||
|
||
override def payloadToBson(payload: E): BSONDocument = payload match { | ||
case Tagged(realPayload, _) => adapter.toBson(realPayload) | ||
case _ => adapter.payloadToBson(payload) | ||
} | ||
|
||
override def bsonToPayload(doc: BSONDocument): E = adapter.bsonToPayload(doc) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters