!per #18463 Make Persistence Query API explorable
* make the standard queries "single method interfaces" that may be implemented by a query journal plugin * remove hints (major problems with varargs anyway), the hints for standard queries should be given in configuration instead, e.g. refresh-interval
This commit is contained in:
parent
a45f31cecb
commit
5bd245fbc8
46 changed files with 1487 additions and 948 deletions
|
|
@ -15,11 +15,9 @@ import scala.concurrent.duration._
|
|||
|
||||
class PersistenceQuerySpec extends WordSpecLike with Matchers with BeforeAndAfterAll {
|
||||
|
||||
val anything: Query[String, _] = null
|
||||
|
||||
val eventAdaptersConfig =
|
||||
s"""
|
||||
|akka.persistence.query.journal.mock {
|
||||
|akka.persistence.query.journal.dummy {
|
||||
| event-adapters {
|
||||
| adapt = ${classOf[PrefixStringWithPAdapter].getCanonicalName}
|
||||
| }
|
||||
|
|
@ -29,35 +27,25 @@ class PersistenceQuerySpec extends WordSpecLike with Matchers with BeforeAndAfte
|
|||
"ReadJournal" must {
|
||||
"be found by full config key" in {
|
||||
withActorSystem() { system ⇒
|
||||
PersistenceQuery.get(system).readJournalFor(MockReadJournal.Identifier)
|
||||
PersistenceQuery.get(system).readJournalFor[DummyReadJournal](DummyReadJournal.Identifier)
|
||||
}
|
||||
}
|
||||
|
||||
"throw if unable to find query journal by config key" in {
|
||||
withActorSystem() { system ⇒
|
||||
intercept[IllegalArgumentException] {
|
||||
PersistenceQuery.get(system).readJournalFor(MockReadJournal.Identifier + "-unknown")
|
||||
PersistenceQuery.get(system).readJournalFor[DummyReadJournal](DummyReadJournal.Identifier + "-unknown")
|
||||
}.getMessage should include("missing persistence read journal")
|
||||
}
|
||||
}
|
||||
|
||||
"expose scaladsl implemented journal as javadsl.ReadJournal" in {
|
||||
withActorSystem() { system ⇒
|
||||
val j: javadsl.ReadJournal = PersistenceQuery.get(system).getReadJournalFor(MockReadJournal.Identifier)
|
||||
}
|
||||
}
|
||||
"expose javadsl implemented journal as scaladsl.ReadJournal" in {
|
||||
withActorSystem() { system ⇒
|
||||
val j: scaladsl.ReadJournal = PersistenceQuery.get(system).readJournalFor(MockJavaReadJournal.Identifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val systemCounter = new AtomicInteger()
|
||||
private def withActorSystem(conf: String = "")(block: ActorSystem ⇒ Unit): Unit = {
|
||||
val config =
|
||||
MockReadJournal.config
|
||||
.withFallback(MockJavaReadJournal.config)
|
||||
DummyReadJournalProvider.config
|
||||
.withFallback(DummyJavaReadJournalProvider.config)
|
||||
.withFallback(ConfigFactory.parseString(conf))
|
||||
.withFallback(ConfigFactory.parseString(eventAdaptersConfig))
|
||||
.withFallback(ConfigFactory.load())
|
||||
|
|
@ -75,3 +63,4 @@ object ExampleQueryModels {
|
|||
class PrefixStringWithPAdapter extends ReadEventAdapter {
|
||||
override def fromJournal(event: Any, manifest: String) = EventSeq.single("p-" + event)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue