feat: async ai workbench tasks

This commit is contained in:
richjohnrambo
2026-09-30 11:37:49 +08:00
parent 47a10c93be
commit d2e70efd9d
4 changed files with 493 additions and 104 deletions
+9 -1
View File
@@ -21,6 +21,7 @@ type App struct {
redis *redis.Client
events events.Publisher
api *httpapi.API
cancel context.CancelFunc
}
func New(cfg *config.Config) (*App, error) {
@@ -60,11 +61,15 @@ func New(cfg *config.Config) (*App, error) {
return nil, err
}
aiService := ai.NewService(ai.NewClient(cfg.AI))
api := httpapi.New(st, auth.New(cfg.Auth, redisClient), publisher, cfg.Auth, cfg.Manager, aiService)
ctx, cancel := context.WithCancel(context.Background())
api.StartAIWorkers(ctx)
return &App{
store: st,
redis: redisClient,
events: publisher,
api: httpapi.New(st, auth.New(cfg.Auth, redisClient), publisher, cfg.Auth, cfg.Manager, aiService),
api: api,
cancel: cancel,
}, nil
}
@@ -77,6 +82,9 @@ func (a *App) Handler() http.Handler {
}
func (a *App) Close() {
if a.cancel != nil {
a.cancel()
}
if a.redis != nil {
_ = a.redis.Close()
}