Adding a New Pipeline
This guide explains how to add a new pipeline to your running Harmony instance without downtime.
Quick Start
- Create a new TOML file in your
pipelines/directory - Define your pipeline configuration
- Save the file
- Harmony automatically detects and loads it
Step-by-Step
1. Create the Pipeline File
Create a new file in your pipelines/ directory:
# Example: Add a new FHIR search pipeline
touch pipelines/fhir-search.toml
Files in the pipelines/ directory are automatically discovered. You can organize them however you prefer:
pipelines/
├── api.toml # Existing pipeline
├── fhir.toml # Existing pipeline
└── fhir-search.toml # New pipeline
2. Write Your Pipeline Configuration
Open the file and define your pipeline. Here's a minimal example:
# pipelines/fhir-search.toml
[pipelines.fhir_search]
description = "FHIR patient search endpoint"
networks = ["http_net"]
endpoints = ["fhir_search_endpoint"]
middleware = ["fhir_auth"]
backends = ["fhir_backend"]
[endpoints.fhir_search_endpoint]
service = "fhir"
[endpoints.fhir_search_endpoint.options]
path_prefix = "/fhir/search"
[middleware.fhir_auth]
type = "jwt_auth"
[middleware.fhir_auth.options]
public_key_path = "/etc/harmony/jwt_public.pem"
[backends.fhir_backend]
service = "http"
[backends.fhir_backend.options]
url = "https://fhir-server.example.com"
timeout_secs = 30
For detailed configuration options, see the Pipelines reference.
3. Save and Harmony Reloads Automatically
When you save the file:
- Harmony's hot-reload system detects the new file
- Configuration is validated
- The pipeline is loaded into the running instance
- No restart required (most changes apply without downtime)
4. Verify the Pipeline
Check your Harmony logs to confirm the pipeline loaded successfully:
# Look for confirmation in logs
tail -f /var/log/harmony/harmony.log
You should see output like:
[INFO] Pipeline fhir_search loaded successfully
Make a test request to verify the endpoint is responding:
curl -H "Authorization: Bearer <your_jwt_token>" \
http://localhost:8080/fhir/search/Patient?name=Smith
Reusing Existing Components
You don't need to redefine middleware or backends if they already exist in other pipeline files. Reference them by name:
# pipelines/new-endpoint.toml
# Reuse existing auth middleware and backend from other pipelines
[pipelines.new_service]
networks = ["http_net"]
endpoints = ["new_endpoint"]
middleware = ["fhir_auth"] # Defined elsewhere
backends = ["fhir_backend"] # Defined elsewhere
[endpoints.new_endpoint]
service = "http"
[endpoints.new_endpoint.options]
path_prefix = "/new-service"
Common Patterns
Multiple Endpoints in One Pipeline
[pipelines.multi_endpoint]
endpoints = ["endpoint1", "endpoint2", "endpoint3"]
middleware = ["auth"]
backends = ["backend1"]
[endpoints.endpoint1]
service = "fhir"
[endpoints.endpoint1.options]
path_prefix = "/fhir"
[endpoints.endpoint2]
service = "http"
[endpoints.endpoint2.options]
path_prefix = "/api"
[endpoints.endpoint3]
service = "dicomweb"
[endpoints.endpoint3.options]
path_prefix = "/dicom"
Middleware Chain
Middleware executes in order. Define a chain for complex request processing:
[pipelines.secure_api]
middleware = [
"auth", # 1. Authenticate first
"policies", # 2. Check authorization
"transform", # 3. Transform data
"rate_limit" # 4. Rate limiting
]
Multiple Backends
Some pipeline use cases may require routing to different backends:
[pipelines.hybrid_api]
backends = ["primary_backend", "fallback_backend"]
Troubleshooting
Pipeline Not Loading
Check the following:
- File syntax - Ensure valid TOML syntax. Use a TOML validator if unsure.
- Referenced components - Verify all networks, endpoints, middleware, and backends exist.
- File location - Confirm the file is in the
pipelines_pathdirectory specified inconfig.toml. - Permissions - Ensure Harmony has read access to the file.
Validation Errors
Harmony logs validation errors when loading fails:
# Check logs for detailed error messages
grep -i "error\|invalid" /var/log/harmony/harmony.log
Common validation errors:
- Unknown network - Network defined in pipeline doesn't exist in
config.toml - Unknown service - Service type (e.g.,
fhir,http) is not recognized - Missing middleware - Middleware referenced in pipeline isn't defined
- Invalid options - Middleware or backend options are invalid for that service type
Reload Not Detected
If Harmony isn't detecting file changes:
- Verify
hot_reloadis enabled inconfig.toml - Check file permissions (Harmony needs read access)
- Restart Harmony if needed (changes will apply on startup)