feat(migrations): Harden task audit tracking and optimize article templates
- Added migration to harden task audit tracking by modifying audit_logs and related tables. - Introduced operator_id to several tables for better tracking of actions. - Updated article_templates with new prompt templates for various article types, enhancing content generation. - Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling. - Added foreign key constraints to articles for better data integrity.
This commit is contained in:
@@ -3,13 +3,16 @@ package bootstrap
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
goredis "github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/geo-platform/tenant-api/internal/shared/auditlog"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/auth"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/cache"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/config"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/llm"
|
||||
"github.com/geo-platform/tenant-api/internal/shared/middleware"
|
||||
@@ -29,7 +32,9 @@ type App struct {
|
||||
JWT *auth.Manager
|
||||
Sessions *auth.SessionStore
|
||||
LLM llm.Client
|
||||
AuditLogs *auditlog.AsyncWriter
|
||||
GenerationStreams *stream.GenerationHub
|
||||
Cache cache.Cache
|
||||
}
|
||||
|
||||
func New(configPath string) (*App, error) {
|
||||
@@ -59,7 +64,9 @@ func New(configPath string) (*App, error) {
|
||||
jwtMgr := auth.NewManager(cfg.JWT.Secret, cfg.JWT.AccessTTL, cfg.JWT.RefreshTTL)
|
||||
sessions := auth.NewSessionStore(rdb)
|
||||
llmClient := llm.New(cfg.LLM)
|
||||
auditLogs := auditlog.NewAsyncWriter(pool, logger)
|
||||
generationStreams := stream.NewGenerationHub()
|
||||
appCache := cache.New(cfg.Cache.Driver, rdb)
|
||||
|
||||
if cfg.Server.Mode == "release" {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
@@ -97,11 +104,20 @@ func New(configPath string) (*App, error) {
|
||||
JWT: jwtMgr,
|
||||
Sessions: sessions,
|
||||
LLM: llmClient,
|
||||
AuditLogs: auditLogs,
|
||||
GenerationStreams: generationStreams,
|
||||
Cache: appCache,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a *App) Close() {
|
||||
if a.AuditLogs != nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
if err := a.AuditLogs.Close(ctx); err != nil {
|
||||
a.Logger.Warn("shutdown with pending audit logs", zap.Error(err))
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
a.DB.Close()
|
||||
_ = a.Redis.Close()
|
||||
_ = a.Logger.Sync()
|
||||
|
||||
Reference in New Issue
Block a user