filter by learning_types and course_thematics

This commit is contained in:
Aleksandr Trushkin
2024-01-10 00:02:40 +03:00
parent 728c8fa59e
commit 5fd0861e2d
10 changed files with 346 additions and 22 deletions

View File

@ -16,6 +16,7 @@ import (
"git.loyso.art/frx/kurious/internal/kurious/adapters"
xhttp "git.loyso.art/frx/kurious/internal/kurious/ports/http"
"git.loyso.art/frx/kurious/internal/kurious/service"
"golang.org/x/sync/errgroup"
)
@ -88,26 +89,30 @@ func app(ctx context.Context) error {
slog.String("addr", httpServer.Addr),
)
err := httpServer.ListenAndServe()
if err != nil {
if err := httpServer.ListenAndServe(); err != nil {
if !errors.Is(err, http.ErrServerClosed) {
return fmt.Errorf("listening http: %w", err)
}
}
return nil
})
eg.Go(func() error {
<-egctx.Done()
xcontext.LogInfo(ctx, log, "trying to shutdown http")
sdctx, sdcancel := context.WithTimeout(context.Background(), time.Second*10)
defer sdcancel()
err := httpServer.Shutdown(sdctx)
if err != nil {
return fmt.Errorf("shutting down the server: %w", err)
}
xcontext.LogInfo(ctx, log, "server closed successfuly")
return nil
})