Files
sq/todos/SQ-014-sdk-producer.md
2026-02-26 21:52:50 +01:00

1.2 KiB

SQ-014: SDK Producer

Status: [ ] TODO Blocked by: SQ-010 Priority: Medium

Description

Ergonomic Rust producer client in sq-sdk. Handles connection management, batching, and retry logic.

Files to Create/Modify

  • crates/sq-sdk/src/lib.rs - re-exports
  • crates/sq-sdk/src/connection.rs - gRPC channel management
  • crates/sq-sdk/src/producer.rs - Producer with batching, linger timer, retry
  • crates/sq-sdk/src/error.rs - SqError type

Producer API

pub struct ProducerConfig {
    pub server_addresses: Vec<String>,
    pub default_ack_mode: AckMode,
    pub max_retries: u32,
    pub retry_backoff_ms: u64,
}

pub struct Producer { /* ... */ }

impl Producer {
    pub async fn connect(config: ProducerConfig) -> Result<Self, SqError>;
    pub async fn send(&self, topic: &str, key: Option<&[u8]>, value: &[u8]) -> Result<SendResult, SqError>;
    pub async fn send_batch(&self, messages: Vec<ProducerMessage>) -> Result<Vec<SendResult>, SqError>;
}

Acceptance Criteria

  • Producer connects to running server, sends message, gets offset back
  • Send batch: all messages get sequential offsets
  • Connection failure: returns appropriate error
  • Multiple server addresses: round-robin or failover