=per #18288 Add docs of leveldb queries

This commit is contained in:
Patrik Nordwall 2015-08-21 11:35:51 +02:00
parent dfba334fda
commit fed622eb9f
17 changed files with 683 additions and 30 deletions

View file

@ -88,6 +88,8 @@ private[persistence] object LeveldbJournal {
* Subscribe the `sender` to changes (appended events) for a specific `tag`.
* Used by query-side. The journal will send [[TaggedEventAppended]] messages to
* the subscriber when `asyncWriteMessages` has been called.
* Events are tagged by wrapping in [[akka.persistence.journal.leveldb.Tagged]]
* via an [[akka.persistence.journal.EventAdapter]].
*/
final case class SubscribeTag(tag: String) extends SubscriptionCommand
final case class TaggedEventAppended(tag: String) extends DeadLetterSuppression

View file

@ -63,6 +63,9 @@ private[persistence] trait LeveldbStore extends Actor with WriteJournalBase with
}
if (tags.nonEmpty && hasTagSubscribers)
allTags ++= tags
require(!p2.persistenceId.startsWith(tagPersistenceIdPrefix),
s"persistenceId [${p.persistenceId}] must not start with $tagPersistenceIdPrefix")
addToMessageBatch(p2, tags, batch)
}
if (hasPersistenceIdSubscribers)

View file

@ -3,6 +3,9 @@
*/
package akka.persistence.journal.leveldb
import java.util.ArrayList
import scala.collection.JavaConverters._
/**
* The LevelDB journal supports tagging of events that are used
* by the `EventsByTag` query. To specify the tags you create an
@ -11,4 +14,12 @@ package akka.persistence.journal.leveldb
*
* The journal will unwrap the event and store the `payload`.
*/
case class Tagged(payload: Any, tags: Set[String])
case class Tagged(payload: Any, tags: Set[String]) {
/**
* Java API
*/
def this(payload: Any, tags: java.util.Set[String]) = {
this(payload, tags.asScala.toSet)
}
}