diff --git a/tasks/mytarin_es/lab_3/README.md b/tasks/mytarin_es/lab_3/README.md index e69de29..5d2921c 100644 --- a/tasks/mytarin_es/lab_3/README.md +++ b/tasks/mytarin_es/lab_3/README.md @@ -0,0 +1,86 @@ +# Отчет по лабораторной работе №3 + +Выполнил студент гр. ИСЭбд-41 Мытарин Е.С. + +## REST API, Gateway и синхронный обмен между микросервисами + +## Создание микросервисов + +1. С помощью команды `dotnet new web -n worker-2` в терминале создал первый микросервис +2. Добавил решение командой `dotnet new sln` +3. Связал решение и проект командой `dotnet sln worker-2.sln add worker-2.csproj` +4. Повторил действие для второго микросервиса +5. Добавил библиотеку Swagger и OpenAi в проекты и запустил с помощью команды `dotnet run` + +Скриншоты протестированных микросервисов: +![](pic/1.png) +![](pic/2.png) + +## Реализация синхронного обмена + +Реализовал код, который вызывает сихронно данные из соседнего микросервиса. + +```cs +//worker-2 +app.MapGet("/Requests/", async () => +{ + var httpClient = new HttpClient(); + var secondWorkerResponse = await httpClient.GetStringAsync("http://worker-1:8080/"); + + return secondWorkerResponse.ToArray(); +}) +.WithName("GetRequests") +.WithOpenApi(); +``` + +## Реализация gateway при помощи nginx + +Добавил nginx.conf: + +```conf +server { + listen 8080; + listen [::]:8080; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location /worker-1/ { + proxy_pass http://worker-1:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Prefix /worker-1; + } + + location /worker-2/ { + proxy_pass http://worker-2:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Prefix /worker-2; + } +} + +``` + +Результат, после выполнения команды `docker-compose up`: + +Docker: + +![](pic/3.png) + +index.html на gateway-1: + +![](pic/4.png) + +worker-1: + +![](pic/5.png) + +worker-2: + +![](pic/6.png) \ No newline at end of file diff --git a/tasks/mytarin_es/lab_3/pic/1.png b/tasks/mytarin_es/lab_3/pic/1.png new file mode 100644 index 0000000..69077f2 Binary files /dev/null and b/tasks/mytarin_es/lab_3/pic/1.png differ diff --git a/tasks/mytarin_es/lab_3/pic/2.png b/tasks/mytarin_es/lab_3/pic/2.png new file mode 100644 index 0000000..2bd8760 Binary files /dev/null and b/tasks/mytarin_es/lab_3/pic/2.png differ diff --git a/tasks/mytarin_es/lab_3/pic/3.png b/tasks/mytarin_es/lab_3/pic/3.png new file mode 100644 index 0000000..4dc6a1a Binary files /dev/null and b/tasks/mytarin_es/lab_3/pic/3.png differ diff --git a/tasks/mytarin_es/lab_3/pic/4.png b/tasks/mytarin_es/lab_3/pic/4.png new file mode 100644 index 0000000..39418e9 Binary files /dev/null and b/tasks/mytarin_es/lab_3/pic/4.png differ diff --git a/tasks/mytarin_es/lab_3/pic/5.png b/tasks/mytarin_es/lab_3/pic/5.png new file mode 100644 index 0000000..3867ffc Binary files /dev/null and b/tasks/mytarin_es/lab_3/pic/5.png differ diff --git a/tasks/mytarin_es/lab_3/pic/6.png b/tasks/mytarin_es/lab_3/pic/6.png new file mode 100644 index 0000000..f5bf917 Binary files /dev/null and b/tasks/mytarin_es/lab_3/pic/6.png differ diff --git a/tasks/mytarin_es/lab_3/static/index.html b/tasks/mytarin_es/lab_3/static/index.html index 20acc3f..5ccf6b2 100644 --- a/tasks/mytarin_es/lab_3/static/index.html +++ b/tasks/mytarin_es/lab_3/static/index.html @@ -6,7 +6,7 @@
Именно этот файл вы видите, когда открываете приложение.
+Мытарин Е.С. ИСЭбд-41.
diff --git a/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.dll b/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.dll index 143fd7b..812216d 100644 Binary files a/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.dll and b/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.dll differ diff --git a/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.exe b/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.exe index 6dbed65..fe1d9cf 100644 Binary files a/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.exe and b/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.exe differ diff --git a/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.pdb b/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.pdb index 29c4fe4..f98fa22 100644 Binary files a/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.pdb and b/tasks/mytarin_es/lab_3/worker-1/bin/Debug/net8.0/worker-1.pdb differ diff --git a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/apphost.exe b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/apphost.exe index 6dbed65..fe1d9cf 100644 Binary files a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/apphost.exe and b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/apphost.exe differ diff --git a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/ref/worker-1.dll b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/ref/worker-1.dll index 80ea97f..5605ed0 100644 Binary files a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/ref/worker-1.dll and b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/ref/worker-1.dll differ diff --git a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/refint/worker-1.dll b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/refint/worker-1.dll index 80ea97f..5605ed0 100644 Binary files a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/refint/worker-1.dll and b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/refint/worker-1.dll differ diff --git a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfo.cs b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfo.cs index afe1392..f9fa471 100644 --- a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfo.cs +++ b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfo.cs @@ -13,7 +13,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("worker-1")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+50cf3cd91240dc331235165635200161393875ec")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d64b702b1390dff3255929bb2b00605248500f1d")] [assembly: System.Reflection.AssemblyProductAttribute("worker-1")] [assembly: System.Reflection.AssemblyTitleAttribute("worker-1")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfoInputs.cache b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfoInputs.cache index 08515b7..da68e55 100644 --- a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfoInputs.cache +++ b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.AssemblyInfoInputs.cache @@ -1 +1 @@ -b8ae3c34e28363ae8927d69e636d3c331fd968023ab00e328e2a8f60b2777d3f +b4384d6c7f5f0291b819e57beb7554a83883f51de1a9b79417abb0b571813599 diff --git a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.MvcApplicationPartsAssemblyInfo.cs b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.MvcApplicationPartsAssemblyInfo.cs index d7cc3f5..f244291 100644 --- a/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.MvcApplicationPartsAssemblyInfo.cs +++ b/tasks/mytarin_es/lab_3/worker-1/obj/Debug/net8.0/worker-1.MvcApplicationPartsAssemblyInfo.cs @@ -1,10 +1,9 @@ //------------------------------------------------------------------------------ //