| Crates.io | drasi-bootstrap-platform |
| lib.rs | drasi-bootstrap-platform |
| version | 0.1.2 |
| created_at | 2026-01-14 23:33:34.096293+00 |
| updated_at | 2026-01-23 06:19:05.815461+00 |
| description | Platform bootstrap plugin for Drasi |
| homepage | |
| repository | https://github.com/drasi-project/drasi-core |
| max_upload_size | |
| id | 2044172 |
| size | 119,975 |
A bootstrap provider for Drasi that fetches initial data from a remote Drasi Query API service. This enables federated Drasi deployments where one Drasi instance can bootstrap queries with data from another Drasi instance.
The Platform Bootstrap Provider connects to a remote Drasi Query API service to retrieve initial graph data (nodes and relationships) for continuous query bootstrap operations. It establishes an HTTP connection, subscribes to query results, and streams elements in JSON-NL (JSON Lines) format.
The Platform Bootstrap Provider supports three configuration approaches:
use drasi_bootstrap_platform::PlatformBootstrapProvider;
let provider = PlatformBootstrapProvider::builder()
.with_query_api_url("http://remote-drasi:8080")
.with_timeout_seconds(600)
.build()?;
use drasi_bootstrap_platform::PlatformBootstrapProvider;
use drasi_lib::bootstrap::PlatformBootstrapConfig;
let config = PlatformBootstrapConfig {
query_api_url: Some("http://remote-drasi:8080".to_string()),
timeout_seconds: 600,
};
let provider = PlatformBootstrapProvider::new(config)?;
use drasi_bootstrap_platform::PlatformBootstrapProvider;
let provider = PlatformBootstrapProvider::with_url(
"http://remote-drasi:8080",
600 // timeout in seconds
)?;
| Name | Description | Data Type | Valid Values | Default |
|---|---|---|---|---|
query_api_url |
Base URL of the remote Drasi Query API service | String |
Valid HTTP/HTTPS URL (e.g., "http://drasi:8080") | Required |
timeout_seconds |
HTTP request timeout in seconds | u64 |
Positive integer (recommended: 300-900 for large datasets) | 300 |
/subscription to this base URL for subscription requests.The Platform Bootstrap Provider expects JSON-NL (newline-delimited JSON) responses from the remote Query API's /subscription endpoint. Each line contains a single element in the following format:
{
"id": "unique-element-id",
"labels": ["Label1", "Label2"],
"properties": {
"propertyName": "value",
"anotherProperty": 42
},
"startId": "optional-start-node-id",
"endId": "optional-end-node-id"
}
["Person", "Employee"])startId and endId fields are treated as nodesstartId and endId are treated as relationships{
"id": "person-1",
"labels": ["Person", "Employee"],
"properties": {
"name": "Alice",
"age": 30,
"department": "Engineering"
}
}
{
"id": "rel-1",
"labels": ["WORKS_FOR"],
"properties": {
"since": "2020-01-15",
"role": "Senior Engineer"
},
"startId": "person-1",
"endId": "company-1"
}
The provider sends POST requests to {query_api_url}/subscription with the following payload:
{
"queryId": "my-query-id",
"queryNodeId": "server-instance-id",
"nodeLabels": ["Person", "Company"],
"relLabels": ["WORKS_FOR", "MANAGES"]
}
use drasi_bootstrap_platform::PlatformBootstrapProvider;
use drasi_lib::DrasiLibBuilder;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create platform bootstrap provider
let bootstrap_provider = PlatformBootstrapProvider::builder()
.with_query_api_url("http://source-drasi:8080")
.with_timeout_seconds(600)
.build()?;
// Configure Drasi with platform bootstrap
let drasi = DrasiLibBuilder::new()
.with_id("federated-instance")
.with_bootstrap_provider(bootstrap_provider)
.build()
.await?;
// Add sources, queries, etc.
// ...
Ok(())
}
use drasi_bootstrap_platform::PlatformBootstrapProvider;
use drasi_lib::{DrasiLibBuilder, Query};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Bootstrap from remote production Drasi instance
let prod_bootstrap = PlatformBootstrapProvider::with_url(
"http://production-drasi:8080",
900 // 15 minutes for large dataset
)?;
let drasi = DrasiLibBuilder::new()
.with_id("staging-instance")
.with_bootstrap_provider(prod_bootstrap)
.build()
.await?;
// Create query that will bootstrap from production
let query = Query::cypher("active-users")
.query("MATCH (u:User) WHERE u.active = true RETURN u")
.from_source("production")
.build();
drasi.add_query(query).await?;
Ok(())
}
use drasi_bootstrap_platform::PlatformBootstrapProvider;
use drasi_lib::DrasiLibBuilder;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create providers for different remote sources
let users_bootstrap = PlatformBootstrapProvider::with_url(
"http://users-drasi:8080",
300
)?;
let products_bootstrap = PlatformBootstrapProvider::with_url(
"http://products-drasi:8080",
300
)?;
// Configure Drasi with multiple bootstrap providers
// Note: You would need to configure separate sources with different
// bootstrap providers for each remote system
let drasi = DrasiLibBuilder::new()
.with_id("aggregation-instance")
.with_bootstrap_provider(users_bootstrap)
.build()
.await?;
Ok(())
}
use drasi_bootstrap_platform::PlatformBootstrapProvider;
fn create_provider() -> anyhow::Result<PlatformBootstrapProvider> {
let provider = PlatformBootstrapProvider::builder()
.with_query_api_url("http://remote-drasi:8080")
.with_timeout_seconds(600)
.build()
.map_err(|e| {
eprintln!("Failed to create bootstrap provider: {}", e);
e
})?;
Ok(provider)
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
match create_provider() {
Ok(provider) => {
println!("Provider created successfully");
// Use provider...
}
Err(e) => {
eprintln!("Initialization failed: {}", e);
return Err(e);
}
}
Ok(())
}
{query_api_url}/subscription with query details and requested labelsElement formatThe provider handles various error scenarios:
The provider uses structured logging with the following levels:
The provider includes comprehensive unit tests:
# Run all tests
cargo test -p drasi-bootstrap-platform
# Run specific test
cargo test -p drasi-bootstrap-platform test_platform_bootstrap_builder_with_valid_url
# Run with debug logging
RUST_LOG=debug cargo test -p drasi-bootstrap-platform -- --nocapture
Copyright 2025 The Drasi Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.