Add ZMQ context customization
This commit is contained in:
parent
6f5270ee37
commit
405bcd6ba3
@ -20,8 +20,9 @@ public class ZmqMagixEndpoint(
|
|||||||
private val pubPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PUB_PORT,
|
private val pubPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PUB_PORT,
|
||||||
private val pullPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PULL_PORT,
|
private val pullPort: Int = MagixEndpoint.DEFAULT_MAGIX_ZMQ_PULL_PORT,
|
||||||
private val coroutineContext: CoroutineContext = Dispatchers.IO,
|
private val coroutineContext: CoroutineContext = Dispatchers.IO,
|
||||||
|
private val zmqContext: ZContext = ZContext()
|
||||||
|
|
||||||
) : MagixEndpoint, AutoCloseable {
|
) : MagixEndpoint, AutoCloseable {
|
||||||
private val zmqContext by lazy { ZContext() }
|
|
||||||
|
|
||||||
override fun subscribe(filter: MagixMessageFilter): Flow<MagixMessage> {
|
override fun subscribe(filter: MagixMessageFilter): Flow<MagixMessage> {
|
||||||
val socket = zmqContext.createSocket(SocketType.SUB)
|
val socket = zmqContext.createSocket(SocketType.SUB)
|
||||||
|
@ -24,8 +24,7 @@ public class ZmqMagixFlowPlugin(
|
|||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
receive: Flow<MagixMessage>,
|
receive: Flow<MagixMessage>,
|
||||||
sendMessage: suspend (MagixMessage) -> Unit,
|
sendMessage: suspend (MagixMessage) -> Unit,
|
||||||
): Job =
|
): Job = scope.launch(Dispatchers.IO) {
|
||||||
scope.launch(Dispatchers.IO) {
|
|
||||||
val logger = LoggerFactory.getLogger("magix-server-zmq")
|
val logger = LoggerFactory.getLogger("magix-server-zmq")
|
||||||
|
|
||||||
ZContext().use { context ->
|
ZContext().use { context ->
|
||||||
|
Loading…
Reference in New Issue
Block a user