Plug framework export

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Bryan Frimin
2025-09-04 10:34:21 +02:00
committed by Sacha Al Himdani
parent d47cac911d
commit 9a3c4d3965
9 changed files with 206 additions and 32 deletions

View File

@@ -330,9 +330,19 @@ func (impl *Implm) Run(
}
}()
frameworkExporterCtx, stopFrameworkExporter := context.WithCancel(context.Background())
wg.Add(1)
go func() {
defer wg.Done()
if err := impl.runFrameworkExporter(frameworkExporterCtx, proboService, l.Named("framework-exporter")); err != nil {
cancel(fmt.Errorf("framework exporter crashed: %w", err))
}
}()
<-ctx.Done()
stopMailer()
stopFrameworkExporter()
stopApiServer()
wg.Wait()
@@ -342,6 +352,26 @@ func (impl *Implm) Run(
return context.Cause(ctx)
}
func (impl *Implm) runFrameworkExporter(
ctx context.Context,
proboService *probo.Service,
l *log.Logger,
) error {
LOOP:
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(30 * time.Second):
if err := proboService.ExportFrameworkJob(ctx); err != nil {
if !errors.Is(err, coredata.ErrNoFrameworkExportAvailable) {
l.ErrorCtx(ctx, "cannot process framework export", log.Error(err))
}
}
goto LOOP
}
}
func (impl *Implm) runApiServer(
ctx context.Context,
l *log.Logger,