4 releases (2 breaking)
Uses new Rust 2024
| new 0.6.0-alpha.0 | Dec 1, 2025 |
|---|---|
| 0.3.1 | Sep 29, 2025 |
| 0.3.0 | Sep 15, 2025 |
| 0.2.0 | Jul 24, 2025 |
#27 in #vixen
Used in yellowstone-vixen-stream
160KB
2.5K
SLoC
Yellowstone Vixen Sources
Overview
Yellowstone Vixen introduces a flexible Source system that allows you to connect to various data sources and stream their updates through a standardized interface. This feature is designed to be extensible, allowing you to create custom sources while maintaining a consistent API.
Key Features
- 🔌 Standardized Connection Interface: Connect to any data source using a unified API
- 📡 Asynchronous Updates: Stream data updates through channels
- ⚙️ Configurable: Set up filters and source-specific configurations
- 🔄 Extensible: Create your own custom sources
How It Works
The Source trait provides a standardized way to:
- Connect to external data sources
- Stream updates through a channel to the Vixen runtime for processing
- Configure filters for data processing
- Manage source-specific configuration
Creating a Custom Source
Here's a step-by-step guide to creating your own source:
use async_trait::async_trait;
use tokio::sync::mpsc::Sender;
use yellowstone_vixen::sources::Source;
use yellowstone_vixen::config::YellowstoneConfig;
use vixen_core::Filters;
#[derive(Debug)]
struct MyCustomSource {
filters: Option<Filters>,
config: Option<YellowstoneConfig>,
}
#[async_trait]
impl Source for MyCustomSource {
async fn connect(
&self,
tx: Sender<Result<SubscribeUpdate, Status>>,
) -> Result<JoinSet<()>, crate::Error> {
// Your connection logic here
todo!()
}
fn name(&self) -> String {
"my-custom-source".to_string()
}
// ... other required methods
}
Required Methods
| Method | Description |
|---|---|
connect |
Establishes connection to the data source and streams updates |
name |
Returns a unique identifier for the source |
set_filters_unchecked |
Sets filters for data processing |
set_config_unchecked |
Sets source-specific configuration |
get_filters |
Retrieves current filters |
get_config |
Retrieves current configuration |
Optional Methods
The trait provides two optional methods with safe default implementations:
filters: Safely sets filters if none are currently setconfig: Safely sets configuration if none is currently set
Best Practices
- Naming: Choose clear, descriptive names for your sources
- Error Handling: Implement proper error handling in your
connectmethod - Resource Management: Ensure proper cleanup of resources when the source is dropped
- Configuration: Use the configuration system to make your source flexible
- Filtering: Implement efficient filtering to reduce unnecessary data transfer
Example Use Case
Here's a practical example of how to use a source:
vixen::Runtime::builder()
// Add the source to the runtime
.source(YellowstoneGrpcSource::new())
// We could call this multiple times to add concurrent Sources
// .source(SolanaAccountsRpcSource::new())
.account(Pipeline::new(TokenProgramAccParser, [Handler]))
.account(Pipeline::new(TokenExtensionProgramAccParser, [Handler]))
.instruction(Pipeline::new(TokenExtensionProgramIxParser, [Handler]))
.instruction(Pipeline::new(TokenProgramIxParser, [Handler]))
.build(config)
.run();
🔮 Roadmap
📅 Planned Features
| Feature | Priority | Description |
|---|---|---|
| Source Testing Harness | High | Make it easy to test Source implementations and speed up contributions |
| Space for cleanup logic | Medium | Expose a method that can be used for Sources that need to cleanup resources |
| Support additional data sources | Medium | Add support for additional data sources |
Contributing
We welcome contributions to expand the ecosystem of sources! When creating a new source:
- Follow the trait implementation guidelines
- Include comprehensive documentation
- Consider adding example usage
Support
If you need help or have questions, please open an issue on GitHub or also check other sources implementations in the repository.
Dependencies
~15–34MB
~486K SLoC