[hw-5] concurrency, graceful shutdown, concurrent tests

This commit is contained in:
Никита Шубин
2025-07-06 20:52:27 +00:00
parent dbf8aaedcf
commit 84201fe495
23 changed files with 742 additions and 157 deletions

View File

@@ -1,6 +1,7 @@
package app
import (
"context"
"fmt"
"net"
"net/http"
@@ -68,7 +69,11 @@ func NewApp(configPath string) (*App, error) {
return app, nil
}
func (app *App) ListenAndServe() error {
func (app *App) Shutdown(ctx context.Context) error {
return app.server.Shutdown(ctx)
}
func (app *App) ListenAndServe(_ context.Context) error {
address := fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.Port)
l, err := net.Listen("tcp", address)
@@ -96,6 +101,9 @@ func (app *App) setupCartService() (*service.CartService, error) {
httpClient,
app.config.ProductService.Token,
fmt.Sprintf("%s:%s", app.config.ProductService.Host, app.config.ProductService.Port),
app.config.ProductService.Limit,
app.config.ProductService.Burst,
app.config.Service.Workers,
)
// LOMS service client