All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.http4k.tracing.persistence.inmemory.kt Maven / Gradle / Ivy

The newest version!
package org.http4k.tracing.persistence

import org.http4k.core.Uri
import org.http4k.tracing.ScenarioTraces
import org.http4k.tracing.TracePersistence
import org.http4k.tracing.TraceRender
import org.http4k.tracing.TraceRenderPersistence

fun TracePersistence.Companion.InMemory() = object : TracePersistence {
    private val list = mutableListOf()
    override fun store(trace: ScenarioTraces) {
        list += trace
    }

    override fun load() = list
}

interface IterableTraceRenderPersistence : TraceRenderPersistence, Iterable

fun TraceRenderPersistence.Companion.InMemory() = object : IterableTraceRenderPersistence {
    private val renders = mutableListOf()

    override fun invoke(render: TraceRender): Uri? {
        renders += render
        return null
    }

    override fun iterator() = renders.iterator()
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy