Examples
The Rust SDK examples in the core repository, and how to start a server to run them against.
In the core repository, you can find the following examples using the Rust SDK.
Before running any of them, start the server with the default root credentials. Without the flag (or IGGY_ROOT_USERNAME/IGGY_ROOT_PASSWORD) root gets a generated password and every example fails with InvalidCredentials:
cargo run --bin iggy-server -- --fresh --with-default-root-credentialsThe examples are cargo example targets of the iggy_examples crate. Run them from the examples/rust directory with cargo run --example <name>. Partition IDs are 0-based: the examples send to and poll from partition 0.
-
Getting started - the basic example which is discussed in the getting started guide.
cargo run --example getting-started-producer cargo run --example getting-started-consumer -
Basic - producer and consumer using the low-level
Clienttrait with CLI args for transport selection (TCP/QUIC/HTTP/WebSocket).cargo run --example basic-producer cargo run --example basic-consumer -
New SDK - an introduction to the high-level SDK as discussed in the dedicated guide.
cargo run --example new-sdk-producer cargo run --example new-sdk-consumer -
Stream builder - examples using the
IggyStream,IggyStreamProducer, andIggyStreamConsumerbuilder APIs as discussed in the stream builder guide.cargo run --example stream-basic cargo run --example stream-producer cargo run --example stream-consumer cargo run --example stream-producer-config cargo run --example stream-consumer-config -
Message envelope - the example of how to send a message with a custom envelope e.g. to differentiate between different types of messages.
cargo run --example message-envelope-producer cargo run --example message-envelope-consumer -
Message headers - the example of how to send a message with custom headers (typed headers, message type discrimination, client-side compression).
cargo run --example message-headers-type-producer cargo run --example message-headers-type-consumer cargo run --example message-headers-compression-producer cargo run --example message-headers-compression-consumer cargo run --example typed-headers-producer cargo run --example typed-headers-consumer -
Multi-tenant - the larger example of how to structure your application to support multiple tenants (separated by the unique streams) with the different users, permissions, topics etc.
cargo run --example multi-tenant-producer cargo run --example multi-tenant-consumer -
TCP TLS - TLS-encrypted TCP connections with custom CA certificates.
cargo run --example tcp-tls-producer cargo run --example tcp-tls-consumer -
Sink data producer - generating random JSON records in bulk batches for sink connector testing.
cargo run --example sink-data-producer