Skip to content

docs: add embedded Go API usage#15

Open
yottahmd wants to merge 1 commit intomainfrom
docs/embedded-dagu-api
Open

docs: add embedded Go API usage#15
yottahmd wants to merge 1 commit intomainfrom
docs/embedded-dagu-api

Conversation

@yottahmd
Copy link
Copy Markdown
Contributor

@yottahmd yottahmd commented Apr 19, 2026

Summary

  • add a VitePress page for the experimental embedded Go API
  • document local runs, run options, custom executors, and distributed embedded execution based on the exported API
  • add the page to the Getting Started sidebar

Verification

  • pnpm build

Summary by CodeRabbit

  • Documentation
    • Added documentation for the Embedded Go API, enabling users to start and manage Dagu DAG runs programmatically from Go applications.
    • Covers local and distributed execution modes, asynchronous patterns, configuration parameters, executor registration, status monitoring, and operational capabilities.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 19, 2026

📝 Walkthrough

Walkthrough

Documentation for an experimental embedded Go API (dagu) is introduced. A new sidebar navigation entry is added to the VitePress configuration, linking to a comprehensive guide covering local execution, distributed execution flow, custom executor registration, and operational parameters.

Changes

Cohort / File(s) Summary
VitePress Navigation Configuration
.vitepress/config.js
Added "Embedded Go API" sidebar entry linking to /getting-started/embedded, positioned between "CLI Commands" and "AI Agent" in the Getting Started section.
Embedded Go API Documentation
getting-started/embedded.md
New documentation page describing the experimental embedded Go API for programmatic DAG execution, including local execution patterns, asynchronous run handling, distributed execution flow, custom executor registration, and configuration options for both embedded and per-run operations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'docs: add embedded Go API usage' accurately and concisely describes the main change: adding documentation for the embedded Go API with a new markdown file and sidebar entry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/embedded-dagu-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
dagu-sh-docs 3981801 Apr 19 2026, 12:31 PM

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
getting-started/embedded.md (1)

239-239: Consider adding a brief example of worker-level overrides.

The text mentions that WorkerOptions.Coordinators and WorkerOptions.TLS can override the engine's distributed settings, but the example on lines 210-214 doesn't demonstrate this. Adding a brief note that workers inherit from engine options by default might improve clarity.

📝 Optional clarity improvement
 `WorkerOptions.Coordinators` overrides `DistributedOptions.Coordinators` when non-empty. `WorkerOptions.TLS` overrides `DistributedOptions.TLS` when non-zero. `HealthPort` starts the worker health endpoint on that port; `0` disables it.
+
+Workers inherit the engine's distributed options by default. Override individual fields only when the worker requires different coordinator addresses or TLS settings.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@getting-started/embedded.md` at line 239, Add a short example or sentence
showing worker-level overrides: state that workers inherit engine
DistributedOptions by default but if WorkerOptions.Coordinators is non-empty it
overrides DistributedOptions.Coordinators for that worker, and if
WorkerOptions.TLS is non-zero it overrides DistributedOptions.TLS; also clarify
that HealthPort starts the worker health endpoint on the given port and 0
disables it. Reference the symbols WorkerOptions.Coordinators,
DistributedOptions.Coordinators, WorkerOptions.TLS, DistributedOptions.TLS, and
HealthPort when adding the note so readers can find the relevant config fields.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@getting-started/embedded.md`:
- Around line 15-63: The embedded Go example must be removed or replaced because
the functions dagu.New, engine.RunYAML, run.Wait, and dagu.WithParams do not
exist in the actual dagu package; either delete this example or replace it with
a working pattern (e.g., demonstrate invoking the dagu CLI via os/exec or
calling the server REST/gRPC API) and update the text to explicitly state that a
native embedding API is not yet available (referencing issue `#583`) if you keep
an aspirational sample. Ensure references to dagu.New, engine.RunYAML, run.Wait,
and dagu.WithParams are eliminated or clearly marked as future/placeholder APIs.

---

Nitpick comments:
In `@getting-started/embedded.md`:
- Line 239: Add a short example or sentence showing worker-level overrides:
state that workers inherit engine DistributedOptions by default but if
WorkerOptions.Coordinators is non-empty it overrides
DistributedOptions.Coordinators for that worker, and if WorkerOptions.TLS is
non-zero it overrides DistributedOptions.TLS; also clarify that HealthPort
starts the worker health endpoint on the given port and 0 disables it. Reference
the symbols WorkerOptions.Coordinators, DistributedOptions.Coordinators,
WorkerOptions.TLS, DistributedOptions.TLS, and HealthPort when adding the note
so readers can find the relevant config fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d654a994-6128-4607-905c-30b4a5f9150d

📥 Commits

Reviewing files that changed from the base of the PR and between aa89796 and 3981801.

📒 Files selected for processing (2)
  • .vitepress/config.js
  • getting-started/embedded.md

Comment on lines +15 to +63
```go
package main

import (
"context"
"fmt"
"log"
"time"

"github.com/dagucloud/dagu"
)

func main() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

engine, err := dagu.New(ctx, dagu.Options{
HomeDir: "/var/lib/myapp/dagu",
})
if err != nil {
log.Fatal(err)
}
defer func() {
if err := engine.Close(context.Background()); err != nil {
log.Printf("close Dagu engine: %v", err)
}
}()

run, err := engine.RunYAML(ctx, []byte(`
name: embedded-local
params:
- MESSAGE
steps:
- name: hello
command: echo "${MESSAGE}"
`), dagu.WithParams(map[string]string{
"MESSAGE": "hello from the host app",
}))
if err != nil {
log.Fatal(err)
}

status, err := run.Wait(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s finished with %s\n", status.RunID, status.Status)
}
```
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify dagu package API matches documentation examples

# Check if the package exists and extract key API signatures
rg -A 10 'func New\(' --type go
rg -A 5 'func.*RunYAML' --type go
rg -A 5 'func.*WithParams' --type go
rg -A 10 'type Status struct' --type go

Repository: dagucloud/docs

Length of output: 653


🏁 Script executed:

#!/bin/bash
# Explore the repository structure to understand what's available
find . -type f -name "*.go" | head -20
git ls-files | head -30
ls -la

Repository: dagucloud/docs

Length of output: 2217


🌐 Web query:

dagucloud/dagu package API documentation go

💡 Result:

The dagucloud/dagu package refers to the Go module for Dagu, a lightweight workflow orchestration engine. Its API documentation is available on pkg.go.dev at https://pkg.go.dev/github.com/dagu-org/dagu (latest v1.30.3 as of 2026-01-04). Note that there appear to be multiple related repositories (dagu-org/dagu, dagucloud/dagu, yohamta/dagu), but dagu-org/dagu is the primary active one with the most recent pkg.go.dev page. This page provides standard Go package documentation including: - Module overview, license (GPL-3.0), Go version compatibility (1.25+). - Dependencies list. - README with installation, quick start, features (YAML workflows, Web UI, CLI, distributed execution via gRPC, AI agent, etc.). - Links to full docs at docs.dagu.sh, GitHub examples, and community. Dagu also exposes a REST API (documented at https://docs.dagu.sh/web-ui/api and https://docs.dagu.cloud/reference/api) for HTTP-based interaction (e.g., /api/v1 or /api/v2 endpoints for DAG management, health checks), but this is the server's HTTP API, not the Go package API. No separate Go client SDK is explicitly documented in results; use the core package for embedding or direct use. For programmatic control, interact via the REST API or gRPC (mentioned for distributed mode). Source code at https://github.com/dagucloud/dagu or https://github.com/dagu-org/dagu.

Citations:


🌐 Web query:

site:pkg.go.dev github.com/dagu-org/dagu New RunYAML WithParams

💡 Result:

No explicit documentation or source code snippets for a "RunYAML WithParams" function or method in github.com/dagu-org/dagu were found in the search results. The pkg.go.dev page for github.com/dagu-org/dagu v1.30.3 (most recent, published 2026-01-04) provides general project information, installation, CLI usage like "dagu start hello.yaml", and YAML workflow examples with params in sub-DAG calls (e.g., params: "SOURCE=s3://bucket/data.csv"), but no Go API details matching the query. The official docs are referenced at docs.dagu.sh, but no specific Go library API for RunYAML is detailed in results. The CLI "dagu start <yaml>" likely handles YAML execution, possibly with params via flags or env vars, but no "WithParams" identified. Repository likely at https://github.com/dagu-org/dagu or https://github.com/dagucloud/dagu based on installer scripts.

Citations:


🌐 Web query:

github.com/dagu-org/dagu embedding API Go example

💡 Result:

No public example exists for embedding the Dagu workflow engine API directly in Go code. Dagu (github.com/dagu-org/dagu) is primarily a standalone binary workflow engine using YAML-defined DAGs, with REST API for programmatic control when the server runs (docs.dagu.sh/overview/api). pkg.go.dev shows the module exists but no documented public embedding API or examples. An open GitHub issue (#583) requests adding direct Go execution like dagu.Start("dagName", dagu.Params("key=val")), but it remains unresolved as of latest updates. To use Dagu programmatically, run the binary via exec.Command or interact via its gRPC/REST interfaces in distributed mode. For embedding workflows in Go, consider alternatives like github.com/rhosocial/go-dag.

Citations:


🌐 Web query:

site:github.com dagucloud/dagu "func New" "RunYAML"

💡 Result:

No function named "func New" referencing or using "RunYAML" was found in the dagucloud/dagu repository or its documentation across multiple searches targeting Go source code, GitHub files, and official docs. The repository is a Go-based workflow engine (https://github.com/dagucloud/dagu) where workflows are defined in YAML and executed via CLI commands like dagu start hello.yaml or API endpoints that accept inline YAML specs (e.g., POST /api/v2/dag-runs with "spec" field). There is an open issue (#583) proposing a public Go API for direct DAG execution like dagu.Start("dagName"), but it remains unimplemented as of 2026-04-19. Code snippets mentioning YAML parsing exist (e.g., migration to goccy/go-yaml in #913), but no matching "func New" with "RunYAML". Searches for source files like internal/digraph/loader.go surfaced coverage reports but no explicit code with the terms. Official docs at docs.dagu.sh focus on YAML workflows and CLI/API usage, with no embedded Go library API documented.

Citations:


🌐 Web query:

dagu-org/dagu Go API embedded example "dagu.New"

💡 Result:

No complete, up-to-date embedded Go API example using dagu.New was found in official documentation or pkg.go.dev pages. Dagu (github.com/dagu-org/dagu) is primarily designed as a standalone binary for YAML-based workflow execution via CLI commands like dagu start workflow.yaml, with a web UI and HTTP/gRPC APIs for management. The pkg.go.dev page (v1.30.3) shows the module but no public Go API documentation for direct embedding like dagu.New. An open GitHub issue #583 (dated 2024-06-03, updated 2025-12-06, still open) requests exactly this feature: "Enable Direct Execution of DAGs via Go Code" with proposed API like dagu.Start("someDAG", dagu.Params("FOO=BAR")). This confirms the feature is planned but not implemented as of the latest sources (repo active as of 2026-04). For embedding workflows in Go applications, current alternatives are: - Execute the dagu binary as a subprocess using os/exec (common for CLI tools). - Use the HTTP/gRPC client APIs once server is running (dagu start-all exposes /api/v1). Example subprocess usage: package main import ( "os/exec" ) func main { cmd := exec.Command("dagu", "start", "hello.yaml") err := cmd.Run if err != nil { panic(err) } } Official docs at docs.dagu.sh focus on YAML/CLI/server usage, not programmatic Go embedding. Repo: https://github.com/dagu-org/dagu (3K+ stars, Go primary lang).

Citations:


Remove or replace this example—the documented API does not exist in the actual dagucloud/dagu package.

The example shows dagu.New(), engine.RunYAML(), run.Wait(), and dagu.WithParams() functions that are not currently implemented in the github.com/dagu-org/dagu package. The package is primarily a CLI tool and server with REST/gRPC APIs, not a Go library for direct programmatic embedding. An open GitHub issue (#583, still unresolved) requests exactly this feature.

Either remove this example, replace it with an actual working approach (e.g., executing the dagu binary via os/exec or using the REST API when the server runs), or clearly mark it as aspirational/future API subject to change.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@getting-started/embedded.md` around lines 15 - 63, The embedded Go example
must be removed or replaced because the functions dagu.New, engine.RunYAML,
run.Wait, and dagu.WithParams do not exist in the actual dagu package; either
delete this example or replace it with a working pattern (e.g., demonstrate
invoking the dagu CLI via os/exec or calling the server REST/gRPC API) and
update the text to explicitly state that a native embedding API is not yet
available (referencing issue `#583`) if you keep an aspirational sample. Ensure
references to dagu.New, engine.RunYAML, run.Wait, and dagu.WithParams are
eliminated or clearly marked as future/placeholder APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant