Is it possible to provide storage plugins (for journaling and snapshotting) instantiated manually to persistent actors? (As opposed to referencing those that've been hard-coded by configuration.) In other words, rather than override journal and snapshot plugin ids. as described by Multiple persistence plugin configurations from the manual, I'd like to do this:
trait ActorWithOverridePlugins extends PersistentActor {
override def persistenceId = "123"
/* Not real. */
override def journalPlugin = new JournalPlugin()
/* Not real. */
override def snapshotPlugin = new SnapshotPlugin()
}
To briefly explain my use case, I'd like to write a parametrizable plugin that will store case classes transparently. It would be instantiated with implementations of whatever Reads and Writes (from Play Framework's JSON library) are appropriate for the case classes any particular persistent actor might handle.
Building on the previous example, it might look like this (with explicit types for clarity):
case class Event(timestamp:Long, message:String)
val format:Format[Event] = Json.format[Event]
trait EventsActor extends PersistentActor {
override def persistenceId = "events"
/* Not real. Also, should be a singleton. */
override def journalPlugin = new HypotheticalJournalPlugin[Event](format)
/* Not real. Also, should be a singleton. */
override def snapshotPlugin = new HypotheticalSnapshotPlugin[Event](format)
}
Writing a configuration for each and every type I might want to handle is doable, but verbose and painful.