lnc-client
Async Rust client library for the LANCE streaming platform.
Features
- Async/await — Built on Tokio for high-performance async I/O
- Producer — Batch records with configurable batching, linger, and backpressure
- Consumer — Standalone and grouped consumer modes with offset persistence
- Topic Management — Create, list, and delete topics by name; produce/consume by numeric ID
- Auto-reconnect — Transparent reconnection with exponential backoff and leader redirection
- Connection pooling — Pool management with health checking and idle timeouts
- TLS/mTLS — Secure connections with rustls (server TLS and mutual TLS)
- Zero-copy — Efficient record handling with
bytes::Bytesfor minimal allocations
Installation
Quick Start
Topic Management
Topics are created by name and referenced by numeric ID for produce/consume operations.
Use the low-level LanceClient for topic administration:
use ;
async
Producer
use ;
async
Consumer (Standalone)
use ;
use Path;
async
Consumer (Grouped)
use ;
async
Configuration
Producer Configuration
use ProducerConfig;
let config = new
.with_batch_size // 16KB batch trigger
.with_linger_ms // 5ms max linger before flush
.with_max_in_flight // concurrent in-flight requests
.with_buffer_memory // 32MB buffer limit
.with_compression // LZ4 compression
.with_connect_timeout
.with_request_timeout;
Consumer Configuration
use ;
use Path;
use Duration;
let config = new
.with_max_fetch_bytes // 1MB per poll
.with_start_position // or SeekPosition::End / SeekPosition::Offset(n)
.with_offset_dir
.with_auto_commit_interval
.with_poll_timeout;
TLS Configuration
use ;
// Plain TCP
let config = new;
// TLS with system root certificates
let config = new
.with_tls;
// TLS with custom CA
let config = new
.with_tls;
// Mutual TLS (mTLS)
let config = new
.with_tls;
Connection Pooling
For high-throughput scenarios or shared connection management:
use ;
use Duration;
let pool = new.await?;
// Get a connection from the pool
let mut conn = pool.get.await?;
// Use the underlying LanceClient
conn.ping.await?;
// Connection is returned to pool when dropped
Low-Level Client
LanceClient is the unified low-level client that handles all protocol operations on
a single TCP connection. Producer and StandaloneConsumer are higher-level abstractions
built on top of it. Use LanceClient directly for topic administration or when you need
fine-grained control:
use Bytes;
use ;
let mut client = connect.await?;
// Topic management
let topic = client.create_topic.await?;
let topics = client.list_topics.await?;
client.delete_topic.await?;
// Retention policies
client.set_retention.await?;
// Direct ingest (without Producer batching)
let payload = from_static;
let batch_id = client.send_ingest_to_topic.await?;
// Fetch data from a topic at an offset
let fetch = client.fetch.await?;
// Subscribe for streaming consumption (topic_id, start_offset, max_batch_bytes, consumer_id)
client.subscribe.await?;
client.commit_offset.await?;
// Latency measurement
let rtt = client.ping.await?;
Error Handling
All operations return Result<T, ClientError>:
use ClientError;
match producer.send.await
Platform Support
The client library supports all major platforms:
- Linux (x86_64, aarch64)
- macOS (x86_64, aarch64)
- Windows (x86_64)
Note: The LANCE server requires Linux with io_uring support, but the client works everywhere.
License
Apache License 2.0 — see LICENSE for details.