All checks were successful
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 7m11s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 7m21s
Build and Release / Lint (push) Successful in 7m32s
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been skipped
Build and Release / Build Binary (linux/arm64) (push) Has been skipped
Refactor AI service layer to reduce code duplication and improve consistency. Changes: - Rename AIOperationRequest to OperationRequest for consistency - Extract shared logic for issue-targeted operations (respond, triage) into triggerIssueAIOp helper - Standardize field alignment in struct definitions - Remove redundant error handling patterns This reduces the API operations file by ~40 lines while maintaining identical functionality.
34 lines
882 B
Go
34 lines
882 B
Go
// Copyright 2026 MarketAlly. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package ai
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"code.gitcaddy.com/server/v3/modules/graceful"
|
|
"code.gitcaddy.com/server/v3/modules/queue"
|
|
"code.gitcaddy.com/server/v3/modules/setting"
|
|
notify_service "code.gitcaddy.com/server/v3/services/notify"
|
|
)
|
|
|
|
var aiOperationQueue *queue.WorkerPoolQueue[*OperationRequest]
|
|
|
|
// Init initializes the AI service integration: queue and notifier.
|
|
func Init(ctx context.Context) error {
|
|
if !setting.AI.Enabled {
|
|
return nil
|
|
}
|
|
|
|
aiOperationQueue = queue.CreateUniqueQueue(graceful.GetManager().ShutdownContext(), "ai_operations", handleAIOperation)
|
|
if aiOperationQueue == nil {
|
|
return errors.New("unable to create ai_operations queue")
|
|
}
|
|
go graceful.GetManager().RunWithCancel(aiOperationQueue)
|
|
|
|
notify_service.RegisterNotifier(NewNotifier())
|
|
|
|
return nil
|
|
}
|