{"id":475885,"date":"2026-04-14T11:29:31","date_gmt":"2026-04-14T11:29:31","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=475885"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=475885","title":{"rendered":"\u041a\u0430\u043a \u043c\u044b \u0441\u0442\u0440\u043e\u0438\u043c Tinder \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0435\u0439: \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0430\u0432\u0442\u043e \u043d\u0430 \u0430\u0432\u0442\u043e, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 Go-\u043c\u043e\u043d\u043e\u043b\u0438\u0442\u0430 \u0437\u0430 3 \u043c\u0435\u0441\u044f\u0446\u0430"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u042f \u0428\u0435\u0432\u043a\u043e\u043f\u043b\u044f\u0441 \u0414\u043c\u0438\u0442\u0440\u0438\u0439, \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <a href=\"https:\/\/swapno.ru\/?utm_source=habr\"><strong>Swapno<\/strong><\/a> \u2014 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f\u043c\u0438 \u043a\u043b\u044e\u0447-\u0432-\u043a\u043b\u044e\u0447, \u0431\u0435\u0437 \u0434\u0438\u043b\u0435\u0440\u043e\u0432. \u041c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u2014 \u043a\u0430\u043a \u0432 Tinder: \u0441\u0432\u0430\u0439\u043f\u0430\u0435\u0448\u044c \u0447\u0443\u0436\u0438\u0435 \u0430\u0432\u0442\u043e, \u0435\u0441\u043b\u0438 \u043e\u0431\u0430 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u043b\u0430\u0439\u043a\u043d\u0443\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u2014 Swap Match, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043c\u0435\u043d. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u044b \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0431\u044d\u043a\u0435\u043d\u0434 \u043d\u0430 Go \u0437\u0430 3 \u043c\u0435\u0441\u044f\u0446\u0430: \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0434\u043e matching engine, \u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438 \u0444\u043e\u0442\u043e \u0438 observability \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u0421 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438, \u0438 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0445 \u0447\u0438\u043d\u0438\u043b\u0438.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/78d\/f5b\/7bc\/78df5b7bc51f9b24bd8c0020be91efa9.png\" width=\"2492\" height=\"1448\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/78d\/f5b\/7bc\/78df5b7bc51f9b24bd8c0020be91efa9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/78d\/f5b\/7bc\/78df5b7bc51f9b24bd8c0020be91efa9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0440\u044b\u043d\u043e\u043a \u043e\u0431\u043c\u0435\u043d\u0430 \u0430\u0432\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043d<\/h2>\n<p>\u0412 \u0420\u043e\u0441\u0441\u0438\u0438 ~300 \u0442\u044b\u0441\u044f\u0447 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0435\u0439, \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u043e\u0431\u043c\u0435\u043d\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0438 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u044b \u043f\u043e \u0444\u043e\u0440\u0443\u043c\u0430\u043c, Avito \u0438 \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043a\u0430\u043d\u0430\u043b\u0430\u043c \u0432 Telegram. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043c\u0435\u043d\u0430 \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u044c: \u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0434\u043e\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u0434\u043e\u043f\u043b\u0430\u0442\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c VIN. \u0414\u0438\u043b\u0435\u0440\u044b \u0431\u0435\u0440\u0443\u0442 10-30% \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0438 \u0437\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043d\u0435\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0432\u0430\u0439\u043f-\u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u043e\u0438\u0441\u043a\u0430: \u0432\u043c\u0435\u0441\u0442\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0438\u043d\u0433\u0430 \u2014 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u00ab\u0434\u0430\/\u043d\u0435\u0442\u00bb. \u041c\u044d\u0442\u0447 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u044f: \u043e\u0431\u0430 \u0445\u043e\u0442\u044f\u0442 \u043c\u0430\u0448\u0438\u043d\u0443 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0418\u0418-\u043e\u0446\u0435\u043d\u043a\u0430 \u0438 VIN-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0435\u0448\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h2>\u041e\u0442 MVP \u043a \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e<\/h2>\n<p>\u041f\u0435\u0440\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043a\u0430\u043a <a href=\"https:\/\/t.me\/SwapnoAutoBot\">Telegram Mini App<\/a> \u2014 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b \u0431\u0435\u0437 App Store \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0412\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043f\u0440\u043e\u0441, \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043e\u0431\u043a\u0430\u0442\u0430\u043b\u0438 matching engine. \u0421\u0435\u0439\u0447\u0430\u0441 \u0433\u043e\u0442\u043e\u0432\u0438\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0443 \u043d\u0430 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0411\u044d\u043a\u0435\u043d\u0434 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a API-first \u2014 \u0441\u043c\u0435\u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8d6\/b2a\/75b\/8d6b2a75b2afe9fd9cc4e16d7c906a88.png\" alt=\"Mini App Swapno\" title=\"Mini App Swapno\" width=\"1996\" height=\"1528\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/8d6\/b2a\/75b\/8d6b2a75b2afe9fd9cc4e16d7c906a88.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8d6\/b2a\/75b\/8d6b2a75b2afe9fd9cc4e16d7c906a88.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption><a href=\"https:\/\/t.me\/SwapnoAutoBot\">Mini App<\/a> Swapno<\/figcaption><\/div>\n<\/figure>\n<h2>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430: \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u0441 \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439<\/h2>\n<p>\u041d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0432\u0438\u043b\u043a\u0430: \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u043b\u0438 \u043c\u043e\u043d\u043e\u043b\u0438\u0442. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u2014 \u0438 \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u043f\u043e\u0436\u0430\u043b\u0435\u043b.<\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u2014 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0443\u0431\u0438\u0432\u0430\u044e\u0442. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u043a\u0438\u043d\u0443\u0442\u044c: \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0430\u0432\u0442\u043e, \u0434\u043b\u044f \u0441\u0432\u0430\u0439\u043f\u043e\u0432, \u0434\u043b\u044f \u043c\u044d\u0442\u0447\u0435\u0439, \u0434\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 5 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, 5 Dockerfile, service mesh \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0448\u044c \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u0442\u044b \u0438\u0434\u0451\u0448\u044c \u0447\u0438\u043d\u0438\u0442\u044c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u0412 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u2014 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0412\u0441\u0451.<\/p>\n<p>\u041d\u043e \u00ab\u043c\u043e\u043d\u043e\u043b\u0438\u0442\u00bb \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u043a\u0430\u0448\u0430\u00bb. \u042f \u0441\u0440\u0430\u0437\u0443 \u0436\u0451\u0441\u0442\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u0441\u043b\u043e\u0438:<\/p>\n<p><code>internal\/<br \/> \u251c\u2500\u2500 domain\/        # \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u0447\u0438\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043d\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439)<br \/> \u251c\u2500\u2500 service\/ \u00a0 \u00a0 \u00a0 # \u0411\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0446\u0438\u044f<br \/> \u251c\u2500\u2500 repository\/<br \/> \u2502 \u00a0 \u251c\u2500\u2500 postgres\/\u00a0 # SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b<br \/> \u2502 \u00a0 \u2514\u2500\u2500 redis\/ \u00a0 \u00a0 # \u041a\u0435\u0448 \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438<br \/> \u251c\u2500\u2500 handler\/ \u00a0 \u00a0 \u00a0 # HTTP-\u0445\u0435\u043d\u0434\u043b\u0435\u0440\u044b (Huma)<br \/> \u251c\u2500\u2500 middleware\/ \u00a0 \u00a0# Auth, rate limiting, logging<br \/> \u2514\u2500\u2500 telegram\/\u00a0 \u00a0 \u00a0 # \u0411\u043e\u0442, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f<\/code><\/p>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043e\u0434\u043d\u043e: \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u043d\u0443\u0442\u0440\u044c. handler \u2192 service \u2192 repository. domain \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e. \u0415\u0441\u043b\u0438 \u044f \u0437\u0430\u0432\u0442\u0440\u0430 \u0437\u0430\u0445\u043e\u0447\u0443 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u0430\u0439\u043f\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u044d\u0442\u043e service\/swipe.go + repository\/postgres\/swipe.go + \u0441\u0432\u043e\u0439 main. \u041f\u0430\u0440\u0430 \u0434\u043d\u0435\u0439, \u043d\u0435 \u043c\u0435\u0441\u044f\u0446\u0435\u0432.<\/p>\n<p><strong>\u0421\u0442\u0435\u043a<\/strong><\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">HTTP<\/p>\n<\/td>\n<td>\n<p align=\"left\">Fiber v2 + Huma v2<\/p>\n<\/td>\n<td>\n<p align=\"left\">Fiber \u2014 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 express-\u0441\u0442\u0438\u043b\u044c. Huma \u2014 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 OpenAPI \u043f\u043e\u0432\u0435\u0440\u0445 \u043b\u044e\u0431\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430. \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0411\u0414<\/p>\n<\/td>\n<td>\n<p align=\"left\">PostgreSQL 17 + pgx\/v5<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041d\u0430\u0434\u0451\u0436\u043d\u043e. <code>FILTER WHERE<\/code> \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445 \u0444\u0438\u0447, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041a\u0435\u0448<\/p>\n<\/td>\n<td>\n<p align=\"left\">Redis 7<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0435\u0441\u0441\u0438\u0438, \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u0432\u0430\u0439\u043f\u043e\u0432, rate limiting, \u043a\u0435\u0448 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u2014 \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">S3<\/p>\n<\/td>\n<td>\n<p align=\"left\">MinIO \u2192 Selectel S3<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e MinIO \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432 \u043f\u0440\u043e\u0434\u0435 \u2014 S3-\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0435 \u043e\u0431\u043b\u0430\u043a\u043e. \u041e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0440\u0430\u0437\u043d\u044b\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u044b<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041b\u043e\u0433\u0438<\/p>\n<\/td>\n<td>\n<p align=\"left\">zerolog<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 JSON, \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043b\u043e\u0433\u0433\u0435\u0440 \u0434\u043b\u044f Go, context-aware \u0447\u0435\u0440\u0435\u0437 <code>logger.L(ctx)<\/code><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e <strong>Huma<\/strong>. \u042f \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b gin, echo, chi \u2014 \u0438 \u0432\u0435\u0437\u0434\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0448\u044c API \u0432 \u043a\u043e\u0434\u0435, \u0430 OpenAPI-\u0441\u043f\u0435\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0448\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u043e\u043d\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u0412 Huma \u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0448\u044c Go-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0442\u0435\u0433\u0430\u043c\u0438 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430. \u0412\u043f\u0435\u0440\u0432\u044b\u0435 \u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u043b Swagger UI \u0438 \u043e\u043d \u0441\u043e\u0432\u043f\u0430\u043b \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u0442\u0434\u0430\u0451\u0442 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<p>\u041b\u043e\u0432\u0443\u0448\u043a\u0430: Huma \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0434\u043b\u044f optional-\u043f\u043e\u043b\u0435\u0439. \u041a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b BrandID *int \u0432 query-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b panic \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a nil. \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u0447\u0430\u0441 \u043d\u0430 \u0434\u0435\u0431\u0430\u0433, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u043d\u044f\u043b: \u0432 query-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 Huma \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f body.<\/p>\n<h2>Matching Engine: \u0441\u0435\u0440\u0434\u0446\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430<\/h2>\n<p>\u042d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438 \u0437\u0434\u0435\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0431\u0438\u0442\u044b\u0445 \u0448\u0438\u0448\u0435\u043a.<\/p>\n<p><strong>\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u0432\u0430\u0439\u043f\u043e\u0432<\/strong><\/p>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043d\u0430\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u00ab\u0441\u0432\u0430\u0439\u043f\u00bb \u2192 \u0431\u044d\u043a\u0435\u043d\u0434 \u0438\u0434\u0451\u0442 \u0432 PostgreSQL \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443, LIMIT 1. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442? \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430 100 \u044e\u0437\u0435\u0440\u0430\u0445 \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 50-100ms, \u0430 \u0441\u0432\u0430\u0439\u043f\u0430\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u2014 \u043f\u043e \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0435 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u041e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0443\u0431\u0438\u0432\u0430\u0435\u0442 UX.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u0435\u0434\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432 Redis:<\/p>\n<p><code>swipe:queue:{user_id} \u2192 [car_id_1, car_id_2, ..., car_id_50]<\/code><\/p>\n<p><code><strong>GET \/swipe\/next<\/strong><\/code><strong>:<\/strong><\/p>\n<p>1. LPOP <code>swipe:queue:{user_id}<\/code> \u2014 O(1), ~0.1ms. \u041c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>2. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u0430 \u2014 \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 PostgreSQL \u043e\u0434\u043d\u0438\u043c \u0442\u044f\u0436\u0451\u043b\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u043b\u0430\u0434\u0451\u043c 50 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 Redis.<\/p>\n<pre><code class=\"sql\">SELECT c.id FROM cars c JOIN user_interests ui ON ui.user_id = $1 WHERE c.status = 'active' \u00a0 AND c.user_id != $1 \u00a0 AND c.body_type = ANY(ui.body_types) \u00a0 AND c.brand_id IN (SELECT id FROM brands WHERE brand_group = ANY(ui.brand_groups)) \u00a0 AND c.price BETWEEN (my_car.price - ui.max_surcharge) AND (my_car.price + ui.max_surcharge) \u00a0 AND c.id NOT IN (SELECT swiped_car_id FROM swipes WHERE swiper_user_id = $1) ORDER BY random() LIMIT 50<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u044f\u0436\u0451\u043b\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437 \u0432 50 \u0441\u0432\u0430\u0439\u043f\u043e\u0432, \u0430 \u043d\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u0437\u0430 0.1ms.<\/p>\n<p>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0435 \u043f\u0440\u0435\u0434\u0432\u0438\u0434\u0435\u043b: \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0432\u0430\u0439\u043f\u043d\u0443\u043b \u0430\u0432\u0442\u043e, \u0430 \u043e\u043d\u043e \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0431\u044b\u043b\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0438\u043b\u0438 \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u043e? LPOP \u0443\u0436\u0435 \u0432\u044b\u0434\u0430\u043b \u044d\u0442\u043e\u0442 car_id. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0432 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0442\u0430\u0442\u0443\u0441 \u0430\u0432\u0442\u043e. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u2014 \u0431\u0435\u0440\u0451\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0412 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 2-3 LPOP&#8217;\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e, \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p><strong>\u041c\u044d\u0442\u0447-\u0434\u0435\u0442\u0435\u043a\u0446\u0438\u044f<\/strong><\/p>\n<p>\u041c\u044d\u0442\u0447 \u2014 \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0430 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u043b\u0430\u0439\u043a\u043d\u0443\u043b\u0438 \u0430\u0432\u0442\u043e \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u041f\u0440\u0438 \u043b\u0430\u0439\u043a\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"go\">func (s SwipeService) Like(ctx context.Context, swiperID uuid.UUID, carID uuid.UUID) (MatchResult, error) { \u00a0 \u00a0 if err := s.swipes.Create(ctx, swiperID, carID, \"like\"); err != nil { \u00a0 \u00a0 \u00a0 \u00a0 return nil, err \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 swiped_car \u043b\u0430\u0439\u043a\u043d\u0443\u043b \u043d\u0430\u0448\u0435 \u0430\u0432\u0442\u043e? \u00a0 \u00a0 swiperCar,  := s.cars.GetByUserID(ctx, swiperID) \u00a0 \u00a0 targetCar,  := s.cars.GetByID(ctx, carID)\u00a0 \u00a0  \u00a0 \u00a0 reciprocal, _ := s.swipes.Exists(ctx, targetCar.UserID, swiperCar.ID) \u00a0 \u00a0 if !reciprocal { \u00a0 \u00a0 \u00a0 \u00a0 return &amp;MatchResult{Match: false}, nil \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 \/\/ \u041c\u044d\u0442\u0447! \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0434\u043e\u043f\u043b\u0430\u0442\u0443. \u00a0 \u00a0 surcharge := math.Abs(swiperCar.Price - targetCar.Price)\u00a0 \u00a0  \u00a0 \u00a0 match, err := s.matches.Create(ctx, swiperCar.ID, carID, swiperID, targetCar.UserID, surcharge) \u00a0 \u00a0 if err != nil { \u00a0 \u00a0 \u00a0 \u00a0 return nil, err \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 go s.notifier.NotifyMatch(ctx, match)\u00a0 \u00a0  \u00a0 \u00a0 return &amp;MatchResult{Match: true, MatchID: match.ID, Surcharge: surcharge}, nil }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0422\u0443\u0442 \u044f \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u043e\u044f\u043b\u0441\u044f race condition: \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043b\u0430\u0439\u043a\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u2192 \u0434\u0432\u0430 \u043c\u044d\u0442\u0447\u0430? \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 matches \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u043c\u0435\u0435\u0442 <code>UNIQUE<\/code> constraint \u043d\u0430 \u043f\u0430\u0440\u0443 (<code>car1_id, car2_id<\/code>), \u0438 \u043c\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a (\u043c\u0435\u043d\u044c\u0448\u0438\u0439 UUID \u043f\u0435\u0440\u0432\u044b\u043c). \u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043e\u0434\u0438\u043d <code>INSERT<\/code> \u043f\u0440\u043e\u0439\u0434\u0451\u0442, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 conflict \u2192 <code>ON CONFLICT DO NOTHING<\/code>. \u041c\u044d\u0442\u0447 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d.<\/p>\n<p><strong>Rate Limiting \u0441\u0432\u0430\u0439\u043f\u043e\u0432<\/strong><\/p>\n<p>\u041c\u044b \u0437\u0430\u043b\u043e\u0436\u0438\u043b\u0438 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u0438\u043c\u0438\u0442\u043e\u0432 \u2014 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0435\u0449\u0451 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c, \u043d\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u2014 Redis INCR \u0441 TTL \u0434\u043e \u043f\u043e\u043b\u0443\u043d\u043e\u0447\u0438:<\/p>\n<pre><code class=\"go\">func (s *SwipeService) checkLimit(ctx context.Context, userID uuid.UUID) error { \u00a0 \u00a0 key := fmt.Sprintf(\"rate:swipe:%s\", userID) \u00a0 \u00a0 count, _ := s.redis.Incr(ctx, key).Result()\u00a0 \u00a0  \u00a0 \u00a0 if count == 1 { \u00a0 \u00a0 \u00a0 \u00a0 s.redis.ExpireAt(ctx, key, endOfDay()) \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 limit := s.getLimitForUser(ctx, userID) \/\/ 5, 10, or \u221e \u00a0 \u00a0 if count &gt; int64(limit) { \u00a0 \u00a0 \u00a0 \u00a0 return apperr.ErrSwipeLimitReached \u00a0 \u00a0 } \u00a0 \u00a0 return nil }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0411\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0441\u043b\u043e\u0432\u0438\u043b \u0432 \u043f\u0440\u043e\u0434\u0435: <code>endOfDay()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0447\u044c \u043f\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (UTC+3), \u0430 Redis TTL \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0445 Unix timestamp&#8217;\u0430\u0445. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0412\u043b\u0430\u0434\u0438\u0432\u043e\u0441\u0442\u043e\u043a\u0430 \u043b\u0438\u043c\u0438\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b\u0441\u044f \u0432 4 \u0443\u0442\u0440\u0430 \u043f\u043e \u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 UTC \u0438 \u0441\u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u00ab\u0434\u0435\u043d\u044c\u00bb \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u2014 \u044d\u0442\u043e UTC-\u0434\u0435\u043d\u044c. \u041d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e.<\/p>\n<p><strong>\u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u0444\u043e\u0442\u043e: fail-open \u0438 \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f<\/strong><\/p>\n<p>\u041f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e \u043c\u044b \u043c\u043e\u0434\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u0444\u043e\u0442\u043e \u043e\u0434\u043d\u0438\u043c batch-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043a OpenAI Vision API. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \u044d\u0442\u043e \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f? \u041d\u0435\u0442 NSFW? \u041d\u0435\u0442 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u043f\u043e\u0432\u0435\u0440\u0445 \u0444\u043e\u0442\u043e?<\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 <strong>fail-open<\/strong>: \u0435\u0441\u043b\u0438 \u0418\u0418 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u2014 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c \u0430\u0432\u0442\u043e, \u0430\u043b\u0435\u0440\u0442\u0438\u043c \u0432 Telegram-\u043a\u0430\u043d\u0430\u043b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0443\u0447\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438. \u041c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0444\u043e\u0442\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u0430 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439.<\/p>\n<pre><code class=\"go\">func (m *Moderator) CheckImages(ctx context.Context, images []ImageData) []int { \u00a0 \u00a0 if m == nil || len(images) == 0 { \u00a0 \u00a0 \u00a0 \u00a0 return nil \/\/ \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u2014 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 result, err := m.client.Moderate(ctx, images) \u00a0 \u00a0 if err != nil { \u00a0 \u00a0 \u00a0 \u00a0 logger.L(ctx).Error().Err(err).Msg(\"moderation API failed, fail-open \u2192 \u0440\u0443\u0447\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f\") \u00a0 \u00a0 \u00a0 \u00a0 return nil \/\/ AI \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u2014 \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u0442\u0441\u044f \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 return result.RejectedIndices }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432 95%+ \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u0420\u0443\u0447\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0430, \u0430 \u043d\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 OpenAI API \u043b\u0451\u0433 \u043d\u0430 10 \u043c\u0438\u043d\u0443\u0442 \u0438 3 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e \u2014 \u0432\u0441\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438 \u0431\u0435\u0437 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438, \u0430 \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0438\u0445 \u0444\u043e\u0442\u043e \u0432 5 \u043c\u0438\u043d\u0443\u0442.<\/p>\n<p><strong>\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u043e\u0442\u043e \u0438 S3 lifecycle<\/strong><\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0444\u043e\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 <code>tmp\/cars\/{car_id}\/<\/code> \u0432 S3. \u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 <code>cars\/{car_id}\/<\/code>. S3 lifecycle rule \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0432\u0441\u0451 \u0438\u0437 tmp\/ \u0447\u0435\u0440\u0435\u0437 14 \u0434\u043d\u0435\u0439.<\/p>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b TTL 1 \u0434\u0435\u043d\u044c. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c: \u0437\u0430\u0447\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u0438? \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0430\u043b\u0435\u0440\u0442: \u00ab\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u043e\u0442\u043e \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438\u00bb. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0444\u043e\u0442\u043e \u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432\u0435\u0447\u0435\u0440\u043e\u043c, \u0430 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0448\u0438\u043b \u0432 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435. \u0424\u043e\u0442\u043e \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043d\u0435\u0432\u043d\u044f\u0442\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0443\u0448\u0451\u043b. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u043d\u044f\u043b TTL \u0434\u043e 14 \u0434\u043d\u0435\u0439:<\/p>\n<pre><code class=\"go\">if len(imageData) == 0 &amp;&amp; len(photos) &gt; 0 { \u00a0 \u00a0 return nil, apperr.ErrPhotosExpired \u00a0 \u00a0 \/\/ \u2192 HTTP 422 \"\u0444\u043e\u0442\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0438 \u0438 \u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u043e\u0442\u043e \u0437\u0430\u043d\u043e\u0432\u043e\" }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u044e\u0440\u043f\u0440\u0438\u0437 \u0441 \u0444\u043e\u0442\u043e: nginx \u0441\u0442\u043e\u0438\u0442 \u043f\u0435\u0440\u0435\u0434 Go-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 <code>client_max_body_size<\/code>. \u042f \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043b \u043b\u0438\u043c\u0438\u0442 \u0432 Go (20 \u041c\u0411), \u043d\u043e \u0437\u0430\u0431\u044b\u043b \u043f\u0440\u043e nginx (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 1 \u041c\u0411). \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0444\u043e\u0442\u043e \u0441 iPhone \u2014 15 \u041c\u0411 HEIC \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 413 Request Entity Too Large \u043e\u0442 nginx. \u041d\u0435 JSON, \u0430 \u0441\u044b\u0440\u043e\u0439 HTML. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c: \u043f\u043e\u0434\u043d\u044f\u0442\u044c nginx \u043b\u0438\u043c\u0438\u0442 \u0434\u043e 50 \u041c\u0411, \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0430\u043d\u043d\u044e\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 Content-Length \u0432 Go-\u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0435, \u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434 \u043f\u0430\u0440\u0441\u0438\u0442\u044c HTML-\u043e\u0448\u0438\u0431\u043a\u0438 \u043e\u0442 nginx.<\/p>\n<p><strong>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f SQL: \u043a\u0430\u043a \u043c\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u043b\u0438 \u0434\u0430\u0448\u0431\u043e\u0440\u0434 \u0432 4 \u0440\u0430\u0437\u0430<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u0441\u043a\u043e\u0433\u043e \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430 \u043d\u0443\u0436\u043d\u044b 15 \u043c\u0435\u0442\u0440\u0438\u043a: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438, \u0430\u0432\u0442\u043e, \u0441\u0432\u0430\u0439\u043f\u044b, \u043c\u044d\u0442\u0447\u0438 \u2014 \u0432\u0441\u0435\u0433\u043e, \u0437\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435, \u043f\u0440\u0435\u043c\u0438\u0443\u043c \u0438 \u0442.\u0434. \u041f\u0435\u0440\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u2014 15 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c SELECT:<\/p>\n<pre><code class=\"sql\">SELECT \u00a0 \u00a0 (SELECT COUNT(*) FROM users), \u00a0 \u00a0 (SELECT COUNT(*) FROM users WHERE created_at &gt;= CURRENT_DATE), \u00a0 \u00a0 (SELECT COUNT(*) FROM users WHERE subs_status = 'premium'), \u00a0 \u00a0 ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c 3-5 \u0440\u0430\u0437. \u041d\u0430 10 000 \u0437\u0430\u043f\u0438\u0441\u044f\u0445 \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u0430 100 000 \u2014 \u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u043b 200ms. \u0414\u043b\u044f \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 Prometheus \u0441\u043a\u0440\u0435\u0439\u043f\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0435 15 \u0441\u0435\u043a\u0443\u043d\u0434 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430.<\/p>\n<p>\u041f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b \u043d\u0430 CTE \u0441 FILTER WHERE \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043d\u0435\u0434\u043e\u043e\u0446\u0435\u043d\u0451\u043d\u043d\u044b\u0445 \u0444\u0438\u0447 PostgreSQL:<\/p>\n<pre><code class=\"sql\">WITH \u00a0 u AS ( \u00a0 \u00a0 SELECT \u00a0 \u00a0 \u00a0 COUNT(*) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 AS total, \u00a0 \u00a0 \u00a0 COUNT(*) FILTER (WHERE created_at &gt;= CURRENT_DATE) AS today, \u00a0 \u00a0 \u00a0 COUNT(*) FILTER (WHERE subs_status = 'premium')\u00a0 \u00a0 AS premium, \u00a0 \u00a0 \u00a0 COUNT(*) FILTER (WHERE banned_at IS NOT NULL) \u00a0 \u00a0 \u00a0 AS banned \u00a0 \u00a0 FROM users \u00a0 ), \u00a0 c AS ( \u00a0 \u00a0 SELECT \u00a0 \u00a0 \u00a0 COUNT(*) \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 AS total, \u00a0 \u00a0 \u00a0 COUNT(*) FILTER (WHERE status = 'active')\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 AS active, \u00a0 \u00a0 \u00a0 COUNT(*) FILTER (WHERE created_at &gt;= CURRENT_DATE) AS today, \u00a0 \u00a0 \u00a0 COALESCE(AVG(price) FILTER (WHERE status = 'active' AND price &gt; 0), 0) AS avg_price, \u00a0 \u00a0 \u00a0 COUNT(DISTINCT user_id)\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 AS users_with \u00a0 \u00a0 FROM cars \u00a0 ), \u00a0 -- swipes, matches \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e SELECT ... FROM u, c, sw, m;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>4 seq-scan&#8217;\u0430 \u0432\u043c\u0435\u0441\u0442\u043e 15. \u041e\u0434\u0438\u043d round-trip. \u041f\u043b\u044e\u0441 Redis-\u043a\u0435\u0448 \u043d\u0430 60 \u0441\u0435\u043a\u0443\u043d\u0434. \u0417\u0430\u043f\u0440\u043e\u0441 \u0441 200ms \u0443\u043f\u0430\u043b \u0434\u043e 15ms, \u0430 \u0441 \u043a\u0435\u0448\u0435\u043c \u2014 0.1ms.<\/p>\n<p><strong>N+1: 50 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u2192 2<\/strong><\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u043a\u0430 \u0436\u0430\u043d\u0440\u0430. \u0421\u043f\u0438\u0441\u043e\u043a 25 \u0430\u0432\u0442\u043e \u0432 \u0430\u0434\u043c\u0438\u043d\u043a\u0435 \u2014 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u044f \u0431\u0440\u0435\u043d\u0434\u0430 \u0438 \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u0435\u0440\u0432\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<pre><code class=\"go\">for i, car := range cars { \u00a0 \u00a0 brand,  := catalog.GetBrandByID(ctx, car.BrandID) \u00a0 \/\/ \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 PG \u00a0 \u00a0 model,  := catalog.GetModelByID(ctx, car.ModelID)\u00a0 \u00a0 \/\/ \u0435\u0449\u0451 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 PG \u00a0 \u00a0 items[i].BrandName = brand.Name \u00a0 \u00a0 items[i].ModelName = model.Name } \/\/ 25 \u0430\u0432\u0442\u043e \u00d7 2 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 = 50 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 N+1. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 batch:<\/p>\n<pre><code class=\"go\">brandIDs, modelIDs := collectIDs(cars) brandsMap,  := catalog.GetBrandsByIDs(ctx, brandIDs)\u00a0 \/\/ WHERE id = ANY($1) \u2014 1 \u0437\u0430\u043f\u0440\u043e\u0441 modelsMap,  := catalog.GetModelsByIDs(ctx, modelIDs) \u00a0 \/\/ 1 \u0437\u0430\u043f\u0440\u043e\u0441 for i, car := range cars { \u00a0 \u00a0 items[i].BrandName = brandsMap[car.BrandID].Name \u00a0 \u00a0 items[i].ModelName = modelsMap[car.ModelID].Name } \/\/ 2 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u043c\u0435\u0441\u0442\u043e 50<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042f \u0437\u043d\u0430\u043b \u043f\u0440\u043e N+1, \u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043d\u0430\u0438\u0432\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043f\u0435\u0440\u0432\u043e\u0439. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u00ab\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0442\u043e\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u00bb. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u043e\u0433\u0434\u0430 \u0443\u0432\u0438\u0434\u0435\u043b \u0432 \u043b\u043e\u0433\u0430\u0445, \u0447\u0442\u043e admin car list \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 400ms.<\/p>\n<p><strong>Observability: \u0442\u043e, \u0447\u0442\u043e \u0441\u043f\u0430\u0441\u0430\u0435\u0442 \u0432 3 \u0447\u0430\u0441\u0430 \u043d\u043e\u0447\u0438<\/strong><\/p>\n<p>\u042f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u0442\u0435\u043a \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0434\u043d\u044f \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u041d\u0435 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043a\u043d\u0438\u0436\u043a\u0430\u0445, \u0430 \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u0436\u0435 \u043e\u0431\u0436\u0451\u0433\u0441\u044f: \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043b\u043e\u0432\u0438\u043b \u0431\u0430\u0433\u0438 \u043f\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0430\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 grep \u043f\u043e \u043b\u043e\u0433\u0430\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0447\u0435\u0440\u0435\u0437 SSH.<\/p>\n<p><strong>\u0422\u0440\u0435\u0439\u0441\u0438\u043d\u0433 (OpenTelemetry \u2192 Jaeger):<\/strong><\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0440\u0435\u0439\u0441. \u0412\u043d\u0443\u0442\u0440\u0438 \u2014 \u0441\u043f\u0430\u043d\u044b \u043d\u0430 PostgreSQL (otelpgx), Redis (redisotel), S3, \u0432\u043d\u0435\u0448\u043d\u0438\u0435 API. \u0420\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0438\u0441\u0442\u043e\u0440\u0438\u044f: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0436\u0430\u043b\u0443\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u00ab\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0442\u043e\u0440\u043c\u043e\u0437\u0438\u0442\u00bb. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u044e Jaeger, \u043d\u0430\u0445\u043e\u0436\u0443 \u0442\u0440\u0435\u0439\u0441 \u2014 3.2 \u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u0418\u0437 \u043d\u0438\u0445 2.8 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u2014 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 5 \u0444\u043e\u0442\u043e \u0432 S3 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u043b \u043d\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u2014 800ms. \u0411\u0435\u0437 \u0442\u0440\u0435\u0439\u0441\u0438\u043d\u0433\u0430 \u044f \u0431\u044b \u0433\u0430\u0434\u0430\u043b \u043d\u0435\u0434\u0435\u043b\u044e.<\/p>\n<p>\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u0435\u0439\u0441: \/metrics \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b 500, Prometheus \u043d\u0435 \u043c\u043e\u0433 \u0441\u043a\u0440\u0435\u0439\u043f\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u0412 \u043b\u043e\u0433\u0430\u0445 \u2014 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e panic \u043b\u043e\u0432\u0438\u043b\u0441\u044f middleware. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u043a\u0430\u0437\u0430\u043b\u0430\u0441\u044c \u0432 <code>gofiber\/adaptor <\/code>\u2014 \u043e\u043d \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 <code>http.Flusher<\/code>, \u0430 <code>promhttp.Handler()<\/code> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0435\u0433\u043e. \u0417\u0430\u043c\u0435\u043d\u0438\u043b \u043d\u0430 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0439 Fiber handler \u0441 <code>prometheus.DefaultGatherer.Gather()<\/code> \u2014 \u043f\u043e\u0447\u0438\u043d\u0438\u043b\u043e\u0441\u044c. \u0411\u0435\u0437 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (\u0442\u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u044f, \u0434\u0430) \u044f \u0431\u044b \u0443\u0437\u043d\u0430\u043b \u043e\u0431 \u044d\u0442\u043e\u043c \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u0432\u0430\u043b\u0438\u043b\u0438\u0441\u044c \u0432\u0441\u0435 \u0430\u043b\u0435\u0440\u0442\u044b.<\/p>\n<p><strong>\u041c\u0435\u0442\u0440\u0438\u043a\u0438 (Prometheus + Grafana):<\/strong><\/p>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u043c\u0435\u0442\u0440\u0438\u043a\u0438: <code>swapno.swipes{direction=\"like\"}<\/code>, <code>swapno.matches<\/code>, <code>swapno.registrations<\/code>, <code>swapno.photo_uploads{status=\"success|fail\"}<\/code>. \u0422\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435: latency, error rate, goroutines. \u0412\u0441\u0451 \u0447\u0435\u0440\u0435\u0437 OTel SDK \u2192 Prometheus exporter.<\/p>\n<p>\u0412\u0430\u0436\u043d\u044b\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u2014 nil-check \u043d\u0430 \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445. \u0415\u0441\u043b\u0438 OTel \u043d\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438\u043b\u0438 \u0432 dev-\u0440\u0435\u0436\u0438\u043c\u0435 \u0431\u0435\u0437 Jaeger) \u2014 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 = <code>nil<\/code>. \u0412\u043c\u0435\u0441\u0442\u043e <code>if-else<\/code> \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435:<\/p>\n<pre><code class=\"go\">if appOtel.SwipesTotal != nil { \u00a0 \u00a0 appOtel.SwipesTotal.Add(ctx, 1, metric.WithAttributes(...)) }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043d\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e. \u0421\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 OTel, \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u043f\u0438\u0448\u0443\u0442\u0441\u044f.<\/p>\n<p><strong>\u041b\u043e\u0433\u0438 (zerolog \u2192 Loki):<\/strong><\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 JSON \u0441 <code>trace_id<\/code> \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<pre><code class=\"go\">logger.L(ctx).Info(). \u00a0 \u00a0 Str(\"car_id\", carID.String()). \u00a0 \u00a0 Int(\"photos\", len(photos)). \u00a0 \u00a0 Msg(\"car published\") \/\/ \u2192 {\"level\":\"info\",\"car_id\":\"...\",\"photos\":3,\"trace_id\":\"abc123\",\"message\":\"car published\"}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 Grafana: \u0432\u0438\u0434\u0438\u0448\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043b\u043e\u0433\u0435 \u2192 \u043a\u043b\u0438\u043a\u0430\u0435\u0448\u044c \u043d\u0430 trace_id \u2192 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0448\u044c \u0432 Jaeger \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u0442\u0440\u0435\u0439\u0441\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442 \u0447\u0430\u0441\u044b \u0434\u0435\u0431\u0430\u0433\u0430.<\/p>\n<p><strong>\u0410\u043b\u0435\u0440\u0442\u0438\u043d\u0433 \u0447\u0435\u0440\u0435\u0437 Telegram-\u0431\u043e\u0442\u0430:<\/strong><\/p>\n<p>\u041a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0443\u043b\u0435\u0442\u0430\u044e\u0442 \u043f\u0440\u044f\u043c\u043e \u0432 Telegram-\u043a\u0430\u043d\u0430\u043b \u0430\u0434\u043c\u0438\u043d\u0430\u043c \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u043e\u0440\u043c\u0430\u0442\u0430:<\/p>\n<p><code>\ud83d\udd34 \u041e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0431\u044d\u043a\u0435\u043d\u0434\u0435<br \/> \u2699\ufe0f \u041e\u043f\u0435\u0440\u0430\u0446\u0438\u044f: publish_moderation_skipped<br \/> \u274c \u041e\u0448\u0438\u0431\u043a\u0430: \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u043e\u0442\u043e \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438<br \/> \ud83d\udccb \u0414\u0435\u0442\u0430\u043b\u0438: car_id=167f0617-..., photos=3<br \/> \ud83d\udd50 08.04.2026 13:50:04<\/code><\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u043b\u0435\u0440\u0442 \u043f\u043e\u043c\u043e\u0433 \u043c\u043d\u0435 \u043f\u043e\u0439\u043c\u0430\u0442\u044c \u0431\u0430\u0433 \u0441 \u0438\u0441\u0442\u0451\u043a\u0448\u0438\u043c\u0438 \u0444\u043e\u0442\u043e, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u0432\u044b\u0448\u0435.<\/p>\n<p><strong>\u0427\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u041d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/strong> \u2014 Telegram Mini App \u0431\u044b\u043b\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u0411\u044d\u043a\u0435\u043d\u0434 API-first, \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>\u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 matching<\/strong> \u2014 \u0443\u0447\u0451\u0442 \u0433\u0435\u043e-\u043b\u043e\u043a\u0430\u0446\u0438\u0438, \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0439, ML-\u043c\u043e\u0434\u0435\u043b\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u0441\u0432\u0430\u0439\u043f\u043e\u0432<\/p>\n<\/li>\n<li>\n<p><strong>\u0427\u0430\u0442 \u043c\u0435\u0436\u0434\u0443 \u043c\u044d\u0442\u0447\u0430\u043c\u0438<\/strong> \u2014 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u043e\u0431\u043c\u0435\u043d\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u0418\u0442\u043e\u0433\u0438<\/strong><\/p>\n<p>\u0417\u0430 3 \u043c\u0435\u0441\u044f\u0446\u0430 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 production-ready \u0431\u044d\u043a\u0435\u043d\u0434 \u043d\u0430 Go:<\/p>\n<ul>\n<li>\n<p><strong>~15 000 \u0441\u0442\u0440\u043e\u043a Go-\u043a\u043e\u0434\u0430<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>40+ API-\u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432<\/strong><\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u043b\u043d\u0430\u044f observability<\/strong> \u0441 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0434\u043d\u044f<\/p>\n<\/li>\n<li>\n<p><strong>\u0412\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430<\/strong> \u2014 p95 &lt; 50ms \u0434\u043b\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u043d\u043e\u043b\u0438\u0442 \u0441 \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u2014 \u043d\u0435 dirty hack, \u0430 \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0434\u043b\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u0447\u0442\u043e \u044f \u0432\u044b\u043d\u0435\u0441: \u043d\u0435 \u0431\u043e\u0439\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0438\u0432\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0435\u0439. \u041f\u0438\u0448\u0438 \u0442\u0443\u043f\u043e, \u0434\u0435\u043f\u043b\u043e\u0439, \u0441\u043c\u043e\u0442\u0440\u0438 \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0439 \u043f\u043e \u0444\u0430\u043a\u0442\u0443. \u041f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0440\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u0437 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435, \u0430 \u043d\u0435 \u0438\u0437 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u0431\u0443\u043c\u0430\u0433\u0435.<\/p>\n<p><em>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0431\u043e\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u2014 matching engine, \u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 observability \u0441\u0442\u0435\u043a\u0430 \u2014 \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435, \u0441\u0434\u0435\u043b\u0430\u044e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u044c\u044e.<\/em><\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1023278\/\">https:\/\/habr.com\/ru\/articles\/1023278\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u042f \u0428\u0435\u0432\u043a\u043e\u043f\u043b\u044f\u0441 \u0414\u043c\u0438\u0442\u0440\u0438\u0439, \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Swapno \u2014 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f\u043c\u0438 \u043a\u043b\u044e\u0447-\u0432-\u043a\u043b\u044e\u0447, \u0431\u0435\u0437 \u0434\u0438\u043b\u0435\u0440\u043e\u0432. \u041c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u2014 \u043a\u0430\u043a \u0432 Tinder: \u0441\u0432\u0430\u0439\u043f\u0430\u0435\u0448\u044c \u0447\u0443\u0436\u0438\u0435 \u0430\u0432\u0442\u043e, \u0435\u0441\u043b\u0438 \u043e\u0431\u0430 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u043b\u0430\u0439\u043a\u043d\u0443\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u044b \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u2014 Swap Match, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043c\u0435\u043d. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u044b \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0431\u044d\u043a\u0435\u043d\u0434 \u043d\u0430 Go \u0437\u0430 3 \u043c\u0435\u0441\u044f\u0446\u0430: \u043e\u0442 \u0432\u044b\u0431\u043e\u0440\u0430 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0434\u043e matching engine, \u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438 \u0444\u043e\u0442\u043e \u0438 observability \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435. \u0421 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0448\u0438\u0431\u043a\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438, \u0438 \u0442\u0435\u043c, \u043a\u0430\u043a \u0438\u0445 \u0447\u0438\u043d\u0438\u043b\u0438.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0440\u044b\u043d\u043e\u043a \u043e\u0431\u043c\u0435\u043d\u0430 \u0430\u0432\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u043d\u0412 \u0420\u043e\u0441\u0441\u0438\u0438 ~300 \u0442\u044b\u0441\u044f\u0447 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u0435\u0439, \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0433\u043e\u0442\u043e\u0432\u044b \u043a \u043e\u0431\u043c\u0435\u043d\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u043e\u043d\u0438 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d\u044b \u043f\u043e \u0444\u043e\u0440\u0443\u043c\u0430\u043c, Avito \u0438 \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043a\u0430\u043d\u0430\u043b\u0430\u043c \u0432 Telegram. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043c\u0435\u043d\u0430 \u2014 \u044d\u0442\u043e \u0431\u043e\u043b\u044c: \u043d\u0443\u0436\u043d\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u0434\u043e\u0433\u043e\u0432\u0430\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u0434\u043e\u043f\u043b\u0430\u0442\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c VIN. \u0414\u0438\u043b\u0435\u0440\u044b \u0431\u0435\u0440\u0443\u0442 10-30% \u043a\u043e\u043c\u0438\u0441\u0441\u0438\u0438 \u0438 \u0437\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u044e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430 \u043d\u0435\u0434\u0435\u043b\u0438.\u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0421\u0432\u0430\u0439\u043f-\u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u043e\u0438\u0441\u043a\u0430: \u0432\u043c\u0435\u0441\u0442\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u043e\u043b\u043b\u0438\u043d\u0433\u0430 \u2014 \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u00ab\u0434\u0430\/\u043d\u0435\u0442\u00bb. \u041c\u044d\u0442\u0447 \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0434\u043e\u0432\u0435\u0440\u0438\u044f: \u043e\u0431\u0430 \u0445\u043e\u0442\u044f\u0442 \u043c\u0430\u0448\u0438\u043d\u0443 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u0418\u0418-\u043e\u0446\u0435\u043d\u043a\u0430 \u0438 VIN-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0435\u0448\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u0438.\u041e\u0442 MVP \u043a \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e\u041f\u0435\u0440\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043a\u0430\u043a Telegram Mini App \u2014 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0437\u044b \u0431\u0435\u0437 App Store \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0412\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043f\u0440\u043e\u0441, \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043e\u0431\u043a\u0430\u0442\u0430\u043b\u0438 matching engine. \u0421\u0435\u0439\u0447\u0430\u0441 \u0433\u043e\u0442\u043e\u0432\u0438\u043c\u0441\u044f \u043a \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0443 \u043d\u0430 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0411\u044d\u043a\u0435\u043d\u0434 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043a\u0430\u043a API-first \u2014 \u0441\u043c\u0435\u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043d\u0435 \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c.Mini App Swapno\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430: \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u0441 \u0447\u0438\u0441\u0442\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439\u041d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0431\u044b\u043b\u0430 \u0440\u0430\u0437\u0432\u0438\u043b\u043a\u0430: \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438\u043b\u0438 \u043c\u043e\u043d\u043e\u043b\u0438\u0442. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u2014 \u0438 \u043d\u0438 \u0440\u0430\u0437\u0443 \u043d\u0435 \u043f\u043e\u0436\u0430\u043b\u0435\u043b.\u041a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u2014 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0443\u0431\u0438\u0432\u0430\u044e\u0442. \u042f \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u043a\u0438\u043d\u0443\u0442\u044c: \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0430\u0432\u0442\u043e, \u0434\u043b\u044f \u0441\u0432\u0430\u0439\u043f\u043e\u0432, \u0434\u043b\u044f \u043c\u044d\u0442\u0447\u0435\u0439, \u0434\u043b\u044f \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c 5 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, 5 Dockerfile, service mesh \u0434\u043b\u044f \u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u0433\u0434\u0430 \u043c\u0435\u043d\u044f\u0435\u0448\u044c \u0444\u043e\u0440\u043c\u0430\u0442 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435, \u0442\u044b \u0438\u0434\u0451\u0448\u044c \u0447\u0438\u043d\u0438\u0442\u044c \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u0434\u0440\u0443\u0433\u043e\u043c. \u0412 \u043c\u043e\u043d\u043e\u043b\u0438\u0442\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u043b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u2014 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u043b \u0432\u0441\u0435 \u043c\u0435\u0441\u0442\u0430, \u0433\u0434\u0435 \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0412\u0441\u0451.\u041d\u043e \u00ab\u043c\u043e\u043d\u043e\u043b\u0438\u0442\u00bb \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442 \u00ab\u043a\u0430\u0448\u0430\u00bb. \u042f \u0441\u0440\u0430\u0437\u0443 \u0436\u0451\u0441\u0442\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b \u0441\u043b\u043e\u0438:internal\/ \u251c\u2500\u2500 domain\/        # \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0430\u0432\u0438\u043b\u0430 (\u0447\u0438\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u043d\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439) \u251c\u2500\u2500 service\/ \u00a0 \u00a0 \u00a0 # \u0411\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430, \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u251c\u2500\u2500 repository\/ \u2502 \u00a0 \u251c\u2500\u2500 postgres\/\u00a0 # SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u2502 \u00a0 \u2514\u2500\u2500 redis\/ \u00a0 \u00a0 # \u041a\u0435\u0448 \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u251c\u2500\u2500 handler\/ \u00a0 \u00a0 \u00a0 # HTTP-\u0445\u0435\u043d\u0434\u043b\u0435\u0440\u044b (Huma) \u251c\u2500\u2500 middleware\/ \u00a0 \u00a0# Auth, rate limiting, logging \u2514\u2500\u2500 telegram\/\u00a0 \u00a0 \u00a0 # \u0411\u043e\u0442, \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043e\u0434\u043d\u043e: \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0432\u043d\u0443\u0442\u0440\u044c. handler \u2192 service \u2192 repository. domain \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0438\u0447\u0435\u0433\u043e. \u0415\u0441\u043b\u0438 \u044f \u0437\u0430\u0432\u0442\u0440\u0430 \u0437\u0430\u0445\u043e\u0447\u0443 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u0430\u0439\u043f\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u044d\u0442\u043e service\/swipe.go + repository\/postgres\/swipe.go + \u0441\u0432\u043e\u0439 main. \u041f\u0430\u0440\u0430 \u0434\u043d\u0435\u0439, \u043d\u0435 \u043c\u0435\u0441\u044f\u0446\u0435\u0432.\u0421\u0442\u0435\u043a\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0422\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043eHTTPFiber v2 + Huma v2Fiber \u2014 \u0431\u044b\u0441\u0442\u0440\u044b\u0439, \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 express-\u0441\u0442\u0438\u043b\u044c. Huma \u2014 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 OpenAPI \u043f\u043e\u0432\u0435\u0440\u0445 \u043b\u044e\u0431\u043e\u0433\u043e \u0440\u043e\u0443\u0442\u0435\u0440\u0430. \u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f, \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438\u0411\u0414PostgreSQL 17 + pgx\/v5\u041d\u0430\u0434\u0451\u0436\u043d\u043e. FILTER WHERE \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u043b\u0443\u0447\u0448\u0438\u0445 \u0444\u0438\u0447, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442\u041a\u0435\u0448Redis 7\u0421\u0435\u0441\u0441\u0438\u0438, \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0441\u0432\u0430\u0439\u043f\u043e\u0432, rate limiting, \u043a\u0435\u0448 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u2014 \u0432\u0441\u0451 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435S3MinIO \u2192 Selectel S3\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e MinIO \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0432 \u043f\u0440\u043e\u0434\u0435 \u2014 S3-\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0435 \u043e\u0431\u043b\u0430\u043a\u043e. \u041e\u0434\u0438\u043d \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0440\u0430\u0437\u043d\u044b\u0435 \u0431\u044d\u043a\u0435\u043d\u0434\u044b\u041b\u043e\u0433\u0438zerolog\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 JSON, \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043b\u043e\u0433\u0433\u0435\u0440 \u0434\u043b\u044f Go, context-aware \u0447\u0435\u0440\u0435\u0437 logger.L(ctx)\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e Huma. \u042f \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b gin, echo, chi \u2014 \u0438 \u0432\u0435\u0437\u0434\u0435 \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430: \u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0448\u044c API \u0432 \u043a\u043e\u0434\u0435, \u0430 OpenAPI-\u0441\u043f\u0435\u043a\u0443 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0448\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0438 \u043e\u043d\u0438 \u0440\u0430\u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u0412 Huma \u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0448\u044c Go-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0442\u0435\u0433\u0430\u043c\u0438 \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e, \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430. \u0412\u043f\u0435\u0440\u0432\u044b\u0435 \u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u043b Swagger UI \u0438 \u043e\u043d \u0441\u043e\u0432\u043f\u0430\u043b \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043e\u0442\u0434\u0430\u0451\u0442 \u0441\u0435\u0440\u0432\u0435\u0440.\u041b\u043e\u0432\u0443\u0448\u043a\u0430: Huma \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0434\u043b\u044f optional-\u043f\u043e\u043b\u0435\u0439. \u041a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b BrandID *int \u0432 query-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b panic \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a nil. \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u0447\u0430\u0441 \u043d\u0430 \u0434\u0435\u0431\u0430\u0433, \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u043e\u043d\u044f\u043b: \u0432 query-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 Huma \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, \u0430 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f body.Matching Engine: \u0441\u0435\u0440\u0434\u0446\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430\u042d\u0442\u043e \u0441\u0430\u043c\u0430\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438 \u0437\u0434\u0435\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0431\u0438\u0442\u044b\u0445 \u0448\u0438\u0448\u0435\u043a.\u041e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u0432\u0430\u0439\u043f\u043e\u0432\u041f\u0435\u0440\u0432\u0430\u044f \u043d\u0430\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u00ab\u0441\u0432\u0430\u0439\u043f\u00bb \u2192 \u0431\u044d\u043a\u0435\u043d\u0434 \u0438\u0434\u0451\u0442 \u0432 PostgreSQL \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044e, \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443, LIMIT 1. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442? \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430 100 \u044e\u0437\u0435\u0440\u0430\u0445 \u2014 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 50-100ms, \u0430 \u0441\u0432\u0430\u0439\u043f\u0430\u044e\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u2014 \u043f\u043e \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0435 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443. \u041e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0443\u0431\u0438\u0432\u0430\u0435\u0442 UX.\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u0435\u0434\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432 Redis:swipe:queue:{user_id} \u2192 [car_id_1, car_id_2, &#8230;, car_id_50]GET \/swipe\/next:1. LPOP swipe:queue:{user_id} \u2014 O(1), ~0.1ms. \u041c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e.2. \u0415\u0441\u043b\u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0443\u0441\u0442\u0430 \u2014 \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0437 PostgreSQL \u043e\u0434\u043d\u0438\u043c \u0442\u044f\u0436\u0451\u043b\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u043a\u043b\u0430\u0434\u0451\u043c 50 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432 Redis.SELECT c.id FROM cars c JOIN user_interests ui ON ui.user_id = $1 WHERE c.status = &#8216;active&#8217; \u00a0 AND c.user_id != $1 \u00a0 AND c.body_type = ANY(ui.body_types) \u00a0 AND c.brand_id IN (SELECT id FROM brands WHERE brand_group = ANY(ui.brand_groups)) \u00a0 AND c.price BETWEEN (my_car.price &#8212; ui.max_surcharge) AND (my_car.price + ui.max_surcharge) \u00a0 AND c.id NOT IN (SELECT swiped_car_id FROM swipes WHERE swiper_user_id = $1) ORDER BY random() LIMIT 50\u0422\u044f\u0436\u0451\u043b\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437 \u0432 50 \u0441\u0432\u0430\u0439\u043f\u043e\u0432, \u0430 \u043d\u0435 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0438\u0434\u0438\u0442 \u043a\u0430\u0440\u0442\u043e\u0447\u043a\u0443 \u0437\u0430 0.1ms.\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0435 \u043f\u0440\u0435\u0434\u0432\u0438\u0434\u0435\u043b: \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u0432\u0430\u0439\u043f\u043d\u0443\u043b \u0430\u0432\u0442\u043e, \u0430 \u043e\u043d\u043e \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0431\u044b\u043b\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043e \u0438\u043b\u0438 \u0434\u0435\u0430\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u043d\u043e? LPOP \u0443\u0436\u0435 \u0432\u044b\u0434\u0430\u043b \u044d\u0442\u043e\u0442 car_id. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u0432 \u0445\u0435\u043d\u0434\u043b\u0435\u0440\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u0442\u0430\u0442\u0443\u0441 \u0430\u0432\u0442\u043e. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u2014 \u0431\u0435\u0440\u0451\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u0437 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u0412 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 2-3 LPOP&#8217;\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0434\u043d\u043e\u0433\u043e, \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e.\u041c\u044d\u0442\u0447-\u0434\u0435\u0442\u0435\u043a\u0446\u0438\u044f\u041c\u044d\u0442\u0447 \u2014 \u044d\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u0430 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0430 \u043b\u0430\u0439\u043a\u043d\u0443\u043b\u0438 \u0430\u0432\u0442\u043e \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430. \u041f\u0440\u0438 \u043b\u0430\u0439\u043a\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0441\u0442\u044c:func (s SwipeService) Like(ctx context.Context, swiperID uuid.UUID, carID uuid.UUID) (MatchResult, error) { \u00a0 \u00a0 if err := s.swipes.Create(ctx, swiperID, carID, &#171;like&#187;); err != nil { \u00a0 \u00a0 \u00a0 \u00a0 return nil, err \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446 swiped_car \u043b\u0430\u0439\u043a\u043d\u0443\u043b \u043d\u0430\u0448\u0435 \u0430\u0432\u0442\u043e? \u00a0 \u00a0 swiperCar,  := s.cars.GetByUserID(ctx, swiperID) \u00a0 \u00a0 targetCar,  := s.cars.GetByID(ctx, carID)\u00a0 \u00a0  \u00a0 \u00a0 reciprocal, _ := s.swipes.Exists(ctx, targetCar.UserID, swiperCar.ID) \u00a0 \u00a0 if !reciprocal { \u00a0 \u00a0 \u00a0 \u00a0 return &amp;MatchResult{Match: false}, nil \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 \/\/ \u041c\u044d\u0442\u0447! \u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0434\u043e\u043f\u043b\u0430\u0442\u0443. \u00a0 \u00a0 surcharge := math.Abs(swiperCar.Price &#8212; targetCar.Price)\u00a0 \u00a0  \u00a0 \u00a0 match, err := s.matches.Create(ctx, swiperCar.ID, carID, swiperID, targetCar.UserID, surcharge) \u00a0 \u00a0 if err != nil { \u00a0 \u00a0 \u00a0 \u00a0 return nil, err \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 go s.notifier.NotifyMatch(ctx, match)\u00a0 \u00a0  \u00a0 \u00a0 return &amp;MatchResult{Match: true, MatchID: match.ID, Surcharge: surcharge}, nil }\u0422\u0443\u0442 \u044f \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u043e\u044f\u043b\u0441\u044f race condition: \u0434\u0432\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043b\u0430\u0439\u043a\u0430\u044e\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u2192 \u0434\u0432\u0430 \u043c\u044d\u0442\u0447\u0430? \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 matches \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u043c\u0435\u0435\u0442 UNIQUE constraint \u043d\u0430 \u043f\u0430\u0440\u0443 (car1_id, car2_id), \u0438 \u043c\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a (\u043c\u0435\u043d\u044c\u0448\u0438\u0439 UUID \u043f\u0435\u0440\u0432\u044b\u043c). \u0414\u0430\u0436\u0435 \u043f\u0440\u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043e\u0434\u0438\u043d INSERT \u043f\u0440\u043e\u0439\u0434\u0451\u0442, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u0442 conflict \u2192 ON CONFLICT DO NOTHING. \u041c\u044d\u0442\u0447 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d.Rate Limiting \u0441\u0432\u0430\u0439\u043f\u043e\u0432\u041c\u044b \u0437\u0430\u043b\u043e\u0436\u0438\u043b\u0438 \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u0438\u043c\u0438\u0442\u043e\u0432 \u2014 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0435\u0449\u0451 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u043c, \u043d\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u2014 Redis INCR \u0441 TTL \u0434\u043e \u043f\u043e\u043b\u0443\u043d\u043e\u0447\u0438:func (s *SwipeService) checkLimit(ctx context.Context, userID uuid.UUID) error { \u00a0 \u00a0 key := fmt.Sprintf(&#171;rate:swipe:%s&#187;, userID) \u00a0 \u00a0 count, _ := s.redis.Incr(ctx, key).Result()\u00a0 \u00a0  \u00a0 \u00a0 if count == 1 { \u00a0 \u00a0 \u00a0 \u00a0 s.redis.ExpireAt(ctx, key, endOfDay()) \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 limit := s.getLimitForUser(ctx, userID) \/\/ 5, 10, or \u221e \u00a0 \u00a0 if count &gt; int64(limit) { \u00a0 \u00a0 \u00a0 \u00a0 return apperr.ErrSwipeLimitReached \u00a0 \u00a0 } \u00a0 \u00a0 return nil }\u0411\u0430\u0433, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0441\u043b\u043e\u0432\u0438\u043b \u0432 \u043f\u0440\u043e\u0434\u0435: endOfDay() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0447\u044c \u043f\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (UTC+3), \u0430 Redis TTL \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0445 Unix timestamp&#8217;\u0430\u0445. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0437 \u0412\u043b\u0430\u0434\u0438\u0432\u043e\u0441\u0442\u043e\u043a\u0430 \u043b\u0438\u043c\u0438\u0442 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043b\u0441\u044f \u0432 4 \u0443\u0442\u0440\u0430 \u043f\u043e \u0438\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u043d\u0430 UTC \u0438 \u0441\u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u00ab\u0434\u0435\u043d\u044c\u00bb \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u2014 \u044d\u0442\u043e UTC-\u0434\u0435\u043d\u044c. \u041d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e.\u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u0444\u043e\u0442\u043e: fail-open \u0438 \u0435\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u041f\u0440\u0438 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0430\u0432\u0442\u043e \u043c\u044b \u043c\u043e\u0434\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u0444\u043e\u0442\u043e \u043e\u0434\u043d\u0438\u043c batch-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043a OpenAI Vision API. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c: \u044d\u0442\u043e \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044f? \u041d\u0435\u0442 NSFW? \u041d\u0435\u0442 \u043d\u043e\u043c\u0435\u0440\u043e\u0432 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043e\u0432 \u043f\u043e\u0432\u0435\u0440\u0445 \u0444\u043e\u0442\u043e?\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 fail-open: \u0435\u0441\u043b\u0438 \u0418\u0418 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u2014 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0435\u043c \u0430\u0432\u0442\u043e, \u0430\u043b\u0435\u0440\u0442\u0438\u043c \u0432 Telegram-\u043a\u0430\u043d\u0430\u043b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0440\u0443\u0447\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438. \u041c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0444\u043e\u0442\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d, \u0430 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439.func (m *Moderator) CheckImages(ctx context.Context, images []ImageData) []int { \u00a0 \u00a0 if m == nil || len(images) == 0 { \u00a0 \u00a0 \u00a0 \u00a0 return nil \/\/ \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u2014 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 result, err := m.client.Moderate(ctx, images) \u00a0 \u00a0 if err != nil { \u00a0 \u00a0 \u00a0 \u00a0 logger.L(ctx).Error().Err(err).Msg(&#171;moderation API failed, fail-open \u2192 \u0440\u0443\u0447\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f&#187;) \u00a0 \u00a0 \u00a0 \u00a0 return nil \/\/ AI \u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u2014 \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u0442\u0441\u044f \u00a0 \u00a0 }\u00a0 \u00a0  \u00a0 \u00a0 return result.RejectedIndices }\u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0418\u0418-\u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0432 95%+ \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u0420\u0443\u0447\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u044f \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u0430\u0445\u043e\u0432\u043a\u0430, \u0430 \u043d\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 OpenAI API \u043b\u0451\u0433 \u043d\u0430 10 \u043c\u0438\u043d\u0443\u0442 \u0438 3 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u044b\u0442\u0430\u043b\u0438\u0441\u044c \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e \u2014 \u0432\u0441\u0435 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438 \u0431\u0435\u0437 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438, \u0430 \u043c\u043e\u0434\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0438\u0445 \u0444\u043e\u0442\u043e \u0432 5 \u043c\u0438\u043d\u0443\u0442.\u0412\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0444\u043e\u0442\u043e \u0438 S3 lifecycle\u0417\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0444\u043e\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 tmp\/cars\/{car_id}\/ \u0432 S3. \u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u2014 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0442\u0441\u044f \u0432 cars\/{car_id}\/. S3 lifecycle rule \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0432\u0441\u0451 \u0438\u0437 tmp\/ \u0447\u0435\u0440\u0435\u0437 14 \u0434\u043d\u0435\u0439.\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b TTL 1 \u0434\u0435\u043d\u044c. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c: \u0437\u0430\u0447\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a\u0438? \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0430\u043b\u0435\u0440\u0442: \u00ab\u041d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0444\u043e\u0442\u043e \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u0440\u0430\u0446\u0438\u0438\u00bb. \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0444\u043e\u0442\u043e \u0432 \u043f\u044f\u0442\u043d\u0438\u0446\u0443 \u0432\u0435\u0447\u0435\u0440\u043e\u043c, \u0430 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0448\u0438\u043b \u0432 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435. \u0424\u043e\u0442\u043e \u0443\u0436\u0435 \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u043d\u0435\u0432\u043d\u044f\u0442\u043d\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u0443\u0448\u0451\u043b. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u043d\u044f\u043b TTL \u0434\u043e 14 \u0434\u043d\u0435\u0439:if len(imageData) == 0 &amp;&amp; len(photos) &gt; 0 { \u00a0 \u00a0 return nil, apperr.ErrPhotosExpired \u00a0 \u00a0 \/\/ \u2192 HTTP 422 &#171;\u0444\u043e\u0442\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0438 \u0438 \u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0444\u043e\u0442\u043e \u0437\u0430\u043d\u043e\u0432\u043e&#187; }\u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u0441\u044e\u0440\u043f\u0440\u0438\u0437 \u0441 \u0444\u043e\u0442\u043e: nginx \u0441\u0442\u043e\u0438\u0442 \u043f\u0435\u0440\u0435\u0434 Go-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0439 client_max_body_size. \u042f \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u043b \u043b\u0438\u043c\u0438\u0442 \u0432 Go (20 \u041c\u0411), \u043d\u043e \u0437\u0430\u0431\u044b\u043b \u043f\u0440\u043e nginx (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 1 \u041c\u0411). \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0444\u043e\u0442\u043e \u0441 iPhone \u2014 15 \u041c\u0411 HEIC \u2014 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-475885","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=475885"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/475885\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=475885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=475885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=475885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}