!per #18050 Make event adapter lookup more efficient
This commit is contained in:
parent
a22b3be9da
commit
b3fedb4cf8
3 changed files with 15 additions and 14 deletions
|
|
@ -16,8 +16,10 @@ import scala.collection.mutable.ArrayBuffer
|
|||
import scala.reflect.ClassTag
|
||||
import scala.util.Try
|
||||
|
||||
/** INTERNAL API */
|
||||
private[akka] class EventAdapters(
|
||||
/**
|
||||
* `EventAdapters` serves as a per-journal collection of bound event adapters.
|
||||
*/
|
||||
class EventAdapters(
|
||||
map: ConcurrentHashMap[Class[_], EventAdapter],
|
||||
bindings: immutable.Seq[(Class[_], EventAdapter)],
|
||||
log: LoggingAdapter) {
|
||||
|
|
@ -62,7 +64,10 @@ private[akka] object EventAdapters {
|
|||
def apply(system: ExtendedActorSystem, config: Config): EventAdapters = {
|
||||
val adapters = configToMap(config, "event-adapters")
|
||||
val adapterBindings = configToListMap(config, "event-adapter-bindings")
|
||||
apply(system, adapters, adapterBindings)
|
||||
if (adapters.isEmpty && adapterBindings.isEmpty)
|
||||
IdentityEventAdapters
|
||||
else
|
||||
apply(system, adapters, adapterBindings)
|
||||
}
|
||||
|
||||
private def apply(
|
||||
|
|
@ -165,4 +170,4 @@ private[akka] object EventAdapters {
|
|||
private[akka] case object IdentityEventAdapters extends EventAdapters(null, null, null) {
|
||||
override def get(clazz: Class[_]): EventAdapter = IdentityEventAdapter
|
||||
override def toString = Logging.simpleName(IdentityEventAdapters)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ import akka.persistence.AtomicWrite
|
|||
private[akka] trait WriteJournalBase {
|
||||
this: Actor ⇒
|
||||
|
||||
lazy val persistence = Persistence(context.system)
|
||||
private def eventAdapters = persistence.adaptersFor(self)
|
||||
val persistence = Persistence(context.system)
|
||||
private val eventAdapters = persistence.adaptersFor(self)
|
||||
|
||||
protected def preparePersistentBatch(rb: immutable.Seq[PersistentEnvelope]): immutable.Seq[AtomicWrite] =
|
||||
rb.collect { // collect instead of flatMap to avoid Some allocations
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue