43 lines
1.2 KiB
Markdown
43 lines
1.2 KiB
Markdown
# SQ-015: SDK Consumer
|
|
|
|
**Status:** `[ ] TODO`
|
|
**Blocked by:** SQ-014, SQ-012
|
|
**Priority:** Medium
|
|
|
|
## Description
|
|
|
|
Ergonomic Rust consumer client in sq-sdk. Wraps the server-streaming Subscribe RPC with poll-based interface and auto-commit support.
|
|
|
|
## Files to Create/Modify
|
|
|
|
- `crates/sq-sdk/src/consumer.rs` - Consumer with poll loop and auto-commit
|
|
|
|
## Consumer API
|
|
|
|
```rust
|
|
pub struct ConsumerConfig {
|
|
pub server_addresses: Vec<String>,
|
|
pub consumer_group: String,
|
|
pub topics: Vec<String>,
|
|
pub auto_commit: bool,
|
|
pub auto_commit_interval_ms: u64,
|
|
pub max_poll_records: u32,
|
|
}
|
|
|
|
pub struct Consumer { /* ... */ }
|
|
|
|
impl Consumer {
|
|
pub async fn connect(config: ConsumerConfig) -> Result<Self, SqError>;
|
|
pub async fn poll(&mut self) -> Result<Vec<ConsumedMessage>, SqError>;
|
|
pub async fn commit(&self, topic: &str, partition: u32, offset: u64) -> Result<(), SqError>;
|
|
}
|
|
```
|
|
|
|
## Acceptance Criteria
|
|
|
|
- [ ] End-to-end: produce 100 messages with Producer, consume all with Consumer
|
|
- [ ] Auto-commit: consumed offsets are committed after interval
|
|
- [ ] Manual commit: explicit commit stores offset
|
|
- [ ] Poll returns empty vec when no new messages (non-blocking)
|
|
- [ ] Consumer group: two consumers resume from committed offset
|