Crates.io | atproto-jetstream |
lib.rs | atproto-jetstream |
version | 0.11.2 |
created_at | 2025-06-08 20:15:37.218766+00 |
updated_at | 2025-08-20 18:54:27.609704+00 |
description | AT Protocol Jetstream event consumer library with WebSocket streaming and compression support |
homepage | https://tangled.sh/@smokesignal.events/atproto-identity-rs |
repository | https://tangled.sh/@smokesignal.events/atproto-identity-rs |
max_upload_size | |
id | 1705230 |
size | 110,348 |
WebSocket consumer for AT Protocol Jetstream events.
Real-time event streaming with Zstandard compression, automatic reconnection, and configurable event filtering for AT Protocol repository changes.
The following command-line tool is available when built with the clap
feature:
atproto-jetstream-consumer
: Real-time event stream consumer with filtering, compression, and background processing supportuse atproto_jetstream::{Consumer, ConsumerTaskConfig, EventHandler, JetstreamEvent, CancellationToken};
use async_trait::async_trait;
struct MyEventHandler;
#[async_trait]
impl EventHandler for MyEventHandler {
async fn handle_event(&self, event: JetstreamEvent) -> anyhow::Result<()> {
println!("Received event: {:?}", event);
Ok(())
}
fn handler_id(&self) -> String {
"my-handler".to_string()
}
}
let config = ConsumerTaskConfig {
user_agent: "my-app/1.0".to_string(),
compression: false,
zstd_dictionary_location: String::new(),
jetstream_hostname: "jetstream1.us-east.bsky.network".to_string(),
collections: vec!["app.bsky.feed.post".to_string()],
};
let consumer = Consumer::new(config);
consumer.register_handler(std::sync::Arc::new(MyEventHandler)).await?;
let cancellation_token = CancellationToken::new();
consumer.run_background(cancellation_token).await?;
let config = ConsumerTaskConfig {
compression: true,
zstd_dictionary_location: "./data/zstd_dictionary".to_string(),
// ... other config
};
// Download dictionary first:
// curl -o data/zstd_dictionary https://github.com/bluesky-social/jetstream/raw/refs/heads/main/pkg/models/zstd_dictionary
# Basic streaming
cargo run --bin atproto-jetstream-consumer \
--hostname jetstream1.us-east.bsky.network \
--collections app.bsky.feed.post \
--user-agent "my-consumer/1.0"
# With compression
cargo run --bin atproto-jetstream-consumer \
--hostname jetstream1.us-east.bsky.network \
--collections app.bsky.feed.post \
--compression \
--zstd-dictionary ./data/zstd_dictionary
# With filtering
cargo run --bin atproto-jetstream-consumer \
--hostname jetstream1.us-east.bsky.network \
--collections "app.bsky.feed.post,app.bsky.actor.profile" \
--dids "did:plc:user123,did:plc:user456"
MIT License