akka.persistence.r2dbc.internal.EnvelopeOrigin.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of akka-persistence-r2dbc_3 Show documentation
Show all versions of akka-persistence-r2dbc_3 Show documentation
An Akka Persistence backed by SQL database with R2DBC
/*
* Copyright (C) 2022 - 2023 Lightbend Inc.
*/
package akka.persistence.r2dbc.internal
import akka.annotation.InternalStableApi
import akka.persistence.query.UpdatedDurableState
import akka.persistence.query.typed.EventEnvelope
/**
* INTERNAL API
*/
@InternalStableApi private[akka] object EnvelopeOrigin {
val SourceQuery = ""
val SourceBacktracking = "BT"
val SourcePubSub = "PS"
def fromQuery(env: EventEnvelope[_]): Boolean =
env.source == SourceQuery
def fromBacktracking(env: EventEnvelope[_]): Boolean =
env.source == SourceBacktracking
def fromBacktracking(change: UpdatedDurableState[_]): Boolean =
change.value == null
def fromPubSub(env: EventEnvelope[_]): Boolean =
env.source == SourcePubSub
def isFilteredEvent(env: Any): Boolean =
env match {
case e: EventEnvelope[_] => e.filtered
case _ => false
}
}