pub struct StandaloneConfig {
pub consumer_id: String,
pub topic_id: u32,
pub topic_name: Option<String>,
pub max_fetch_bytes: u32,
pub start_position: SeekPosition,
pub offset_dir: Option<PathBuf>,
pub auto_commit_interval: Option<Duration>,
pub connect_timeout: Duration,
pub poll_timeout: Duration,
}Expand description
Configuration for standalone consumer mode
There are three ways to specify which topic to consume:
-
Name-based (recommended) — pass only the topic name via
StandaloneConfig::with_topic_name. The consumer resolves the name to a numeric ID automatically by callingcreate_topic(which is idempotent) on connect. -
ID + name — use
StandaloneConfig::new_with_idwhen you already hold a resolvedTopicInfoand want to skip the extra round-trip. -
ID-only (legacy) — use
StandaloneConfig::newwith a numeric ID directly. This preserves backward compatibility with existing callers.
Fields§
§consumer_id: StringIdentifier for this consumer (used for offset storage)
topic_id: u32Topic ID to consume from.
When this is 0 and topic_name is Some, the consumer will
resolve the name to an ID on the first call to
StandaloneConsumer::connect.
topic_name: Option<String>Human-readable topic name.
When set and topic_id == 0, StandaloneConsumer::connect resolves
the name to an ID via create_topic (idempotent).
max_fetch_bytes: u32Maximum bytes to fetch per poll
start_position: SeekPositionStarting position if no stored offset exists
offset_dir: Option<PathBuf>Directory for offset persistence (None = in-memory only)
auto_commit_interval: Option<Duration>Auto-commit interval (None = manual commit only)
connect_timeout: DurationConnection timeout
poll_timeout: DurationPoll timeout for blocking operations
Implementations§
Source§impl StandaloneConfig
impl StandaloneConfig
Sourcepub fn new(consumer_id: impl Into<String>, topic_id: u32) -> Self
pub fn new(consumer_id: impl Into<String>, topic_id: u32) -> Self
Create a standalone config using a numeric topic ID.
This is the legacy constructor and is kept for backward
compatibility. Prefer StandaloneConfig::with_topic_name for new
code — it lets the client resolve the name automatically and avoids
coupling call sites to numeric IDs.
Sourcepub fn with_topic_name(
consumer_id: impl Into<String>,
topic_name: impl Into<String>,
) -> Self
pub fn with_topic_name( consumer_id: impl Into<String>, topic_name: impl Into<String>, ) -> Self
Create a standalone config using only the topic name.
When this config is passed to StandaloneConsumer::connect, the
consumer calls create_topic (idempotent) to resolve the name to a
numeric ID before subscribing. No extra setup code is required on the
call site.
The name must match [a-zA-Z0-9-]+; an error is returned at connect
time if validation fails.
§Examples
use lnc_client::{StandaloneConsumer, StandaloneConfig};
let mut consumer = StandaloneConsumer::connect(
"127.0.0.1:1992",
StandaloneConfig::with_topic_name("my-consumer", "rithmic-actions"),
).await?;Sourcepub fn new_with_id(
consumer_id: impl Into<String>,
topic_name: impl Into<String>,
topic_id: u32,
) -> Self
pub fn new_with_id( consumer_id: impl Into<String>, topic_name: impl Into<String>, topic_id: u32, ) -> Self
Create a standalone config with both a topic name and a pre-resolved numeric ID.
Use this when you already have a TopicInfo from a prior
create_topic call and want to avoid the extra round-trip that
StandaloneConfig::with_topic_name performs on connect.
§Examples
use lnc_client::{ClientConfig, LanceClient, StandaloneConsumer, StandaloneConfig};
let mut mgmt = LanceClient::connect(ClientConfig::new("127.0.0.1:1992")).await?;
let info = mgmt.create_topic("rithmic-actions").await?;
let mut consumer = StandaloneConsumer::connect(
"127.0.0.1:1992",
StandaloneConfig::new_with_id("my-consumer", &info.name, info.id),
).await?;Sourcepub fn with_consumer_id(self, id: impl Into<String>) -> Self
pub fn with_consumer_id(self, id: impl Into<String>) -> Self
Set the consumer ID for offset tracking
Sourcepub fn with_max_fetch_bytes(self, bytes: u32) -> Self
pub fn with_max_fetch_bytes(self, bytes: u32) -> Self
Set the maximum bytes to fetch per poll
Sourcepub fn with_start_position(self, position: SeekPosition) -> Self
pub fn with_start_position(self, position: SeekPosition) -> Self
Set the starting position when no stored offset exists
Sourcepub fn with_offset_dir(self, dir: &Path) -> Self
pub fn with_offset_dir(self, dir: &Path) -> Self
Set the directory for offset persistence If not set, offsets are stored in memory only (lost on restart)
Sourcepub fn with_auto_commit_interval(self, interval: Option<Duration>) -> Self
pub fn with_auto_commit_interval(self, interval: Option<Duration>) -> Self
Set auto-commit interval (None to disable auto-commit)
Sourcepub fn with_manual_commit(self) -> Self
pub fn with_manual_commit(self) -> Self
Disable auto-commit (manual commit only)
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
Set connection timeout
Sourcepub fn with_poll_timeout(self, timeout: Duration) -> Self
pub fn with_poll_timeout(self, timeout: Duration) -> Self
Set poll timeout
Trait Implementations§
Source§impl Clone for StandaloneConfig
impl Clone for StandaloneConfig
Source§fn clone(&self) -> StandaloneConfig
fn clone(&self) -> StandaloneConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for StandaloneConfig
impl RefUnwindSafe for StandaloneConfig
impl Send for StandaloneConfig
impl Sync for StandaloneConfig
impl Unpin for StandaloneConfig
impl UnsafeUnpin for StandaloneConfig
impl UnwindSafe for StandaloneConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request