mirror of
				https://github.com/3ybactuk/marketplace-go-service-project.git
				synced 2025-10-30 14:03:45 +03:00 
			
		
		
		
	Merge branch 'hw-5' into 'master'
[hw-5] concurrency, graceful shutdown, concurrent tests See merge request nvshubin1/homework!5
This commit is contained in:
		| @@ -1,7 +1,14 @@ | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"os/signal" | ||||||
|  | 	"syscall" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"github.com/rs/zerolog/log" | ||||||
|  |  | ||||||
| 	"route256/cart/internal/app" | 	"route256/cart/internal/app" | ||||||
| ) | ) | ||||||
| @@ -9,10 +16,27 @@ import ( | |||||||
| func main() { | func main() { | ||||||
| 	srv, err := app.NewApp(os.Getenv("CONFIG_FILE")) | 	srv, err := app.NewApp(os.Getenv("CONFIG_FILE")) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		log.Fatal().Err(err).Msg("failed creating app") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := srv.ListenAndServe(); err != nil { | 	ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) | ||||||
| 		panic(err) | 	defer stop() | ||||||
|  |  | ||||||
|  | 	go func() { | ||||||
|  | 		if err := srv.ListenAndServe(ctx); err != nil && err != http.ErrServerClosed { | ||||||
|  | 			log.Fatal().Err(err).Msg("serving error") | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	<-ctx.Done() | ||||||
|  | 	log.Info().Msg("shutdown signal received") | ||||||
|  |  | ||||||
|  | 	shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||||||
|  | 	defer cancel() | ||||||
|  |  | ||||||
|  | 	if err := srv.Shutdown(shutdownCtx); err != nil { | ||||||
|  | 		log.Error().Err(err).Msg("graceful shutdown failed") | ||||||
|  | 	} else { | ||||||
|  | 		log.Info().Msg("server stopped gracefully") | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
							
								
								
									
										63
									
								
								cart/go.mod
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								cart/go.mod
									
									
									
									
									
								
							| @@ -3,27 +3,71 @@ module route256/cart | |||||||
| go 1.23.9 | go 1.23.9 | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
|  | 	github.com/ozontech/allure-go/pkg/framework v0.6.34 | ||||||
| 	github.com/rs/zerolog v1.34.0 | 	github.com/rs/zerolog v1.34.0 | ||||||
| 	github.com/stretchr/testify v1.10.0 | 	github.com/stretchr/testify v1.10.0 | ||||||
| 	google.golang.org/grpc v1.72.0 | 	github.com/testcontainers/testcontainers-go v0.37.0 | ||||||
|  | 	golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 | ||||||
|  | 	google.golang.org/grpc v1.72.2 | ||||||
| 	gopkg.in/yaml.v3 v3.0.1 | 	gopkg.in/yaml.v3 v3.0.1 | ||||||
| ) | ) | ||||||
|  |  | ||||||
| require ( | require ( | ||||||
|  | 	dario.cat/mergo v1.0.1 // indirect | ||||||
|  | 	github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect | ||||||
|  | 	github.com/Microsoft/go-winio v0.6.2 // indirect | ||||||
|  | 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect | ||||||
|  | 	github.com/containerd/log v0.1.0 // indirect | ||||||
|  | 	github.com/containerd/platforms v0.2.1 // indirect | ||||||
|  | 	github.com/cpuguy83/dockercfg v0.3.2 // indirect | ||||||
| 	github.com/davecgh/go-spew v1.1.1 // indirect | 	github.com/davecgh/go-spew v1.1.1 // indirect | ||||||
|  | 	github.com/distribution/reference v0.6.0 // indirect | ||||||
|  | 	github.com/docker/docker v28.0.1+incompatible // indirect | ||||||
|  | 	github.com/docker/go-connections v0.5.0 // indirect | ||||||
|  | 	github.com/docker/go-units v0.5.0 // indirect | ||||||
|  | 	github.com/ebitengine/purego v0.8.4 // indirect | ||||||
|  | 	github.com/felixge/httpsnoop v1.0.4 // indirect | ||||||
| 	github.com/gabriel-vasile/mimetype v1.4.8 // indirect | 	github.com/gabriel-vasile/mimetype v1.4.8 // indirect | ||||||
|  | 	github.com/go-logr/logr v1.4.3 // indirect | ||||||
|  | 	github.com/go-logr/stdr v1.2.2 // indirect | ||||||
|  | 	github.com/go-ole/go-ole v1.2.6 // indirect | ||||||
| 	github.com/go-playground/locales v0.14.1 // indirect | 	github.com/go-playground/locales v0.14.1 // indirect | ||||||
| 	github.com/go-playground/universal-translator v0.18.1 // indirect | 	github.com/go-playground/universal-translator v0.18.1 // indirect | ||||||
| 	github.com/google/go-cmp v0.7.0 // indirect | 	github.com/gogo/protobuf v1.3.2 // indirect | ||||||
| 	github.com/kr/pretty v0.3.1 // indirect | 	github.com/google/uuid v1.6.0 // indirect | ||||||
|  | 	github.com/klauspost/compress v1.17.4 // indirect | ||||||
| 	github.com/leodido/go-urn v1.4.0 // indirect | 	github.com/leodido/go-urn v1.4.0 // indirect | ||||||
|  | 	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect | ||||||
|  | 	github.com/magiconair/properties v1.8.10 // indirect | ||||||
|  | 	github.com/moby/docker-image-spec v1.3.1 // indirect | ||||||
|  | 	github.com/moby/patternmatcher v0.6.0 // indirect | ||||||
|  | 	github.com/moby/sys/sequential v0.5.0 // indirect | ||||||
|  | 	github.com/moby/sys/user v0.1.0 // indirect | ||||||
|  | 	github.com/moby/sys/userns v0.1.0 // indirect | ||||||
|  | 	github.com/moby/term v0.5.0 // indirect | ||||||
|  | 	github.com/morikuni/aec v1.0.0 // indirect | ||||||
|  | 	github.com/opencontainers/go-digest v1.0.0 // indirect | ||||||
|  | 	github.com/opencontainers/image-spec v1.1.1 // indirect | ||||||
|  | 	github.com/ozontech/allure-go/pkg/allure v0.6.14 // indirect | ||||||
|  | 	github.com/pkg/errors v0.9.1 // indirect | ||||||
| 	github.com/pmezard/go-difflib v1.0.0 // indirect | 	github.com/pmezard/go-difflib v1.0.0 // indirect | ||||||
| 	github.com/rogpeppe/go-internal v1.13.1 // indirect | 	github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect | ||||||
| 	go.opentelemetry.io/otel v1.36.0 // indirect | 	github.com/shirou/gopsutil/v4 v4.25.1 // indirect | ||||||
| 	go.opentelemetry.io/otel/sdk v1.36.0 // indirect | 	github.com/sirupsen/logrus v1.9.3 // indirect | ||||||
| 	golang.org/x/crypto v0.37.0 // indirect | 	github.com/tklauser/go-sysconf v0.3.12 // indirect | ||||||
| 	golang.org/x/net v0.39.0 // indirect | 	github.com/tklauser/numcpus v0.6.1 // indirect | ||||||
| 	golang.org/x/text v0.24.0 // indirect | 	github.com/yusufpapurcu/wmi v1.2.4 // indirect | ||||||
|  | 	go.opentelemetry.io/auto/sdk v1.1.0 // indirect | ||||||
|  | 	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel v1.37.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/metric v1.37.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/sdk v1.37.0 // indirect | ||||||
|  | 	go.opentelemetry.io/otel/trace v1.37.0 // indirect | ||||||
|  | 	go.opentelemetry.io/proto/otlp v1.7.0 // indirect | ||||||
|  | 	golang.org/x/crypto v0.38.0 // indirect | ||||||
|  | 	golang.org/x/net v0.40.0 // indirect | ||||||
|  | 	golang.org/x/text v0.25.0 // indirect | ||||||
| 	google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect | 	google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect | ||||||
| 	google.golang.org/protobuf v1.36.6 // indirect | 	google.golang.org/protobuf v1.36.6 // indirect | ||||||
| ) | ) | ||||||
| @@ -33,5 +77,6 @@ require ( | |||||||
| 	github.com/gojuno/minimock/v3 v3.4.5 | 	github.com/gojuno/minimock/v3 v3.4.5 | ||||||
| 	github.com/mattn/go-colorable v0.1.13 // indirect | 	github.com/mattn/go-colorable v0.1.13 // indirect | ||||||
| 	github.com/mattn/go-isatty v0.0.19 // indirect | 	github.com/mattn/go-isatty v0.0.19 // indirect | ||||||
|  | 	go.uber.org/goleak v1.3.0 | ||||||
| 	golang.org/x/sys v0.33.0 // indirect | 	golang.org/x/sys v0.33.0 // indirect | ||||||
| ) | ) | ||||||
|   | |||||||
							
								
								
									
										179
									
								
								cart/go.sum
									
									
									
									
									
								
							
							
						
						
									
										179
									
								
								cart/go.sum
									
									
									
									
									
								
							| @@ -1,13 +1,46 @@ | |||||||
|  | dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= | ||||||
|  | dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= | ||||||
|  | github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= | ||||||
|  | github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= | ||||||
|  | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= | ||||||
|  | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= | ||||||
|  | github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= | ||||||
|  | github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= | ||||||
|  | github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= | ||||||
|  | github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | ||||||
|  | github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= | ||||||
|  | github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= | ||||||
|  | github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= | ||||||
|  | github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= | ||||||
| github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | ||||||
| github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= | github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= | ||||||
|  | github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= | ||||||
|  | github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= | ||||||
|  | github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= | ||||||
|  | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||||
|  | github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= | ||||||
|  | github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= | ||||||
|  | github.com/docker/docker v28.0.1+incompatible h1:FCHjSRdXhNRFjlHMTv4jUNlIBbTeRjrWfeFuJp7jpo0= | ||||||
|  | github.com/docker/docker v28.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= | ||||||
|  | github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= | ||||||
|  | github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= | ||||||
|  | github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= | ||||||
|  | github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= | ||||||
|  | github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw= | ||||||
|  | github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= | ||||||
|  | github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= | ||||||
|  | github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= | ||||||
| github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= | github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= | ||||||
| github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= | github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= | ||||||
| github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= | github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= | ||||||
| github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= | ||||||
|  | github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | ||||||
| github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= | github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= | ||||||
| github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= | github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= | ||||||
|  | github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= | ||||||
|  | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= | ||||||
| github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= | github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= | ||||||
| github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= | github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= | ||||||
| github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= | ||||||
| @@ -17,68 +50,172 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91 | |||||||
| github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= | github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= | ||||||
| github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= | github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= | ||||||
| github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | ||||||
|  | github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | ||||||
|  | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | ||||||
| github.com/gojuno/minimock/v3 v3.4.5 h1:Jcb0tEYZvVlQNtAAYpg3jCOoSwss2c1/rNugYTzj304= | github.com/gojuno/minimock/v3 v3.4.5 h1:Jcb0tEYZvVlQNtAAYpg3jCOoSwss2c1/rNugYTzj304= | ||||||
| github.com/gojuno/minimock/v3 v3.4.5/go.mod h1:o9F8i2IT8v3yirA7mmdpNGzh1WNesm6iQakMtQV6KiE= | github.com/gojuno/minimock/v3 v3.4.5/go.mod h1:o9F8i2IT8v3yirA7mmdpNGzh1WNesm6iQakMtQV6KiE= | ||||||
| github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= | ||||||
| github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= | ||||||
|  | github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||||
| github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= | github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= | ||||||
| github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= | github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= | ||||||
| github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | ||||||
| github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||||
|  | github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= | ||||||
|  | github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= | ||||||
|  | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= | ||||||
|  | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||||
|  | github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= | ||||||
|  | github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= | ||||||
| github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= | ||||||
| github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | ||||||
| github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | ||||||
| github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | ||||||
| github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= | github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= | ||||||
| github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= | github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= | ||||||
|  | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= | ||||||
|  | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= | ||||||
|  | github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= | ||||||
|  | github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= | ||||||
| github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= | github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= | ||||||
| github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= | github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= | ||||||
| github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= | github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= | ||||||
| github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= | github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= | ||||||
| github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= | github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= | ||||||
| github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= | github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= | ||||||
|  | github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= | ||||||
|  | github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= | ||||||
|  | github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= | ||||||
|  | github.com/moby/sys/sequential v0.5.0 h1:OPvI35Lzn9K04PBbCLW0g4LcFAJgHsvXsRyewg5lXtc= | ||||||
|  | github.com/moby/sys/sequential v0.5.0/go.mod h1:tH2cOOs5V9MlPiXcQzRC+eEyab644PWKGRYaaV5ZZlo= | ||||||
|  | github.com/moby/sys/user v0.1.0 h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg= | ||||||
|  | github.com/moby/sys/user v0.1.0/go.mod h1:fKJhFOnsCN6xZ5gSfbM6zaHGgDJMrqt9/reuj4T7MmU= | ||||||
|  | github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= | ||||||
|  | github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= | ||||||
|  | github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= | ||||||
|  | github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= | ||||||
|  | github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= | ||||||
|  | github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= | ||||||
|  | github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= | ||||||
|  | github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= | ||||||
|  | github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= | ||||||
|  | github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= | ||||||
|  | github.com/ozontech/allure-go/pkg/allure v0.6.14 h1:lDamtSF+WtHQLg2+qQYijtC4Fk3KLGb6txNxxTZwUGc= | ||||||
|  | github.com/ozontech/allure-go/pkg/allure v0.6.14/go.mod h1:4oEG2yq+DGOzJS/ZjPc87C/mx3tAnlYpYonk77Ru/vQ= | ||||||
|  | github.com/ozontech/allure-go/pkg/framework v0.6.34 h1:IjM65Y3JP7ale7Ug3aBnFV4+c1NYYBCrgl/VrtEd/FY= | ||||||
|  | github.com/ozontech/allure-go/pkg/framework v0.6.34/go.mod h1:oISDLE6Tfww35TBQz+1nrtbLtyBqR6ELxOtJ+MVjHOw= | ||||||
|  | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||||
| github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= | ||||||
|  | github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= | ||||||
| github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= | github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= | ||||||
| github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= | github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= | ||||||
| github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= | github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0= | ||||||
| github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= | github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY= | ||||||
| github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= | github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ= | ||||||
|  | github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs= | ||||||
|  | github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI= | ||||||
|  | github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||||||
|  | github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||||||
|  | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||||
|  | github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= | ||||||
|  | github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= | ||||||
|  | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||||||
| github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | ||||||
| github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | ||||||
|  | github.com/testcontainers/testcontainers-go v0.37.0 h1:L2Qc0vkTw2EHWQ08djon0D2uw7Z/PtHS/QzZZ5Ra/hg= | ||||||
|  | github.com/testcontainers/testcontainers-go v0.37.0/go.mod h1:QPzbxZhQ6Bclip9igjLFj6z0hs01bU8lrl2dHQmgFGM= | ||||||
|  | github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= | ||||||
|  | github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= | ||||||
|  | github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= | ||||||
|  | github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= | ||||||
|  | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||||
|  | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||||
|  | github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= | ||||||
|  | github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= | ||||||
| go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= | go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= | ||||||
| go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= | go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= | ||||||
| go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= | ||||||
| go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E= | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= | ||||||
| go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE= | go.opentelemetry.io/otel v1.37.0 h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ= | ||||||
| go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs= | go.opentelemetry.io/otel v1.37.0/go.mod h1:ehE/umFRLnuLa/vSccNq9oS1ErUlkkK71gMcN34UG8I= | ||||||
| go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs= | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0 h1:Ahq7pZmv87yiyn3jeFz/LekZmPLLdKejuO3NcK9MssM= | ||||||
| go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY= | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.37.0/go.mod h1:MJTqhM0im3mRLw1i8uGHnCvUEeS7VwRyxlLC78PA18M= | ||||||
|  | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 h1:IeMeyr1aBvBiPVYihXIaeIZba6b8E1bYp7lbdxK8CQg= | ||||||
|  | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0/go.mod h1:oVdCUtjq9MK9BlS7TtucsQwUcXcymNiEDjgDD2jMtZU= | ||||||
|  | go.opentelemetry.io/otel/metric v1.37.0 h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE= | ||||||
|  | go.opentelemetry.io/otel/metric v1.37.0/go.mod h1:04wGrZurHYKOc+RKeye86GwKiTb9FKm1WHtO+4EVr2E= | ||||||
|  | go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= | ||||||
|  | go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= | ||||||
| go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= | go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= | ||||||
| go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= | go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= | ||||||
| go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w= | go.opentelemetry.io/otel/trace v1.37.0 h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4= | ||||||
| go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= | go.opentelemetry.io/otel/trace v1.37.0/go.mod h1:TlgrlQ+PtQO5XFerSPUYG0JSgGyryXewPGyayAWSBS0= | ||||||
| golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= | go.opentelemetry.io/proto/otlp v1.7.0 h1:jX1VolD6nHuFzOYso2E73H85i92Mv8JQYk0K9vz09os= | ||||||
| golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= | go.opentelemetry.io/proto/otlp v1.7.0/go.mod h1:fSKjH6YJ7HDlwzltzyMj036AJ3ejJLCgCSHGj4efDDo= | ||||||
| golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= | ||||||
| golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | ||||||
|  | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||||
|  | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||||
|  | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||||||
|  | golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= | ||||||
|  | golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= | ||||||
|  | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||||
|  | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||||
|  | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||||
|  | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||||
|  | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||||
|  | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | ||||||
|  | golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= | ||||||
|  | golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= | ||||||
|  | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||||
|  | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||||
|  | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||||
|  | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||||
|  | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
|  | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
|  | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
|  | golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||||
|  | golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
|  | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
| golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
| golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
|  | golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
|  | golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
| golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||||
| golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= | golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= | ||||||
| golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | ||||||
| golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= | golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= | ||||||
| golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= | golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= | ||||||
|  | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||||
|  | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||||
|  | golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= | ||||||
|  | golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= | ||||||
|  | golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44= | ||||||
|  | golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||||||
|  | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||||
|  | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||||
|  | golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= | ||||||
|  | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | ||||||
|  | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
|  | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
|  | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
|  | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||||
|  | google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a h1:SGktgSolFCo75dnHJF2yMvnns6jCmHFJ0vE4Vn2JKvQ= | ||||||
|  | google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a/go.mod h1:a77HrdMjoeKbnd2jmgcWdaS++ZLZAEq3orIOAEIKiVw= | ||||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE= | google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE= | ||||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= | google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= | ||||||
| google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= | google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= | ||||||
| google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= | google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= | ||||||
| google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= | ||||||
| google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= | ||||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||||
| gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= | ||||||
| gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= | ||||||
|  | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||||
| gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||||||
| gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||||||
|  | gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= | ||||||
|  | gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| package app | package app | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| @@ -68,7 +69,11 @@ func NewApp(configPath string) (*App, error) { | |||||||
| 	return app, nil | 	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) | 	address := fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.Port) | ||||||
|  |  | ||||||
| 	l, err := net.Listen("tcp", address) | 	l, err := net.Listen("tcp", address) | ||||||
| @@ -96,6 +101,9 @@ func (app *App) setupCartService() (*service.CartService, error) { | |||||||
| 		httpClient, | 		httpClient, | ||||||
| 		app.config.ProductService.Token, | 		app.config.ProductService.Token, | ||||||
| 		fmt.Sprintf("%s:%s", app.config.ProductService.Host, app.config.ProductService.Port), | 		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 | 	// LOMS service client | ||||||
|   | |||||||
| @@ -10,23 +10,40 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	"route256/cart/internal/domain/entity" | 	"route256/cart/internal/domain/entity" | ||||||
| 	"route256/cart/internal/domain/model" | 	"route256/cart/internal/domain/model" | ||||||
|  | 	"route256/cart/internal/infra/errgroup" | ||||||
|  | 
 | ||||||
|  | 	"github.com/rs/zerolog/log" | ||||||
|  | 	"golang.org/x/time/rate" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type ProductService struct { | type ProductService struct { | ||||||
| 	httpClient http.Client | 	httpClient http.Client | ||||||
| 	token      string | 	token      string | ||||||
| 	address    string | 	address    string | ||||||
|  | 
 | ||||||
|  | 	limiter *rate.Limiter | ||||||
|  | 
 | ||||||
|  | 	workers int | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func NewProductService(httpClient http.Client, token string, address string) *ProductService { | func NewProductService(httpClient http.Client, token, address string, limitRPS, burst, workers int) *ProductService { | ||||||
|  | 	log.Debug().Msgf("creating product server with %d worker limit", workers) | ||||||
|  | 
 | ||||||
| 	return &ProductService{ | 	return &ProductService{ | ||||||
| 		httpClient: httpClient, | 		httpClient: httpClient, | ||||||
| 		token:      token, | 		token:      token, | ||||||
| 		address:    address, | 		address:    address, | ||||||
|  | 
 | ||||||
|  | 		limiter: rate.NewLimiter(rate.Limit(limitRPS), burst), | ||||||
|  | 		workers: workers, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (s *ProductService) GetProductBySku(ctx context.Context, sku entity.Sku) (*model.Product, error) { | func (s *ProductService) GetProductBySku(ctx context.Context, sku entity.Sku) (*model.Product, error) { | ||||||
|  | 	if err := s.limiter.Wait(ctx); err != nil { | ||||||
|  | 		return nil, fmt.Errorf("limiter.Wait: %w", err) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	ctx, cancel := context.WithTimeout(ctx, 5*time.Second) | 	ctx, cancel := context.WithTimeout(ctx, 5*time.Second) | ||||||
| 	defer cancel() | 	defer cancel() | ||||||
| 
 | 
 | ||||||
| @@ -73,3 +90,32 @@ type GetProductResponse struct { | |||||||
| 	Price int32  `json:"price"` | 	Price int32  `json:"price"` | ||||||
| 	Sku   int64  `json:"sku"` | 	Sku   int64  `json:"sku"` | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func (s *ProductService) GetProducts(ctx context.Context, skus []entity.Sku) ([]*model.Product, error) { | ||||||
|  | 	if len(skus) == 0 { | ||||||
|  | 		return []*model.Product{}, nil | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	results := make([]*model.Product, len(skus)) | ||||||
|  | 
 | ||||||
|  | 	g, _ := errgroup.WithContext(ctx, s.workers) | ||||||
|  | 
 | ||||||
|  | 	for i, sku := range skus { | ||||||
|  | 		g.Go(func(groupCtx context.Context) error { | ||||||
|  | 			p, err := s.GetProductBySku(groupCtx, sku) | ||||||
|  | 			if err != nil { | ||||||
|  | 				return err | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			results[i] = p | ||||||
|  | 
 | ||||||
|  | 			return nil | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if err := g.Wait(); err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return results, nil | ||||||
|  | } | ||||||
| @@ -2,15 +2,21 @@ package repository | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
|  | 	"sync" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"route256/cart/internal/domain/entity" |  | ||||||
| 	"route256/cart/internal/domain/model" |  | ||||||
|  |  | ||||||
| 	"github.com/stretchr/testify/assert" | 	"github.com/stretchr/testify/assert" | ||||||
| 	"github.com/stretchr/testify/require" | 	"github.com/stretchr/testify/require" | ||||||
|  | 	"go.uber.org/goleak" | ||||||
|  |  | ||||||
|  | 	"route256/cart/internal/domain/entity" | ||||||
|  | 	"route256/cart/internal/domain/model" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | func TestMain(m *testing.M) { | ||||||
|  | 	goleak.VerifyTestMain(m) | ||||||
|  | } | ||||||
|  |  | ||||||
| func TestAddItem(t *testing.T) { | func TestAddItem(t *testing.T) { | ||||||
| 	t.Parallel() | 	t.Parallel() | ||||||
|  |  | ||||||
| @@ -267,3 +273,135 @@ func TestDeleteItemsByUserID(t *testing.T) { | |||||||
|  |  | ||||||
| 	assert.Len(t, repo.storage, 0, "check storage length") | 	assert.Len(t, repo.storage, 0, "check storage length") | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func TestConcurrent_AddItemSameSku(t *testing.T) { | ||||||
|  | 	t.Parallel() | ||||||
|  |  | ||||||
|  | 	const ( | ||||||
|  | 		goroutines = 100 | ||||||
|  | 		userID     = entity.UID(42) | ||||||
|  | 		sku        = entity.Sku(777) | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	repo := NewInMemoryRepository(1) | ||||||
|  | 	ctx := context.Background() | ||||||
|  |  | ||||||
|  | 	var wg sync.WaitGroup | ||||||
|  |  | ||||||
|  | 	wg.Add(goroutines) | ||||||
|  |  | ||||||
|  | 	for i := 0; i < goroutines; i++ { | ||||||
|  | 		go func() { | ||||||
|  | 			defer wg.Done() | ||||||
|  |  | ||||||
|  | 			item := &model.Item{ | ||||||
|  | 				Product: &model.Product{Sku: sku}, | ||||||
|  | 				Count:   1, | ||||||
|  | 			} | ||||||
|  | 			require.NoError(t, repo.AddItem(ctx, userID, item)) | ||||||
|  | 		}() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	wg.Wait() | ||||||
|  |  | ||||||
|  | 	cart, err := repo.GetItemsByUserID(ctx, userID) | ||||||
|  | 	require.NoError(t, err) | ||||||
|  |  | ||||||
|  | 	assert.Len(t, cart.Items, 1, "only one item should exist") | ||||||
|  | 	assert.Equal(t, uint32(goroutines), cart.ItemCount[sku], "wrong count") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestConcurrent_AddItemDifferentUsers(t *testing.T) { | ||||||
|  | 	t.Parallel() | ||||||
|  |  | ||||||
|  | 	const ( | ||||||
|  | 		users       = 50 | ||||||
|  | 		addsPerUser = 10 | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	repo := NewInMemoryRepository(users) | ||||||
|  | 	ctx := context.Background() | ||||||
|  |  | ||||||
|  | 	var wg sync.WaitGroup | ||||||
|  |  | ||||||
|  | 	for u := 0; u < users; u++ { | ||||||
|  | 		uid := entity.UID(u) | ||||||
|  | 		wg.Add(1) | ||||||
|  |  | ||||||
|  | 		go func(id entity.UID) { | ||||||
|  | 			defer wg.Done() | ||||||
|  |  | ||||||
|  | 			for i := 0; i < addsPerUser; i++ { | ||||||
|  | 				item := &model.Item{ | ||||||
|  | 					Product: &model.Product{Sku: entity.Sku(i)}, | ||||||
|  | 					Count:   1, | ||||||
|  | 				} | ||||||
|  | 				require.NoError(t, repo.AddItem(ctx, id, item)) | ||||||
|  | 			} | ||||||
|  | 		}(uid) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	wg.Wait() | ||||||
|  |  | ||||||
|  | 	for u := 0; u < users; u++ { | ||||||
|  | 		uid := entity.UID(u) | ||||||
|  | 		cart, err := repo.GetItemsByUserID(ctx, uid) | ||||||
|  | 		require.NoError(t, err) | ||||||
|  |  | ||||||
|  | 		assert.Lenf(t, cart.Items, addsPerUser, "user %d has wrong item count", u) | ||||||
|  | 		for i := 0; i < addsPerUser; i++ { | ||||||
|  | 			sku := entity.Sku(i) | ||||||
|  | 			assert.Equalf(t, uint32(1), cart.ItemCount[sku], "user %d: sku %d count", u, sku) | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func TestConcurrent_AddAndRead(t *testing.T) { | ||||||
|  | 	t.Parallel() | ||||||
|  |  | ||||||
|  | 	repo := NewInMemoryRepository(1) | ||||||
|  | 	ctx := context.Background() | ||||||
|  | 	uid := entity.UID(1) | ||||||
|  | 	sku := entity.Sku(9) | ||||||
|  |  | ||||||
|  | 	const ( | ||||||
|  | 		writerGoroutines = 20 | ||||||
|  | 		readerGoroutines = 20 | ||||||
|  | 		iterations       = 100 | ||||||
|  | 	) | ||||||
|  |  | ||||||
|  | 	var wg sync.WaitGroup | ||||||
|  |  | ||||||
|  | 	for i := 0; i < writerGoroutines; i++ { | ||||||
|  | 		wg.Add(1) | ||||||
|  | 		go func() { | ||||||
|  | 			defer wg.Done() | ||||||
|  | 			for j := 0; j < iterations; j++ { | ||||||
|  | 				item := &model.Item{ | ||||||
|  | 					Product: &model.Product{Sku: sku}, | ||||||
|  | 					Count:   1, | ||||||
|  | 				} | ||||||
|  | 				require.NoError(t, repo.AddItem(ctx, uid, item)) | ||||||
|  | 			} | ||||||
|  | 		}() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	for i := 0; i < readerGoroutines; i++ { | ||||||
|  | 		wg.Add(1) | ||||||
|  | 		go func() { | ||||||
|  | 			defer wg.Done() | ||||||
|  | 			for j := 0; j < iterations; j++ { | ||||||
|  | 				_, err := repo.GetItemsByUserID(ctx, uid) | ||||||
|  | 				require.NoError(t, err) | ||||||
|  | 			} | ||||||
|  | 		}() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	wg.Wait() | ||||||
|  |  | ||||||
|  | 	cart, err := repo.GetItemsByUserID(ctx, uid) | ||||||
|  | 	require.NoError(t, err) | ||||||
|  | 	expected := uint32(writerGoroutines * iterations) | ||||||
|  |  | ||||||
|  | 	assert.Equal(t, expected, cart.ItemCount[sku], "wrong item count") | ||||||
|  | } | ||||||
|   | |||||||
| @@ -4,9 +4,6 @@ import ( | |||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"slices" | 	"slices" | ||||||
| 	"sync" |  | ||||||
|  |  | ||||||
| 	"github.com/rs/zerolog/log" |  | ||||||
|  |  | ||||||
| 	"route256/cart/internal/domain/entity" | 	"route256/cart/internal/domain/entity" | ||||||
| 	"route256/cart/internal/domain/model" | 	"route256/cart/internal/domain/model" | ||||||
| @@ -22,6 +19,7 @@ type Repository interface { | |||||||
|  |  | ||||||
| type ProductService interface { | type ProductService interface { | ||||||
| 	GetProductBySku(ctx context.Context, sku entity.Sku) (*model.Product, error) | 	GetProductBySku(ctx context.Context, sku entity.Sku) (*model.Product, error) | ||||||
|  | 	GetProducts(ctx context.Context, skus []entity.Sku) ([]*model.Product, error) | ||||||
| } | } | ||||||
|  |  | ||||||
| type LomsService interface { | type LomsService interface { | ||||||
| @@ -77,9 +75,6 @@ func (s *CartService) AddItem(ctx context.Context, userID entity.UID, item *mode | |||||||
| // GetUserCart gets all user cart's item ids, gets the item description from the product-service | // GetUserCart gets all user cart's item ids, gets the item description from the product-service | ||||||
| // and return a list of the collected items. | // and return a list of the collected items. | ||||||
| // In case of failed request to product-service, return nothing and error. | // In case of failed request to product-service, return nothing and error. | ||||||
| // |  | ||||||
| // TODO: add worker group, BUT it's OK for now, |  | ||||||
| // assuming user does not have hundreds of different items in his cart. |  | ||||||
| func (s *CartService) GetItemsByUserID(ctx context.Context, userID entity.UID) (*model.Cart, error) { | func (s *CartService) GetItemsByUserID(ctx context.Context, userID entity.UID) (*model.Cart, error) { | ||||||
| 	if userID <= 0 { | 	if userID <= 0 { | ||||||
| 		return nil, fmt.Errorf("userID invalid") | 		return nil, fmt.Errorf("userID invalid") | ||||||
| @@ -99,66 +94,32 @@ func (s *CartService) GetItemsByUserID(ctx context.Context, userID entity.UID) ( | |||||||
|  |  | ||||||
| 	resultCart := &model.Cart{ | 	resultCart := &model.Cart{ | ||||||
| 		UserID:     userID, | 		UserID:     userID, | ||||||
| 		Items:      make([]*model.Item, len(cart.Items)), | 		Items:      make([]*model.Item, 0, len(cart.Items)), | ||||||
| 		TotalPrice: 0, | 		TotalPrice: 0, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	errCh := make(chan error, 1) | 	products, err := s.productService.GetProducts(ctx, cart.Items) | ||||||
|  |  | ||||||
| 	var ( |  | ||||||
| 		wg       sync.WaitGroup |  | ||||||
| 		sumMutex sync.Mutex |  | ||||||
| 	) |  | ||||||
|  |  | ||||||
| 	for idx, sku := range cart.Items { |  | ||||||
| 		wg.Add(1) |  | ||||||
|  |  | ||||||
| 		go func(sku entity.Sku, count uint32, idx int) { |  | ||||||
| 			defer wg.Done() |  | ||||||
|  |  | ||||||
| 			product, err := s.productService.GetProductBySku(ctx, sku) |  | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 				select { |  | ||||||
| 				case errCh <- fmt.Errorf("productService.GetProductBySku: %w", err): |  | ||||||
| 				case <-ctx.Done(): |  | ||||||
| 				} |  | ||||||
|  |  | ||||||
| 				log.Error().Err(err).Msg("productService.GetProductBySku") |  | ||||||
|  |  | ||||||
| 				return |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			resultCart.Items[idx] = &model.Item{ |  | ||||||
| 				Product: product, |  | ||||||
| 				Count:   count, |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			sumMutex.Lock() |  | ||||||
| 			resultCart.TotalPrice += uint32(product.Price) * count |  | ||||||
| 			sumMutex.Unlock() |  | ||||||
| 		}(sku, cart.ItemCount[sku], idx) |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	doneCh := make(chan struct{}) |  | ||||||
| 	go func() { |  | ||||||
| 		wg.Wait() |  | ||||||
|  |  | ||||||
| 		close(doneCh) |  | ||||||
| 	}() |  | ||||||
|  |  | ||||||
| 	select { |  | ||||||
| 	case err := <-errCh: |  | ||||||
| 		cancel() |  | ||||||
|  |  | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	case <-doneCh: | 	} | ||||||
|  |  | ||||||
|  | 	for _, product := range products { | ||||||
|  | 		cnt := cart.ItemCount[product.Sku] | ||||||
|  |  | ||||||
|  | 		resultCart.Items = append(resultCart.Items, &model.Item{ | ||||||
|  | 			Product: product, | ||||||
|  | 			Count:   cnt, | ||||||
|  | 		}) | ||||||
|  |  | ||||||
|  | 		resultCart.TotalPrice += cnt * uint32(product.Price) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	slices.SortStableFunc(resultCart.Items, func(a, b *model.Item) int { | 	slices.SortStableFunc(resultCart.Items, func(a, b *model.Item) int { | ||||||
| 		return int(a.Product.Sku - b.Product.Sku) | 		return int(a.Product.Sku - b.Product.Sku) | ||||||
| 	}) | 	}) | ||||||
|  |  | ||||||
| 	return resultCart, nil | 	return resultCart, nil | ||||||
| } | } | ||||||
| } |  | ||||||
|  |  | ||||||
| func (s *CartService) DeleteItem(ctx context.Context, userID entity.UID, sku entity.Sku) error { | func (s *CartService) DeleteItem(ctx context.Context, userID entity.UID, sku entity.Sku) error { | ||||||
| 	if userID <= 0 { | 	if userID <= 0 { | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import ( | |||||||
| 	"github.com/gojuno/minimock/v3" | 	"github.com/gojuno/minimock/v3" | ||||||
| 	"github.com/stretchr/testify/assert" | 	"github.com/stretchr/testify/assert" | ||||||
| 	"github.com/stretchr/testify/require" | 	"github.com/stretchr/testify/require" | ||||||
|  | 	"go.uber.org/goleak" | ||||||
|  |  | ||||||
| 	"route256/cart/internal/domain/entity" | 	"route256/cart/internal/domain/entity" | ||||||
| 	"route256/cart/internal/domain/model" | 	"route256/cart/internal/domain/model" | ||||||
| @@ -33,6 +34,21 @@ func (f *productServiceFake) GetProductBySku(_ context.Context, sku entity.Sku) | |||||||
| 	}, nil | 	}, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (f *productServiceFake) GetProducts(ctx context.Context, skus []entity.Sku) ([]*model.Product, error) { | ||||||
|  | 	res := make([]*model.Product, len(skus)) | ||||||
|  |  | ||||||
|  | 	for i, sku := range skus { | ||||||
|  | 		prod, err := f.GetProductBySku(ctx, sku) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return nil, err | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		res[i] = prod | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return res, nil | ||||||
|  | } | ||||||
|  |  | ||||||
| type lomsServiceFake struct{} | type lomsServiceFake struct{} | ||||||
|  |  | ||||||
| func (f *lomsServiceFake) StocksInfo(_ context.Context, sku entity.Sku) (uint32, error) { | func (f *lomsServiceFake) StocksInfo(_ context.Context, sku entity.Sku) (uint32, error) { | ||||||
| @@ -51,6 +67,10 @@ func (f *lomsServiceFake) OrderCreate(_ context.Context, cart *model.Cart) (int6 | |||||||
| 	return 1234, nil | 	return 1234, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func TestMain(m *testing.M) { | ||||||
|  | 	goleak.VerifyTestMain(m) | ||||||
|  | } | ||||||
|  |  | ||||||
| func TestCartService_AddItem(t *testing.T) { | func TestCartService_AddItem(t *testing.T) { | ||||||
| 	t.Parallel() | 	t.Parallel() | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										62
									
								
								cart/internal/infra/errgroup/errgroup.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								cart/internal/infra/errgroup/errgroup.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | |||||||
|  | package errgroup | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"sync" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type Group struct { | ||||||
|  | 	ctx    context.Context | ||||||
|  | 	cancel context.CancelFunc | ||||||
|  |  | ||||||
|  | 	wg sync.WaitGroup | ||||||
|  |  | ||||||
|  | 	firstErr chan error | ||||||
|  |  | ||||||
|  | 	// Used to limit number of goroutines (workers) for group. | ||||||
|  | 	workerLimCh chan struct{} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func WithContext(parent context.Context, workers int) (*Group, context.Context) { | ||||||
|  | 	ctx, cancel := context.WithCancel(parent) | ||||||
|  | 	return &Group{ | ||||||
|  | 		ctx:         ctx, | ||||||
|  | 		cancel:      cancel, | ||||||
|  | 		firstErr:    make(chan error, 1), | ||||||
|  | 		workerLimCh: make(chan struct{}, workers), | ||||||
|  | 	}, ctx | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (g *Group) Go(f func(ctx context.Context) error) { | ||||||
|  | 	// Wait for worker to be freed. | ||||||
|  | 	g.workerLimCh <- struct{}{} | ||||||
|  |  | ||||||
|  | 	g.wg.Add(1) | ||||||
|  | 	go func() { | ||||||
|  | 		defer func() { | ||||||
|  | 			g.wg.Done() | ||||||
|  |  | ||||||
|  | 			<-g.workerLimCh // release worker | ||||||
|  | 		}() | ||||||
|  |  | ||||||
|  | 		if err := f(g.ctx); err != nil { | ||||||
|  | 			select { | ||||||
|  | 			case g.firstErr <- err: | ||||||
|  | 				g.cancel() | ||||||
|  | 			default: // got error from other goroutine | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (g *Group) Wait() error { | ||||||
|  | 	g.wg.Wait() | ||||||
|  | 	g.cancel() | ||||||
|  |  | ||||||
|  | 	select { | ||||||
|  | 	case err := <-g.firstErr: | ||||||
|  | 		return err | ||||||
|  | 	default: | ||||||
|  | 		return nil | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -17,6 +17,7 @@ import ( | |||||||
| 	"github.com/ozontech/allure-go/pkg/framework/suite" | 	"github.com/ozontech/allure-go/pkg/framework/suite" | ||||||
| 	"github.com/testcontainers/testcontainers-go" | 	"github.com/testcontainers/testcontainers-go" | ||||||
| 	"github.com/testcontainers/testcontainers-go/wait" | 	"github.com/testcontainers/testcontainers-go/wait" | ||||||
|  | 	"go.uber.org/goleak" | ||||||
| 	"google.golang.org/grpc" | 	"google.golang.org/grpc" | ||||||
|  |  | ||||||
| 	"route256/cart/internal/app" | 	"route256/cart/internal/app" | ||||||
| @@ -64,6 +65,8 @@ type CartHandlerSuite struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestCartHandlerSuite(t *testing.T) { | func TestCartHandlerSuite(t *testing.T) { | ||||||
|  | 	defer goleak.VerifyNone(t) | ||||||
|  |  | ||||||
| 	suite.RunSuite(t, new(CartHandlerSuite)) | 	suite.RunSuite(t, new(CartHandlerSuite)) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -111,6 +114,9 @@ func (s *CartHandlerSuite) BeforeAll(t provider.T) { | |||||||
| 			*http.DefaultClient, | 			*http.DefaultClient, | ||||||
| 			testToken, | 			testToken, | ||||||
| 			productURL, | 			productURL, | ||||||
|  | 			10, | ||||||
|  | 			10, | ||||||
|  | 			10, | ||||||
| 		) | 		) | ||||||
|  |  | ||||||
| 		lomsClient := pbLoms.NewLOMSClient(s.lomsConn) | 		lomsClient := pbLoms.NewLOMSClient(s.lomsConn) | ||||||
|   | |||||||
| @@ -18,3 +18,4 @@ | |||||||
| 2. [Тестирование в Go](./homework-2) | 2. [Тестирование в Go](./homework-2) | ||||||
| 3. [Межсервисное взаимодействие и основы эксплуатации](./homework-3) | 3. [Межсервисное взаимодействие и основы эксплуатации](./homework-3) | ||||||
| 4. [Базы данных](./homework-4) | 4. [Базы данных](./homework-4) | ||||||
|  | 5. [Многопоточное программирование](./homework-5) | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								docs/homework-5/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								docs/homework-5/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | |||||||
|  | # Домашнее задание по модулю "Многопоточное программирование" | ||||||
|  |  | ||||||
|  | ## Основное задание | ||||||
|  |  | ||||||
|  | Уменьшить время ответа cart.list. | ||||||
|  |     - Распараллельные вызовы ручки http://route256.pavl.uk:8080/docs/#/ProductService/ProductService_GetProduct продакт | ||||||
|  |       сервиса | ||||||
|  |     - Самим написать аналог https://pkg.go.dev/golang.org/x/sync/errgroup и использовать его | ||||||
|  |     - В случае ошибки - отменять все текущие запросы и вернуть ошибку из errgroup | ||||||
|  |     - При общении с Product Service необходимо использовать лимит 10 RPS на клиентской стороне | ||||||
|  |     - Группа живет в рамках одного запроса = группа не переиспользуется между запросами | ||||||
|  |     - in-memory репозитории защитить мьютексами | ||||||
|  |  | ||||||
|  | ## Дополнительное задание | ||||||
|  |  | ||||||
|  | - Тесты на многопоточность in-memory репозитория | ||||||
|  | - Грейсфул завершение приложения (использовать signal.Notify) | ||||||
|  | - Контроль утечек (горутин через https://github.com/uber-go/goleak) | ||||||
|  | - Контроль рейзов (через тесты с флагом -race) | ||||||
|  | - Реализовать параллельный запуск тестов | ||||||
|  |  | ||||||
|  | ## Автоматические проверки | ||||||
|  |  | ||||||
|  | Ваше решение должно проходить автоматические проверки: | ||||||
|  |  | ||||||
|  | - Компиляция | ||||||
|  | - Линтер | ||||||
|  | - Unit-тесты | ||||||
|  | - Code coverage >40% | ||||||
|  | - Автотесты | ||||||
|  |  | ||||||
|  | Прохождение автоматических проверок влияет на итоговую оценку за домашнюю работу. | ||||||
|  |  | ||||||
|  | ### Дедлайны сдачи и проверки задания: | ||||||
|  | - 28 июня 23:59 (сдача) / 1 июля, 23:59 (проверка) | ||||||
| @@ -10,8 +10,7 @@ github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmO | |||||||
| github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= | ||||||
| github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= | github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= | ||||||
| github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= | github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs= | ||||||
| github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw= | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= | ||||||
| github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= |  | ||||||
| github.com/elastic/go-sysinfo v1.15.3/go.mod h1:K/cNrqYTDrSoMh2oDkYEMS2+a72GRxMvNP+GC+vRIlo= | github.com/elastic/go-sysinfo v1.15.3/go.mod h1:K/cNrqYTDrSoMh2oDkYEMS2+a72GRxMvNP+GC+vRIlo= | ||||||
| github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8= | github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8= | ||||||
| github.com/envoyproxy/go-control-plane v0.13.4/go.mod h1:kDfuBlDVsSj2MjrLEtRWtHlsWIFcGyB2RMO44Dc5GZA= | github.com/envoyproxy/go-control-plane v0.13.4/go.mod h1:kDfuBlDVsSj2MjrLEtRWtHlsWIFcGyB2RMO44Dc5GZA= | ||||||
| @@ -58,6 +57,7 @@ github.com/zeebo/errs v1.4.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtC | |||||||
| github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= | github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= | ||||||
| go.opentelemetry.io/contrib/detectors/gcp v1.35.0/go.mod h1:qGWP8/+ILwMRIUf9uIVLloR1uo5ZYAslM4O6OqUi1DA= | go.opentelemetry.io/contrib/detectors/gcp v1.35.0/go.mod h1:qGWP8/+ILwMRIUf9uIVLloR1uo5ZYAslM4O6OqUi1DA= | ||||||
| go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= | go.opentelemetry.io/otel/sdk v1.19.0/go.mod h1:NedEbbS4w3C6zElbLdPJKOpJQOrGUJ+GfzpjUvI0v1A= | ||||||
|  | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= | ||||||
| go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | ||||||
| golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= | golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= | ||||||
| golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | ||||||
| @@ -69,6 +69,8 @@ golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT | |||||||
| golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||||||
| golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||||||
| golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | ||||||
|  | golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= | ||||||
|  | golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | ||||||
| golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | ||||||
| golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= | golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= | ||||||
| golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= | golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0= | ||||||
| @@ -77,11 +79,9 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 | |||||||
| golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= | ||||||
| golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= | golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= | ||||||
| google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8= | google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8= | ||||||
| google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a/go.mod h1:a77HrdMjoeKbnd2jmgcWdaS++ZLZAEq3orIOAEIKiVw= |  | ||||||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= | google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= | ||||||
| google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= | google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= | ||||||
| google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= | google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= | ||||||
| google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= |  | ||||||
| google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20/go.mod h1:Nr5H8+MlGWr5+xX/STzdoEqJrO+YteqFbMyCsrb6mH0= | google.golang.org/grpc/examples v0.0.0-20230224211313-3775f633ce20/go.mod h1:Nr5H8+MlGWr5+xX/STzdoEqJrO+YteqFbMyCsrb6mH0= | ||||||
| google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= | ||||||
| google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= | ||||||
|   | |||||||
| @@ -1,7 +1,14 @@ | |||||||
| package main | package main | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
|  | 	"os/signal" | ||||||
|  | 	"syscall" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
|  | 	"github.com/rs/zerolog/log" | ||||||
|  |  | ||||||
| 	"route256/loms/internal/app" | 	"route256/loms/internal/app" | ||||||
| ) | ) | ||||||
| @@ -9,10 +16,27 @@ import ( | |||||||
| func main() { | func main() { | ||||||
| 	srv, err := app.NewApp(os.Getenv("CONFIG_FILE")) | 	srv, err := app.NewApp(os.Getenv("CONFIG_FILE")) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		panic(err) | 		log.Fatal().Err(err).Msg("failed creating app") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := srv.ListenAndServe(); err != nil { | 	ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) | ||||||
| 		panic(err) | 	defer stop() | ||||||
|  |  | ||||||
|  | 	go func() { | ||||||
|  | 		if err := srv.ListenAndServe(ctx); err != nil && err != http.ErrServerClosed { | ||||||
|  | 			log.Fatal().Err(err).Msg("serving error") | ||||||
|  | 		} | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	<-ctx.Done() | ||||||
|  | 	log.Info().Msg("shutdown signal received") | ||||||
|  |  | ||||||
|  | 	shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second) | ||||||
|  | 	defer cancel() | ||||||
|  |  | ||||||
|  | 	if err := srv.Shutdown(shutdownCtx); err != nil { | ||||||
|  | 		log.Error().Err(err).Msg("graceful shutdown failed") | ||||||
|  | 	} else { | ||||||
|  | 		log.Info().Msg("server stopped gracefully") | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -8,7 +8,15 @@ VALUES | |||||||
|   (135717466, 100, 20), |   (135717466, 100, 20), | ||||||
|   (135937324, 100, 30), |   (135937324, 100, 30), | ||||||
|   (1625903, 10000, 0), |   (1625903, 10000, 0), | ||||||
|   (1148162, 100, 0); |   (1148162, 100, 0), | ||||||
|  |   (2958025, 100, 0), | ||||||
|  |   (3596599, 100, 0), | ||||||
|  |   (3618852, 100, 0), | ||||||
|  |   (4288068, 100, 0), | ||||||
|  |   (4465995, 100, 0), | ||||||
|  |   (30816475, 100, 0), | ||||||
|  |   (2618151, 100, 0); | ||||||
|  |  | ||||||
|  |  | ||||||
| -- +goose Down | -- +goose Down | ||||||
| DELETE FROM stocks | DELETE FROM stocks | ||||||
| @@ -20,5 +28,12 @@ WHERE | |||||||
|     135717466, |     135717466, | ||||||
|     135937324, |     135937324, | ||||||
|     1625903, |     1625903, | ||||||
|     1148162 |     1148162, | ||||||
|  |     2958025, | ||||||
|  |     3596599, | ||||||
|  |     3618852, | ||||||
|  |     4288068, | ||||||
|  |     4465995, | ||||||
|  |     30816475, | ||||||
|  |     2618151 | ||||||
|   ); |   ); | ||||||
| @@ -5,6 +5,7 @@ go 1.23.9 | |||||||
| require ( | require ( | ||||||
| 	github.com/gojuno/minimock/v3 v3.4.5 | 	github.com/gojuno/minimock/v3 v3.4.5 | ||||||
| 	github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 | 	github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 | ||||||
|  | 	github.com/jackc/pgx v3.6.2+incompatible | ||||||
| 	github.com/jackc/pgx/v5 v5.7.5 | 	github.com/jackc/pgx/v5 v5.7.5 | ||||||
| 	github.com/opentracing/opentracing-go v1.2.0 | 	github.com/opentracing/opentracing-go v1.2.0 | ||||||
| 	github.com/ozontech/allure-go/pkg/framework v0.6.34 | 	github.com/ozontech/allure-go/pkg/framework v0.6.34 | ||||||
| @@ -12,6 +13,7 @@ require ( | |||||||
| 	github.com/rs/zerolog v1.34.0 | 	github.com/rs/zerolog v1.34.0 | ||||||
| 	github.com/stretchr/testify v1.10.0 | 	github.com/stretchr/testify v1.10.0 | ||||||
| 	github.com/testcontainers/testcontainers-go v0.37.0 | 	github.com/testcontainers/testcontainers-go v0.37.0 | ||||||
|  | 	go.uber.org/goleak v1.3.0 | ||||||
| 	google.golang.org/grpc v1.73.0 | 	google.golang.org/grpc v1.73.0 | ||||||
| 	google.golang.org/protobuf v1.36.6 | 	google.golang.org/protobuf v1.36.6 | ||||||
| 	gopkg.in/yaml.v3 v3.0.1 | 	gopkg.in/yaml.v3 v3.0.1 | ||||||
| @@ -22,6 +24,7 @@ require ( | |||||||
| 	github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect | 	github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect | ||||||
| 	github.com/Microsoft/go-winio v0.6.2 // indirect | 	github.com/Microsoft/go-winio v0.6.2 // indirect | ||||||
| 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect | 	github.com/cenkalti/backoff/v4 v4.2.1 // indirect | ||||||
|  | 	github.com/cockroachdb/apd v1.1.0 // indirect | ||||||
| 	github.com/containerd/log v0.1.0 // indirect | 	github.com/containerd/log v0.1.0 // indirect | ||||||
| 	github.com/containerd/platforms v0.2.1 // indirect | 	github.com/containerd/platforms v0.2.1 // indirect | ||||||
| 	github.com/cpuguy83/dockercfg v0.3.2 // indirect | 	github.com/cpuguy83/dockercfg v0.3.2 // indirect | ||||||
| @@ -34,8 +37,11 @@ require ( | |||||||
| 	github.com/go-logr/logr v1.4.2 // indirect | 	github.com/go-logr/logr v1.4.2 // indirect | ||||||
| 	github.com/go-logr/stdr v1.2.2 // indirect | 	github.com/go-logr/stdr v1.2.2 // indirect | ||||||
| 	github.com/go-ole/go-ole v1.2.6 // indirect | 	github.com/go-ole/go-ole v1.2.6 // indirect | ||||||
|  | 	github.com/gofrs/uuid v4.4.0+incompatible // indirect | ||||||
| 	github.com/gogo/protobuf v1.3.2 // indirect | 	github.com/gogo/protobuf v1.3.2 // indirect | ||||||
|  | 	github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect | ||||||
| 	github.com/klauspost/compress v1.18.0 // indirect | 	github.com/klauspost/compress v1.18.0 // indirect | ||||||
|  | 	github.com/lib/pq v1.10.9 // indirect | ||||||
| 	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect | 	github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect | ||||||
| 	github.com/magiconair/properties v1.8.10 // indirect | 	github.com/magiconair/properties v1.8.10 // indirect | ||||||
| 	github.com/mfridman/interpolate v0.0.2 // indirect | 	github.com/mfridman/interpolate v0.0.2 // indirect | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								loms/go.sum
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								loms/go.sum
									
									
									
									
									
								
							| @@ -8,6 +8,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo | |||||||
| github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= | github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= | ||||||
| github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= | github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= | ||||||
| github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | ||||||
|  | github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= | ||||||
|  | github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= | ||||||
| github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= | github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= | ||||||
| github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= | github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= | ||||||
| github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= | github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= | ||||||
| @@ -42,6 +44,8 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre | |||||||
| github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= | github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= | ||||||
| github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= | ||||||
| github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | ||||||
|  | github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= | ||||||
|  | github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= | ||||||
| github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= | ||||||
| github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= | ||||||
| github.com/gojuno/minimock/v3 v3.4.5 h1:Jcb0tEYZvVlQNtAAYpg3jCOoSwss2c1/rNugYTzj304= | github.com/gojuno/minimock/v3 v3.4.5 h1:Jcb0tEYZvVlQNtAAYpg3jCOoSwss2c1/rNugYTzj304= | ||||||
| @@ -55,10 +59,14 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= | |||||||
| github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= | github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= | ||||||
| github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= | github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= | ||||||
|  | github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 h1:vr3AYkKovP8uR8AvSGGUK1IDqRa5lAAvEkZG1LKaCRc= | ||||||
|  | github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= | ||||||
| github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= | ||||||
| github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= | ||||||
| github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= | github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= | ||||||
| github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= | github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= | ||||||
|  | github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o= | ||||||
|  | github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I= | ||||||
| github.com/jackc/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs= | github.com/jackc/pgx/v5 v5.7.5 h1:JHGfMnQY+IEtGM63d+NGMjoRpysB2JBwDr5fsngwmJs= | ||||||
| github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= | github.com/jackc/pgx/v5 v5.7.5/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= | ||||||
| github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= | github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= | ||||||
| @@ -71,6 +79,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= | |||||||
| github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= | ||||||
| github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= | ||||||
| github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= | ||||||
|  | github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= | ||||||
|  | github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= | ||||||
| github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= | ||||||
| github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= | github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= | ||||||
| github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= | github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= | ||||||
| @@ -128,6 +138,8 @@ github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah | |||||||
| github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas= | github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas= | ||||||
| github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs= | github.com/shirou/gopsutil/v4 v4.25.1 h1:QSWkTc+fu9LTAWfkZwZ6j8MSUk4A2LV7rbH0ZqmLjXs= | ||||||
| github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI= | github.com/shirou/gopsutil/v4 v4.25.1/go.mod h1:RoUCUpndaJFtT+2zsZzzmhvbfGoDCJ7nFXKJf8GqJbI= | ||||||
|  | github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= | ||||||
|  | github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= | ||||||
| github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= | ||||||
| github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= | ||||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||||
| @@ -167,6 +179,8 @@ go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKr | |||||||
| go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= | go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= | ||||||
| go.opentelemetry.io/proto/otlp v1.7.0 h1:jX1VolD6nHuFzOYso2E73H85i92Mv8JQYk0K9vz09os= | go.opentelemetry.io/proto/otlp v1.7.0 h1:jX1VolD6nHuFzOYso2E73H85i92Mv8JQYk0K9vz09os= | ||||||
| go.opentelemetry.io/proto/otlp v1.7.0/go.mod h1:fSKjH6YJ7HDlwzltzyMj036AJ3ejJLCgCSHGj4efDDo= | go.opentelemetry.io/proto/otlp v1.7.0/go.mod h1:fSKjH6YJ7HDlwzltzyMj036AJ3ejJLCgCSHGj4efDDo= | ||||||
|  | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= | ||||||
|  | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= | ||||||
| go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= | ||||||
| go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= | ||||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||||
|   | |||||||
| @@ -30,6 +30,10 @@ import ( | |||||||
| type App struct { | type App struct { | ||||||
| 	config     *config.Config | 	config     *config.Config | ||||||
| 	controller *server.Server | 	controller *server.Server | ||||||
|  |  | ||||||
|  | 	grpcServer *grpc.Server | ||||||
|  | 	httpServer *http.Server | ||||||
|  | 	gwConn     *grpc.ClientConn | ||||||
| } | } | ||||||
|  |  | ||||||
| func NewApp(configPath string) (*App, error) { | func NewApp(configPath string) (*App, error) { | ||||||
| @@ -72,26 +76,65 @@ func NewApp(configPath string) (*App, error) { | |||||||
| 	return app, nil | 	return app, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (app *App) ListenAndServe() error { | func (app *App) Shutdown(ctx context.Context) (err error) { | ||||||
|  | 	if app.httpServer != nil { | ||||||
|  | 		err = app.httpServer.Shutdown(ctx) | ||||||
|  |  | ||||||
|  | 		if err != nil { | ||||||
|  | 			log.Error().Err(err).Msgf("failed http gateway server shutdown") | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	done := make(chan struct{}) | ||||||
|  | 	if app.grpcServer != nil { | ||||||
|  | 		go func() { | ||||||
|  | 			app.grpcServer.GracefulStop() | ||||||
|  |  | ||||||
|  | 			close(done) | ||||||
|  | 		}() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	select { | ||||||
|  | 	case <-done: | ||||||
|  | 	case <-ctx.Done(): | ||||||
|  | 		if app.grpcServer != nil { | ||||||
|  | 			app.grpcServer.Stop() | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	if app.gwConn != nil { | ||||||
|  | 		err2 := app.gwConn.Close() | ||||||
|  |  | ||||||
|  | 		if err2 != nil { | ||||||
|  | 			err = err2 | ||||||
|  |  | ||||||
|  | 			log.Error().Err(err).Msgf("failed gateway connection close") | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return err | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (app *App) ListenAndServe(ctx context.Context) error { | ||||||
| 	grpcAddr := fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.GRPCPort) | 	grpcAddr := fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.GRPCPort) | ||||||
| 	l, err := net.Listen("tcp", grpcAddr) | 	l, err := net.Listen("tcp", grpcAddr) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	grpcServer := grpc.NewServer( | 	app.grpcServer = grpc.NewServer( | ||||||
| 		grpc.ChainUnaryInterceptor( | 		grpc.ChainUnaryInterceptor( | ||||||
| 			mw.Logging, | 			mw.Logging, | ||||||
| 			mw.Validate, | 			mw.Validate, | ||||||
| 		), | 		), | ||||||
| 	) | 	) | ||||||
| 	reflection.Register(grpcServer) | 	reflection.Register(app.grpcServer) | ||||||
|  |  | ||||||
| 	pb.RegisterLOMSServer(grpcServer, app.controller) | 	pb.RegisterLOMSServer(app.grpcServer, app.controller) | ||||||
|  |  | ||||||
| 	go func() { | 	go func() { | ||||||
| 		if err = grpcServer.Serve(l); err != nil { | 		if err = app.grpcServer.Serve(l); err != nil { | ||||||
| 			log.Fatal().Msgf("failed to serve: %v", err) | 			log.Fatal().Err(err).Msg("failed to serve") | ||||||
| 		} | 		} | ||||||
| 	}() | 	}() | ||||||
|  |  | ||||||
| @@ -106,21 +149,22 @@ func (app *App) ListenAndServe() error { | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return fmt.Errorf("grpc.NewClient: %w", err) | 		return fmt.Errorf("grpc.NewClient: %w", err) | ||||||
| 	} | 	} | ||||||
|  | 	app.gwConn = conn | ||||||
|  |  | ||||||
| 	gwmux := runtime.NewServeMux() | 	gwmux := runtime.NewServeMux() | ||||||
| 	if err = pb.RegisterLOMSHandler(context.Background(), gwmux, conn); err != nil { | 	if err = pb.RegisterLOMSHandler(ctx, gwmux, conn); err != nil { | ||||||
| 		return fmt.Errorf("pb.RegisterLOMSHandler: %w", err) | 		return fmt.Errorf("pb.RegisterLOMSHandler: %w", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	gwServer := &http.Server{ | 	app.httpServer = &http.Server{ | ||||||
| 		Addr:        fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.HTTPPort), | 		Addr:        fmt.Sprintf("%s:%s", app.config.Service.Host, app.config.Service.HTTPPort), | ||||||
| 		Handler:     gwmux, | 		Handler:     gwmux, | ||||||
| 		ReadTimeout: 10 * time.Second, | 		ReadTimeout: 10 * time.Second, | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	log.Info().Msgf("Serving http loms at http://%s", gwServer.Addr) | 	log.Info().Msgf("Serving http loms at http://%s", app.httpServer.Addr) | ||||||
|  |  | ||||||
| 	return gwServer.ListenAndServe() | 	return app.httpServer.ListenAndServe() | ||||||
| } | } | ||||||
|  |  | ||||||
| func getPostgresPools(c *config.Config) (masterPool, replicaPool *pgxpool.Pool, err error) { | func getPostgresPools(c *config.Config) (masterPool, replicaPool *pgxpool.Pool, err error) { | ||||||
|   | |||||||
| @@ -1,37 +1,16 @@ | |||||||
| [ | [ | ||||||
|   { |   {"sku": 139275865,"total_count": 65534,"reserved": 0}, | ||||||
|     "sku": 139275865, |   {"sku": 2956315,"total_count": 100,"reserved": 30}, | ||||||
|     "total_count": 65534, |   {"sku": 1076963,"total_count": 100,"reserved": 35}, | ||||||
|     "reserved": 0 |   {"sku": 135717466,"total_count": 100,"reserved": 20}, | ||||||
|   }, |   {"sku": 135937324,"total_count": 100,"reserved": 30}, | ||||||
|   { |   {"sku": 1625903,"total_count": 10000,"reserved": 0}, | ||||||
|     "sku": 2956315, |   {"sku": 1148162,"total_count": 100,"reserved": 0}, | ||||||
|     "total_count": 100, |   {"sku": 2958025,"total_count": 100,"reserved": 0}, | ||||||
|     "reserved": 30 |   {"sku": 3596599,"total_count": 100,"reserved": 0}, | ||||||
|   }, |   {"sku": 3618852,"total_count": 100,"reserved": 0}, | ||||||
|   { |   {"sku": 4288068,"total_count": 100,"reserved": 0}, | ||||||
|     "sku": 1076963, |   {"sku": 4465995,"total_count": 100,"reserved": 0}, | ||||||
|     "total_count": 100, |   {"sku": 30816475,"total_count": 100,"reserved": 0}, | ||||||
|     "reserved": 35 |   {"sku": 2618151,"total_count": 100,"reserved": 0} | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     "sku": 135717466, |  | ||||||
|     "total_count": 100, |  | ||||||
|     "reserved": 20 |  | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     "sku": 135937324, |  | ||||||
|     "total_count": 100, |  | ||||||
|     "reserved": 30 |  | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     "sku": 1625903, |  | ||||||
|     "total_count": 10000, |  | ||||||
|     "reserved": 0 |  | ||||||
|   }, |  | ||||||
|   { |  | ||||||
|     "sku": 1148162, |  | ||||||
|     "total_count": 100, |  | ||||||
|     "reserved": 0 |  | ||||||
|   } |  | ||||||
| ] | ] | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ func NewStockRepository(write, read *pgxpool.Pool) service.StockRepository { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func (s *stockRepo) GetQuerier(ctx context.Context) *Queries { | func (s *stockRepo) GetWriter(ctx context.Context) *Queries { | ||||||
| 	tx, ok := postgres.TxFromCtx(ctx) | 	tx, ok := postgres.TxFromCtx(ctx) | ||||||
| 	if ok { | 	if ok { | ||||||
| 		return New(tx) | 		return New(tx) | ||||||
| @@ -36,8 +36,17 @@ func (s *stockRepo) GetQuerier(ctx context.Context) *Queries { | |||||||
| 	return New(s.write) | 	return New(s.write) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (s *stockRepo) GetReader(ctx context.Context) *Queries { | ||||||
|  | 	tx, ok := postgres.TxFromCtx(ctx) | ||||||
|  | 	if ok { | ||||||
|  | 		return New(tx) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return New(s.read) | ||||||
|  | } | ||||||
|  |  | ||||||
| func (s *stockRepo) StockReserve(ctx context.Context, stock *entity.Stock) error { | func (s *stockRepo) StockReserve(ctx context.Context, stock *entity.Stock) error { | ||||||
| 	querier := s.GetQuerier(ctx) | 	querier := s.GetWriter(ctx) | ||||||
|  |  | ||||||
| 	rows, err := querier.StockReserve(ctx, &StockReserveParams{ | 	rows, err := querier.StockReserve(ctx, &StockReserveParams{ | ||||||
| 		Sku:      int64(stock.Item.ID), | 		Sku:      int64(stock.Item.ID), | ||||||
| @@ -55,7 +64,7 @@ func (s *stockRepo) StockReserve(ctx context.Context, stock *entity.Stock) error | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *stockRepo) StockReserveRemove(ctx context.Context, stock *entity.Stock) error { | func (s *stockRepo) StockReserveRemove(ctx context.Context, stock *entity.Stock) error { | ||||||
| 	querier := s.GetQuerier(ctx) | 	querier := s.GetWriter(ctx) | ||||||
|  |  | ||||||
| 	rows, err := querier.StockReserveRemove(ctx, &StockReserveRemoveParams{ | 	rows, err := querier.StockReserveRemove(ctx, &StockReserveRemoveParams{ | ||||||
| 		Sku:      int64(stock.Item.ID), | 		Sku:      int64(stock.Item.ID), | ||||||
| @@ -81,7 +90,7 @@ func (s *stockRepo) StockReserveRemove(ctx context.Context, stock *entity.Stock) | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *stockRepo) StockCancel(ctx context.Context, stock *entity.Stock) error { | func (s *stockRepo) StockCancel(ctx context.Context, stock *entity.Stock) error { | ||||||
| 	querier := s.GetQuerier(ctx) | 	querier := s.GetWriter(ctx) | ||||||
|  |  | ||||||
| 	rows, err := querier.StockCancel(ctx, &StockCancelParams{ | 	rows, err := querier.StockCancel(ctx, &StockCancelParams{ | ||||||
| 		Sku:      int64(stock.Item.ID), | 		Sku:      int64(stock.Item.ID), | ||||||
| @@ -107,7 +116,7 @@ func (s *stockRepo) StockCancel(ctx context.Context, stock *entity.Stock) error | |||||||
| } | } | ||||||
|  |  | ||||||
| func (s *stockRepo) StockGetByID(ctx context.Context, sku entity.Sku) (*entity.Stock, error) { | func (s *stockRepo) StockGetByID(ctx context.Context, sku entity.Sku) (*entity.Stock, error) { | ||||||
| 	querier := s.GetQuerier(ctx) | 	querier := s.GetReader(ctx) | ||||||
|  |  | ||||||
| 	stock, err := querier.StockGetByID(ctx, int64(sku)) | 	stock, err := querier.StockGetByID(ctx, int64(sku)) | ||||||
| 	switch { | 	switch { | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ import ( | |||||||
| 	"github.com/gojuno/minimock/v3" | 	"github.com/gojuno/minimock/v3" | ||||||
| 	"github.com/stretchr/testify/assert" | 	"github.com/stretchr/testify/assert" | ||||||
| 	"github.com/stretchr/testify/require" | 	"github.com/stretchr/testify/require" | ||||||
|  | 	"go.uber.org/goleak" | ||||||
|  |  | ||||||
| 	"route256/loms/internal/domain/entity" | 	"route256/loms/internal/domain/entity" | ||||||
| 	"route256/loms/internal/domain/model" | 	"route256/loms/internal/domain/model" | ||||||
| @@ -39,6 +40,10 @@ func (t *mockTxManager) ReadWithRepeatableRead(ctx context.Context, fn func(ctx | |||||||
| 	return fn(ctx) | 	return fn(ctx) | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func TestMain(m *testing.M) { | ||||||
|  | 	goleak.VerifyTestMain(m) | ||||||
|  | } | ||||||
|  |  | ||||||
| func TestLomsService_OrderCreate(t *testing.T) { | func TestLomsService_OrderCreate(t *testing.T) { | ||||||
| 	t.Parallel() | 	t.Parallel() | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,11 +12,13 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/jackc/pgx/v5/pgxpool" | 	"github.com/jackc/pgx/v5/pgxpool" | ||||||
|  | 	_ "github.com/jackc/pgx/v5/stdlib" | ||||||
| 	"github.com/ozontech/allure-go/pkg/framework/provider" | 	"github.com/ozontech/allure-go/pkg/framework/provider" | ||||||
| 	"github.com/ozontech/allure-go/pkg/framework/suite" | 	"github.com/ozontech/allure-go/pkg/framework/suite" | ||||||
| 	"github.com/pressly/goose/v3" | 	"github.com/pressly/goose/v3" | ||||||
| 	"github.com/testcontainers/testcontainers-go" | 	"github.com/testcontainers/testcontainers-go" | ||||||
| 	"github.com/testcontainers/testcontainers-go/wait" | 	"github.com/testcontainers/testcontainers-go/wait" | ||||||
|  | 	"go.uber.org/goleak" | ||||||
| 	"google.golang.org/grpc" | 	"google.golang.org/grpc" | ||||||
| 	"google.golang.org/grpc/credentials/insecure" | 	"google.golang.org/grpc/credentials/insecure" | ||||||
|  |  | ||||||
| @@ -47,10 +49,9 @@ func startPostgres(ctx context.Context, migrationsDir string) (*pgxpool.Pool, fu | |||||||
| 			"POSTGRESQL_USERNAME": "user", | 			"POSTGRESQL_USERNAME": "user", | ||||||
| 			"POSTGRESQL_PASSWORD": "postgres", | 			"POSTGRESQL_PASSWORD": "postgres", | ||||||
| 			"POSTGRESQL_DATABASE": "loms_test", | 			"POSTGRESQL_DATABASE": "loms_test", | ||||||
| 			"POSTGRESQL_PORT":     "5437", |  | ||||||
| 		}, | 		}, | ||||||
| 		ExposedPorts: []string{"5437/tcp"}, | 		ExposedPorts: []string{"5432/tcp"}, | ||||||
| 		WaitingFor:   wait.ForListeningPort("5437/tcp").WithStartupTimeout(30 * time.Second), | 		WaitingFor:   wait.ForListeningPort("5432/tcp").WithStartupTimeout(30 * time.Second), | ||||||
| 	} | 	} | ||||||
| 	container, err := testcontainers.GenericContainer(ctx, | 	container, err := testcontainers.GenericContainer(ctx, | ||||||
| 		testcontainers.GenericContainerRequest{ContainerRequest: req, Started: true}) | 		testcontainers.GenericContainerRequest{ContainerRequest: req, Started: true}) | ||||||
| @@ -58,7 +59,7 @@ func startPostgres(ctx context.Context, migrationsDir string) (*pgxpool.Pool, fu | |||||||
| 		return nil, nil, err | 		return nil, nil, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	endpoint, err := container.Endpoint(ctx, "") | 	endpoint, err := container.PortEndpoint(ctx, "5432", "") | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		container.Terminate(ctx) | 		container.Terminate(ctx) | ||||||
| 		return nil, nil, err | 		return nil, nil, err | ||||||
| @@ -84,6 +85,7 @@ func startPostgres(ctx context.Context, migrationsDir string) (*pgxpool.Pool, fu | |||||||
| 		container.Terminate(ctx) | 		container.Terminate(ctx) | ||||||
| 		return nil, nil, err | 		return nil, nil, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if err := goose.Up(std, migrationsDir); err != nil { | 	if err := goose.Up(std, migrationsDir); err != nil { | ||||||
| 		container.Terminate(ctx) | 		container.Terminate(ctx) | ||||||
| 		return nil, nil, err | 		return nil, nil, err | ||||||
| @@ -109,6 +111,8 @@ type LomsIntegrationSuite struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| func TestLomsIntegrationSuite(t *testing.T) { | func TestLomsIntegrationSuite(t *testing.T) { | ||||||
|  | 	defer goleak.VerifyNone(t) | ||||||
|  |  | ||||||
| 	suite.RunSuite(t, new(LomsIntegrationSuite)) | 	suite.RunSuite(t, new(LomsIntegrationSuite)) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -116,6 +120,8 @@ func (s *LomsIntegrationSuite) BeforeAll(t provider.T) { | |||||||
| 	ctx := context.Background() | 	ctx := context.Background() | ||||||
| 	t.WithNewStep("init cart-service", func(sCtx provider.StepCtx) { | 	t.WithNewStep("init cart-service", func(sCtx provider.StepCtx) { | ||||||
| 		pool, cleanup, err := startPostgres(ctx, migrationsDir) | 		pool, cleanup, err := startPostgres(ctx, migrationsDir) | ||||||
|  | 		sCtx.Require().NoError(err, "failed postgres setup") | ||||||
|  |  | ||||||
| 		s.cleanup = cleanup | 		s.cleanup = cleanup | ||||||
|  |  | ||||||
| 		orderRepo := ordersRepository.NewOrderRepository(pool) | 		orderRepo := ordersRepository.NewOrderRepository(pool) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Никита Шубин
					Никита Шубин