36 lines
479 B
Go
36 lines
479 B
Go
|
package app
|
||
|
|
||
|
import (
|
||
|
"log/slog"
|
||
|
"ms-auth/internal/lib"
|
||
|
|
||
|
_ "github.com/jackc/pgx/v5/stdlib"
|
||
|
)
|
||
|
|
||
|
type Server interface {
|
||
|
Start()
|
||
|
GracefullyStop()
|
||
|
}
|
||
|
|
||
|
type App struct {
|
||
|
server Server
|
||
|
cfg *lib.Config
|
||
|
}
|
||
|
|
||
|
func NewApp(cfg *lib.Config, server Server) *App {
|
||
|
return &App{
|
||
|
server: server,
|
||
|
cfg: cfg,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (app *App) Start() {
|
||
|
app.server.Start()
|
||
|
slog.Info("app started")
|
||
|
}
|
||
|
|
||
|
func (app *App) GracefullyStop() {
|
||
|
app.server.GracefullyStop()
|
||
|
slog.Info("app stopped")
|
||
|
}
|