π Phlow β Modular Flow Runtime for Composable Backends
Phlow is a high-performance and highly composable flow runtime built with Rust. It provides a new way to build backend systems using declarative configuration, modular logic, and pluggable runtime behavior β all driven by YAML, JSON, or TOML.
Phlow comes with native support for OpenTelemetry, enabling full observability of flows, modules, and runtime execution. You can export traces and metrics to systems like Jaeger, Grafana Tempo, or AWS X-Ray with minimal configuration using environment variables.
Whether you're building APIs, consumers, automations, or event-driven systems, Phlow makes it easy to connect logic, transform data, and monitor everything β all in a composable and developer-friendly way.
π Table of Contents
- π― Philosophy
- π Use Cases
- π Module Types
- π§± Example:
main.yamlfor an HTTP Gateway - π§© YAML Superpowers
- π§ Creating Your Own Module:
log - π¦ Project Structure
- π‘ Observability
- π§ͺ OpenTelemetry + Jaeger (Local Dev Setup)
- π Environment Settings
- π License
)
## π― Philosophy
### 1. **Flow over Frameworks**
### 2. **Composability**
)
)
### 3. **Extensibility with Scripts**
)
### 5. **Separation of Control and Behavior**
)
## π Module Types
| | |
|||
| | ) |
| | ) |
## π§± Example: `main.yaml` for an HTTP Gateway
π§© YAML Superpowers
Phlow extends YAML with:
!eval: execute inline expressions using Phlow Script (phs).!include: include other YAML files into the flow tree.!import: import external script files (.phs or .rhai) and evaluate them with!eval.
π§ Creating Your Own Module: log
Phlow modules are written in Rust and compiled as shared libraries. Hereβs a real example of a simple log module that prints messages at various log levels.
π§ Code (src/lib.rs)
use ;
plugin!;
π οΈ Example usage in a flow
steps:
- id: notify
module: log
with:
level: info
message: "Process started"
- use: log
with:
level: error
message: "something went wrong: " + main.error
π¦ Project Structure
## π‘ Observability
)
)
π§ͺ OpenTelemetry + Jaeger (Local Dev Setup)
To enable observability with Jaeger during development, you can run a full OpenTelemetry-compatible collector locally in seconds.
π 1. Run Jaeger with OTLP support
This container supports OTLP over HTTP and gRPC, which are both compatible with Phlow's OpenTelemetry output.
βοΈ 2. Configure environment variables
Set the following environment variables in your shell or .env file:
π 3. Open the Jaeger UI
Once running, access the Jaeger web interface at:
Search for your service using the name defined in OTEL_SERVICE_NAME.
β Tips
- Combine this with
PHLOW_OTEL=true,PHLOW_SPAN=INFO, andPHLOW_LOG=DEBUGfor full observability. - You can also integrate with Grafana Tempo or AWS X-Ray by replacing the collector backend.
π Environment Settings
Below is a list of all environment variables used by the application, combining those defined in both files, along with their descriptions, default values, and types.
Environment Variables Table
| Variable | Description | Default Value | Type |
|---|---|---|---|
| PHLOW_PACKAGE_CONSUMERS_COUNT | Number of package consumersDefines how many threads will be used to process packages. | 10 |
i32 |
| PHLOW_MIN_ALLOCATED_MEMORY_MB | Minimum allocated memory (MB)Defines the minimum amount of memory, in MB, allocated to the process. | 10 |
usize |
| PHLOW_GARBAGE_COLLECTION_ENABLED | Enable garbage collectionEnables or disables garbage collection (GC). | true |
bool |
| PHLOW_GARBAGE_COLLECTION_INTERVAL_SECONDS | Garbage collection interval (seconds)Defines the interval at which garbage collection will be performed. | 60 |
u64 |
| PHLOW_LOG | Log levelDefines the log verbosity for standard logging output. Possible values typically include TRACE, DEBUG, INFO, WARN, ERROR. |
WARN |
str |
| PHLOW_SPAN | Span levelDefines the verbosity level for span (OpenTelemetry) tracing. Possible values typically include TRACE, DEBUG, INFO, WARN, ERROR. |
INFO |
str |
| PHLOW_OTEL | Enable OpenTelemetryEnables or disables OpenTelemetry tracing and metrics. | true |
bool |
Notes
- If an environment variable is not set, the default value indicated in the table above will be used.
- Set the corresponding environment variables before running the application to override the defaults.
- The log level (
PHLOW_LOG) and span level (PHLOW_SPAN) control different layers of logging:PHLOW_LOG: Affects standard logging (e.g., error, warning, info messages).PHLOW_SPAN: Affects tracing spans (useful for deeper telemetry insights with OpenTelemetry).
- The
PHLOW_OTELvariable controls whether or not OpenTelemetry providers (for both tracing and metrics) are initialized.
π License
MIT Β© 2025 β Built with β€οΈ and Rust.