Module turmoil

Source
Expand description

Consensus and Blob implementations suitable for use with turmoil.

Both implementations function by forwarding calls to a server backend via turmoil::net::TcpStreams. The server backend keeps a simple in-memory state (implemented using MemConsensus and MemBlob, respectively), which it uses to respond to RPCs.

In a turmoil test, both the consensus and the blob server should be run as separate hosts. This gives turmoil the ability to partition and crash them independently, for the maximum amount of interesting interleaving.

use mz_persist::turmoil::{BlobState, ConsensusState, serve_blob, serve_consensus};

let mut sim = turmoil::Builder::new().build();

sim.host("consensus", {
    let state = ConsensusState::new();
    move || serve_consensus(7000, state.clone())
});

sim.host("blob", {
    let state = BlobState::new();
    move || serve_blob(7000, state.clone())
});

To connect to these servers, use the following PersistLocation:

โ“˜
PersistLocation {
    blob_uri: "turmoil://blob:7000".parse().unwrap(),
    consensus_uri: "turmoil://consensus:7000".parse().unwrap(),
}

Structsยง

BlobConfig
Configuration for a TurmoilBlob.
BlobState
State of a turmoil blob server.
ConsensusConfig
Configuration for a TurmoilConsensus.
ConsensusState
State of a turmoil consensus server.
TurmoilBlob
A Blob implementation for use in turmoil tests.
TurmoilConsensus
A Consensus implementation for use in turmoil tests.

Enumsยง

BlobCommand ๐Ÿ”’
ConsensusCommand ๐Ÿ”’
RpcError ๐Ÿ”’
Serializable representation of ExternalError.

Constantsยง

RPC_TIMEOUT ๐Ÿ”’
Timeout for RPC calls.

Functionsยง

rpc_read ๐Ÿ”’
Read an RPC message from the given connection.
rpc_write ๐Ÿ”’
Write an RPC message to the given connection.
serve_blob
Run a turmoil blob server.
serve_blob_connection ๐Ÿ”’
serve_consensus
Run a turmoil consensus server.
serve_consensus_connection ๐Ÿ”’