mirror of
https://github.com/corda/corda.git
synced 2025-06-02 23:50:54 +00:00
[CORDA-3628] - Remove overloads for sendAll (#6078)
This commit is contained in:
parent
29a36c6b4f
commit
56067acd20
@ -333,7 +333,7 @@ abstract class FlowLogic<out T> {
|
|||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun sendAll(payload: Any, sessions: Set<FlowSession>, maySkipCheckpoint: Boolean = false) {
|
fun sendAll(payload: Any, sessions: Set<FlowSession>, maySkipCheckpoint: Boolean = false) {
|
||||||
val sessionToPayload = sessions.map { it to payload }.toMap()
|
val sessionToPayload = sessions.map { it to payload }.toMap()
|
||||||
return sendAll(sessionToPayload, maySkipCheckpoint)
|
return sendAllMap(sessionToPayload, maySkipCheckpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -348,7 +348,7 @@ abstract class FlowLogic<out T> {
|
|||||||
*/
|
*/
|
||||||
@Suspendable
|
@Suspendable
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun sendAll(payloadsPerSession: Map<FlowSession, Any>, maySkipCheckpoint: Boolean = false) {
|
fun sendAllMap(payloadsPerSession: Map<FlowSession, Any>, maySkipCheckpoint: Boolean = false) {
|
||||||
val request = FlowIORequest.Send(
|
val request = FlowIORequest.Send(
|
||||||
sessionToMessage = serializePayloads(payloadsPerSession)
|
sessionToMessage = serializePayloads(payloadsPerSession)
|
||||||
)
|
)
|
||||||
|
@ -272,7 +272,7 @@ In addition ``FlowLogic`` provides functions that can receive messages from mult
|
|||||||
* Receives from all ``FlowSession`` objects specified in the passed in list. The received types must be the same.
|
* Receives from all ``FlowSession`` objects specified in the passed in list. The received types must be the same.
|
||||||
* ``sendAll(payload: Any, sessions: Set<FlowSession>)``
|
* ``sendAll(payload: Any, sessions: Set<FlowSession>)``
|
||||||
* Sends the ``payload`` object to all the provided ``FlowSession``\s.
|
* Sends the ``payload`` object to all the provided ``FlowSession``\s.
|
||||||
* ``sendAll(payloadsPerSession: Map<FlowSession, Any>)``
|
* ``sendAllMap(payloadsPerSession: Map<FlowSession, Any>)``
|
||||||
* Sends a potentially different payload to each ``FlowSession``, as specified by the provided ``payloadsPerSession``.
|
* Sends a potentially different payload to each ``FlowSession``, as specified by the provided ``payloadsPerSession``.
|
||||||
|
|
||||||
.. note:: It's more efficient to call ``sendAndReceive`` instead of calling ``send`` and then ``receive``. It's also more efficient to call ``sendAll``/``receiveAll`` instead of multiple ``send``/``receive`` respectively.
|
.. note:: It's more efficient to call ``sendAndReceive`` instead of calling ``send`` and then ``receive``. It's also more efficient to call ``sendAll``/``receiveAll`` instead of multiple ``send``/``receive`` respectively.
|
||||||
|
@ -91,7 +91,7 @@ interface MessagingService : ServiceLifecycleSupport {
|
|||||||
* @param addressedMessages The list of messages together with the recipients, retry ids and sequence keys.
|
* @param addressedMessages The list of messages together with the recipients, retry ids and sequence keys.
|
||||||
*/
|
*/
|
||||||
@Suspendable
|
@Suspendable
|
||||||
fun send(addressedMessages: List<AddressedMessage>)
|
fun sendAll(addressedMessages: List<AddressedMessage>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an initialised [Message] with the current time, etc, already filled in.
|
* Returns an initialised [Message] with the current time, etc, already filled in.
|
||||||
|
@ -54,7 +54,7 @@ class MessagingExecutor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun send(messages: Map<MessageRecipients, Message>) {
|
fun sendAll(messages: Map<MessageRecipients, Message>) {
|
||||||
messages.forEach { recipients, message -> send(message, recipients) }
|
messages.forEach { recipients, message -> send(message, recipients) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ class P2PMessagingClient(val config: NodeConfiguration,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun send(addressedMessages: List<MessagingService.AddressedMessage>) {
|
override fun sendAll(addressedMessages: List<MessagingService.AddressedMessage>) {
|
||||||
for ((message, target, sequenceKey) in addressedMessages) {
|
for ((message, target, sequenceKey) in addressedMessages) {
|
||||||
send(message, target, sequenceKey)
|
send(message, target, sequenceKey)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ class FlowMessagingImpl(val serviceHub: ServiceHubInternal): FlowMessaging {
|
|||||||
@Suspendable
|
@Suspendable
|
||||||
override fun sendSessionMessages(messageData: List<Message>) {
|
override fun sendSessionMessages(messageData: List<Message>) {
|
||||||
val addressedMessages = messageData.map { createMessage(it.destination, it.sessionMessage, it.dedupId) }
|
val addressedMessages = messageData.map { createMessage(it.destination, it.sessionMessage, it.dedupId) }
|
||||||
serviceHub.networkService.send(addressedMessages)
|
serviceHub.networkService.sendAll(addressedMessages)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createMessage(destination: Destination, message: SessionMessage, deduplicationId: SenderDeduplicationId): MessagingService.AddressedMessage {
|
private fun createMessage(destination: Destination, message: SessionMessage, deduplicationId: SenderDeduplicationId): MessagingService.AddressedMessage {
|
||||||
|
@ -165,7 +165,7 @@ class FlowParallelMessagingTests {
|
|||||||
Pair(session, messageType)
|
Pair(session, messageType)
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
|
||||||
sendAll(messagesPerSession)
|
sendAllMap(messagesPerSession)
|
||||||
val messages = receiveAll(String::class.java, messagesPerSession.keys.toList())
|
val messages = receiveAll(String::class.java, messagesPerSession.keys.toList())
|
||||||
|
|
||||||
messages.map { it.unwrap { payload -> assertEquals("pong", payload) } }
|
messages.map { it.unwrap { payload -> assertEquals("pong", payload) } }
|
||||||
|
@ -161,7 +161,7 @@ class MockNodeMessagingService(private val configuration: NodeConfiguration,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun send(addressedMessages: List<MessagingService.AddressedMessage>) {
|
override fun sendAll(addressedMessages: List<MessagingService.AddressedMessage>) {
|
||||||
for ((message, target, sequenceKey) in addressedMessages) {
|
for ((message, target, sequenceKey) in addressedMessages) {
|
||||||
send(message, target, sequenceKey)
|
send(message, target, sequenceKey)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user