Tier: Starter · Status: Full · Java original:
firefly-starter-data· .NET project:FireflyFramework.Starter.Data
starterdata is the bring-your-own-DB starter. It composes
startercore and leaves the persistence pool to
the consumer — perfect for services that already own a *sql.DB /
pgxpool.Pool configuration.
type Data struct {
*startercore.Core
}
func New(cfg startercore.Config) *DataStarterName defaults to "starter-data".
import (
"database/sql"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/fireflyframework/fireflyframework-go/migrations"
"github.com/fireflyframework/fireflyframework-go/starterdata"
"github.com/fireflyframework/fireflyframework-go/startercore"
)
func main() {
db, _ := sql.Open("pgx", os.Getenv("DATABASE_URL"))
if err := migrations.Run(ctx, db, migrations.NewFSSource(migrationFS, "db")); err != nil {
log.Fatal(err)
}
d := starterdata.New(startercore.Config{AppName: "orders"})
repo := newOrderRepo(db)
orderscore.Register(d.Bus, repo)
// … wire HTTP, run via d.NewApplication() …
}Three reasons:
- The
Coreabstraction can't hold a typed*sql.DBwithout either pulling pgx into every service or losing type safety.starterdatalets the consumer keep their typed pool while still getting the standardCorefacilities. - Services that don't need a database (read-side projections,
thin BFFs, event consumers) should not be forced to depend on a
DB driver. Use
starterdataonly when persistence is needed. - Migration timing is application-specific (some services run
migrations elsewhere, some at startup) — leaving the choice in
main.gokeeps it explicit.
cd starterdata
go test ./...Covers the wired Core being non-nil and the StarterName overrride.