Tier: Starter · Status: Full · Java original:
firefly-starter-core· .NET project:FireflyFramework.Starter.Core
startercore is the one-call infrastructure-tier wiring for any
Firefly Go service. A single New(Config{...}) returns a Core
struct holding every component a typical service needs:
Logger—slog.Loggerwith correlation-id enrichment.Cache—cache.Adapter, defaultMemory.Bus—cqrs.Buswith theValidationMiddlewarepre-installed.Broker—eda.Broker, defaultInMemory.Health—observability.Compositewith a default cache health indicator.Idempotency—web.IdempotencyConfig.Metrics—actuator.Registry.Scheduler—scheduling.Scheduler.
Plus four convenience methods:
Middleware()— the canonical outermost HTTP middleware chain (problem renderer, correlation, idempotency).ActuatorHandler(infoContributors...)— pre-wired/actuator/{health,info,metrics,env,goroutines,version}mux.NewApplication()—lifecycle.Applicationpre-configured with the core's logger.PrintBanner()— emits the ASCII banner identifying app + version- runtime.
type Config struct {
AppName string
AppVersion string
StarterName string
Logger *slog.Logger
Cache cache.Adapter
Bus *cqrs.Bus
Broker eda.Broker
Health *observability.Composite
Idempotency *web.IdempotencyConfig
Metrics *actuator.Registry
Scheduler *scheduling.Scheduler
}
type Core struct { ... }
func New(Config) *Core
func (*Core) Middleware() func(http.Handler) http.Handler
func (*Core) ActuatorHandler(infoContributors ...func() map[string]any) http.Handler
func (*Core) NewApplication() *lifecycle.Application
func (*Core) PrintBanner()import (
"context"
"net/http"
"os/signal"
"syscall"
"github.com/fireflyframework/fireflyframework-go/startercore"
)
func main() {
core := startercore.New(startercore.Config{
AppName: "orders",
AppVersion: "1.0.0",
})
apiMux := http.NewServeMux()
adminMux := http.NewServeMux()
adminMux.Handle("/actuator/", core.ActuatorHandler())
core.PrintBanner()
app := core.NewApplication().
OnHTTP(":8080", core.Middleware()(apiMux)).
OnHTTP(":8081", adminMux)
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer cancel()
_ = app.Run(ctx)
}cd startercore
go test ./...Covers every default component being non-nil, the panic→500 middleware chain, and the banner content.