add duplicating local filter for RSocketMagixEndpoint
This commit is contained in:
parent
039e0d083b
commit
df6defd637
@ -20,6 +20,7 @@ import kotlinx.serialization.encodeToString
|
||||
import ru.mipt.npm.magix.api.MagixEndpoint
|
||||
import ru.mipt.npm.magix.api.MagixMessage
|
||||
import ru.mipt.npm.magix.api.MagixMessageFilter
|
||||
import ru.mipt.npm.magix.api.filter
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.coroutines.coroutineContext
|
||||
|
||||
@ -38,7 +39,7 @@ public class RSocketMagixEndpoint<T>(
|
||||
val flow = rSocket.requestStream(payload)
|
||||
return flow.map {
|
||||
MagixEndpoint.magixJson.decodeFromString(serializer, it.data.readText())
|
||||
}.flowOn(coroutineContext[CoroutineDispatcher]?:Dispatchers.Unconfined)
|
||||
}.filter(filter).flowOn(coroutineContext[CoroutineDispatcher] ?: Dispatchers.Unconfined)
|
||||
}
|
||||
|
||||
override suspend fun broadcast(message: MagixMessage<T>) {
|
||||
|
@ -21,7 +21,7 @@ public class ZmqMagixEndpoint<T>(
|
||||
payloadSerializer: KSerializer<T>,
|
||||
private val pubPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PUB_PORT,
|
||||
private val pullPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PULL_PORT,
|
||||
private val coroutineContext: CoroutineContext = Dispatchers.IO
|
||||
private val coroutineContext: CoroutineContext = Dispatchers.IO,
|
||||
) : MagixEndpoint<T>, AutoCloseable {
|
||||
private val zmqContext by lazy { ZContext() }
|
||||
|
||||
@ -54,9 +54,8 @@ public class ZmqMagixEndpoint<T>(
|
||||
}
|
||||
}
|
||||
}
|
||||
}.filter(filter).flowOn(
|
||||
coroutineContext[CoroutineDispatcher] ?: Dispatchers.IO
|
||||
) //should be flown on IO because of blocking calls
|
||||
}.filter(filter).flowOn(coroutineContext[CoroutineDispatcher] ?: Dispatchers.IO)
|
||||
//should be flown on IO because of blocking calls
|
||||
}
|
||||
|
||||
private val publishSocket by lazy {
|
||||
|
Loading…
Reference in New Issue
Block a user