Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+str akka#17579 akka#17617 Initial step for ModelAdapter
+ per plugin scoped adapters + could be swapped during runtime - todo not happy yet with initialization (message)? + adapters work both ways + tests show "tagging"
- Loading branch information
Showing
6 changed files
with
299 additions
and
23 deletions.
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
akka-persistence/src/main/scala/akka/persistence/journal/ModelAdapter.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,27 @@ | ||
/* | ||
* Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com> | ||
*/ | ||
|
||
package akka.persistence.journal | ||
|
||
import akka.actor.ActorSystem | ||
import akka.event.Logging | ||
|
||
trait ModelAdapter[JournalModel] { | ||
//#model-adapter-api | ||
def toJournal(event: Any): JournalModel | ||
|
||
def fromJournal(event: JournalModel): Any | ||
//#model-adapter-api | ||
} | ||
|
||
/** No-op model adapter which passes through the incoming events as-is. */ | ||
final class IdentityModelAdapter(val system: ActorSystem) extends ModelAdapter[Any] { | ||
val log = Logging(system, "hello") | ||
|
||
override def toJournal(event: Any): Any = { | ||
log.warning("Adapting event: {}", event) | ||
event | ||
} | ||
override def fromJournal(event: Any): Any = event | ||
} |
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
Oops, something went wrong.