mirror of
https://github.com/3ybactuk/marketplace-go-service-project.git
synced 2025-10-30 14:03:45 +03:00
[hw-5] concurrency, graceful shutdown, concurrent tests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user