feat: store connection and source CRUD

This commit is contained in:
2026-06-27 13:02:17 +08:00
parent 3d0b91fe23
commit 7cd84c8468
5 changed files with 131 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
package store
import (
"fmt"
"aiaa-notification-service/internal/config"
"github.com/jmoiron/sqlx"
_ "github.com/go-sql-driver/mysql"
)
type Store struct {
DB *sqlx.DB
}
func NewStore(cfg config.DatabaseConfig) (*Store, error) {
db, err := sqlx.Connect("mysql", cfg.DSN())
if err != nil {
return nil, fmt.Errorf("connect mysql: %w", err)
}
db.SetMaxOpenConns(25)
db.SetMaxIdleConns(5)
return &Store{DB: db}, nil
}
func (s *Store) Close() error {
return s.DB.Close()
}