feat(generation): migrate article generation and template-assist to RabbitMQ queues
Replace in-process generation with queue-based async execution via RabbitMQ. Add generation task runtime for lifecycle management, article generation payload/queue abstractions, and template-assist queue publisher. Refactor prompt generation service to support batch generation with per-item error tracking. Update stream hub to bridge queue events to SSE. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -70,9 +70,12 @@ func (r *auditRepository) CreateAuditLog(ctx context.Context, input AuditLogInpu
|
||||
}
|
||||
|
||||
func (r *auditRepository) CreateGenerationTask(ctx context.Context, input GenerationTaskInput) (int64, error) {
|
||||
operatorID := input.OperatorID
|
||||
var operatorID *int64
|
||||
if input.OperatorID > 0 {
|
||||
operatorID = &input.OperatorID
|
||||
}
|
||||
return r.q.CreateGenerationTask(ctx, generated.CreateGenerationTaskParams{
|
||||
OperatorID: pgInt8(&operatorID),
|
||||
OperatorID: pgInt8(operatorID),
|
||||
TenantID: input.TenantID,
|
||||
ArticleID: pgInt8(input.ArticleID),
|
||||
QuotaReservationID: pgInt8(input.QuotaReservationID),
|
||||
|
||||
@@ -57,10 +57,13 @@ func (r *quotaRepository) GetCurrentBalance(ctx context.Context, tenantID int64,
|
||||
}
|
||||
|
||||
func (r *quotaRepository) InsertQuotaLedger(ctx context.Context, input QuotaLedgerInput) (int64, error) {
|
||||
operatorID := input.OperatorID
|
||||
var operatorID *int64
|
||||
if input.OperatorID > 0 {
|
||||
operatorID = &input.OperatorID
|
||||
}
|
||||
return r.q.InsertQuotaLedger(ctx, generated.InsertQuotaLedgerParams{
|
||||
TenantID: input.TenantID,
|
||||
OperatorID: pgInt8(&operatorID),
|
||||
OperatorID: pgInt8(operatorID),
|
||||
QuotaType: input.QuotaType,
|
||||
Delta: int32(input.Delta),
|
||||
BalanceAfter: int32(input.BalanceAfter),
|
||||
@@ -72,10 +75,13 @@ func (r *quotaRepository) InsertQuotaLedger(ctx context.Context, input QuotaLedg
|
||||
|
||||
func (r *quotaRepository) CreateQuotaReservation(ctx context.Context, input QuotaReservationInput) (int64, error) {
|
||||
expireAt := input.ExpireAt
|
||||
operatorID := input.OperatorID
|
||||
var operatorID *int64
|
||||
if input.OperatorID > 0 {
|
||||
operatorID = &input.OperatorID
|
||||
}
|
||||
return r.q.CreateQuotaReservation(ctx, generated.CreateQuotaReservationParams{
|
||||
TenantID: input.TenantID,
|
||||
OperatorID: pgInt8(&operatorID),
|
||||
OperatorID: pgInt8(operatorID),
|
||||
QuotaType: input.QuotaType,
|
||||
ResourceType: input.ResourceType,
|
||||
ResourceID: pgInt8(input.ResourceID),
|
||||
|
||||
Reference in New Issue
Block a user