Skip to main content

Module offset

Module offset 

Source
Expand description

Client-side offset persistence for LANCE consumers

Provides traits and implementations for storing consumer offsets locally, enabling stateless broker architecture per the Client-Managed Offset Strategy.

§Design Philosophy

LANCE treats the broker as a stateless data pipe. Offset tracking is the client’s responsibility, enabling:

  • Exactly-once semantics (store offset with business data atomically)
  • Stateless horizontal scaling
  • Reduced broker metadata overhead

§Example

use lnc_client::offset::{OffsetStore, LockFileOffsetStore};
use std::path::Path;

let store = LockFileOffsetStore::open(
    Path::new("/var/lib/lance/offsets"),
    "my-consumer",
)?;

// Load stored offset for a topic
let offset = store.load(topic_id, consumer_id).unwrap_or(0);

// After processing, save the new offset
store.save(topic_id, consumer_id, new_offset)?;

Structs§

CollectingCommitHook
A hook that collects commit events for testing
CommitInfo
Information about a committed offset
HookedOffsetStore
Offset store wrapper that invokes post-commit hooks
LockFileOffsetStore
File-based offset store with lock file protection
LoggingCommitHook
A simple logging hook for debugging
MemoryOffsetStore
In-memory offset store for testing and ephemeral consumers

Traits§

OffsetStore
Trait for client-side offset persistence
PostCommitHook
Trait for post-commit hooks