Files
sq/todos/SQ-001-domain-types.md
2026-02-26 21:52:50 +01:00

1.3 KiB

SQ-001: Domain Types

Status: [ ] TODO Blocked by: SQ-000 Priority: High

Description

Define the core domain types in sq-models: Message, Header, TopicName, Offset, and configuration types. These are the foundational types used throughout the entire system.

Files to Create/Modify

  • crates/sq-models/src/lib.rs - re-exports
  • crates/sq-models/src/message.rs - Message, Header, TopicName, Offset types
  • crates/sq-models/src/config.rs - TopicConfig, WalConfig

Key Types

pub struct Message {
    pub offset: u64,
    pub topic: TopicName,
    pub key: Option<Vec<u8>>,
    pub value: Vec<u8>,
    pub headers: Vec<Header>,
    pub timestamp_ms: u64,
}

pub struct Header {
    pub key: String,
    pub value: Vec<u8>,
}

pub struct TopicName(pub String);

pub struct WalConfig {
    pub max_segment_bytes: u64,    // default 64MB
    pub max_segment_age_secs: u64, // default 60s
    pub data_dir: PathBuf,
}

pub struct TopicConfig {
    pub name: TopicName,
    pub partitions: u32,           // default 1
    pub replication_factor: u32,   // default 3
}

Acceptance Criteria

  • All types compile and are public
  • Message implements Clone, Debug, PartialEq
  • Unit test: construct a Message, verify all fields
  • Property test (optional): arbitrary Message roundtrip through Debug/PartialEq