### Consumer Quick Start Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/node/intro.mdx Example demonstrating how to receive and process messages using the Iggy Node.js SDK. ```APIDOC ## Consumer Quick Start ### Description This example demonstrates how to initialize the Iggy client and poll for messages from a specific partition, then process the received messages. ### Method N/A (Client Initialization and Message Polling) ### Endpoint N/A (Direct TCP Communication) ### Parameters N/A for client initialization in this snippet. ### Request Example ```typescript import { Client, PollingStrategy, Consumer } from 'apache-iggy'; const client = new Client({ transport: 'TCP', options: { port: 8090, host: '127.0.0.1', }, credentials: { username: 'iggy', password: 'iggy', }, }); const STREAM_ID = 1; const TOPIC_ID = 1; const PARTITION_ID = 1; const polledMessages = await client.message.poll({ streamId: STREAM_ID, topicId: TOPIC_ID, consumer: Consumer.Single, partitionId: PARTITION_ID, pollingStrategy: PollingStrategy.Offset(BigInt(0)), count: 10, autocommit: false, }); if (polledMessages && polledMessages.messages.length > 0) { for (const message of polledMessages.messages) { const payload = message.payload.toString('utf8'); console.log(`Offset: ${message.headers.offset}, Payload: ${payload}`); } } ``` ### Response #### Success Response (200) - **polledMessages** (object) - An object containing the polled messages, including their offset, headers, and payload. #### Response Example ```json { "messages": [ { "id": 1, "offset": 0, "headers": {}, "payload": "message-1" } // ... more messages ] } ``` ``` -------------------------------- ### Java Consumer Example for Iggy SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/java/intro.mdx A quick start example illustrating how to set up a consumer using the Iggy Java SDK. It demonstrates connecting to the server, polling for messages from a specific stream and topic, and processing their payloads. ```java import org.apache.iggy.client.blocking.tcp.IggyTcpClient; import org.apache.iggy.consumergroup.Consumer; import org.apache.iggy.identifier.StreamId; import org.apache.iggy.identifier.TopicId; import org.apache.iggy.message.Message; import org.apache.iggy.message.PolledMessages; import org.apache.iggy.message.PollingStrategy; import java.math.BigInteger; import java.nio.charset.StandardCharsets; import java.util.Optional; public class SampleConsumer { static final StreamId STREAM_ID = StreamId.of("sample-stream"); static final TopicId TOPIC_ID = TopicId.of("sample-topic"); public static void main(String[] args) { try (var client = IggyTcpClient.builder() .host("localhost") .port(8090) .credentials("iggy", "iggy") .buildAndLogin()) { BigInteger offset = BigInteger.ZERO; Consumer consumer = Consumer.of(0L); while (true) { PolledMessages polledMessages = client.messages().pollMessages( STREAM_ID, TOPIC_ID, Optional.of(0L), consumer, PollingStrategy.offset(offset), 10L, false); if (polledMessages.messages().isEmpty()) { break; } for (Message msg : polledMessages.messages()) { String payload = new String(msg.payload(), StandardCharsets.UTF_8); System.out.printf("Offset: %d, Payload: %s%n", offset, payload); } offset = offset.add(BigInteger.valueOf(polledMessages.messages().size())); } } } } ``` -------------------------------- ### Producer Quick Start Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/node/intro.mdx Example demonstrating how to send messages using the Iggy Node.js SDK. ```APIDOC ## Producer Quick Start ### Description This example shows how to initialize the Iggy client and send a batch of messages to a specified stream, topic, and partition. ### Method N/A (Client Initialization and Message Sending) ### Endpoint N/A (Direct TCP Communication) ### Parameters N/A for client initialization in this snippet. ### Request Example ```typescript import { Client, Partitioning } from 'apache-iggy'; const client = new Client({ transport: 'TCP', options: { port: 8090, host: '127.0.0.1', }, credentials: { username: 'iggy', password: 'iggy', }, }); const messages = Array.from({ length: 10 }).map((_, i) => ({ id: i + 1, headers: [], payload: `message-${i + 1}`, })); await client.message.send({ streamId: 1, topicId: 1, messages, partition: Partitioning.PartitionId(1), }); ``` ### Response N/A (Asynchronous operation, success indicated by lack of error) ``` -------------------------------- ### Java Producer Example for Iggy SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/java/intro.mdx A quick start example demonstrating how to create a producer using the Iggy Java SDK. It shows how to connect to the Iggy server, create a stream and topic, and send messages. ```java import org.apache.iggy.client.blocking.tcp.IggyTcpClient; import org.apache.iggy.identifier.StreamId; import org.apache.iggy.identifier.TopicId; import org.apache.iggy.message.Message; import org.apache.iggy.message.Partitioning; import org.apache.iggy.topic.CompressionAlgorithm; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import static java.util.Optional.empty; public class Producer { static final String STREAM_NAME = "sample-stream"; static final StreamId STREAM_ID = StreamId.of(STREAM_NAME); static final String TOPIC_NAME = "sample-topic"; static final TopicId TOPIC_ID = TopicId.of(TOPIC_NAME); public static void main(String[] args) { try (var client = IggyTcpClient.builder() .host("localhost") .port(8090) .credentials("iggy", "iggy") .buildAndLogin()) { client.streams().createStream(STREAM_NAME); client.topics().createTopic( STREAM_ID, 1L, CompressionAlgorithm.None, BigInteger.ZERO, BigInteger.ZERO, empty(), TOPIC_NAME); Partitioning partitioning = Partitioning.partitionId(0L); for (int i = 0; i < 10; i++) { String payload = "message-" + i; client.messages().sendMessages( STREAM_ID, TOPIC_ID, partitioning, List.of(Message.of(payload))); } } } } ``` -------------------------------- ### Basic Producer Example Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/examples.mdx This example demonstrates how to create an Iggy client, connect, authenticate, create a stream and topic, and send messages. ```APIDOC ## Basic Producer ### Description This C# code snippet shows how to set up a basic producer using the Iggy client library. It covers client configuration, connection, authentication, stream and topic creation (with error handling for existing resources), and sending a batch of messages to a specific partition. ### Method N/A (Client-side code) ### Endpoint N/A (Client-side code) ### Parameters N/A (Client-side code) ### Request Example ```csharp // See the full code example in the description. // This section is illustrative and not a direct request body. var payload = Encoding.UTF8.GetBytes("Event #0"); var messages = new List { new Message(Guid.NewGuid(), payload) }; await client.SendMessagesAsync( Identifier.String(StreamName), Identifier.String(TopicName), partitioning, messages ); ``` ### Response #### Success Response (Console Output) - Messages sent confirmation. #### Response Example ``` Sent 100 messages ``` ``` -------------------------------- ### Iggy Client Setup and Connection (Rust) Source: https://github.com/apache/iggy-website/blob/main/content/docs/introduction/getting-started.mdx Illustrates the setup and connection process for the Iggy client in a Rust application. It initializes the client, establishes a connection to the Iggy server, and logs in using user credentials. This is the entry point for any Iggy client interaction, ensuring the client is ready to perform operations like consuming messages. ```rust use iggy::prelude::*; use std::error::Error; use std::time::Duration; use tokio::time::sleep; use tracing::info; const STREAM_NAME: &str = "sample-stream"; const TOPIC_NAME: &str = "sample-topic"; const PARTITION_ID: u32 = 1; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); let client = IggyClient::default(); client.connect().await?; client .login_user(DEFAULT_ROOT_USERNAME, DEFAULT_ROOT_PASSWORD) .await?; consume_messages(&client).await } async fn consume_messages(client: &IggyClient) -> Result<(), Box> { let interval = Duration::from_millis(500); info!( ``` -------------------------------- ### Basic Consumer Example Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/examples.mdx This example demonstrates how to create an Iggy client, connect, authenticate, and poll messages from a topic using a specific consumer and offset. ```APIDOC ## Basic Consumer ### Description This C# code snippet illustrates how to set up a basic consumer using the Iggy client library. It shows client setup, connection, authentication, and polling messages from a specified stream and topic using a consumer ID, offset, and batch size. It then iterates through the polled messages and prints their offset and payload. ### Method N/A (Client-side code) ### Endpoint N/A (Client-side code) ### Parameters N/A (Client-side code) ### Request Example ```csharp // See the full code example in the description. // This section is illustrative and not a direct request body. var polledMessages = await client.PollMessagesAsync( Identifier.String("dev"), Identifier.String("events"), 0, consumer, PollingStrategy.Offset(offset), messagesPerBatch, false ); ``` ### Response #### Success Response (Console Output) - For each message polled, its offset and payload are printed. #### Response Example ``` Offset: 0, Payload: Event #0 Offset: 1, Payload: Event #1 ... ``` ``` -------------------------------- ### C# SDK Installation Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/intro.mdx Install the Iggy C# SDK using the .NET CLI. ```APIDOC ## Installation ```bash dotnet add package Apache.Iggy ``` ``` -------------------------------- ### C# SDK Consumer Example Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/intro.mdx Example demonstrating how to use the C# SDK to consume messages from Iggy. ```APIDOC ## Quick start - Consumer ### Description This example shows how to create a consumer using the C# SDK to poll and process messages from a specified stream and topic. ### Method N/A (SDK Usage) ### Endpoint N/A (SDK Usage) ### Parameters N/A (SDK Usage) ### Request Example ```csharp using System.Text; using Apache.Iggy; using Apache.Iggy.Configuration; using Apache.Iggy.Contracts; using Apache.Iggy.Enums; using Apache.Iggy.Factory; using Apache.Iggy.Kinds; var client = IggyClientFactory.CreateClient(new IggyClientConfigurator() { BaseAddress = "127.0.0.1:8090", Protocol = Protocol.Tcp, }); await client.ConnectAsync(); await client.LoginUser("iggy", "iggy"); var consumer = Consumer.New(1); var offset = 0ul; uint messagesPerBatch = 10; while (true) { var polledMessages = await client.PollMessagesAsync( Identifier.String("sample-stream"), Identifier.String("sample-topic"), 0, consumer, PollingStrategy.Offset(offset), messagesPerBatch, false ); if (!polledMessages.Messages.Any()) break; offset += (ulong)polledMessages.Messages.Count; foreach (var message in polledMessages.Messages) { var payload = Encoding.UTF8.GetString(message.Payload); Console.WriteLine($"Offset: {message.Header.Offset}, Payload: {payload}"); } } ``` ### Response N/A (SDK Usage) ### Response Example N/A (SDK Usage) ``` -------------------------------- ### Install Iggy with Helm Charts Source: https://github.com/apache/iggy-website/blob/main/content/docs/server/docker.mdx This Helm command installs the Iggy application using the provided Helm charts. It assumes the charts are located in the `./helm/charts/iggy` directory within the current path. This is a quick start command for deploying Iggy to a Kubernetes cluster. ```bash helm install iggy ./helm/charts/iggy ``` -------------------------------- ### Configure Logging and Client Setup Source: https://github.com/apache/iggy-website/blob/main/content/docs/introduction/getting-started.mdx Initializes tracing for logging and sets up the Iggy client connection and authentication flow. ```rust use std::error::Error; use iggy::prelude::*; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); let client = IggyClient::default(); client.connect().await?; client .login_user(DEFAULT_ROOT_USERNAME, DEFAULT_ROOT_PASSWORD) .await?; Ok(()) } ``` -------------------------------- ### Full Consumer Application Example Source: https://github.com/apache/iggy-website/blob/main/content/docs/introduction/getting-started.mdx A complete Rust application demonstrating how to connect to Iggy, authenticate, and continuously consume messages from a stream. ```APIDOC ## Iggy Consumer Application ### Description This code provides a full example of a Rust consumer application that connects to an Iggy server, logs in, and continuously polls for messages from a specified stream and topic. ### Language Rust ### Code Example ```rust use iggy::prelude::*; use std::error::Error; use std::time::Duration; use tokio::time::sleep; use tracing::info; const STREAM_NAME: &str = "sample-stream"; const TOPIC_NAME: &str = "sample-topic"; const PARTITION_ID: u32 = 1; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); let client = IggyClient::default(); client.connect().await?; client .login_user(DEFAULT_ROOT_USERNAME, DEFAULT_ROOT_PASSWORD) .await?; consume_messages(&client).await } async fn consume_messages(client: &IggyClient) -> Result<(), Box> { let interval = Duration::from_millis(500); let mut offset = 0; let messages_per_batch = 10; let consumer = Consumer::default(); loop { let polled_messages = client .poll_messages( &STREAM_NAME.try_into()?, &TOPIC_NAME.try_into()?, Some(PARTITION_ID), &consumer, &PollingStrategy::offset(offset), messages_per_batch, false, ) .await?; if polled_messages.messages.is_empty() { info!("No messages found."); sleep(interval).await; continue; } offset += polled_messages.messages.len() as u64; for message in polled_messages.messages { // Process each message, e.g., handle_message(&message)?; info!("Received message: ID - {}, Offset - {}, Payload - {:?}", message.id, message.offset, std::str::from_utf8(&message.payload)); } sleep(interval).await; } } // Placeholder for message handling logic // fn handle_message(message: &Message) -> Result<(), Box> { // // Your message processing logic here // Ok(()) // } ``` ``` -------------------------------- ### C# SDK Producer Example Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/intro.mdx Example demonstrating how to use the C# SDK to produce messages to Iggy. ```APIDOC ## Quick start - Producer ### Description This example shows how to create a producer using the C# SDK to send messages to a specified stream and topic. ### Method N/A (SDK Usage) ### Endpoint N/A (SDK Usage) ### Parameters N/A (SDK Usage) ### Request Example ```csharp using System.Text; using Apache.Iggy; using Apache.Iggy.Configuration; using Apache.Iggy.Enums; using Apache.Iggy.Factory; using Apache.Iggy.Kinds; using Apache.Iggy.Messages; const string StreamName = "sample-stream"; const string TopicName = "sample-topic"; var client = IggyClientFactory.CreateClient(new IggyClientConfigurator() { BaseAddress = "127.0.0.1:8090", Protocol = Protocol.Tcp, }); await client.ConnectAsync(); await client.LoginUser("iggy", "iggy"); await client.CreateStreamAsync(StreamName); await client.CreateTopicAsync( Identifier.String(StreamName), TopicName, 1, CompressionAlgorithm.None ); var partitioning = Partitioning.PartitionId(0); for (int i = 0; i < 10; i++) { var payload = Encoding.UTF8.GetBytes($"message-{i}"); var messages = new List { new Message(Guid.NewGuid(), payload) }; await client.SendMessagesAsync( Identifier.String(StreamName), Identifier.String(TopicName), partitioning, messages ); } ``` ### Response N/A (SDK Usage) ### Response Example N/A (SDK Usage) ``` -------------------------------- ### Quick Iggy Rust SDK Example Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/rust/intro.mdx A comprehensive example demonstrating the Iggy Rust SDK's high-level API. It covers connecting to the server, creating a stream and topic, sending messages, and polling for received messages with offset and payload details. ```rust use iggy::prelude::*; #[tokio::main] async fn main() -> Result<(), Box> { let client = IggyClient::from_connection_string("iggy://iggy:iggy@localhost:8090")?; client.connect().await?; // Create stream and topic client.create_stream("my-stream").await?; client.create_topic( &"my-stream".try_into()?, "my-topic", 2, CompressionAlgorithm::None, None, IggyExpiry::NeverExpire, MaxTopicSize::ServerDefault, ).await?; // Send a message let msg = IggyMessage::from_str("hello world")?; client.send_messages( &"my-stream".try_into()?, &"my-topic".try_into()?, &Partitioning::balanced(), &mut [msg], ).await?; // Poll messages let polled = client.poll_messages( &"my-stream".try_into()?, &"my-topic".try_into()?, Some(1), &Consumer::default(), &PollingStrategy::offset(0), 10, false, ).await?; for message in &polled.messages { let payload = std::str::from_utf8(&message.payload)?; println!("Offset: {}, Payload: {}", message.header.offset, payload); } Ok(()) } ``` -------------------------------- ### Install Iggy Go SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/go/intro.mdx Command to install the Iggy Go SDK dependency using the Go package manager. ```bash go get github.com/apache/iggy/foreign/go ``` -------------------------------- ### Install Iggy Python SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/python/intro.mdx Installs the Iggy Python SDK using pip. This is the first step to using the client library in your Python applications. ```bash pip install apache-iggy ``` -------------------------------- ### Initialize Iggy Streams and Topics via CLI Source: https://github.com/apache/iggy-website/blob/main/content/docs/connectors/introduction.mdx Commands to create the necessary streams and topics for the Iggy connector examples using the Iggy CLI tool. ```bash iggy --username iggy --password iggy stream create example_stream iggy --username iggy --password iggy topic create example_stream example_topic 1 none 1d iggy --username iggy --password iggy stream create qw iggy --username iggy --password iggy topic create qw records 1 none 1d ``` -------------------------------- ### Install Apache Iggy C# SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/intro.mdx Command to add the Apache Iggy package to a .NET project using the dotnet CLI. ```bash dotnet add package Apache.Iggy ``` -------------------------------- ### Install Iggy Node.js SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/node/intro.mdx Installs the Iggy Node.js SDK using npm. This package provides the client library for interacting with the Iggy API. ```bash npm install apache-iggy ``` -------------------------------- ### Configure Sink Connector via TOML Source: https://github.com/apache/iggy-website/blob/main/content/docs/connectors/sinks/sink.mdx Example TOML configuration for a sink connector, defining stream subscriptions, batching parameters, and custom plugin settings. ```toml type = "sink" key = "stdout" enabled = true version = 0 name = "Stdout sink" path = "target/release/libiggy_connector_stdout_sink" plugin_config_format = "toml" [[streams]] stream = "example_stream" topics = ["example_topic"] schema = "json" batch_length = 100 poll_interval = "5ms" consumer_group = "stdout_sink_connector" [plugin_config] print_payload = true ``` -------------------------------- ### Run Iggy Server with Docker Compose Source: https://github.com/apache/iggy-website/blob/main/content/docs/introduction/about.mdx Builds and starts the Iggy server using Docker Compose, setting up necessary configurations for optimal performance. ```yaml docker compose up ``` -------------------------------- ### Iggy Server Configuration: TOML Source: https://context7.com/apache/iggy-website/llms.txt Example TOML file illustrating key server configuration sections including TCP, QUIC, HTTP, WebSocket, and system settings like segment size and memory pool. ```toml # config.toml - Key configuration sections [tcp] enabled = true address = "127.0.0.1:8090" socket_migration = true [tcp.tls] enabled = false cert_file = "certs/iggy_cert.pem" key_file = "certs/iggy_key.pem" [quic] enabled = true address = "127.0.0.1:8080" max_concurrent_bidi_streams = 10_000 [http] enabled = true address = "127.0.0.1:3000" web_ui = false [http.jwt] algorithm = "HS256" access_token_expiry = "1 h" [websocket] enabled = true address = "127.0.0.1:8092" [system] path = "local_data" [system.segment] size = "1 GiB" cache_indexes = "open_segment" [system.partition] enforce_fsync = false messages_required_to_save = 1024 size_of_messages_required_to_save = "1 MiB" [system.memory_pool] enabled = true size = "4 GiB" bucket_capacity = 8192 [system.sharding] cpu_allocation = "numa:auto" # or "all", "4", "5..8" [message_saver] enabled = true enforce_fsync = true interval = "30 s" ``` -------------------------------- ### Configure Iggy Runtime and Protobuf Connectors Source: https://github.com/apache/iggy-website/blob/main/content/docs/connectors/sdk.mdx Provides a complete setup for Iggy runtime, a Protobuf source connector, and a Protobuf sink connector. These configurations define stream handling, schema paths, and data transformation rules. ```toml [iggy] address = "localhost:8090" username = "iggy" password = "iggy" [connectors] config_type = "local" config_dir = "path/to/connectors" # Source Connector [source] type = "source" key = "protobuf" path = "target/release/libiggy_connector_protobuf_source" [plugin_config] schema_path = "schemas/message.proto" message_type = "com.example.Message" # Sink Connector [sink] type = "sink" [[transforms]] type = "proto_convert" target_format = "json" ``` -------------------------------- ### Iggy Connection String Formats Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/rust/high-level-sdk.mdx Examples of Iggy connection strings, showing basic format, protocol specification (TCP, QUIC, HTTP), and advanced options for TCP connections. ```bash iggy://iggy:secret@localhost:3050 ``` ```bash iggy+tcp://iggy:secret@localhost:3050 ``` ```bash iggy+quic://iggy:secret@localhost:3050 ``` ```bash iggy+http://iggy:secret@localhost:3050 ``` ```bash iggy://iggy:secret@localhost:3050?tls=true&tls_domain=test.com&reconnection_retries=5&reconnection_interval=5s&reestablish_after=10s&heartbeat_interval=3s&nodelay=true ``` -------------------------------- ### Iggy Connectors: Source and Sink Configuration Source: https://context7.com/apache/iggy-website/llms.txt Example TOML configuration for Iggy connectors, detailing settings for a PostgreSQL source to ingest CDC data and a Quickwit sink to forward messages, including data transforms. ```toml # Connector runtime config.toml [iggy] address = "localhost:8090" username = "iggy" password = "iggy" # PostgreSQL Source - ingest CDC data into Iggy [[sources]] id = "pg-source" path = "connectors/postgres_source.so" stream = "cdc-stream" topic = "orders" partitions_count = 4 [sources.config] connection_string = "postgres://user:pass@localhost/mydb" table = "orders" poll_interval = "1s" # Quickwit Sink - forward messages to search engine [[sinks]] id = "quickwit-sink" path = "connectors/quickwit_sink.so" stream = "events" topic = "logs" consumer_group = "quickwit-cg" [sinks.config] endpoint = "http://localhost:7280" index = "events" # Data transforms [[sinks.transforms]] type = "add_fields" config = { timestamp = "timestamp_millis", id = "uuid_v7" } [[sinks.transforms]] type = "filter_fields" config = { fields = ["id", "timestamp", "payload"] } ``` -------------------------------- ### Initialize Iggy Client and System Source: https://github.com/apache/iggy-website/blob/main/content/docs/introduction/getting-started.mdx Connects to the Iggy server, logs in, and initializes the system by creating a stream and a topic if they don't already exist. It uses tracing for logging. ```rust async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); let client = IggyClient::default(); client.connect().await?; client .login_user(DEFAULT_ROOT_USERNAME, DEFAULT_ROOT_PASSWORD) .await?; init_system(&client).await; Ok(()) } async fn init_system(client: &IggyClient) { match client.create_stream(STREAM_NAME).await { Ok(_) => info!("Stream was created."), Err(_) => warn!("Stream already exists and will not be created again."), } match client .create_topic( &STREAM_NAME.try_into().unwrap(), TOPIC_NAME, 1, CompressionAlgorithm::default(), None, IggyExpiry::NeverExpire, MaxTopicSize::ServerDefault, ) .await { Ok(_) => info!("Topic was created."), Err(_) => warn!("Topic already exists and will not be created again."), } } ``` -------------------------------- ### Install Iggy CLI using Cargo Source: https://github.com/apache/iggy-website/blob/main/content/docs/cli/start.mdx Installs the Iggy CLI using the Cargo package manager. After installation, the `iggy` command can be used to access its functionalities. ```bash cargo install iggy-cli ``` -------------------------------- ### C++ SDK: Connect and Manage Streams/Topics Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/cpp/intro.mdx Demonstrates how to connect to Iggy using a connection string, log in, create a stream, and create a topic with a specified number of partitions using the C++ SDK. It also shows how to clean up the connection. ```cpp #include "lib.rs.h" // Connect via connection string (supports all transports) auto* client = iggy::ffi::new_connection( "iggy://iggy:iggy@localhost:8090" ); client->connect(); client->login_user("iggy", "iggy"); // Create a stream client->create_stream("my-stream"); // Build an identifier for the stream iggy::ffi::Identifier stream_id; stream_id.kind = "string"; stream_id.length = 9; for (char c : std::string("my-stream")) stream_id.value.push_back(static_cast(c)); // Create a topic with 2 partitions client->create_topic(stream_id, "my-topic", 2); // Cleanup iggy::ffi::delete_connection(client); ``` -------------------------------- ### Main Application Entry Point (Rust) Source: https://github.com/apache/iggy-website/blob/main/content/docs/introduction/getting-started.mdx The main function sets up the tracing subscriber, initializes the Iggy client, connects to the server, logs in, initializes the system (stream and topic creation), and starts the message production process. ```Rust use iggy::prelude::*; use std::error::Error; use std::str::FromStr; use std::time::Duration; use tokio::time::sleep; use tracing::{info, warn}; const STREAM_NAME: &str = "sample-stream"; const TOPIC_NAME: &str = "sample-topic"; const PARTITION_ID: u32 = 1; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt::init(); let client = IggyClient::default(); client.connect().await?; client .login_user(DEFAULT_ROOT_USERNAME, DEFAULT_ROOT_PASSWORD) .await?; init_system(&client).await; produce_messages(&client).await?; Ok(()) } ``` -------------------------------- ### Initialize Iggy Client via Connection String Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/introduction.mdx Demonstrates how to initialize an Iggy client using a connection string with various transport protocols and configuration options. ```rust // Rust - TCP with default options let client = IggyClient::from_connection_string("iggy://iggy:iggy@localhost:8090")?; // Rust - QUIC with TLS let client = IggyClient::from_connection_string("iggy+quic://iggy:iggy@localhost:8080")?; // Rust - TCP with options let client = IggyClient::from_connection_string( "iggy://iggy:iggy@localhost:8090?tls=true&reconnection_retries=unlimited&heartbeat_interval=5s" )?; ``` ```python # Python client = IggyClient.from_connection_string("iggy://iggy:iggy@localhost:8090") ``` -------------------------------- ### Install Iggy Rust SDK Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/rust/intro.mdx Installs the Iggy Rust SDK using Cargo, the Rust package manager. This is the first step to using the SDK in your Rust project. ```bash cargo add iggy ``` -------------------------------- ### Go Producer Example: Connect, Create Stream/Topic, Send Messages Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/go/examples.mdx This Go code snippet demonstrates how to use the Iggy client to connect to the server, log in, create a stream and a topic, and then send messages to that topic. It includes error handling and demonstrates the basic producer workflow. ```go package main import ( "fmt" "time" "github.com/apache/iggy/foreign/go/client" "github.com/apache/iggy/foreign/go/client/tcp" iggcon "github.com/apache/iggy/foreign/go/contracts" ) var ( StreamId = uint32(0) TopicId = uint32(0) PartitionId = uint32(0) ) func main() { // Create the client with TCP transport cli, err := client.NewIggyClient( client.WithTcp(tcp.WithServerAddress("127.0.0.1:8090")), ) if err != nil { panic(err) } defer cli.Close() // Log in if _, err := cli.LoginUser("iggy", "iggy"); err != nil { panic(err) } // Create a stream if _, err := cli.CreateStream("sample-stream"); err != nil { panic(err) } // Create a topic with 1 partition, no compression, no expiry streamIdentifier, _ := iggcon.NewIdentifier(StreamId) if _, err := cli.CreateTopic( streamIdentifier, "sample-topic", 1, // partitions count iggcon.CompressionAlgorithmNone, iggcon.IggyExpiryNeverExpire, 0, // max topic size nil, // replication factor ); err != nil { panic(err) } // Send messages in a loop partitioning := iggcon.PartitionId(PartitionId) for i := 1; i <= 10; i++ { payload := fmt.Sprintf("message-%d", i) message, _ := iggcon.NewIggyMessage([]byte(payload)) streamIdentifier, _ := iggcon.NewIdentifier(StreamId) topicIdentifier, _ := iggcon.NewIdentifier(TopicId) if err := cli.SendMessages( streamIdentifier, topicIdentifier, partitioning, []iggcon.IggyMessage{message}, ); err != nil { panic(err) } time.Sleep(500 * time.Millisecond) } } ``` -------------------------------- ### Get Consumer Offset Source: https://github.com/apache/iggy-website/blob/main/content/docs/server/schema.mdx Retrieves the current offset for a consumer group on a specific topic and partition. ```APIDOC ## Get Consumer Offset ### Description Retrieves the current consumer offset for a given consumer, topic, and partition. ### Method (Not specified, likely GET) ### Endpoint (Not specified, but related to consumer offsets) ### Parameters #### Request Body - **consumer** (Consumer) - Required - The consumer details. - **stream_id** (Identifier) - Required - The ID of the stream. - **topic_id** (Identifier) - Required - The ID of the topic. - **partition_id** (u32) - Optional - The ID of the partition. If not provided, the offset for all partitions is retrieved. ### Request Example (Not provided) ### Response #### Success Response (120) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Produce Messages with Iggy C# Client Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/intro.mdx Demonstrates how to initialize an Iggy client, create a stream and topic, and send a batch of messages to a specific partition. ```csharp using System.Text; using Apache.Iggy; using Apache.Iggy.Configuration; using Apache.Iggy.Enums; using Apache.Iggy.Factory; using Apache.Iggy.Kinds; using Apache.Iggy.Messages; const string StreamName = "sample-stream"; const string TopicName = "sample-topic"; var client = IggyClientFactory.CreateClient(new IggyClientConfigurator() { BaseAddress = "127.0.0.1:8090", Protocol = Protocol.Tcp, }); await client.ConnectAsync(); await client.LoginUser("iggy", "iggy"); await client.CreateStreamAsync(StreamName); await client.CreateTopicAsync( Identifier.String(StreamName), TopicName, 1, CompressionAlgorithm.None ); var partitioning = Partitioning.PartitionId(0); for (int i = 0; i < 10; i++) { var payload = Encoding.UTF8.GetBytes($"message-{i}"); var messages = new List { new Message(Guid.NewGuid(), payload) }; await client.SendMessagesAsync( Identifier.String(StreamName), Identifier.String(TopicName), partitioning, messages ); } ``` -------------------------------- ### Manage Iggy Resources and Messages via SDKs Source: https://context7.com/apache/iggy-website/llms.txt Demonstrates how to connect to an Iggy server, create streams and topics, send messages, and poll for messages using Java, Go, and C#. ```java import org.apache.iggy.client.blocking.tcp.IggyTcpClient; import org.apache.iggy.identifier.StreamId; import org.apache.iggy.identifier.TopicId; import org.apache.iggy.message.*; import org.apache.iggy.consumergroup.Consumer; import org.apache.iggy.topic.CompressionAlgorithm; import java.math.BigInteger; import java.util.List; import static java.util.Optional.empty; public class Example { public static void main(String[] args) { try (var client = IggyTcpClient.builder() .host("localhost").port(8090) .credentials("iggy", "iggy") .buildAndLogin()) { client.streams().createStream("sample-stream"); client.topics().createTopic( StreamId.of("sample-stream"), 1L, CompressionAlgorithm.None, BigInteger.ZERO, BigInteger.ZERO, empty(), "sample-topic"); for (int i = 0; i < 10; i++) { client.messages().sendMessages( StreamId.of("sample-stream"), TopicId.of("sample-topic"), Partitioning.partitionId(0L), List.of(Message.of("message-" + i))); } PolledMessages polled = client.messages().pollMessages( StreamId.of("sample-stream"), TopicId.of("sample-topic"), java.util.Optional.of(0L), Consumer.of(0L), PollingStrategy.offset(BigInteger.ZERO), 10L, false); for (Message msg : polled.messages()) { System.out.printf("Payload: %s%n", new String(msg.payload())); } } } } ``` ```go package main import ( "fmt" "github.com/apache/iggy/foreign/go/client" "github.com/apache/iggy/foreign/go/client/tcp" iggcon "github.com/apache/iggy/foreign/go/contracts" ) func main() { cli, _ := client.NewIggyClient( client.WithTcp(tcp.WithServerAddress("127.0.0.1:8090")), ) defer cli.Close() cli.LoginUser("iggy", "iggy") cli.CreateStream("sample-stream") streamId, _ := iggcon.NewIdentifier(uint32(0)) cli.CreateTopic(streamId, "sample-topic", 1, iggcon.CompressionAlgorithmNone, iggcon.IggyExpiryNeverExpire, 0, nil) for i := 1; i <= 10; i++ { msg, _ := iggcon.NewIggyMessage([]byte(fmt.Sprintf("message-%d", i))) cli.SendMessages(streamId, iggcon.NewIdentifier(uint32(0)), iggcon.PartitionId(0), []iggcon.IggyMessage{msg}) } consumer := iggcon.DefaultConsumer() partitionId := uint32(0) polled, _ := cli.PollMessages(streamId, iggcon.NewIdentifier(uint32(0)), consumer, iggcon.OffsetPollingStrategy(0), 10, false, &partitionId) for _, msg := range polled.Messages { fmt.Printf("Offset: %d, Payload: %s\n", msg.Header.Offset, string(msg.Payload)) } } ``` ```csharp using System.Text; using Apache.Iggy; using Apache.Iggy.Configuration; using Apache.Iggy.Enums; using Apache.Iggy.Factory; using Apache.Iggy.Kinds; using Apache.Iggy.Messages; var client = IggyClientFactory.CreateClient(new IggyClientConfigurator() { BaseAddress = "127.0.0.1:8090", Protocol = Protocol.Tcp, }); await client.ConnectAsync(); await client.LoginUser("iggy", "iggy"); await client.CreateStreamAsync("sample-stream"); await client.CreateTopicAsync( Identifier.String("sample-stream"), "sample-topic", 1, CompressionAlgorithm.None); for (int i = 0; i < 10; i++) { var messages = new List { new Message(Guid.NewGuid(), Encoding.UTF8.GetBytes($"message-{i}")) }; await client.SendMessagesAsync( Identifier.String("sample-stream"), Identifier.String("sample-topic"), Partitioning.PartitionId(0), messages); } var polled = await client.PollMessagesAsync( Identifier.String("sample-stream"), Identifier.String("sample-topic"), 0, Consumer.New(1), PollingStrategy.Offset(0), 10, false); foreach (var msg in polled.Messages) { Console.WriteLine($"Offset: {msg.Header.Offset}, Payload: {Encoding.UTF8.GetString(msg.Payload)}"); } ``` -------------------------------- ### Iggy Server Configuration: Environment Variables Source: https://context7.com/apache/iggy-website/llms.txt Example of overriding Iggy server configurations using environment variables with the IGGY_ prefix. ```bash # Environment variable overrides export IGGY_TCP_ADDRESS=0.0.0.0:8090 export IGGY_HTTP_ENABLED=true export IGGY_SYSTEM_PATH=/data/iggy export IGGY_ROOT_USERNAME=iggy export IGGY_ROOT_PASSWORD=my-secret-password ``` -------------------------------- ### Configure Message Expiry in TOML Source: https://github.com/apache/iggy-website/blob/main/content/blog/message-expiry.mdx Example configuration for the message cleaner and default segment expiration policy in the Iggy server configuration file. ```toml [message_cleaner] enabled = true interval = 60 [system.segment] message_expiry = 0 ``` -------------------------------- ### Rust: Create ProtoConvert with Schema Configuration Source: https://github.com/apache/iggy-website/blob/main/content/docs/connectors/sdk.mdx Demonstrates creating a ProtoConvert instance in Rust with automatic schema loading from a file path and field mappings. It shows how to configure source and target formats, schema path, message type, and field renaming. ```rust use iggy_connector_sdk::transforms::proto_convert::{ProtoConvert, ProtoConvertConfig}; use iggy_connector_sdk::Schema; use std::collections::HashMap; use std::path::PathBuf; let converter = ProtoConvert::new(ProtoConvertConfig { source_format: Schema::Proto, target_format: Schema::Json, schema_path: Some(PathBuf::from("schemas/user.proto")), message_type: Some("com.example.User".to_string()), field_mappings: Some(HashMap::from([ ("user_id".to_string(), "id".to_string()), ("full_name".to_string(), "name".to_string()), ])), ..ProtoConvertConfig::default() }); ``` -------------------------------- ### Consumer Group Management Structures Source: https://github.com/apache/iggy-website/blob/main/content/docs/server/schema.mdx Rust structures defining the payloads for consumer group operations such as getting, creating, deleting, joining, and leaving groups. ```rust pub struct GetConsumerGroup { pub stream_id: Identifier, pub topic_id: Identifier, pub group_id: Identifier } pub struct GetConsumerGroups { pub stream_id: Identifier, pub topic_id: Identifier } pub struct CreateConsumerGroup { pub stream_id: Identifier, pub topic_id: Identifier, pub name: String, } pub struct DeleteConsumerGroup { pub stream_id: Identifier, pub topic_id: Identifier, pub group_id: Identifier } pub struct JoinConsumerGroup { pub stream_id: Identifier, pub topic_id: Identifier, pub group_id: Identifier } pub struct LeaveConsumerGroup { pub stream_id: Identifier, pub topic_id: Identifier, pub group_id: Identifier } ``` -------------------------------- ### Iggy CLI Cluster Operations Source: https://github.com/apache/iggy-website/blob/main/content/docs/cli/start.mdx Provides commands for interacting with the Iggy cluster. Currently includes a command to get cluster information. Aliased as 'cl'. ```bash # Get cluster info iggy -u iggy -p iggy cluster list ``` -------------------------------- ### Produce Messages with Apache Iggy C# Client Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/csharp/examples.mdx Demonstrates how to initialize an Iggy client, create streams and topics, and send a batch of messages to a specific partition. It handles potential exceptions for existing resources and uses UTF-8 encoding for message payloads. ```csharp using System.Text; using Apache.Iggy; using Apache.Iggy.Configuration; using Apache.Iggy.Enums; using Apache.Iggy.Exceptions; using Apache.Iggy.Factory; using Apache.Iggy.Kinds; using Apache.Iggy.Messages; const string StreamName = "dev"; const string TopicName = "events"; var client = IggyClientFactory.CreateClient(new IggyClientConfigurator() { BaseAddress = "127.0.0.1:8090", Protocol = Protocol.Tcp, }); await client.ConnectAsync(); await client.LoginUser("iggy", "iggy"); try { await client.CreateStreamAsync(StreamName); } catch (InvalidResponseException) { Console.WriteLine("Stream already exists."); } try { await client.CreateTopicAsync( Identifier.String(StreamName), TopicName, 2, CompressionAlgorithm.None ); } catch (InvalidResponseException) { Console.WriteLine("Topic already exists."); } var partitioning = Partitioning.PartitionId(0); for (int i = 0; i < 100; i++) { var payload = Encoding.UTF8.GetBytes($"Event #{i}"); var messages = new List { new Message(Guid.NewGuid(), payload) }; await client.SendMessagesAsync( Identifier.String(StreamName), Identifier.String(TopicName), partitioning, messages ); } Console.WriteLine("Sent 100 messages"); ``` -------------------------------- ### Manage Iggy Streams via CLI Source: https://context7.com/apache/iggy-website/llms.txt Commands to install the Iggy CLI and perform basic stream management operations like creation, listing, and deletion. ```bash cargo install iggy-cli iggy -u iggy -p iggy stream create my-stream iggy -u iggy -p iggy stream list iggy -u iggy -p iggy stream get my-stream iggy -u iggy -p iggy stream delete my-stream ``` -------------------------------- ### Initialize Iggy Client and Send Messages Source: https://github.com/apache/iggy-website/blob/main/content/docs/sdk/go/intro.mdx Demonstrates how to initialize an Iggy client, authenticate, create streams and topics, and send messages to the server. This snippet assumes a running Iggy server at localhost:8090. ```go package main import ( "fmt" "log" iggy "github.com/apache/iggy/foreign/go" ) func main() { client, err := iggy.NewClient("localhost:8090") if err != nil { log.Fatal(err) } defer client.Close() err = client.Login("iggy", "iggy") if err != nil { log.Fatal(err) } // Create a stream err = client.CreateStream("my-stream") if err != nil { log.Fatal(err) } // Create a topic with 2 partitions err = client.CreateTopic("my-stream", "my-topic", 2) if err != nil { log.Fatal(err) } // Send a message err = client.SendMessages("my-stream", "my-topic", 1, [][]byte{[]byte("Hello from Go!")}) if err != nil { log.Fatal(err) } fmt.Println("Message sent successfully") } ``` -------------------------------- ### Define Connector Configuration via TOML Source: https://github.com/apache/iggy-website/blob/main/content/docs/connectors/sources/source.mdx Example TOML configuration for a source connector. This defines the connector type, stream destinations, and custom plugin parameters. ```toml type = "source" key = "random" enabled = true version = 0 name = "Random source" path = "libiggy_connector_random_source" config_format = "toml" [[streams]] stream = "example_stream" topic = "example_topic" schema = "json" batch_length = 100 linger_time = "5ms" [plugin_config] messages_count = 10 [transforms.add_fields] enabled = true [[transforms.add_fields.fields]] key = "message" value.static = "hello" ```