core.testing / InMemoryMessagingNetwork

# InMemoryMessagingNetwork

`class InMemoryMessagingNetwork`

An in-memory network allows you to manufacture InMemoryMessagings for a set of participants. Each InMemoryMessaging maintains a queue of messages it has received, and a background thread that dispatches messages one by one to registered handlers. Alternatively, a messaging system may be manually pumped, in which case no thread is created and a caller is expected to force delivery one at a time (this is useful for unit testing).

### Types

Builder | `inner class Builder : MessagingServiceBuilder<InMemoryMessaging>`
Handle | `class Handle : SingleMessageRecipient`
InMemoryMessaging | `inner class InMemoryMessaging : MessagingService` An InMemoryMessaging provides a MessagingService that isnt backed by any kind of network or disk storage system, but just uses regular queues on the heap instead. It is intended for unit testing and developer convenience when all entities on the network are being simulated in-process.
LatencyCalculator | `interface LatencyCalculator`

### Constructors

<init>

`InMemoryMessagingNetwork()`

An in-memory network allows you to manufacture InMemoryMessagings for a set of participants. Each InMemoryMessaging maintains a queue of messages it has received, and a background thread that dispatches messages one by one to registered handlers. Alternatively, a messaging system may be manually pumped, in which case no thread is created and a caller is expected to force delivery one at a time (this is useful for unit testing).

### Properties

allMessages | `val allMessages: <ERROR CLASS><<ERROR CLASS><SingleMessageRecipient, Message, MessageRecipients>>` A stream of (sender, message, recipients) triples
endpoints | `val endpoints: List<InMemoryMessaging>`
everyoneOnline | `val everyoneOnline: AllPossibleRecipients`
latencyCalculator | `var latencyCalculator: LatencyCalculator?` This can be set to an object which can inject artificial latency between sender/recipient pairs.

### Functions

createNode | `fun createNode(manuallyPumped: Boolean): <ERROR CLASS><Handle, MessagingServiceBuilder<InMemoryMessaging>>` Creates a node and returns the new object that identifies its location on the network to senders, and the InMemoryMessaging that the recipient/in-memory node uses to receive messages and send messages itself.
createNodeWithID | `fun createNodeWithID(manuallyPumped: Boolean, id: Int): MessagingServiceBuilder<InMemoryMessaging>` Creates a node at the given address: useful if you want to recreate a node to simulate a restart
setupTimestampingNode | `fun setupTimestampingNode(manuallyPumped: Boolean): <ERROR CLASS><NodeInfo, InMemoryMessaging>`
stop | `fun stop(): Unit`