add initial application structure with configuration, logging, and health check endpoints

This commit is contained in:
kever
2026-01-15 21:39:15 +08:00
parent fed727e593
commit ed8c3d55b8
103 changed files with 39974 additions and 80 deletions

25
internal/infra/db/ent.go Normal file
View File

@@ -0,0 +1,25 @@
package db
import (
"context"
"go.uber.org/fx"
"epic-ent/internal/config"
"epic-ent/internal/ent"
)
func NewEntClient(lc fx.Lifecycle, cfg *config.Config) (*ent.Client, error) {
client, err := ent.Open("mysql", cfg.MySQL.DSN)
if err != nil {
return nil, err
}
lc.Append(fx.Hook{
OnStop: func(ctx context.Context) error {
return client.Close()
},
})
return client, nil
}

View File

@@ -14,6 +14,7 @@ var Module = fx.Options(
fx.Provide(
infraLog.NewLogger,
db.NewMySQL,
db.NewEntClient,
cache.NewRedis,
http.NewEcho,
),