| Crates.io | changes-stream2 |
| lib.rs | changes-stream2 |
| version | 0.2.20 |
| created_at | 2021-03-15 08:28:46.083425+00 |
| updated_at | 2025-09-19 07:38:17.437808+00 |
| description | couchdb follower |
| homepage | |
| repository | https://github.com/elwerene/changes-stream-rust.git |
| max_upload_size | |
| id | 369154 |
| size | 62,010 |
Fork of https://github.com/ashleygwilliams/changes-stream-rust / https://crates.io/crates/changes-stream.
An implementation of changes-stream in Rust.
This code reads in a readable stream from an endpoint, parses each line and returns CouchDB changes events as defined in src/event.rs.
in your Cargo.toml:
[dependencies]
changes-stream2 = "0.2"
from examples/follower.rs:
use changes_stream2::{ChangesStream, Event};
use futures_util::stream::StreamExt;
#[tokio::main]
async fn main() {
let url = "https://replicate.npmjs.com/_changes".to_string();
let mut changes = ChangesStream::new(url).await.unwrap();
while let Some(event) = changes.next().await {
match event {
Ok(Event::Change(change)) => println!("Change ({}): {}", change.seq, change.id),
Ok(Event::Finished(finished)) => println!("Finished: {}", finished.last_seq),
Err(err) => println!("Error: {:?}", err),
}
}
}
Enables metrics collection of the changes stream as counter values. The name is generated from the host and path of the url(database name). The metrics are:
couchdb_changes_{name}_bytes: Total bytes read from the changes streamcouchdb_changes_{name}_entries: Total parsed change entriesChanges the type of ChangeEvent::Doc from serde_json::Map<String, serde_json::Value> to serde_json::value::RawValue.
Use the native-tls crate for TLS connections. This is the default.
Use the rustls crate for TLS connections.