Crates.io | fuel-streams-core |
lib.rs | fuel-streams-core |
version | |
source | src |
created_at | 2024-08-24 06:25:35.415663+00 |
updated_at | 2025-03-14 01:02:41.610266+00 |
description | Core components for working with streams of Fuel blockchain data |
homepage | https://fuel.network/ |
repository | https://github.com/fuellabs/data-systems |
max_upload_size | |
id | 1349850 |
Cargo.toml error: | TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Fuel Streams Core is a library for building data streaming applications on the Fuel blockchain. It provides tools for efficient handling of real-time blockchain data, using NATS for scalable streaming and offering support for Fuel-specific data types.
[!NOTE] This crate is specifically modeled for the Fuel Data Systems project, and is not intended for general use outside of the project.
Add this dependency to your Cargo.toml
:
[dependencies]
fuel-streams-core = "*"
Here's a simple example to get you started with Fuel Streams Core:
use fuel_streams_core::prelude::*;
use fuel_streams_store::db::*;
use fuel_web_utils::api_key::*;
use fuel_message_broker::*;
use futures::StreamExt;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Connect to NATS server
let db = Db::new(DbConnectionOpts::default()).await?;
let broker = NatsMessageBroker::setup("nats://localhost:4222", None).await?;
// Create or get existing stream for blocks
let stream = Stream::<Block>::get_or_init(&broker, &db).await;
// Subscribe to the stream
let subject = BlocksSubject::new(); // blocks.*.*
let api_key_role = ApiKeyRole::default();
let mut subscription = stream.subscribe(
subject,
DeliverPolicy::New,
&api_key_role
)
.await;
// Process incoming blocks
while let Some(block) = subscription.next().await {
println!("Received block: {:?}", block?);
}
Ok(())
}
Contributions are welcome! Please feel free to submit a Pull Request.
For more information on contributing, please see the CONTRIBUTING.md file in the root of the repository.
This repo is licensed under the Apache-2.0
license. See LICENSE
for more information.