0ebb8a21a1
Clean Up Testing and Linting * somescriptcleanup * mostgolangci * deplatest * imageversions * usingscratch * movedqueuefrtesting * finishedunittesting * linting * taskfilecontext
42 lines
761 B
Go
42 lines
761 B
Go
package server
|
|
|
|
import (
|
|
"context"
|
|
"queryorchestration/internal/database"
|
|
"queryorchestration/internal/database/repository"
|
|
"queryorchestration/internal/otel"
|
|
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
type Config struct {
|
|
Database *database.Connection
|
|
Validator *validator.Validate
|
|
}
|
|
|
|
type NewConfig struct {
|
|
BasePath string
|
|
}
|
|
|
|
func New(ctx context.Context, cfg *NewConfig) *Config {
|
|
closeTracer := otel.New(ctx)
|
|
defer closeTracer()
|
|
|
|
database.RunMigrations(&database.MigrationConfig{
|
|
BasePath: cfg.BasePath,
|
|
})
|
|
|
|
dbPool := database.GetDBPool(ctx)
|
|
dbQueries := repository.New(dbPool)
|
|
db := &database.Connection{
|
|
Pool: dbPool,
|
|
Queries: dbQueries,
|
|
}
|
|
valid := validator.New()
|
|
|
|
return &Config{
|
|
Database: db,
|
|
Validator: valid,
|
|
}
|
|
}
|