complex

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 15 Imported by: 0

README

Complex Example

A realistic multi-level dependency graph with shared dependencies, multiple convergence points, and varied parallelization.

Dependency Tree

                 env
              /   |   \
             ▼    ▼    ▼
         config secrets logger
            |      \    /
            ▼       ▼  ▼
           db       auth
            \      /    \
             ▼    ▼      ▼
             user      admin
               \        /
                ▼      ▼
                gateway

Execution Levels

  1. Level 0: env (root)
  2. Level 1: config, secrets, logger (run in parallel)
  3. Level 2: db, auth (run in parallel - auth waits for secrets+logger, db waits for config)
  4. Level 3: user, admin (run in parallel)
  5. Level 4: gateway (final convergence)

What It Demonstrates

  • Shared dependencies: Both auth and db depend on different subsets of level 1
  • Multiple convergence points: user depends on db+auth, admin depends only on auth
  • Mixed fan-out/fan-in: Several parallel branches with different convergence patterns
  • Realistic architecture: Mirrors a real application with config, secrets, database, auth, and API layers

Run It

cd examples/complex
go run .

Expected Output

The output shows the layered execution:

[env] Loading environment...
[env] Done
[config] Loading...  [secrets] Loading...  [logger] Initializing...
[logger] Done
[secrets] Done  
[config] Done
[db] Connecting...  [auth] Initializing auth with secrets...
[db] Done
[auth] Done
[user] Loading user service...  [admin] Loading admin service...
[user] Done
[admin] Done
[gateway] Starting gateway...
[gateway] Done

=== Timing ===
Total: ~500ms (with parallel execution)
Sequential would be: ~950ms

Key Insight

Even though there are 9 nodes, the execution only takes 5 "levels" of time because nodes at the same level run concurrently.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
nodes
db
env

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL