Add parameterless constructor to LevelDB journals (#22007)
* add parameterless constructor #22002 * add parameterless constructor #22002 * remove the filter in MiMa.scala #22002 * add LeveldbStore.emptyConfig to use default config #22002
This commit is contained in:
parent
ef1e0e01a2
commit
0eeced1732
4 changed files with 25 additions and 6 deletions
|
|
@ -20,9 +20,15 @@ import com.typesafe.config.Config
|
|||
*
|
||||
* Journal backed by a local LevelDB store. For production use.
|
||||
*/
|
||||
private[persistence] class LeveldbJournal(val config: Config) extends AsyncWriteJournal with LeveldbStore {
|
||||
private[persistence] class LeveldbJournal(cfg: Config) extends AsyncWriteJournal with LeveldbStore {
|
||||
import LeveldbJournal._
|
||||
|
||||
def this() = this(LeveldbStore.emptyConfig)
|
||||
|
||||
override def prepareConfig: Config =
|
||||
if (cfg ne LeveldbStore.emptyConfig) cfg
|
||||
else context.system.settings.config.getConfig("akka.persistence.journal.leveldb")
|
||||
|
||||
override def receivePluginInternal: Receive = {
|
||||
case r @ ReplayTaggedMessages(fromSequenceNr, toSequenceNr, max, tag, replyTo) ⇒
|
||||
import context.dispatcher
|
||||
|
|
|
|||
|
|
@ -6,25 +6,33 @@
|
|||
package akka.persistence.journal.leveldb
|
||||
|
||||
import java.io.File
|
||||
|
||||
import scala.collection.mutable
|
||||
import akka.actor._
|
||||
import akka.persistence._
|
||||
import akka.persistence.journal.WriteJournalBase
|
||||
import akka.serialization.SerializationExtension
|
||||
import org.iq80.leveldb._
|
||||
|
||||
import scala.collection.immutable
|
||||
import scala.util._
|
||||
import scala.concurrent.Future
|
||||
import scala.util.control.NonFatal
|
||||
import akka.persistence.journal.Tagged
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.{ Config, ConfigFactory }
|
||||
|
||||
private[persistence] object LeveldbStore {
|
||||
val emptyConfig = ConfigFactory.empty()
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL API.
|
||||
*/
|
||||
private[persistence] trait LeveldbStore extends Actor with WriteJournalBase with LeveldbIdMapping with LeveldbRecovery {
|
||||
|
||||
val config: Config
|
||||
def prepareConfig: Config
|
||||
|
||||
val config: Config = prepareConfig
|
||||
val nativeLeveldb = config.getBoolean("native")
|
||||
|
||||
val leveldbOptions = new Options().createIfMissing(true)
|
||||
|
|
|
|||
|
|
@ -18,10 +18,16 @@ import scala.concurrent.Future
|
|||
* set for each actor system that uses the store via `SharedLeveldbJournal.setStore`. The
|
||||
* shared LevelDB store is for testing only.
|
||||
*/
|
||||
class SharedLeveldbStore(cfg: Config) extends { override val config = cfg.getConfig("store") } with LeveldbStore {
|
||||
class SharedLeveldbStore(cfg: Config) extends LeveldbStore {
|
||||
import AsyncWriteTarget._
|
||||
import context.dispatcher
|
||||
|
||||
def this() = this(LeveldbStore.emptyConfig)
|
||||
|
||||
override def prepareConfig: Config =
|
||||
if (cfg ne LeveldbStore.emptyConfig) cfg.getConfig("store")
|
||||
else context.system.settings.config.getConfig("akka.persistence.journal.leveldb-shared.store")
|
||||
|
||||
def receive = {
|
||||
case WriteMessages(messages) ⇒
|
||||
// TODO it would be nice to DRY this with AsyncWriteJournal, but this is using
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue