Go API & Programmatic Usage
Use ETLX as a Go library to execute pipelines, run specific stages, or embed ETLX into your own applications.
Go API & Programmatic Usage
ETLX is not only a CLI tool โ it is also a Go library that you can embed directly into your own applications.
The official etlx binary is built using the same public Go APIs exposed by the project.
This page documents those APIs in a ready-to-use way, based on how cmd/main.go constructs and executes pipelines.
๐ง CLI Internals (Important Context)
The ETLX CLI:
- Uses Goโs standard
flagpackage - Does not rely on Cobra or subcommands
- Internally calls the same APIs you can call from Go
This means:
๐ Anything the CLI can do, you can do programmatically
๐ฆ Installing as a Go Dependency
go get github.com/realdatadriven/etlx
๐ง Core Concepts (Go Perspective)
At runtime, ETLX works in three phases:
- Parse Markdown configuration
- Resolve execution scope (date, only, skip, steps, etc.)
- Execute pipeline + collect logs
The Go API mirrors this exactly.
๐ Creating an ETLX Engine
import "github.com/realdatadriven/etlx"
engine := &etlx.ETLX{}
This ETLX instance holds:
- Parsed pipeline configuration
- Execution options
- Runtime state
- Execution logs
๐ Loading a Pipeline Configuration
Load from file
err := engine.ConfigFromFile("pipeline.md")
if err != nil {
panic(err)
}
Load from in-memory Markdown
Useful for dynamic or generated pipelines:
md := `# ETLX Pipeline...`
err := engine.ConfigFromMDText(md)
if err != nil {
panic(err)
}
๐ Running a Pipeline (Equivalent to CLI)
Equivalent CLI:
etlx --config pipeline.md --date 2025-01-01
Minimal execution
dates := []time.Time{
time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC),
}
logs, err := engine.RunETL(dates, nil, nil)
if err != nil {
panic(err)
}
๐ฏ Execution Options (--only, --skip, --steps)
The CLI flags are translated into a simple options map.
Run only specific keys
opts := map[string]any{
"only": []string{"sales", "customers"},
}
logs, err := engine.RunETL(dates, nil, opts)
Equivalent CLI:
etlx --config pipeline.md --only sales,customers
Skip specific keys
opts := map[string]any{
"skip": []string{"debug_tables"},
}
Run specific lifecycle steps
opts := map[string]any{
"steps": []string{"extract", "load"},
}
Equivalent CLI:
etlx --config pipeline.md --steps extract,load
๐งน Clean & Drop Operations
Equivalent CLI:
etlx --config pipeline.md --clean
etlx --config pipeline.md --drop
Clean SQL blocks
opts := map[string]any{
"clean": true,
}
engine.RunETL(dates, nil, opts)
Drop SQL blocks
opts := map[string]any{
"drop": true,
}
engine.RunETL(dates, nil, opts)
๐ Accessing Execution Logs
Every execution returns structured logs.
logs, _ := engine.RunETL(dates, nil, nil)
for _, log := range logs {
fmt.Println(
log.Name,
log.Ref,
log.Duration,
log.Success,
log.Msg,
)
}
Each log entry typically contains:
| Field | Description |
|---|---|
name | Step or block name |
ref | Reference date |
start | Start timestamp |
end | End timestamp |
duration | Execution time |
success | Success / failure |
msg | Message or error |
๐งช Running Specific Sections
ETLX exposes explicit execution entry points for each pipeline capability.
All functions share the same execution model:
func(dates []time.Time, cfg any, opts map[string]any) ([]etlx.Log, error)
The difference is which Markdown sections are executed.
โถ๏ธ RunETL
Executes the full ETL / ELT lifecycle see ETL / ELT
logs, err := engine.RunETL(dates, nil, nil)
๐งช RunDATA_QUALITY
Runs operational or auxiliary scripts see Data Quality
logs, err := engine.RunDATA_QUALITY(dates, nil, nil)
๐ค RunEXPORTS
Executes export definitions see Exports
logs, err := engine.RunEXPORTS(dates, nil, nil)
๐ RunSCRIPTS
Runs operational or auxiliary scripts see Scripts
logs, err := engine.RunSCRIPTS(dates, nil, nil)
โ๏ธ RunACTIONS
Runs post-processing or orchestration actions see Actions
logs, err := engine.RunACTIONS(dates, nil, nil)
๐งพ RunLOGS
Processes logging or audit blocks see Logs / Observability
logs, err := engine.RunLOGS(dates, nil, nil)
๐ RunNOTIFY
Executes notification definitions see Notificatios
logs, err := engine.RunNOTIFY(dates, nil, nil)
๐งต Using ETLX Inside Long-Running Services
func runPipeline(ref time.Time) error {
engine := &etlx.ETLX{}
if err := engine.ConfigFromFile("pipeline.md"); err != nil {
return err
}
_, err := engine.RunETL([]time.Time{ref}, nil, nil)
return err
}
๐ง Why This Matters
Because ETLX is:
- A runtime
- An open specification
- A Go library
You are not locked into:
- A closed binary
- A hidden execution model
- A proprietary DSL
The Markdown pipeline is the documentation, and the Go API is the execution layer.
๐ Summary
โ CLI uses standard Go flags โ Go API mirrors the CLI exactly โ Pipelines can be executed from files or memory โ Each lifecycle has its own entry point โ Structured logs for audit & observability โ Ideal for embedding, automation, and regulated workloads
Last updated 09 Jan 2026, 11:14 -01 .