Skip to main content

StandaloneConfig

Struct StandaloneConfig 

Source
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:

  1. Name-based (recommended) — pass only the topic name via StandaloneConfig::with_topic_name. The consumer resolves the name to a numeric ID automatically by calling create_topic (which is idempotent) on connect.

  2. ID + name — use StandaloneConfig::new_with_id when you already hold a resolved TopicInfo and want to skip the extra round-trip.

  3. ID-only (legacy) — use StandaloneConfig::new with a numeric ID directly. This preserves backward compatibility with existing callers.

Fields§

§consumer_id: String

Identifier for this consumer (used for offset storage)

§topic_id: u32

Topic 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: u32

Maximum bytes to fetch per poll

§start_position: SeekPosition

Starting 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: Duration

Connection timeout

§poll_timeout: Duration

Poll timeout for blocking operations

Implementations§

Source§

impl StandaloneConfig

Source

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.

Source

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?;
Source

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?;
Source

pub fn with_consumer_id(self, id: impl Into<String>) -> Self

Set the consumer ID for offset tracking

Source

pub fn with_max_fetch_bytes(self, bytes: u32) -> Self

Set the maximum bytes to fetch per poll

Source

pub fn with_start_position(self, position: SeekPosition) -> Self

Set the starting position when no stored offset exists

Source

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)

Source

pub fn with_auto_commit_interval(self, interval: Option<Duration>) -> Self

Set auto-commit interval (None to disable auto-commit)

Source

pub fn with_manual_commit(self) -> Self

Disable auto-commit (manual commit only)

Source

pub fn with_connect_timeout(self, timeout: Duration) -> Self

Set connection timeout

Source

pub fn with_poll_timeout(self, timeout: Duration) -> Self

Set poll timeout

Trait Implementations§

Source§

impl Clone for StandaloneConfig

Source§

fn clone(&self) -> StandaloneConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StandaloneConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more