TagResolver

zio.blocks.projection.TagResolver
See theTagResolver companion trait
object TagResolver

Works out the tags of an event type and the aliases left behind by renamed cases. It reads the current tags from Schema[E], and the old ones from the RenameCase actions of an optional Migration[E, E].

Without a migration there are no aliases. With one, each renamed case becomes an alias, so old events can still be read and queried. The names are used exactly as written in the migration.

val migration: Migration[UserEvent, UserEvent] =
 Migration.newBuilder[UserEvent, UserEvent]
   .renameCase("UserCreated", "UserRegistered")
   .build

val info = TagResolver.resolve[UserEvent](migration)
// info.aliases == Map("UserCreated" -> "UserRegistered")

The event stores call these functions when they are created, so applications normally only pass a migration and do not call them directly.

Attributes

Companion
trait
Source
TagResolver.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def aliasMap[E](migration: Migration[E, E]): Map[String, String]

The old-to-current aliases of a migration, with chains of renames followed: if A was renamed to B and B to C, then A maps to C. A cycle of renames stops instead of looping.

The old-to-current aliases of a migration, with chains of renames followed: if A was renamed to B and B to C, then A maps to C. A cycle of renames stops instead of looping.

Attributes

Source
TagResolver.scala
def aliasMapFromDynamic(dm: DynamicMigration): Map[String, String]

Reads the RenameCase actions of a migration into a map from the old name to the new one. Other actions are ignored. If one old name is renamed more than once, the last rename wins. Chains are not followed here, see aliasMap.

Reads the RenameCase actions of a migration into a map from the old name to the new one. Other actions are ignored. If one old name is renamed more than once, the last rename wins. Chains are not followed here, see aliasMap.

Attributes

Source
TagResolver.scala
def aliases[E : Schema](migration: Migration[E, E] = ...): Map[String, String]

The old-to-current tag aliases of the given migration. Pass null for no migration, which is the default.

The old-to-current tag aliases of the given migration. Pass null for no migration, which is the default.

Attributes

Source
TagResolver.scala
def allTags[E : Schema](migration: Migration[E, E] = ...): Set[String]

All tags of E, current and old. Pass null for no migration, which is the default.

All tags of E, current and old. Pass null for no migration, which is the default.

Attributes

Source
TagResolver.scala
def currentTags[E](using schema: Schema[E]): Set[String]

The tags that events of type E are stored under now.

The tags that events of type E are stored under now.

For a sealed event type there is one tag per case: the number from its @eventTag, or the case name if it has none. For a single, non-sealed type the tag is its @eventTag number or its type name, and there is none if the name is empty, Object or Any.

Attributes

Source
TagResolver.scala
def resolve[E : Schema](migration: Migration[E, E]): TagInfo

Builds a TagInfo with the aliases of the given migration.

Builds a TagInfo with the aliases of the given migration.

Attributes

Source
TagResolver.scala
def resolve[E : Schema]: TagInfo

Builds a TagInfo with no aliases, for an event type never renamed.

Builds a TagInfo with no aliases, for an event type never renamed.

Attributes

Source
TagResolver.scala
inline def resolveAuto[E](using schema: Schema[E]): TagInfo

Builds a TagInfo, using a Migration[E, E] if a given instance is available and none otherwise. It is Scala 3 only, and resolves the instance at the call site.

Builds a TagInfo, using a Migration[E, E] if a given instance is available and none otherwise. It is Scala 3 only, and resolves the instance at the call site.

Attributes

Source
TagResolver.scala
def resolveImplicit[E](implicit evidence$1: Schema[E], migration: Migration[E, E] = ...): TagInfo

Builds a TagInfo, using a Migration[E, E] if one is in implicit scope and none otherwise. This form also works in Scala 2.

Builds a TagInfo, using a Migration[E, E] if one is in implicit scope and none otherwise. This form also works in Scala 2.

Attributes

Source
TagResolver.scala
def resolveOpt[E](opt: Option[Migration[E, E]])(using schema: Schema[E]): TagInfo

Builds a TagInfo from Schema[E] and an optional migration. This is the function the others call.

Builds a TagInfo from Schema[E] and an optional migration. This is the function the others call.

Chains of renames are followed, so if A was renamed to B and B to C, then A maps to C.

Attributes

Source
TagResolver.scala
def unknownTags(tagInfo: TagInfo, distinctDbTags: Set[String]): Set[String]

The tags found in the store that tagInfo does not know about. The same as TagInfo.unknownTags.

The tags found in the store that tagInfo does not know about. The same as TagInfo.unknownTags.

Attributes

Source
TagResolver.scala