Lightstreamer Rust Client
This project is a Rust implementation of the Lightstreamer TLCP (Text-based Live Connections Protocol). It provides a robust client SDK to interact with Lightstreamer servers, enabling real-time data streaming for financial applications, IoT systems, and other use cases requiring live data updates. While it was initially developed to support the ig_trading_api project, it has evolved into a more comprehensive SDK with broader applicability.
About Lightstreamer
Lightstreamer is a high-performance real-time messaging server that provides several key features:
- Real-time data streaming with optimized bandwidth usage
- Support for various transport mechanisms (WebSockets, HTTP streaming, etc.)
- Different subscription modes for various data delivery patterns
- Robust connection management with automatic recovery
- Scalable architecture for high-volume applications
Features
This Rust client SDK provides the following capabilities:
-
Connection Management:
- Full-duplex WebSocket-based connection mode
- Automatic reconnection with configurable retry policies
- Session recovery after temporary disconnections
- Connection status monitoring and event notifications
- Proxy support for enterprise environments
-
Subscription Capabilities:
- Support for multiple subscription modes (MERGE, DISTINCT, COMMAND, RAW)
- Subscription to individual items or item groups
- Field schema definition for structured data
- Real-time item updates with change detection
- Snapshot support for initial state recovery
-
Configuration Options:
- Extensive connection options (polling intervals, timeouts, etc.)
- Bandwidth control and throttling
- Custom HTTP headers for authentication
- Logging configuration for debugging
-
Event Handling:
- Comprehensive event listener system
- Subscription lifecycle events (subscription, unsubscription)
- Item update notifications with field-level change detection
- Connection status change notifications
- Error handling and reporting
Implementation Status
The current implementation supports most core features of the Lightstreamer protocol, with a focus on the WebSocket transport mechanism and the MERGE subscription mode. While initially developed for specific trading API requirements, the library has expanded to include:
- All subscription modes (MERGE, DISTINCT, COMMAND, RAW)
- Robust error handling and recovery mechanisms
- Comprehensive configuration options
- Thread-safe asynchronous operation using Tokio
Some advanced features that may be implemented in future versions include:
- Message sending capabilities (MPN)
- Client-side filtering and frequency limitations
- Additional transport mechanisms beyond WebSockets
- Enhanced security features
Installation
To use this SDK in your Rust project, add the following dependency to your Cargo.toml
:
[]
= "0.1.4"
Usage
Here's a comprehensive example of how to use the Lightstreamer Rust Client SDK:
// This example shows how to use the Lightstreamer Rust client
use ;
use ;
use Arc;
use Notify;
use Duration;
// Define a custom subscription listener
;
async
Handling Client Events
You can also add listeners to handle client events:
Here's an example of implementing a client listener:
// Note: ClientListener is a private trait, this is just for illustration
use ClientStatus;
;
// This is just an example of what the ClientListener trait might look like
// The actual implementation is internal to the library
// Then add the listener to your client
// client.add_listener(Box::new(MyClientListener));
Contribution and Contact
We welcome contributions to this project! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and ensure that the project still builds and all tests pass.
- Commit your changes and push your branch to your forked repository.
- Submit a pull request to the main repository.
If you have any questions, issues, or would like to provide feedback, please feel free to contact the project maintainer:
Joaquín Béjar García
- Email: jb@taunais.com
- GitHub: joaquinbejar
We appreciate your interest and look forward to your contributions!
✍️ License
Licensed under MIT license