Small wrapper that makes use the CloudEventConverter:
class GameEventQueries(private val eventStoreQueries: EventStoreQueries, private val cloudEventConverter: CloudEventConverter<GameEvent>) {
@Suppress("UNCHECKED_CAST")
fun <T : GameEvent> query(filter: Filter): Sequence<T> =
eventStoreQueries.queryForSequence(filter)
.map(cloudEventConverter::toDomainEvent)
.map { it as T }
fun <T : GameEvent> queryOne(filter: Filter): T = query<T>(filter).first()
}
Small wrapper that makes use the
CloudEventConverter
: