| Crates.io | drasi-bootstrap-noop |
| lib.rs | drasi-bootstrap-noop |
| version | 0.1.2 |
| created_at | 2026-01-15 00:15:58.560035+00 |
| updated_at | 2026-01-23 06:20:16.549131+00 |
| description | No-op bootstrap provider plugin for Drasi |
| homepage | |
| repository | https://github.com/drasi-project/drasi-core |
| max_upload_size | |
| id | 2044234 |
| size | 82,220 |
A lightweight bootstrap provider plugin for Drasi that returns no data. This provider is useful when sources don't require bootstrap support or when you want to disable initial data loading while maintaining continuous change streaming.
The NoOp Bootstrap Provider implements the BootstrapProvider trait but intentionally returns zero elements. This makes it ideal for scenarios where:
Send + Sync)sources:
- id: my_source
source_type: http # Any source type
bootstrap_provider:
type: noop # No additional configuration needed
properties:
# Source-specific properties
The NoOp provider can be instantiated using either the constructor or builder pattern:
use drasi_bootstrap_noop::NoOpBootstrapProvider;
// Option 1: Direct instantiation
let provider = NoOpBootstrapProvider::new();
// Option 2: Builder pattern (for API consistency)
let provider = NoOpBootstrapProvider::builder()
.build();
Stream changes from an HTTP endpoint without loading historical data:
use drasi_lib::{DrasiLib, DrasiLibConfig, Query};
use drasi_bootstrap_noop::NoOpBootstrapProvider;
use drasi_source_http::HttpSourceBuilder;
let source = HttpSourceBuilder::new("api_source")
.with_endpoint("http://api.example.com/events")
.with_bootstrap_provider(Box::new(NoOpBootstrapProvider::new()))
.build()
.await?;
let mut drasi = DrasiLib::new(config);
drasi.initialize().await?;
drasi.add_source(source).await?;
// Query will only process new changes, no historical data
let query = Query::cypher("recent_changes")
.query("MATCH (n:Event) WHERE n.timestamp > datetime() RETURN n")
.from_source("api_source")
.build();
drasi.add_query(query).await?;
drasi.start().await?;
Disable bootstrap when testing continuous query logic:
use drasi_lib::sources::mock::MockSource;
use drasi_bootstrap_noop::NoOpBootstrapProvider;
let mock_source = MockSource::builder()
.with_id("test_source")
.with_bootstrap_provider(Box::new(NoOpBootstrapProvider::new()))
.build();
// Mock source will only process injected changes, no bootstrap
mock_source.inject_change(my_test_change).await?;
Stream PostgreSQL WAL changes without loading existing table data:
use drasi_source_postgres::PostgresReplicationSource;
use drasi_bootstrap_noop::NoOpBootstrapProvider;
let source = PostgresReplicationSource::builder()
.with_id("pg_stream")
.with_host("localhost")
.with_database("mydb")
.with_bootstrap_provider(Box::new(NoOpBootstrapProvider::new()))
.build()
.await?;
// Only new inserts/updates/deletes will be processed
// Existing rows in the database are ignored
Use different bootstrap providers for different sources:
use drasi_bootstrap_noop::NoOpBootstrapProvider;
use drasi_bootstrap_postgres::PostgresBootstrapProvider;
// Source 1: Full bootstrap from PostgreSQL
let source1 = build_source_with_bootstrap(
Box::new(PostgresBootstrapProvider::new())
);
// Source 2: No bootstrap, streaming only
let source2 = build_source_with_bootstrap(
Box::new(NoOpBootstrapProvider::new())
);
// Different bootstrap strategies for different sources
drasi.add_source(source1).await?;
drasi.add_source(source2).await?;
pub struct NoOpBootstrapProvider;
The main provider struct. This is a zero-sized type (ZST) with no fields.
impl NoOpBootstrapProvider {
/// Create a new NoOp bootstrap provider
pub fn new() -> Self;
/// Create a builder for NoOpBootstrapProvider
/// Returns NoOpBootstrapProviderBuilder for API consistency
pub fn builder() -> NoOpBootstrapProviderBuilder;
}
impl BootstrapProvider for NoOpBootstrapProvider {
async fn bootstrap(
&self,
request: BootstrapRequest,
context: &BootstrapContext,
event_tx: BootstrapEventSender,
) -> Result<usize>;
}
Behavior: Logs the bootstrap request for the query and immediately returns Ok(0) without sending any events.
Returns: Result<usize> - Always returns Ok(0) indicating zero elements were sent.
pub struct NoOpBootstrapProviderBuilder;
Builder for creating NoOpBootstrapProvider instances. Provided for API consistency with other bootstrap providers, though no configuration options are available.
impl NoOpBootstrapProviderBuilder {
/// Create a new builder
pub fn new() -> Self;
/// Build the NoOpBootstrapProvider
pub fn build(self) -> NoOpBootstrapProvider;
}
The NoOp provider logs bootstrap operations at the info level:
INFO No-op bootstrap for query my_query: returning no data
This helps confirm that bootstrap was intentionally skipped rather than failed.
| Provider | Use Case | Data Source | Performance |
|---|---|---|---|
| NoOp | No historical data needed | None | Instant |
| PostgreSQL | Bootstrap from database snapshot | PostgreSQL DB | Depends on table size |
| ScriptFile | Bootstrap from JSONL files | Local files | Depends on file size |
| Platform | Bootstrap from remote Drasi | HTTP API | Depends on network/data |
| Application | Bootstrap from in-memory storage | Application state | Depends on stored data |
Use the NoOp provider when:
Don't use the NoOp provider when:
The NoOp provider is part of Drasi's universal pluggable bootstrap architecture where ALL sources support configurable bootstrap providers. This means:
Sources that integrate the NoOp provider:
The NoOp provider is intentionally minimal:
#[async_trait]
impl BootstrapProvider for NoOpBootstrapProvider {
async fn bootstrap(
&self,
request: BootstrapRequest,
_context: &BootstrapContext,
_event_tx: BootstrapEventSender,
) -> Result<usize> {
info!(
"No-op bootstrap for query {}: returning no data",
request.query_id
);
Ok(0)
}
}
Key design decisions:
_context and _event_tx are unused (prefixed with _)The NoOp provider has minimal dependencies:
[dependencies]
drasi-lib = { path = "../../../lib" }
anyhow = "1.0"
async-trait = "0.1"
log = "0.4"
Note: The current Cargo.toml includes unnecessary dependencies (tokio-postgres, redis, etc.) that should be removed in a future cleanup. The provider only actually uses the four dependencies listed above.
Licensed under the Apache License, Version 2.0. See LICENSE file for details.
Contributions are welcome! The NoOp provider is intentionally simple, but improvements could include:
Please see the main Drasi contributing guidelines for more information.