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

xtdb.api.log.FileListCache.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0-beta4
Show newest version
package xtdb.api.log

import java.util.concurrent.CompletableFuture

interface FileListCache {
    fun appendFileNotification(notification: Notification): CompletableFuture
    fun subscribeFileNotifications(subscriber: Subscriber)

    interface Notification

    interface Subscriber {
        fun onSubscribe(closeHook: AutoCloseable)
        fun accept(record: Notification)
    }

    companion object {
        @JvmField
        val SOLO = object : FileListCache {
            private var sub: Subscriber? = null

            override fun appendFileNotification(notification: Notification): CompletableFuture {
                sub?.accept(notification)
                return CompletableFuture.completedFuture(Unit)
            }

            override fun subscribeFileNotifications(subscriber: Subscriber) {
                sub = subscriber
                subscriber.onSubscribe { sub = null }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy