Show HN: Kessoku – Next-generation DI for Go with parallel provider execution
3 months ago
1
Kessoku is a compile-time dependency injection library for Go that speeds up application startup through parallel dependency injection. Unlike traditional DI frameworks that initialize services sequentially, Kessoku automatically executes independent providers in parallel, dramatically reducing startup time for applications with multiple slow services. Built as a powerful alternative to google/wire, it generates optimized code at compile time with zero runtime overhead.
Sequential: DB → Cache → Auth = Total waiting time Parallel: DB + Cache + Auth = Fastest service wins
// Before: Sequential (google/wire)wire.Build(NewDB, NewCache, NewAuth, NewApp) // Each waits for previous// After: Parallel (Kessoku) kessoku.Inject[*App]("InitApp",
kessoku.Async(kessoku.Provide(NewDB)), // }kessoku.Async(kessoku.Provide(NewCache)), // } All run togetherkessoku.Async(kessoku.Provide(NewAuth)), // }kessoku.Provide(NewApp), // waits for all
) // Fastest possible startup
Result: Every restart gets faster. Multiple slow services? Maximum impact.
Your typical day: Restart your app 10 times during development. Each restart wastes time waiting for services to start one by one.
gantt
title Sequential vs Parallel Startup
dateFormat X
axisFormat %L
section Sequential (slow)
DB Service :0, 3
Cache Service :3, 5
Auth Service :5, 6
section Parallel (fast)
DB Service :0, 3
Cache Service :0, 2
Auth Service :0, 1
Loading
Perfect for:
Cold start nightmares: Your Lambda/serverless function times out during initialization
Dev restart hell: You restart your app 10+ times daily, losing 3+ seconds each time
google/wire refugees: You love compile-time DI but hate slow startup times
Install kessoku:
go get -tool github.com/mazrean/kessoku/cmd/kessoku
Create main.go:
package main
import (
"fmt""time""github.com/mazrean/kessoku"
)
funcSlowDB() string {
time.Sleep(200*time.Millisecond)
return"DB-connected"
}
funcSlowCache() string {
time.Sleep(150*time.Millisecond)
return"Cache-ready"
}
//go:generate go tool kessoku $GOFILEvar_=kessoku.Inject[string]("InitApp",
kessoku.Async(kessoku.Provide(SlowDB)),
kessoku.Async(kessoku.Provide(SlowCache)),
kessoku.Provide(func(db, cachestring) string {
returnfmt.Sprintf("App running with %s and %s", db, cache)
}),
)
funcmain() {
start:=time.Now()
result, _:=InitApp()
fmt.Printf("%s in %v\n", result, time.Since(start))
}
Run:
go generate && go run main.go
# Shows: App running with DB-connected and Cache-ready (parallel startup)
Recommended:
go get -tool github.com/mazrean/kessoku/cmd/kessoku
Download binary
Download the latest binary for your platform from the releases page.
Linux/macOS:
# Download and install (replace with your platform)
curl -L -o kessoku.tar.gz https://github.com/mazrean/kessoku/releases/latest/download/kessoku_Linux_x86_64.tar.gz
tar -xzf kessoku.tar.gz
sudo mv kessoku /usr/local/bin/
Windows:
# Download and installInvoke-WebRequest-Uri "https://github.com/mazrean/kessoku/releases/latest/download/kessoku_Windows_x86_64.zip"-OutFile "kessoku.zip"Expand-Archive-Path "kessoku.zip"-DestinationPath "."Move-Item"kessoku.exe""$env:USERPROFILE\bin\"-Force
# Add $env:USERPROFILE\bin to your PATH if not already added
Rule: Independent async providers run in parallel, dependent ones wait automatically.
Kessoku
google/wire
uber/fx
Startup Speed
Parallel
Sequential
Sequential + runtime
Learning Curve
Minimal
Minimal
Steep
Production Ready
Yes
Yes
Yes
Choose Kessoku if: You have multiple slow services (DB, cache, APIs) and startup time matters Choose google/wire if: You want maximum simplicity and startup speed isn't critical Choose uber/fx if: You need complex lifecycle management and don't mind runtime overhead