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

com.lightningkite.lightningserver.pubsub.PubSub.kt Maven / Gradle / Ivy

The newest version!
package com.lightningkite.lightningserver.pubsub

import com.lightningkite.lightningserver.core.Disconnectable
import com.lightningkite.lightningserver.serialization.Serialization
import com.lightningkite.lightningserver.serverhealth.HealthCheckable
import com.lightningkite.lightningserver.serverhealth.HealthStatus
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.serialization.KSerializer
import kotlinx.serialization.serializer

@Deprecated("Renamed to just 'PubSub'", ReplaceWith("PubSub", "com.lightningkite.lightningserver.pubsub.PubSub"))
typealias PubSubInterface = PubSub

interface PubSub : HealthCheckable, Disconnectable {
    fun  get(key: String, serializer: KSerializer): PubSubChannel
    fun string(key: String): PubSubChannel
    override suspend fun healthCheck(): HealthStatus {
        return try {
            get("health-check-test-key").emit(true)
            HealthStatus(HealthStatus.Level.OK)
        } catch (e: Exception) {
            HealthStatus(HealthStatus.Level.ERROR, additionalMessage = e.message)
        }
    }
}

inline operator fun  PubSub.get(key: String): PubSubChannel {
    return get(key, Serialization.Internal.json.serializersModule.serializer())
}

interface PubSubChannel : Flow, FlowCollector {}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy