Skip to content

Configuration

Configure Recoco via the Settings struct passed to init_lib_context, and through environment variables.

Every Recoco application must initialize the library context before creating any flows:

use recoco::settings::Settings;
recoco::lib_context::init_lib_context(Some(Settings::default())).await?;

Call this once per application, typically at the start of main(). It loads the operation registry, sets up authentication registries, and applies your configuration.

recoco::settings::Settings controls global behavior:

use recoco::settings::{Settings, DatabaseConnectionSpec, GlobalExecutionOptions};
let settings = Settings {
// Database configuration for persisted flows
database: Some(DatabaseConnectionSpec {
url: "postgres://user:pass@localhost:5432/recoco_db".to_string(),
user: Some("user".to_string()),
password: Some("pass".to_string()),
max_connections: 10,
min_connections: 1,
}),
// Concurrency controls
global_execution_options: GlobalExecutionOptions {
source_max_inflight_rows: Some(1000),
source_max_inflight_bytes: Some(10 * 1024 * 1024), // 10MB
},
// Application namespace (used to prefix database tables)
app_namespace: "my_app".to_string(),
// Whether to silently ignore errors when dropping targets during teardown
ignore_target_drop_failures: false,
};
recoco::lib_context::init_lib_context(Some(settings)).await?;

Required when using persisted flows (requires the persistence feature).

FieldTypeDescription
urlStringPostgreSQL connection URL
userOption<String>Override the username from the URL
passwordOption<String>Override the password from the URL
max_connectionsu32Maximum connection pool size
min_connectionsu32Minimum idle connections to keep open

Controls concurrency and backpressure during flow execution.

FieldTypeDescription
source_max_inflight_rowsOption<usize>Max rows in-flight from all sources at once
source_max_inflight_bytesOption<usize>Max bytes in-flight from all sources at once
FieldTypeDefaultDescription
app_namespaceString""Namespace prefix for database tables and keys (empty string means no prefix)
ignore_target_drop_failuresboolfalseSuppress errors when dropping target tables during teardown
VariableDescriptionDefault
RUST_LOGLogging verbosity filter (e.g., info, debug, recoco=trace)info
DATABASE_URLPostgreSQL connection URL your application can read to populate Settings::database (Recoco does not read this automatically)
Terminal window
# Enable info-level logging for all crates
RUST_LOG=info cargo run
# Verbose Recoco logging, quiet everything else
RUST_LOG=recoco=debug,warn cargo run
# Trace-level for a specific module
RUST_LOG=recoco::execution=trace cargo run
use recoco::builder::FlowBuilder;
use recoco::execution::evaluator::evaluate_transient_flow;
use recoco::prelude::*;
use recoco::settings::Settings;
// No database configuration required
recoco::lib_context::init_lib_context(Some(Settings::default())).await?;
let mut builder = FlowBuilder::new("my_flow").await?;
// ... add inputs and transforms ...
let flow = builder.build_transient_flow().await?;
let inputs = vec![value::Value::Basic("hello world".into())];
let result = evaluate_transient_flow(&flow.0, &inputs).await?;

Persisted (requires persistence feature and a database)

Section titled “Persisted (requires persistence feature and a database)”
[dependencies]
recoco = { version = "0.2", features = ["persistence", "source-local-file"] }
use recoco::builder::FlowBuilder;
use recoco::settings::{Settings, DatabaseConnectionSpec};
let settings = Settings {
database: Some(DatabaseConnectionSpec {
url: std::env::var("DATABASE_URL")?,
user: None,
password: None,
max_connections: 10,
min_connections: 1,
}),
..Default::default()
};
recoco::lib_context::init_lib_context(Some(settings)).await?;
let mut builder = FlowBuilder::new("my_flow").await?;
// ... add inputs and transforms ...
let flow = builder.build_flow().await?;