feat: async ai workbench tasks
This commit is contained in:
+9
-1
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user