diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c658578..9e2366c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,8 +25,8 @@ jobs: if: success() id: build-test-flight-step with: - project-path: '3-microservices-architecture-style/src/Services/Flight/src/Flight.Api' - tests-path: '3-microservices-architecture-style/src/Services/Flight/tests/' + project-path: 'src/Services/Flight/src/Flight.Api' + tests-path: 'src/Services/Flight/tests/' # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/ # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not @@ -40,8 +40,8 @@ jobs: if: success() id: build-test-identity-step with: - project-path: '3-microservices-architecture-style/src/Services/Identity/src/Identity.Api' - tests-path: '3-microservices-architecture-style/src/Services/Identity/tests/' + project-path: 'src/Services/Identity/src/Identity.Api' + tests-path: 'src/Services/Identity/tests/' # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/ # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not @@ -55,8 +55,8 @@ jobs: if: success() id: build-test-passenger-step with: - project-path: '3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api' - tests-path: '3-microservices-architecture-style/src/Services/Passenger/tests/' + project-path: 'src/Services/Passenger/src/Passenger.Api' + tests-path: 'src/Services/Passenger/tests/' # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/ # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not @@ -70,8 +70,8 @@ jobs: if: success() id: build-test-booking-step with: - project-path: '3-microservices-architecture-style/src/Services/Booking/src/Booking.Api' - tests-path: '3-microservices-architecture-style/src/Services/Booking/tests/' + project-path: 'src/Services/Booking/src/Booking.Api' + tests-path: 'src/Services/Booking/tests/' # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/ # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not @@ -98,7 +98,7 @@ jobs: tag-name: ${{ steps.last_release.outputs.tag_name }} registry-username: ${{ secrets.DOCKERHUB_USERNAME }} registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} - dockerfile-path: '3-microservices-architecture-style/src/Services/Identity/Dockerfile' + dockerfile-path: 'src/Services/Identity/Dockerfile' image-name: 'booking-microservices-identity' - name: Build and Publish Flight Microservice to Docker @@ -108,7 +108,7 @@ jobs: tag-name: ${{ steps.last_release.outputs.tag_name }} registry-username: ${{ secrets.DOCKERHUB_USERNAME }} registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} - dockerfile-path: '3-microservices-architecture-style/src/Services/Flight/Dockerfile' + dockerfile-path: 'src/Services/Flight/Dockerfile' image-name: 'booking-microservices-flight' - name: Build and Publish Passenger Microservice to Docker @@ -118,7 +118,7 @@ jobs: tag-name: ${{ steps.last_release.outputs.tag_name }} registry-username: ${{ secrets.DOCKERHUB_USERNAME }} registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} - dockerfile-path: '3-microservices-architecture-style/src/Services/Passenger/Dockerfile' + dockerfile-path: 'src/Services/Passenger/Dockerfile' image-name: 'booking-microservices-passenger' - name: Build and Publish Booking Microservice to Docker @@ -128,5 +128,5 @@ jobs: tag-name: ${{ steps.last_release.outputs.tag_name }} registry-username: ${{ secrets.DOCKERHUB_USERNAME }} registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} - dockerfile-path: '3-microservices-architecture-style/src/Services/Booking/Dockerfile' + dockerfile-path: 'src/Services/Booking/Dockerfile' image-name: 'booking-microservices-booking' diff --git a/1-monolith-architecture-style/README.md b/1-monolith-architecture-style/README.md deleted file mode 100644 index b09544e..0000000 --- a/1-monolith-architecture-style/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# 🪁 Monolith Architecture Style - -> In **Monolith Architecture**, the entire application is built as a single, tightly coupled unit. All components (e.g., Api, business logic, and data access) are part of the same codebase and deployed together. - -# Table of Contents - -- [Key Features](#key-features) -- [When to Use](#when-to-use) -- [Challenges](#challenges) -- [Monolith Architecture Design](#monolith-architecture-design) -- [Development Setup](#development-setup) - - [Dotnet Tools Packages](#dotnet-tools-packages) - - [Husky](#husky) - - [Upgrade Nuget Packages](#upgrade-nuget-packages) -- [How to Run](#how-to-run) - - [Docker Compose](#docker-compose) - - [Build](#build) - - [Run](#run) - - [Test](#test) -- [Documentation Apis](#documentation-apis) - - -## Key Features -1. **Single Codebase**: All components (UI, business logic, data access) are part of one project. -2. **Tight Coupling**: Components are highly dependent on each other, making changes riskier. -3. **Simple Deployment**: The entire application is deployed as a single unit. -4. **Centralized Database**: Typically uses a single database for all data storage and access. - - -## When to Use -1. **Small to Medium Projects**: Ideal for applications with limited complexity and scope. -2. **Rapid Development**: Suitable for projects requiring quick development and deployment. -3. **Small Teams**: Works well for small teams with limited resources. -4. **Low Scalability Needs**: Best for applications with predictable and low traffic. - - -## Challenges -- Harder to maintain as the codebase grows. -- Limited scalability (scaling requires scaling the entire application). -- Difficult to adopt new technologies incrementally. - -## Monolith Architecture Design - -![](./assets/booking-monolith.png) - - -## Development Setup - -### Dotnet Tools Packages -For installing our requirement packages with .NET cli tools, we need to install `dotnet tool manifest`. -```bash -dotnet new tool-manifest -``` -And after that we can restore our dotnet tools packages with .NET cli tools from `.config` folder and `dotnet-tools.json` file. -``` -dotnet tool restore -``` - -### Husky -Here we use `husky` to handel some pre commit rules and we used `conventional commits` rules and `formatting` as pre commit rules, here in [package.json](.././package.json). of course, we can add more rules for pre commit in future. (find more about husky in the [documentation](https://typicode.github.io/husky/get-started.html)) -We need to install `husky` package for `manage` `pre commits hooks` and also I add two packages `@commitlint/cli` and `@commitlint/config-conventional` for handling conventional commits rules in [package.json](.././package.json). -Run the command bellow in the root of project to install all npm dependencies related to husky: - -```bash -npm install -``` - -> Note: In the root of project we have `.husky` folder and it has `commit-msg` file for handling conventional commits rules with provide user friendly message and `pre-commit` file that we can run our `scripts` as a `pre-commit` hooks. that here we call `format` script from [package.json](./package.json) for formatting purpose. - -### Upgrade Nuget Packages -For upgrading our nuget packages to last version, we use the great package [dotnet-outdated](https://github.com/dotnet-outdated/dotnet-outdated). -Run the command below in the root of project to upgrade all of packages to last version: -```bash -dotnet outdated -u -``` - -## How to Run - -> ### Docker Compose - -To run this app in `Docker`, use the [docker-compose.yaml](./deployments/docker-compose/docker-compose.yaml) and execute the below command at the `root` of the application: - -```bash -docker-compose -f ./deployments/docker-compose/docker-compose.yaml up -d -``` - -> ### Build -To `build` monolith app, run this command in the `root` of the project: -```bash -dotnet build -``` - -> ### Run -To `run` monolith app, run this command in the root of the `Api` folder where the `csproj` file is located: -```bash -dotnet run -``` - -> ### Test - -To `test` monolith app, run this command in the `root` of the project: -```bash -dotnet test -``` - -> ### Documentation Apis - -Each microservice provides `API documentation` and navigate to `/swagger` for `Swagger OpenAPI` or `/scalar/v1` for `Scalar OpenAPI` to visit list of endpoints. - -As part of API testing, I created the [booking.rest](./booking.rest) file which can be run with the [REST Client](https://github.com/Huachao/vscode-restclient) `VSCode plugin`. diff --git a/1-monolith-architecture-style/assets/booking-monolith.drawio b/1-monolith-architecture-style/assets/booking-monolith.drawio deleted file mode 100644 index d4033ca..0000000 --- a/1-monolith-architecture-style/assets/booking-monolith.drawio +++ /dev/null @@ -1,348 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/1-monolith-architecture-style/assets/booking-monolith.png b/1-monolith-architecture-style/assets/booking-monolith.png deleted file mode 100644 index f090df5..0000000 Binary files a/1-monolith-architecture-style/assets/booking-monolith.png and /dev/null differ diff --git a/1-monolith-architecture-style/booking.rest b/1-monolith-architecture-style/booking.rest deleted file mode 100644 index 1af03e6..0000000 --- a/1-monolith-architecture-style/booking.rest +++ /dev/null @@ -1,230 +0,0 @@ - -@booking-monolith-api=https://localhost:4000 - -@contentType = application/json -@flightid = "3c5c0000-97c6-fc34-2eb9-08db322230c9" -@passengerId = "8c9c0000-97c6-fc34-2eb9-66db322230c9" - -################################# Identity API ################################# - -### -# @name Authenticate -POST {{booking-monolith-api}}/connect/token -Content-Type: application/x-www-form-urlencoded - -grant_type=password -&client_id=client -&client_secret=secret -&username=samh -&password=Admin@123456 -&scope=booking-monolith role -### - - - -### -# @name Register_New_User -POST {{booking-monolith-api}}/api/v1/identity/register-user -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "firstName": "John", - "lastName": "Do", - "username": "admin", - "passportNumber": "41290000", - "email": "admin@admin.com", - "password": "Admin@12345", - "confirmPassword": "Admin@12345" -} -### - -################################# Flight API ################################# - -### -# @name Create_Seat -Post {{booking-monolith-api}}/api/v1/flight/seat -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "seatNumber": "1255", - "type": 1, - "class": 1, - "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9" -} -### - - -### -# @name Reserve_Seat -Post {{booking-monolith-api}}/api/v1/flight/reserve-seat -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9", - "seatNumber": "1255" -} -### - - -### -# @name Get_Available_Seats -GET {{booking-monolith-api}}/api/v1/flight/get-available-seats/{{flightid}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Get_Flight_By_Id -GET {{booking-monolith-api}}/api/v1/flight/{{flightid}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Get_Available_Flights -GET {{booking-monolith-api}}/api/v1/flight/get-available-flights -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Create_Flights -POST {{booking-monolith-api}}/api/v1/flight -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "flightNumber": "12BB", - "aircraftId": "3c5c0000-97c6-fc34-fcd3-08db322230c8", - "departureAirportId": "3c5c0000-97c6-fc34-a0cb-08db322230c8", - "departureDate": "2022-03-01T14:55:41.255Z", - "arriveDate": "2022-03-01T14:55:41.255Z", - "arriveAirportId": "3c5c0000-97c6-fc34-fc3c-08db322230c8", - "durationMinutes": 120, - "flightDate": "2022-03-01T14:55:41.255Z", - "status": 1, - "price": 8000 -} -### - - -### -# @name Update_Flights -PUT {{booking-monolith-api}}/api/v1/flight -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "id": 1, - "flightNumber": "BD467", - "aircraftId": "3c5c0000-97c6-fc34-fcd3-08db322230c8", - "departureAirportId": "3c5c0000-97c6-fc34-a0cb-08db322230c8", - "departureDate": "2022-04-23T12:17:45.140Z", - "arriveDate": "2022-04-23T12:17:45.140Z", - "arriveAirportId": "3c5c0000-97c6-fc34-fc3c-08db322230c8", - "durationMinutes": 120, - "flightDate": "2022-04-23T12:17:45.140Z", - "status": 4, - "isDeleted": false, - "price": 99000 -} -### - - -### -# @name Delete_Flights -DELETE {{booking-monolith-api}}/api/v1/flight/{{flightid}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Create_Airport -POST {{booking-monolith-api}}/api/v1/flight/airport -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "name": "mehrabad", - "address": "tehran", - "code": "12YD" -} -### - - - -### -# @name Create_Aircraft -POST {{booking-monolith-api}}/api/v1/flight/aircraft -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "name": "airbus2", - "model": "322", - "manufacturingYear": 2012 -} -### - - -################################# Passenger API ################################# - - -### -# @name Complete_Registration_Passenger -POST {{booking-monolith-api}}/api/v1/passenger/complete-registration -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "passportNumber": "41290000", - "passengerType": 1, - "age": 30 -} -### - - -### -# @name Get_Passenger_By_Id -GET {{booking-monolith-api}}/api/v1/passenger/{{passengerId}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -################################# Booking API ################################# - - -### -# @name Create_Booking -POST {{booking-monolith-api}}/api/v1/booking -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "passengerId": "8c9c0000-97c6-fc34-2eb9-66db322230c9", - "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9", - "description": "I want to fly to iran" -} -### diff --git a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json b/1-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json deleted file mode 100644 index b435130..0000000 --- a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json +++ /dev/null @@ -1,1307 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY", - "label": "Managed_Prometheus_jamesnk-telemetry", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "9.4.8" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "description": "ASP.NET Core metrics from OpenTelemetry NuGet", - "editable": true, - "fiscalYearStartMonth": 0, - "gnetId": 17706, - "graphTooltip": 0, - "id": null, - "links": [], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "dark-green", - "mode": "continuous-GrYlRd", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMin": 0, - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "s" - }, - "overrides": [ - { - "__systemRef": "hideSeriesFrom", - "matcher": { - "id": "byNames", - "options": { - "mode": "exclude", - "names": [ - "p50" - ], - "prefix": "All except:", - "readOnly": true - } - }, - "properties": [ - { - "id": "custom.hideFrom", - "value": { - "legend": false, - "tooltip": false, - "viz": false - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 0, - "y": 0 - }, - "id": 40, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.50, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "legendFormat": "p50", - "range": true, - "refId": "p50" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.75, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p75", - "range": true, - "refId": "p75" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.90, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p90", - "range": true, - "refId": "p90" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.95, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p95", - "range": true, - "refId": "p95" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.98, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p98", - "range": true, - "refId": "p98" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.99, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p99", - "range": true, - "refId": "p99" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.999, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p99.9", - "range": true, - "refId": "p99.9" - } - ], - "title": "Requests Duration", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "percentunit" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "All" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "4XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "5XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 12, - "y": 0 - }, - "id": 47, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", status_code=~\"4..|5..\"}[$__rate_interval]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval]))", - "legendFormat": "All", - "range": true, - "refId": "All" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", status_code=~\"4..\"}[$__rate_interval]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval]))", - "hide": false, - "legendFormat": "4XX", - "range": true, - "refId": "4XX" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", status_code=~\"5..\"}[$__rate_interval]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval]))", - "hide": false, - "legendFormat": "5XX", - "range": true, - "refId": "5XX" - } - ], - "title": "Errors Rate", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 6, - "x": 0, - "y": 9 - }, - "id": 49, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(kestrel_current_connections{job=\"$job\", instance=\"$instance\"})", - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Current Connections", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 6, - "x": 6, - "y": 9 - }, - "id": 55, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(http_server_current_requests{job=\"$job\", instance=\"$instance\"})", - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Current Requests", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "blue", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 12, - "y": 9 - }, - "id": 58, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "center", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "value" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": "sum(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"})", - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Total Requests", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "dark-red", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 18, - "y": 9 - }, - "id": 59, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "center", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "value" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": "sum(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", exception_name!=\"\"})", - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Total Unhandled Exceptions", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "green", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 12, - "y": 13 - }, - "id": 60, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (scheme) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval])\r\n )", - "legendFormat": "{{scheme}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests Secured", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "purple", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 18, - "y": 13 - }, - "id": 42, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (protocol) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval])\r\n )", - "legendFormat": "{{protocol}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests HTTP Protocol", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Requests" - }, - "properties": [ - { - "id": "custom.width", - "value": 300 - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "color", - "value": { - "mode": "continuous-BlPu" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Endpoint" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "targetBlank": false, - "title": "Test", - "url": "/d/NagEsjE4z/asp-net-core-endpoint-details?var-route=${__data.fields.route}&var-method=${__data.fields.method}&${__url_time_range}" - } - ] - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "route" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "method" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 17 - }, - "hideTimeOverride": false, - "id": 51, - "options": { - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Value" - } - ] - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": " topk(10,\r\n sum by (route, method, method_route) (\r\n label_join(max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route!=\"\"}[$__rate_interval]), \"method_route\", \" \", \"method\", \"route\")\r\n ))", - "format": "table", - "instant": true, - "interval": "", - "legendFormat": "{{route}}", - "range": false, - "refId": "A" - } - ], - "title": "Top 10 Requested Endpoints", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "method": false, - "route": false - }, - "indexByName": { - "Time": 0, - "Value": 4, - "method": 2, - "method_route": 3, - "route": 1 - }, - "renameByName": { - "Value": "Requests", - "method": "", - "method_route": "Endpoint", - "route": "" - } - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Requests" - }, - "properties": [ - { - "id": "custom.width", - "value": 300 - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "color", - "value": { - "mode": "continuous-YlRd" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Endpoint" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "title": "", - "url": "/d/NagEsjE4z/asp-net-core-endpoint-details?var-route=${__data.fields.route}&var-method=${__data.fields.method}&${__url_time_range}" - } - ] - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "route" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "method" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 17 - }, - "hideTimeOverride": false, - "id": 54, - "options": { - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Value" - } - ] - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": " topk(10,\r\n sum by (route, method, method_route) (\r\n label_join(max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route!=\"\", exception_name!=\"\"}[$__rate_interval]), \"method_route\", \" \", \"method\", \"route\")\r\n ))", - "format": "table", - "instant": true, - "interval": "", - "legendFormat": "{{route}}", - "range": false, - "refId": "A" - } - ], - "title": "Top 10 Unhandled Exception Endpoints", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "method": false - }, - "indexByName": { - "Time": 0, - "Value": 4, - "method": 2, - "method_route": 3, - "route": 1 - }, - "renameByName": { - "Value": "Requests", - "method": "", - "method_route": "Endpoint", - "route": "" - } - } - } - ], - "type": "table" - } - ], - "refresh": "", - "revision": 1, - "schemaVersion": 38, - "style": "dark", - "tags": [ - "dotnet", - "prometheus", - "aspnetcore" - ], - "templating": { - "list": [ - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests, job)", - "hide": 0, - "includeAll": false, - "label": "Job", - "multi": false, - "name": "job", - "options": [], - "query": { - "query": "label_values(http_server_current_requests, job)", - "refId": "StandardVariableQuery" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "hide": 0, - "includeAll": false, - "label": "Instance", - "multi": false, - "name": "instance", - "options": [], - "query": { - "query": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "refId": "StandardVariableQuery" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - } - ] - }, - "time": { - "from": "now-30m", - "to": "now" - }, - "timepicker": {}, - "timezone": "", - "title": "ASP.NET Core", - "uid": "KdDACDp4z", - "version": 5, - "weekStart": "" -} \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json b/1-monolith-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json deleted file mode 100644 index 4839d46..0000000 --- a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json +++ /dev/null @@ -1,892 +0,0 @@ -{ - "__inputs": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "7.4.3" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - } - ], - "annotations": { - "list": [] - }, - "editable": false, - "gnetId": 13978, - "graphTooltip": 0, - "hideControls": false, - "id": null, - "links": [], - "refresh": "", - "rows": [ - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 1, - "fillGradient": 0, - "gridPos": {}, - "id": 2, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "(\n (1 - rate(node_cpu_seconds_total{job=\"node\", mode=\"idle\", instance=\"$instance\"}[$__interval]))\n/ ignoring(cpu) group_left\n count without (cpu)( node_cpu_seconds_total{job=\"node\", mode=\"idle\", instance=\"$instance\"})\n)\n", - "format": "time_series", - "interval": "1m", - "intervalFactor": 5, - "legendFormat": "{{cpu}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "CPU Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percentunit", - "label": null, - "logBase": 1, - "max": 1, - "min": 0, - "show": true - }, - { - "format": "percentunit", - "label": null, - "logBase": 1, - "max": 1, - "min": 0, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 3, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "node_load1{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "1m load average", - "refId": "A" - }, - { - "expr": "node_load5{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "5m load average", - "refId": "B" - }, - { - "expr": "node_load15{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "15m load average", - "refId": "C" - }, - { - "expr": "count(node_cpu_seconds_total{job=\"node\", instance=\"$instance\", mode=\"idle\"})", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "logical cores", - "refId": "D" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Load Average", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - }, - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 1, - "fillGradient": 0, - "gridPos": {}, - "id": 4, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 9, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "(\n node_memory_MemTotal_bytes{job=\"node\", instance=\"$instance\"}\n-\n node_memory_MemFree_bytes{job=\"node\", instance=\"$instance\"}\n-\n node_memory_Buffers_bytes{job=\"node\", instance=\"$instance\"}\n-\n node_memory_Cached_bytes{job=\"node\", instance=\"$instance\"}\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory used", - "refId": "A" - }, - { - "expr": "node_memory_Buffers_bytes{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory buffers", - "refId": "B" - }, - { - "expr": "node_memory_Cached_bytes{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory cached", - "refId": "C" - }, - { - "expr": "node_memory_MemFree_bytes{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory free", - "refId": "D" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Memory Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(50, 172, 45, 0.97)", - "rgba(237, 129, 40, 0.89)", - "rgba(245, 54, 54, 0.9)" - ], - "datasource": "$datasource", - "format": "percent", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": true, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": {}, - "id": 5, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 3, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "tableColumn": "", - "targets": [ - { - "expr": "100 -\n(\n avg(node_memory_MemAvailable_bytes{job=\"node\", instance=\"$instance\"})\n/\n avg(node_memory_MemTotal_bytes{job=\"node\", instance=\"$instance\"})\n* 100\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "", - "refId": "A" - } - ], - "thresholds": "80, 90", - "title": "Memory Usage", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "current" - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - }, - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 6, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [ - { - "alias": "/ read| written/", - "yaxis": 1 - }, - { - "alias": "/ io time/", - "yaxis": 2 - } - ], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_disk_read_bytes_total{job=\"node\", instance=\"$instance\", device!=\"\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}} read", - "refId": "A" - }, - { - "expr": "rate(node_disk_written_bytes_total{job=\"node\", instance=\"$instance\", device!=\"\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}} written", - "refId": "B" - }, - { - "expr": "rate(node_disk_io_time_seconds_total{job=\"node\", instance=\"$instance\", device!=\"\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}} io time", - "refId": "C" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk I/O", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 1, - "fillGradient": 0, - "gridPos": {}, - "id": 7, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [ - { - "alias": "used", - "color": "#E0B400" - }, - { - "alias": "available", - "color": "#73BF69" - } - ], - "spaceLength": 10, - "span": 6, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "sum(\n max by (device) (\n node_filesystem_size_bytes{job=\"node\", instance=\"$instance\", fstype!=\"\"}\n -\n node_filesystem_avail_bytes{job=\"node\", instance=\"$instance\", fstype!=\"\"}\n )\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "used", - "refId": "A" - }, - { - "expr": "sum(\n max by (device) (\n node_filesystem_avail_bytes{job=\"node\", instance=\"$instance\", fstype!=\"\"}\n )\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "available", - "refId": "B" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk Space Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - }, - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 8, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_network_receive_bytes_total{job=\"node\", instance=\"$instance\", device!=\"lo\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Network Received", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 9, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_network_transmit_bytes_total{job=\"node\", instance=\"$instance\", device!=\"lo\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Network Transmitted", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - } - ], - "schemaVersion": 14, - "style": "dark", - "tags": [], - "templating": { - "list": [ - { - "current": { - "text": "Prometheus", - "value": "Prometheus" - }, - "hide": 0, - "label": null, - "name": "datasource", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "type": "datasource" - }, - { - "allValue": null, - "current": {}, - "datasource": "$datasource", - "hide": 0, - "includeAll": false, - "label": null, - "multi": false, - "name": "instance", - "options": [], - "query": "label_values(node_exporter_build_info{job=\"node\"}, instance)", - "refresh": 2, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-1h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "browser", - "title": "Node Exporter Quickstart and Dashboard", - "version": 0, - "description": "A quickstart to setup Prometheus Node Exporter with preconfigured dashboards, alerting rules, and recording rules." -} \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/postgresql.json b/1-monolith-architecture-style/deployments/configs/grafana/dashboards/postgresql.json deleted file mode 100644 index d1d696f..0000000 --- a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/postgresql.json +++ /dev/null @@ -1,1459 +0,0 @@ -{ - "__inputs": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "7.2.0" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "description": "A quickstart to setup the Prometheus PostgreSQL Exporter with preconfigured dashboards, alerting rules, and recording rules.", - "editable": true, - "gnetId": 14114, - "graphTooltip": 0, - "id": 1, - "iteration": 1603191461722, - "links": [], - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 20, - "x": 0, - "y": 0 - }, - "hiddenSeries": false, - "id": 1, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_fetched{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "fetched", - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_returned{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "returned", - "measurement": "postgresql", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_inserted{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "inserted", - "measurement": "postgresql", - "policy": "default", - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_updated{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "updated", - "measurement": "postgresql", - "policy": "default", - "refId": "D", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_deleted{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "deleted", - "measurement": "postgresql", - "policy": "default", - "refId": "E", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Rows", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "$datasource", - "decimals": 0, - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 0 - }, - "height": "55px", - "id": 11, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": true, - "lineColor": "rgb(31, 120, 193)", - "show": true - }, - "tableColumn": "", - "targets": [ - { - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_xact_commit{datname=~\"$db\",instance=~\"$instance\"}[5m])) + sum(irate(pg_stat_database_xact_rollback{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "xact_commit" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 1800, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": "", - "title": "QPS", - "transparent": true, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "decimals": 1, - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 7 - }, - "hiddenSeries": false, - "id": 2, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "hideZero": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_alloc{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_alloc", - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_backend_fsync{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_backend_fsync", - "measurement": "postgresql", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_backend{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_backend", - "measurement": "postgresql", - "policy": "default", - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_clean{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_clean", - "measurement": "postgresql", - "policy": "default", - "refId": "D", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_checkpoint{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_checkpoint", - "measurement": "postgresql", - "policy": "default", - "refId": "E", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Buffers", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 7 - }, - "hiddenSeries": false, - "id": 3, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "conflicts", - "dsType": "prometheus", - "expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "deadlocks", - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "conflicts" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "deadlocks", - "dsType": "prometheus", - "expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "conflicts", - "measurement": "postgresql", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "deadlocks" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Conflicts/Deadlocks", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 14 - }, - "hiddenSeries": false, - "id": 12, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": true, - "pluginVersion": "7.2.1", - "pointradius": 1, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) / (sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) + sum(pg_stat_database_blks_read{datname=~\"$db\",instance=~\"$instance\"}))", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "cache hit rate", - "refId": "A", - "step": 240 - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Cache hit ratio", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percentunit", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 14 - }, - "hiddenSeries": false, - "id": 13, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "pg_stat_database_numbackends{datname=~\"$db\",instance=~\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{__name__}}", - "refId": "A", - "step": 240 - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Number of active connections", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "refresh": false, - "schemaVersion": 26, - "style": "dark", - "tags": [ - "postgres" - ], - "templating": { - "list": [ - { - "allValue": ".*", - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "$datasource", - "definition": "", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "instance", - "options": [], - "query": "label_values(up{job=~\"postgres.*\"},instance)", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": ".*", - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "$datasource", - "definition": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)", - "hide": 0, - "includeAll": true, - "label": "db", - "multi": false, - "name": "db", - "options": [], - "query": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "current": { - "selected": false, - "text": "Postgres Overview", - "value": "Postgres Overview" - }, - "hide": 0, - "includeAll": false, - "label": "datasource", - "multi": false, - "name": "datasource", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" - }, - { - "allValue": null, - "current": { - "selected": true, - "text": "postgres", - "value": "postgres" - }, - "datasource": "$datasource", - "definition": "label_values(pg_up, job)", - "hide": 0, - "includeAll": false, - "label": "job", - "multi": false, - "name": "job", - "options": [ - { - "selected": true, - "text": "postgres", - "value": "postgres" - } - ], - "query": "label_values(pg_up, job)", - "refresh": 0, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-1h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "browser", - "title": "PostgreSQL Exporter Quickstart and Dashboard", - "uid": "wGgaPlciz", - "version": 5 -} \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml b/1-monolith-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml deleted file mode 100644 index f1fb0bb..0000000 --- a/1-monolith-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml +++ /dev/null @@ -1,14 +0,0 @@ -# https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards -apiVersion: 1 - -providers: - - name: "default" - orgId: 1 - folder: "" - type: file - disableDeletion: false - editable: true - allowUiUpdates: true - updateIntervalSeconds: 5 # how often Grafana will scan for changed dashboards - options: - path: /var/lib/grafana/dashboards # path to dashboards on disk \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml b/1-monolith-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml deleted file mode 100644 index 5b04359..0000000 --- a/1-monolith-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml +++ /dev/null @@ -1,88 +0,0 @@ -# https://grafana.com/docs/grafana/latest/administration/provisioning/ -# https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/grafana-datasources.yaml -# https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - -apiVersion: 1 - -datasources: - # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/grafana-datasources.yaml - - name: Prometheus - type: prometheus - typeName: Prometheus - uid: prometheus-uid - access: proxy - orgId: 1 - url: http://prometheus:9090 - basicAuth: false - isDefault: true - readOnly: false - user: '' - database: '' - version: 1 - editable: false - jsonData: - httpMethod: GET - - - name: Jaeger - type: jaeger - access: proxy - url: http://jaeger-all-in-one:16686 - editable: false - uid: jaeger-uid - - - name: Zipkin - type: zipkin - access: proxy - url: http://zipkin-all-in-one:9411 - editable: false - uid: zipkin-uid - - # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/grafana-datasources.yaml - - name: Tempo - type: tempo - access: proxy - orgId: 1 - url: http://tempo:3200 - basicAuth: false - isDefault: false - version: 1 - editable: false - apiVersion: 1 - uid: tempo-uid - jsonData: - httpMethod: GET - serviceMap: - datasourceUid: prometheus-uid - streamingEnabled: - search: true - - #https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - - name: Loki - type: loki - access: proxy - uid: loki-uid - url: http://loki:3100 - user: '' - database: '' - readOnly: false - jsonData: - derivedFields: - - datasourceUid: tempo-uid - matcherRegex: "^.*?traceI[d|D]=(\\w+).*$" - name: traceId - url: '$${__value.raw}' - - - name: Kibana - type: elasticsearch - url: http://elasticsearch:9200 - access: proxy - isDefault: false - uid: kibana-uid - jsonData: - esVersion: 7 - timeField: "@timestamp" - maxConcurrentShardRequests: 256 - interval: Daily - logMessageField: "message" # Optional: Field for log messages - logLevelField: "level" # Optional: Field for log levels - editable: true \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/otel-collector-config.yaml b/1-monolith-architecture-style/deployments/configs/otel-collector-config.yaml deleted file mode 100644 index ea6ef40..0000000 --- a/1-monolith-architecture-style/deployments/configs/otel-collector-config.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/examples/demo/otel-collector-config.yaml -# https://opentelemetry.io/docs/collector/configuration/ -# https://opentelemetry.io/docs/collector/architecture/ -# https://betterstack.com/community/guides/observability/opentelemetry-collector/ -# https://signoz.io/blog/opentelemetry-collector-complete-guide/ - -# This configuration sets up an OpenTelemetry Collector that receives trace data via the OTLP protocol over HTTP on port 4318, applies batch processing, and then exports the processed traces -# to exporter components like `Jaeger` endpoint located at `jaeger-all-in-one:4317`. It also includes a health_check extension for monitoring the collector's status. - -# Receivers in the OpenTelemetry Collector are components that collect telemetry data (traces, metrics, and logs) from various sources, such as instrumented applications or agents. -# They act as entry points, converting incoming data into OpenTelemetry's internal format for processing and export. -# https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components -# https://opentelemetry.io/docs/collector/architecture/#receivers -# https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/README.md -# https://opentelemetry.io/docs/collector/configuration/#receivers -receivers: - # supported receivers - # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver - # instead of specifying details explicitly we can just use `otlp` and it uses both grpc and http - otlp: - protocols: - grpc: - endpoint: 0.0.0.0:4317 - http: - endpoint: 0.0.0.0:4318 -# prometheus: -# config: -# scrape_configs: -# - job_name: 'node-exporter' -# scrape_interval: 10s -# static_configs: -# - targets: [ 'node-exporter:9100' ] - - -# Processors in the OpenTelemetry Collector modify and enhance telemetry data by filtering, transforming, enriching, or batching it to prepare it for export. -# https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor -processors: - batch: # Batches logs for better performance - -# - Exporters in the OpenTelemetry Collector send processed telemetry data to backend systems like observability platforms, databases, or cloud services for storage, visualization, and analysis. -# - The `key` follows the `type/name` format, where `type` specifies the exporter `type` (e.g., otlp, kafka, prometheus), and `name` (optional) can be appended to provide a unique name for multiple instance of the same type -# https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components -# https://opentelemetry.io/docs/collector/architecture/#exporters -# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter -# https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter -# https://opentelemetry.io/docs/collector/configuration/#exporters -exporters: - - # valid values: [prometheusremotewrite zipkin otlphttp file kafka prometheus debug nop otlp opencensus] - - # Prometheus exporter metrics - prometheus: - endpoint: "0.0.0.0:8889" - - prometheusremotewrite: - endpoint: "http://prometheus:9090/api/v1/write" - - # https://grafana.com/docs/loki/latest/send-data/otel/ - # https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/lokiexporter/README.md - otlphttp/loki: - endpoint: "http://loki:3100/otlp" - tls: - insecure: true - - # # we can also use `loki component` from `opentelemetry-collector-contrib` if we don't want to use builtin `otlphttp` exporter type and `http://loki:3100/otlp` loki endpoint - # loki: - # endpoint: "http://loki:3100/loki/api/v1/push" - # tls: - # insecure: true - - debug: - - # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/elasticsearchexporter - # using `elasticsearch` from `opentelemetry-collector-contrib` components because it doesn't exist in `opentelemetry-collector` - elasticsearch: - endpoint: "http://elasticsearch:9200" - - zipkin: - endpoint: "http://zipkin-all-in-one:9411/api/v2/spans" - format: proto - - # export collected telemetry traces to jaeger OTLP grpc port, we can send data to other available endpoints and ports on jaeger as well - otlp/jaeger: - endpoint: "http://jaeger-all-in-one:4317" - tls: - insecure: true - - otlp/tempo: - endpoint: "http://tempo:4317" - tls: - insecure: true - - # seq-otlp: - # endpoint: "http://seq:5341/ingest/otlp" - -# https://opentelemetry.io/docs/collector/configuration/#extensions -# https://github.com/open-telemetry/opentelemetry-collector/blob/main/extension/README.md -extensions: - pprof: - endpoint: 0.0.0.0:1888 - zpages: - endpoint: 0.0.0.0:55679 - health_check: - endpoint: 0.0.0.0:13133 - -# - The service section is used to configure what components are enabled in the Collector based on the configuration found in the receivers, processors, exporters, and extensions sections. -# - If a component is configured, but not defined within the service section, then it’s not enabled. -# https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components -# https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/README.md -# https://opentelemetry.io/docs/collector/architecture/ -# https://opentelemetry.io/docs/collector/configuration/#service -service: - # The `service.extensions` subsection determines which of the configured extensions will be enabled - extensions: [pprof, zpages, health_check] - # The `service.pipeline` Each pipeline starts with one or more receivers collecting data, which is then processed sequentially by processors (applying transformations, filtering, or sampling). - # The processed data is finally sent to all configured exporters, ensuring each receives a copy. Components must be pre-configured in their respective sections before being used in a pipeline. - # pipeline activate predefined components, defined components are disabled by default - pipelines: - traces: - receivers: [otlp] - processors: [batch] - # https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exporter-selection - exporters: [debug, zipkin, otlp/jaeger, otlp/tempo] - metrics: - receivers: [otlp] - processors: [batch] - exporters: [debug, prometheusremotewrite, prometheus] - logs: - receivers: [otlp] - processors: [batch] - exporters: [otlphttp/loki, elasticsearch] \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/prometheus.yaml b/1-monolith-architecture-style/deployments/configs/prometheus.yaml deleted file mode 100644 index 1928aaf..0000000 --- a/1-monolith-architecture-style/deployments/configs/prometheus.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/examples/demo/prometheus.yaml -# https://prometheus.io/docs/introduction/first_steps/ -# https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - -global: - scrape_interval: 5s - -scrape_configs: - # when we use otel-collector we should comment other jobs in prometheus config, and we read configs from `otel-collector-config` - - job_name: "otel-collector" - scrape_interval: 10s - static_configs: - # otel-collector Prometheus exporter metrics - - targets: [ 'otel-collector:8889' ] - - targets: [ 'otel-collector:8888' ] - - - job_name: "prometheus" - static_configs: - - targets: ["prometheus:9090"] - -# # https://prometheus.io/docs/guides/node-exporter/ -# # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ -# - job_name: "node-exporter" -# static_configs: -# - targets: [ 'node-exporter:9100' ] - -# # if we don't use otel collector we should uncomment this -# # scrap application metrics -# # http://localhost:4000/metrics by AddPrometheusExporter() -# - job_name: vertical-slice-template-api -# scrape_interval: 10s -# metrics_path: /metrics -# static_configs: -# - targets: ['host.docker.internal:4000'] -# -# # if we don't use otel collector we should uncomment this -# # scrap application health metrics -# # http://localhost:4000/health/metrics by AddPrometheusExporter() -# - job_name: vertical-slice-template-api-healthchecks -# scrape_interval: 10s -# metrics_path: /health/metrics -# static_configs: -# - targets: ['host.docker.internal:4000'] - -## https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/prometheus.yaml -# - job_name: 'tempo' -# static_configs: -# - targets: [ 'tempo:3200' ] \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/configs/tempo.yaml b/1-monolith-architecture-style/deployments/configs/tempo.yaml deleted file mode 100644 index fcb2ed3..0000000 --- a/1-monolith-architecture-style/deployments/configs/tempo.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# https://grafana.com/docs/tempo/latest/configuration/ -# https://github.com/grafana/tempo/blob/main/example/docker-compose/local/tempo.yaml - -# https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/tempo.yaml -stream_over_http_enabled: true -server: - http_listen_port: 3200 - log_level: info - -distributor: - receivers: - otlp: - protocols: - grpc: - endpoint: "tempo:4317" - -ingester: - max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally - -compactor: - compaction: - block_retention: 1h # overall Tempo trace retention. set for demo purposes - -metrics_generator: - registry: - external_labels: - source: tempo - cluster: docker-compose - storage: - path: /var/tempo/generator/wal - remote_write: - - url: http://prometheus:9090/api/v1/write - send_exemplars: true - traces_storage: - path: /var/tempo/generator/traces - -storage: - trace: - backend: local # backend configuration to use - wal: - path: /var/tempo/wal # where to store the wal locally - local: - path: /var/tempo/blocks - -overrides: - defaults: - metrics_generator: - processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator - generate_native_histograms: both \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml b/1-monolith-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml deleted file mode 100644 index e93ae59..0000000 --- a/1-monolith-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml +++ /dev/null @@ -1,361 +0,0 @@ -# ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/examples/demo/docker-compose.yaml -# ref: https://github.com/joaofbantunes/DotNetMicroservicesObservabilitySample/blob/main/docker-compose.yml -# ref: https://github.com/oskardudycz/EventSourcing.NetCore/blob/main/docker-compose.yml -# https://github.com/grafana/intro-to-mltp -# https://stackoverflow.com/questions/65272764/ports-are-not-available-listen-tcp-0-0-0-0-50070-bind-an-attempt-was-made-to - - -name: booking-monolith-infrastructure - -services: - ####################################################### - # rabbitmq - ####################################################### - rabbitmq: - image: rabbitmq:management - container_name: rabbitmq - restart: unless-stopped - ports: - - "5672:5672" - - "15672:15672" - # volumes: - # - rabbitmq:/var/lib/rabbitmq - networks: - - infrastructure - - ####################################################### - # postgres - ####################################################### - postgres: - image: postgres:latest - container_name: postgres - restart: unless-stopped - ports: - - '5432:5432' - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - command: - - "postgres" - - "-c" - - "wal_level=logical" - - "-c" - - "max_prepared_transactions=10" - volumes: - - postgres-data:/var/lib/postgresql/data - networks: - - infrastructure - - - ####################################################### - # EventStoreDB - ####################################################### - eventstore: - container_name: eventstore - image: eventstore/eventstore:latest - restart: unless-stopped - environment: - - EVENTSTORE_CLUSTER_SIZE=1 - - EVENTSTORE_RUN_PROJECTIONS=All - - EVENTSTORE_START_STANDARD_PROJECTIONS=True - - EVENTSTORE_HTTP_PORT=2113 - - EVENTSTORE_INSECURE=True - - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=True - ports: - - "2113:2113" - networks: - - infrastructure - - - # ####################################################### - # # Mongo - # ####################################################### - mongo: - image: mongo:latest - container_name: mongo - restart: unless-stopped - # environment: - # - MONGO_INITDB_ROOT_USERNAME=root - # - MONGO_INITDB_ROOT_PASSWORD=secret - ports: - - 27017:27017 - networks: - - infrastructure - - - # ####################################################### - # # Redis - # ####################################################### - redis: - image: redis - container_name: redis - restart: unless-stopped - ports: - - 6379:6379 - networks: - - infrastructure - - - # ####################################################### - # # jaeger - # # https://www.jaegertracing.io/docs/1.64/deployment/ - # # https://www.jaegertracing.io/docs/1.6/deployment/ - # ####################################################### - jaeger-all-in-one: - image: jaegertracing/all-in-one:latest - container_name: jaeger-all-in-one - restart: unless-stopped - ports: - - "6831:6831/udp" # UDP port for Jaeger agent - - "16686:16686" # endpoints and Jaeger UI - - "14268:14268" # HTTP port for accept trace spans directly from clients - - "14317:4317" # OTLP gRPC receiver for jaeger - - "14318:4318" # OTLP http receiver for jaeger - # - "9411" # Accepts Zipkin spans - /api/v2/spans - networks: - - infrastructure - - - # ####################################################### - # # zipkin - # # https://zipkin.io/pages/quickstart - # ####################################################### - zipkin-all-in-one: - image: openzipkin/zipkin:latest - container_name: zipkin-all-in-one - restart: unless-stopped - ports: - - "9411:9411" - networks: - - infrastructure - - - # ####################################################### - # # otel-collector - # # https://opentelemetry.io/docs/collector/installation/ - # # https://github.com/open-telemetry/opentelemetry-collector - # # https://github.com/open-telemetry/opentelemetry-collector-contrib - # # we can use none contrib docker `otel/opentelemetry-collector` version from `https://github.com/open-telemetry/opentelemetry-collector` repository but, - # # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. - # ####################################################### - otel-collector: - image: otel/opentelemetry-collector-contrib:latest - container_name: otel-collector - restart: unless-stopped - command: ["--config=/etc/otelcol-contrib/config.yaml"] - volumes: - - ./../configs/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml - ports: - - "11888:1888" # pprof extension - - "8888:8888" # Prometheus metrics exposed by the Collector - - "8889:8889" # Prometheus exporter metrics - - "13133:13133" # health_check extension - - "4317:4317" # OTLP gRPC receiver - - "4318:4318" # OTLP http receiver - - "55679:55679" # zpages extension - networks: - - infrastructure - - - # ####################################################### - # # prometheus - # # https://prometheus.io/docs/introduction/first_steps/ - # # https://prometheus.io/docs/prometheus/3.1/installation/ - # # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - # ####################################################### - prometheus: - image: prom/prometheus:latest - restart: unless-stopped - ports: - - "9090:9090" - volumes: - - ./../configs/prometheus.yaml:/etc/prometheus/prometheus.yml - # to passe one flag, such as "--log.level=debug" or "--web.enable-remote-write-receiver", we need to override the whole command, as we can't just pass one extra argument - command: - - "--config.file=/etc/prometheus/prometheus.yml" - - "--storage.tsdb.path=/prometheus" - - "--web.console.libraries=/usr/share/prometheus/console_libraries" - - "--web.console.templates=/usr/share/prometheus/consoles" - # need this for the OpenTelemetry collector to be able to put metrics into Prometheus - - "--web.enable-remote-write-receiver" - # - "--log.level=debug" - networks: - - infrastructure - - - # ####################################################### - # # node-exporter - # # https://prometheus.io/docs/guides/node-exporter/ - # # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - # ####################################################### - node-exporter: - image: prom/node-exporter:latest - container_name: node-exporter - restart: unless-stopped - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - '--path.procfs=/host/proc' - - '--path.rootfs=/rootfs' - - '--path.sysfs=/host/sys' - ports: - - "9101:9100" - networks: - - infrastructure - - - # ####################################################### - # # grafana - # # https://grafana.com/docs/grafana/latest/administration/provisioning/ - # # https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ - # # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ - # # https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - # ####################################################### - grafana: - image: grafana/grafana:latest - container_name: grafana - restart: unless-stopped - environment: - - GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource - - GF_SECURITY_ADMIN_USER=admin - - GF_SECURITY_ADMIN_PASSWORD=admin - - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor - # - GF_AUTH_ANONYMOUS_ENABLED=true - # - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - # - GF_AUTH_DISABLE_LOGIN_FORM=true - depends_on: - - prometheus - ports: - - "3000:3000" - volumes: - - ./../configs/grafana/provisioning:/etc/grafana/provisioning - - ./../configs/grafana/dashboards:/var/lib/grafana/dashboards - ## https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/ - # - ./../configs/grafana/grafana.ini:/etc/grafana/grafana.ini - networks: - - infrastructure - - - # ####################################################### - # # tempo - # # https://github.com/grafana/tempo/blob/main/example/docker-compose/otel-collector/docker-compose.yaml - # # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared - # # https://github.com/grafana/tempo/blob/main/example/docker-compose/local - # # https://github.com/grafana/tempo/tree/main/example/docker-compose - # ####################################################### - tempo: - image: grafana/tempo:latest - container_name: tempo - restart: unless-stopped - command: [ "-config.file=/etc/tempo.yaml" ] - volumes: - - ./../configs/tempo.yaml:/etc/tempo.yaml - ports: - - "3200" # tempo - - "24317:4317" # otlp grpc - - "24318:4318" # otlp http - networks: - - infrastructure - - - # ####################################################### - # # loki - # # https://grafana.com/docs/opentelemetry/collector/send-logs-to-loki/ - # # https://github.com/grafana/loki/blob/main/production/docker-compose.yaml - # # https://github.com/grafana/loki/blob/main/examples/getting-started/docker-compose.yaml - # ####################################################### - loki: - image: grafana/loki:latest - hostname: loki - container_name: loki - ports: - - "3100:3100" - command: -config.file=/etc/loki/local-config.yaml - volumes: - - ./../configs/loki-config.yaml:/etc/loki/local-config.yaml - networks: - - infrastructure - - - # ####################################################### - # # elasticsearch - # # https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docker.html#docker-compose-file - # ####################################################### - elasticsearch: - container_name: elasticsearch - restart: unless-stopped - image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0 - environment: - - discovery.type=single-node - - cluster.name=docker-cluster - - node.name=docker-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - xpack.security.enabled=false - - xpack.security.http.ssl.enabled=false - - xpack.security.transport.ssl.enabled=false - - network.host=0.0.0.0 - - http.port=9200 - - transport.host=localhost - - bootstrap.memory_lock=true - - cluster.routing.allocation.disk.threshold_enabled=false - ulimits: - memlock: - soft: -1 - hard: -1 - volumes: - - elastic-data:/usr/share/elasticsearch/data - ports: - - ${ELASTIC_HOST_PORT:-9200}:${ELASTIC_PORT:-9200} - - 9300:9300 - networks: - - infrastructure - - - # ####################################################### - # # kibana - # # https://www.elastic.co/guide/en/kibana/current/docker.html - # ####################################################### - kibana: - image: docker.elastic.co/kibana/kibana:8.17.0 - container_name: kibana - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - ports: - - ${KIBANA_HOST_PORT:-5601}:${KIBANA_PORT:-5601} - depends_on: - - elasticsearch - networks: - - infrastructure - - - # ####################################################### - # # cadvisor - # ####################################################### - cadvisor: - image: gcr.io/cadvisor/cadvisor:latest - container_name: cadvisor - restart: unless-stopped - ports: - - "8080:8080" - volumes: - - /:/rootfs:ro - - /var/run:/var/run:ro - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - - /dev/disk/:/dev/disk:ro - devices: - - /dev/kmsg - networks: - - infrastructure - - -networks: - infrastructure: - name: infrastructure - driver: bridge - -volumes: - postgres-data: \ No newline at end of file diff --git a/1-monolith-architecture-style/deployments/docker-compose/docker-compose.yaml b/1-monolith-architecture-style/deployments/docker-compose/docker-compose.yaml deleted file mode 100644 index c179852..0000000 --- a/1-monolith-architecture-style/deployments/docker-compose/docker-compose.yaml +++ /dev/null @@ -1,365 +0,0 @@ -name: booking-monolith - -services: - - ####################################################### - # EventStoreDB - ####################################################### - eventstore: - container_name: eventstore - image: eventstore/eventstore:latest - restart: unless-stopped - environment: - - EVENTSTORE_CLUSTER_SIZE=1 - - EVENTSTORE_RUN_PROJECTIONS=All - - EVENTSTORE_START_STANDARD_PROJECTIONS=True - - EVENTSTORE_HTTP_PORT=2113 - - EVENTSTORE_INSECURE=True - - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=True - ports: - - "2113:2113" - networks: - - booking - - ####################################################### - # postgres - ####################################################### - postgres: - image: postgres:latest - container_name: postgres - restart: unless-stopped - ports: - - '5432:5432' - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - command: - - "postgres" - - "-c" - - "wal_level=logical" - - "-c" - - "max_prepared_transactions=10" - volumes: - - postgres-data:/var/lib/postgresql/data - networks: - - booking - - ####################################################### - # Mongo - ####################################################### - mongo: - image: mongo:latest - container_name: mongo - restart: unless-stopped - # environment: - # - MONGO_INITDB_ROOT_USERNAME=root - # - MONGO_INITDB_ROOT_PASSWORD=secret - ports: - - 27017:27017 - networks: - - booking - - ####################################################### - # jaeger - # https://www.jaegertracing.io/docs/1.64/deployment/ - # https://www.jaegertracing.io/docs/1.6/deployment/ - ####################################################### - jaeger-all-in-one: - image: jaegertracing/all-in-one:latest - container_name: jaeger-all-in-one - restart: unless-stopped - ports: - - "6831:6831/udp" # UDP port for Jaeger agent - - "16686:16686" # endpoints and Jaeger UI - - "14268:14268" # HTTP port for accept trace spans directly from clients - - "14317:4317" # OTLP gRPC receiver for jaeger - - "14318:4318" # OTLP http receiver for jaeger - # - "9411" # Accepts Zipkin spans - /api/v2/spans - networks: - - booking - - ####################################################### - # zipkin - # https://zipkin.io/pages/quickstart - ####################################################### - zipkin-all-in-one: - image: openzipkin/zipkin:latest - container_name: zipkin-all-in-one - restart: unless-stopped - ports: - - "9411:9411" - networks: - - booking - - ####################################################### - # prometheus - # https://prometheus.io/docs/introduction/first_steps/ - # https://prometheus.io/docs/prometheus/3.1/installation/ - # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - ####################################################### - prometheus: - image: prom/prometheus:latest - restart: unless-stopped - ports: - - "9090:9090" - volumes: - - ./../configs/prometheus.yaml:/etc/prometheus/prometheus.yml - # to passe one flag, such as "--log.level=debug" or "--web.enable-remote-write-receiver", we need to override the whole command, as we can't just pass one extra argument - command: - - "--config.file=/etc/prometheus/prometheus.yml" - - "--storage.tsdb.path=/prometheus" - - "--web.console.libraries=/usr/share/prometheus/console_libraries" - - "--web.console.templates=/usr/share/prometheus/consoles" - # need this for the OpenTelemetry collector to be able to put metrics into Prometheus - - "--web.enable-remote-write-receiver" - # - "--log.level=debug" - networks: - - booking - - ####################################################### - # otel-collector - # https://opentelemetry.io/docs/collector/installation/ - # https://github.com/open-telemetry/opentelemetry-collector - # https://github.com/open-telemetry/opentelemetry-collector-contrib - # we can use none contrib docker `otel/opentelemetry-collector` version from `https://github.com/open-telemetry/opentelemetry-collector` repository but, - # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. - ####################################################### - otel-collector: - image: otel/opentelemetry-collector-contrib:latest - container_name: otel-collector - restart: unless-stopped - command: ["--config=/etc/otelcol-contrib/config.yaml"] - volumes: - - ./../configs/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml - ports: - - "11888:1888" # pprof extension - - "8888:8888" # Prometheus metrics exposed by the Collector - - "8889:8889" # Prometheus exporter metrics - - "13133:13133" # health_check extension - - "4317:4317" # OTLP gRPC receiver - - "4318:4318" # OTLP http receiver - - "55679:55679" # zpages extension - networks: - - booking - - ####################################################### - # rabbitmq - ####################################################### - rabbitmq: - image: rabbitmq:management - container_name: rabbitmq - restart: unless-stopped - ports: - - "5672:5672" - - "15672:15672" - # volumes: - # - rabbitmq:/var/lib/rabbitmq - networks: - - booking - - ####################################################### - # Redis - ####################################################### - redis: - image: redis - container_name: redis - restart: unless-stopped - ports: - - 6379:6379 - networks: - - booking - - ####################################################### - # node-exporter - # https://prometheus.io/docs/guides/node-exporter/ - # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - ####################################################### - node-exporter: - image: prom/node-exporter:latest - container_name: node-exporter - restart: unless-stopped - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - '--path.procfs=/host/proc' - - '--path.rootfs=/rootfs' - - '--path.sysfs=/host/sys' - ports: - - "9101:9100" - networks: - - booking - - ####################################################### - # grafana - # https://grafana.com/docs/grafana/latest/administration/provisioning/ - # https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ - # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ - # https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - ####################################################### - grafana: - image: grafana/grafana:latest - container_name: grafana - restart: unless-stopped - environment: - - GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource - - GF_SECURITY_ADMIN_USER=admin - - GF_SECURITY_ADMIN_PASSWORD=admin - - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor - # - GF_AUTH_ANONYMOUS_ENABLED=true - # - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - # - GF_AUTH_DISABLE_LOGIN_FORM=true - depends_on: - - prometheus - ports: - - "3000:3000" - volumes: - - ./../configs/grafana/provisioning:/etc/grafana/provisioning - - ./../configs/grafana/dashboards:/var/lib/grafana/dashboards - networks: - - booking - - ####################################################### - # tempo - # https://github.com/grafana/tempo/blob/main/example/docker-compose/otel-collector/docker-compose.yaml - # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared - # https://github.com/grafana/tempo/blob/main/example/docker-compose/local - # https://github.com/grafana/tempo/tree/main/example/docker-compose - ####################################################### - tempo: - image: grafana/tempo:latest - container_name: tempo - restart: unless-stopped - command: [ "-config.file=/etc/tempo.yaml" ] - volumes: - - ./../configs/tempo.yaml:/etc/tempo.yaml - ports: - - "3200" # tempo - - "24317:4317" # otlp grpc - - "24318:4318" # otlp http - networks: - - booking - - ####################################################### - # loki - # https://grafana.com/docs/opentelemetry/collector/send-logs-to-loki/ - # https://github.com/grafana/loki/blob/main/production/docker-compose.yaml - # https://github.com/grafana/loki/blob/main/examples/getting-started/docker-compose.yaml - ####################################################### - loki: - image: grafana/loki:latest - hostname: loki - container_name: loki - ports: - - "3100:3100" - command: -config.file=/etc/loki/local-config.yaml - volumes: - - ./../configs/loki-config.yaml:/etc/loki/local-config.yaml - networks: - - booking - - ####################################################### - # elasticsearch - # https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docker.html#docker-compose-file - ####################################################### - elasticsearch: - container_name: elasticsearch - restart: unless-stopped - image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0 - environment: - - discovery.type=single-node - - cluster.name=docker-cluster - - node.name=docker-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - xpack.security.enabled=false - - xpack.security.http.ssl.enabled=false - - xpack.security.transport.ssl.enabled=false - - network.host=0.0.0.0 - - http.port=9200 - - transport.host=localhost - - bootstrap.memory_lock=true - - cluster.routing.allocation.disk.threshold_enabled=false - ulimits: - memlock: - soft: -1 - hard: -1 - volumes: - - elastic-data:/usr/share/elasticsearch/data - ports: - - ${ELASTIC_HOST_PORT:-9200}:${ELASTIC_PORT:-9200} - - 9300:9300 - networks: - - booking - - ####################################################### - # kibana - # https://www.elastic.co/guide/en/kibana/current/docker.html - ####################################################### - kibana: - image: docker.elastic.co/kibana/kibana:8.17.0 - container_name: kibana - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - ports: - - ${KIBANA_HOST_PORT:-5601}:${KIBANA_PORT:-5601} - depends_on: - - elasticsearch - networks: - - booking - - ####################################################### - # cadvisor - ####################################################### - cadvisor: - image: gcr.io/cadvisor/cadvisor:latest - container_name: cadvisor - restart: unless-stopped - ports: - - "8080:8080" - volumes: - - /:/rootfs:ro - - /var/run:/var/run:ro - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - - /dev/disk/:/dev/disk:ro - devices: - - /dev/kmsg - networks: - - booking - - ####################################################### - # booking-monolith - ####################################################### - bookingmonolith: - image: booking-monolith - build: - args: - Version: "1" - context: ../../../ - dockerfile: 1-monolith-architecture-style/src/BookingMonolith/dev.Dockerfile - container_name: bookingmonolith - ports: - - 4001:80 - - 4000:443 - volumes: - - ~/.aspnet/https:/https:ro - environment: - - ASPNETCORE_ENVIRONMENT=docker - - ASPNETCORE_URLS=https://+;http://+ - - ASPNETCORE_HTTPS_PORT=4000 - - ASPNETCORE_HTTP_PORT=4001 - - ASPNETCORE_Kestrel__Certificates__Default__Password=password - - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx - networks: - - booking - -networks: - booking: - name: booking - driver: bridge - -volumes: - elastic-data: - postgres-data: \ No newline at end of file diff --git a/1-monolith-architecture-style/src/Api/src/Api.csproj b/1-monolith-architecture-style/src/Api/src/Api.csproj deleted file mode 100644 index a63c543..0000000 --- a/1-monolith-architecture-style/src/Api/src/Api.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - Api - - - - - - - diff --git a/1-monolith-architecture-style/src/Api/src/Extensions/MediatRExtensions.cs b/1-monolith-architecture-style/src/Api/src/Extensions/MediatRExtensions.cs deleted file mode 100644 index e67be88..0000000 --- a/1-monolith-architecture-style/src/Api/src/Extensions/MediatRExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BookingMonolith; -using BuildingBlocks.Caching; -using BuildingBlocks.EFCore; -using BuildingBlocks.Logging; -using BuildingBlocks.Validation; -using MediatR; - -namespace Api.Extensions; - -public static class MediatRExtensions -{ - public static IServiceCollection AddCustomMediatR(this IServiceCollection services) - { - services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(AppDomain.CurrentDomain.GetAssemblies())); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); - services.AddScoped(typeof(IPipelineBehavior<,>), typeof(EfTxBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(InvalidateCachingBehavior<,>)); - - return services; - } -} diff --git a/1-monolith-architecture-style/src/Api/src/Extensions/SharedInfrastructureExtensions.cs b/1-monolith-architecture-style/src/Api/src/Extensions/SharedInfrastructureExtensions.cs deleted file mode 100644 index 2e64410..0000000 --- a/1-monolith-architecture-style/src/Api/src/Extensions/SharedInfrastructureExtensions.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Threading.RateLimiting; -using BookingMonolith; -using BookingMonolith.Booking.Data; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Data.Seed; -using BookingMonolith.Identity.Data; -using BookingMonolith.Identity.Data.Seed; -using BookingMonolith.Identity.Extensions.Infrastructure; -using BookingMonolith.Passenger.Data; -using BuildingBlocks.Core; -using BuildingBlocks.EFCore; -using BuildingBlocks.EventStoreDB; -using BuildingBlocks.HealthCheck; -using BuildingBlocks.Jwt; -using BuildingBlocks.Logging; -using BuildingBlocks.Mapster; -using BuildingBlocks.MassTransit; -using BuildingBlocks.Mongo; -using BuildingBlocks.OpenApi; -using BuildingBlocks.OpenTelemetryCollector; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.ProblemDetails; -using BuildingBlocks.Web; -using Figgle; -using FluentValidation; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.AspNetCore.Mvc; -using Serilog; - -namespace Api.Extensions; - -public static class SharedInfrastructureExtensions -{ - public static WebApplicationBuilder AddSharedInfrastructure(this WebApplicationBuilder builder) - { - builder.Host.UseDefaultServiceProvider( - (context, options) => - { - // Service provider validation - // ref: https://andrewlock.net/new-in-asp-net-core-3-service-provider-validation/ - options.ValidateScopes = context.HostingEnvironment.IsDevelopment() || - context.HostingEnvironment.IsStaging() || - context.HostingEnvironment.IsEnvironment("tests"); - - options.ValidateOnBuild = true; - }); - - var appOptions = builder.Services.GetOptions(nameof(AppOptions)); - Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name)); - - builder.AddCustomSerilog(builder.Environment); - builder.Services.AddJwt(); - builder.Services.AddScoped(); - builder.Services.AddTransient(); - builder.Services.AddPersistMessageProcessor(); - - builder.Services.AddEndpointsApiExplorer(); - builder.Services.AddControllers(); - builder.Services.AddAspnetOpenApi(); - builder.Services.AddCustomVersioning(); - builder.Services.AddHttpContextAccessor(); - builder.Services.AddScoped(); - builder.Services.AddCustomMediatR(); - - builder.Services.AddCustomMassTransit( - builder.Environment, - TransportType.InMemory, - AppDomain.CurrentDomain.GetAssemblies()); - - - builder.Services.Scan( - scan => scan - .FromAssemblyOf() - .AddClasses(classes => classes.AssignableTo()) - .AsImplementedInterfaces() - .WithScopedLifetime()); - - - builder.AddMinimalEndpoints(assemblies: typeof(BookingMonolithRoot).Assembly); - builder.Services.AddValidatorsFromAssembly(typeof(BookingMonolithRoot).Assembly); - builder.Services.AddCustomMapster(typeof(BookingMonolithRoot).Assembly); - - builder.AddMongoDbContext(); - builder.AddMongoDbContext(); - builder.AddMongoDbContext(); - - builder.AddCustomDbContext(); - builder.Services.AddScoped(); - builder.AddCustomIdentityServer(); - - builder.Services.Configure( - options => - { - options.ForwardedHeaders = - ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; - }); - - builder.AddCustomDbContext(); - builder.Services.AddScoped(); - - builder.AddCustomDbContext(); - - // ref: https://github.com/oskardudycz/EventSourcing.NetCore/tree/main/Sample/EventStoreDB/ECommerce - builder.Services.AddEventStore(builder.Configuration, typeof(BookingMonolithRoot).Assembly) - .AddEventStoreDBSubscriptionToAll(); - - builder.Services.Configure( - options => options.SuppressModelStateInvalidFilter = true); - - builder.Services.AddRateLimiter( - options => - { - options.GlobalLimiter = PartitionedRateLimiter.Create( - httpContext => - RateLimitPartition.GetFixedWindowLimiter( - partitionKey: httpContext.User.Identity?.Name ?? - httpContext.Request.Headers.Host.ToString(), - factory: partition => new FixedWindowRateLimiterOptions - { - AutoReplenishment = true, - PermitLimit = 10, - QueueLimit = 0, - Window = TimeSpan.FromMinutes(1) - })); - }); - - builder.AddCustomObservability(); - builder.Services.AddCustomHealthCheck(); - - builder.Services.AddEasyCaching( - options => { options.UseInMemory(builder.Configuration, "mem"); }); - - builder.Services.AddProblemDetails(); - - return builder; - } - - - public static WebApplication UserSharedInfrastructure(this WebApplication app) - { - var appOptions = app.Configuration.GetOptions(nameof(AppOptions)); - - app.UseCustomProblemDetails(); - app.UseCustomObservability(); - app.UseCustomHealthCheck(); - - app.UseSerilogRequestLogging( - options => - { - options.EnrichDiagnosticContext = LogEnrichHelper.EnrichFromRequest; - }); - - app.UseCorrelationId(); - app.UseRateLimiter(); - app.MapGet("/", x => x.Response.WriteAsync(appOptions.Name)); - - if (app.Environment.IsDevelopment()) - { - app.UseAspnetOpenApi(); - } - - app.UseForwardedHeaders(); - app.UseMigration(); - app.UseMigration(); - app.UseMigration(); - - app.UseIdentityServer(); - - return app; - } -} diff --git a/1-monolith-architecture-style/src/Api/src/Program.cs b/1-monolith-architecture-style/src/Api/src/Program.cs deleted file mode 100644 index c3b80d5..0000000 --- a/1-monolith-architecture-style/src/Api/src/Program.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Api.Extensions; -using BuildingBlocks.Web; - -var builder = WebApplication.CreateBuilder(args); - -builder.AddSharedInfrastructure(); - -var app = builder.Build(); - -// ref: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-7.0#routing-basics -app.UseAuthentication(); -app.UseAuthorization(); - -app.UserSharedInfrastructure(); -app.MapMinimalEndpoints(); - -app.Run(); - -namespace Api -{ - public partial class Program - { - } -} diff --git a/1-monolith-architecture-style/src/Api/src/Properties/launchSettings.json b/1-monolith-architecture-style/src/Api/src/Properties/launchSettings.json deleted file mode 100644 index 4659237..0000000 --- a/1-monolith-architecture-style/src/Api/src/Properties/launchSettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "Monolith.Api": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchUrl": "swagger", - "launchBrowser": true, - "applicationUrl": "https://localhost:4000;http://localhost:4001", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/1-monolith-architecture-style/src/Api/src/appsettings.docker.json b/1-monolith-architecture-style/src/Api/src/appsettings.docker.json deleted file mode 100644 index 2c63c08..0000000 --- a/1-monolith-architecture-style/src/Api/src/appsettings.docker.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/1-monolith-architecture-style/src/Api/src/appsettings.json b/1-monolith-architecture-style/src/Api/src/appsettings.json deleted file mode 100644 index fff2405..0000000 --- a/1-monolith-architecture-style/src/Api/src/appsettings.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "AppOptions": { - "Name": "Booking-Monolith" - }, - "LogOptions": { - "Level": "information", - "LogTemplate": "{Timestamp:HH:mm:ss} [{Level:u4}] {Message:lj}{NewLine}{Exception}", - "File": { - "Enabled": false, - "Path": "logs/logs.txt", - "Interval": "day" - } - }, - "PostgresOptions": { - "ConnectionString": "Server=localhost;Port=5432;Database=booking_monolith;User Id=postgres;Password=postgres;Include Error Detail=true" - }, - "MongoOptions": { - "ConnectionString": "mongodb://localhost:27017", - "DatabaseName": "booking_modular_monolith_read" - }, - "EventStoreOptions": { - "ConnectionString": "esdb://localhost:2113?tls=false" - }, - "PersistMessageOptions": { - "Interval": 30, - "Enabled": true, - "ConnectionString": "Server=localhost;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true" - }, - "Jwt": { - "Authority": "https://localhost:4000", - "Audience": "booking-monolith" - }, - "HealthOptions": { - "Enabled": false - }, - "ObservabilityOptions": { - "InstrumentationName": "booking_monolith_service", - "OTLPOptions": { - "OTLPGrpExporterEndpoint": "http://localhost:4317" - }, - "AspireDashboardOTLPOptions": { - "OTLPGrpExporterEndpoint": "http://localhost:4319" - }, - "ZipkinOptions": { - "HttpExporterEndpoint": "http://localhost:9411/api/v2/spans" - }, - "JaegerOptions": { - "OTLPGrpcExporterEndpoint": "http://localhost:14317", - "HttpExporterEndpoint": "http://localhost:14268/api/traces" - }, - "UsePrometheusExporter": true, - "UseOTLPExporter": true, - "UseAspireOTLPExporter": true, - "UseGrafanaExporter": false, - "ServiceName": "Booking Monolith Service" - }, - "AllowedHosts": "*" -} diff --git a/1-monolith-architecture-style/src/Api/src/appsettings.test.json b/1-monolith-architecture-style/src/Api/src/appsettings.test.json deleted file mode 100644 index 7a73a41..0000000 --- a/1-monolith-architecture-style/src/Api/src/appsettings.test.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/1-monolith-architecture-style/src/Api/src/keys/is-signing-key-296345BF73910ADD1DAC302B848E47E7.json b/1-monolith-architecture-style/src/Api/src/keys/is-signing-key-296345BF73910ADD1DAC302B848E47E7.json deleted file mode 100644 index cd34668..0000000 --- a/1-monolith-architecture-style/src/Api/src/keys/is-signing-key-296345BF73910ADD1DAC302B848E47E7.json +++ /dev/null @@ -1 +0,0 @@ -{"Version":1,"Id":"296345BF73910ADD1DAC302B848E47E7","Created":"2025-04-06T20:57:25.1670058Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8KNpFTgHKl5Nl-o13RQ8rseNpYdUTB-_FLsIGbeu6jM5x9l_rDfygUsYH6TAnyqXDFeW4U7xf8kJXDDvH1V0jkKcQaHFWYcZnKAirRBnuReu2OcaGWcn0vDccI5liTTRfp_Dknwhf3jgrU-LOBlPDoVGWwTwOQHXa4iHQjfOCG77Ey6CmJZ0w6JMi802tSMbpc2G2376b05GuzpoKwfgG_F8ZJcAtl1cql4KD11CcynPTNqK0fXOcIeGCQKgJDkJp_cHlk-sv4xJTFl5nqRx62v9auoB3AeKxqRqKqserGT-ZFYDeSxOlgmDSreVFezZ4tYd80Iq-ZpQXK5e3uz8gJ1B37_ySzgF_Rkscf67FivIqcpcV-WZzvnKXeQP0Wo7B7Qt8sKwCAW-vh3X5iMdDi-tecOWaRqeNrffbjd4efP1FK5wqmNrZirrcuCZDgPyYUiB1bSUE1HSj5vW4kFy_NF-3k0EVcQf5KqJpJ9QkTQgmTPkFCwwEcyX-P2hA21G64_M_7EjZXnjw29xjnkI7zO3mx3sA5bwPf6sCmxgE6joaI6P7G4u8JB5pbSHynOWWNTWRZm8YHngZCfK1DZa6Y-uAnrNzVQdcbB-uVGwszavP3Ohqtu7NBCaIkIhyT9N783n5-J8KAbSKu2FBF-qwNaUcmSAhbnRLyQwou-F0sxgM9iLwNcCo6jcgqz5g3MBEIcWa5IKdbtYXQQzbj3NlKmYg1l-x0SrxZD9403gNIS-zCEWLPEgpLr-NU06_Y5Vkbvn8jHKAr45nDFvY_osVvCPQ8qFuq_P-z3HMqFrfuPNlLrf_ZoJCpIKYNdXPJwHQXzGpz41QiN2omk52K5N8UCiGnDog66tJZAqGjtWWHpFCF2O4LXA9uEwnlD06N_i1T9umOtLnlGsF5SM0G3YjG_G8APqd6GDnJsM1wBoVXzzldGvS8GEwwxvVRGvLrSljPdR_l-8JifzUzhIOxMdlZUE8D9tQJhqZJovm34kfgx8AA0j4FQxAKPUhz99dapc5rmP1pgkuv7b9ZgtWa9js16GUJUYV3Dd6HC3lWU4zdXnQIsJPBUdgsiKptAXayc1KevAzw7o2PB7_auENui4cj1MuDxbaf9yrq9ZIol_tPw5rdN440vhHPIPzVi-1Wv0YyvyPD0fj2GAU5fL97lVlCprWuM71-rjVtARrn0pbf4ENBYk4ABWWke8ZHppbdFQQbjBv-yKCeiGA7qbRAeb_NMK2wmWUGz9DTVWtb04kmitXvg1-aj6ZwY-uIDSY5uaHPz7b8mxFywlSQ9plQzIkb-EfZk6RWxW1-NqyHMEAryM4QxwdDX9LjSo37CPdHCdOSRsMzH6zGH0_SgeN4W25Lk0RhoBHMMQk_gF5FCXjDteFlAdPFw9K5qmVVohHfEnAMDUZ4xYYgDx0Z254jsbSIFOuqEmUvmb5WvbKFtlcLrpFAuoqcNLfI61JM0LLxZNjpktGOMX5q1E_tYm5Y-bxd6W_2r-UUkCTKWJMp7_wr2CJPyegVshEBuUaO4_GyndCTY9_jh4OEYgyFQliEg66g3CUVy7ZBERrfz1CiHmpTqoKbs3toPsHMrB6yaQe9UtcYzLBRP3OVku3WmE1IylfUsZ64YA2DBU399JjYckXlWU3PxH9GAxcnIW8cU_29XZZ0ueGLFeSRP0mBb8TqVIcqd3xoAUbZGPnleme-D44yco8ZSGFVhQqt5qstzIA2DQALjVf2E5vg-yL8Gj9s5q-xjPjBgZgyW23gbBEO6PynDK3jfnucHXcLsHMpvZwyV1yaU3314mNLUpu241_7ukMuWC5FmxaVWqe4n9h-W479YlK5WmI5TDmWcc12DQI92eIAYCSYA60SOJhnuGsyFHwedfxIjVjouZeAWWHj1QOM3uZ1rwYOB0DZSlqI6C2kecv4D2CFq7gYosBxQX9fSnJ2MyUiGOxbdlRtwGB_dtRtlqWpt-acu-l9i5jNwdM6QnNejoPthvWPCcvfaaqFjWjnZQQKSBBfWV9Coe7mnaJYhyqWFUQ4AKcDuboQ3k3jj2p-5LTnbFlTQ3SzLfsgjLjpD5hqIY1ND5NWOT3D0pQumfh5tJxgSa0g-HhW7XBSGs2783OFdgAMuxCkZUgisdu0MRyQzdqWEY30trlpnpsAGOO3E8MMxQ2COy7Y-WrUykioag1qkJTbT-1FgHgw9Qj4dnQ136_tC3BvVrmO6pId26PzdPDpV_4T5vNLoyuiyyUqnHcKOETFrHpbj2cXmi-sYuqrwfNZKfcPIsAkekmcWlLd9s4glvD3xJ0SB0s6gJURjvupdD96l2kfdHw8qieB0ovlGISrpjnAKGn6F81_32rYULB-NDN8H4aTdiVmhvwf6KkpXHA9Euuyyir4BqHmIknr8WWuugIMxRw3ysCS4OIV5ocsjzIfQ9r_15bNWsoyWPDkVnKcS1ffbURzYPNIqTO6Ik5iC7rk705WAxaojy","DataProtected":true} \ No newline at end of file diff --git a/1-monolith-architecture-style/src/Api/src/keys/is-signing-key-73D9025BDA857BF270C99C6594EE4246.json b/1-monolith-architecture-style/src/Api/src/keys/is-signing-key-73D9025BDA857BF270C99C6594EE4246.json deleted file mode 100644 index 5ca82b6..0000000 --- a/1-monolith-architecture-style/src/Api/src/keys/is-signing-key-73D9025BDA857BF270C99C6594EE4246.json +++ /dev/null @@ -1 +0,0 @@ -{"Version":1,"Id":"73D9025BDA857BF270C99C6594EE4246","Created":"2024-09-02T18:34:53.8631045Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8MEQ06y_es9CrKY4Ou9Uc7Hf97ujXcMcuawi9V5VrBvxWbAqbdjBlk5zKK_NzrDURTwaFvgOfLUQ__0r-sMvtTXBZLhWhNWJnLn1-KWhtnpvPt5jFTAf2f5mvrjVTTN8E-NTGMGk2yLOYm2TVE3QL7DuLRrazydXLJvIB71O2d_OrAfB7Pq62xrnwLgp4BErb_HphYUExsAEp7jn6uL34QJ5HI6zsb_ct2SHvOl0CzUH2yIjjrY_u-5GAgmqqpUyysGwUh8RpR_CDPCd8ZxgSOiKAlBkp3kQXxf86MF0C-kfBKU-iflrJRSJ1-5R8F5nNPK8FL29I4i7SYCugIkLvqez3wTewPUFv00bTpcfs3V_tmfqBFLyNWm4sppzpU9HGB3elZ0z5bBa_IGbtIrlHC_o4SDSxKKdD4OUZHGLE5X--xWBw5uV9GSgrSH6bcnHZ6rLd3qrt7b82BMr-rVIGyFzGIE6OTLVGkXSL6FdpJ9Lezp06qnZ6DtLFI86lVJGsYIuXR_AIVrz9U8uqCrK6jLwGCk9nR0adPtAUJfgcXGVVTQlvt_YgZv5k5_rYcVl0yLNdgd-BoidXeoqLPJxIJOCohwumVcqTPkf-gB_hjgNk6IEqXZxm0Tzl0d2jpyERDHdHxIvS5o1h4YUfkiMcliRfQMNkLoDxf0H2hFNXRYQKkQ1y6cwS9juq66Uj_-v-vN1etE-hK45ULFCfyppBvb2aTYfTuce5S0ps1t0ZIjvpm7Kvjg3doHEi97N-IqxYaf8r6n8gBcaUwlrfcHaYNPLRyWywX_varEmLm9qGK5KJj2itGNfw0wU0EygIeoV6V_PzqyAkf0JcVTC7lcog37TPdNU2AGzH0S8oXiAQEd49wPs2ZApjiOaiz26efr03I-hD5N91-R2_9ACGjENGPVHMyUtMVV5RPs3-pQMv9f_zweOuLQo7ZfhScqu4HmxGW70amuV4anMxGCQzbi3JWnkTmspptzClJyvE_MJVSTQ6SX04DaS4buSG3wZEc9Qy9SqTj-9CJ7XFGFs8XYmKUj_cIoQF1XuoSnWblsnnEC7EbNRF7y9fG8ZG-Sk3TEEYnalxRrcS-i26wVNdnuUBEmidz_HfsxFxCDKKmx7GHTvHxy72kI84ucMeQeVFjJI3ZDynGn--cL9xBiUbUKM8WDhJ-AgZ76wwh0qAPw5xJ6yHi-15moxySUkvFLjlNkP2Ad5j3_3ab_r6VIunM6zhsq7pSBWIg5povuV5ZwNVZQX0IeLqV9bHug443LaK5a57dTK8wy346AFftV-wc71i4Nt5MIFcOs3lxRPqYij1enbrPYvIV4-N8Sy6aaYj25Qn7VHrGeW72aZPAYY5W-czoPw_Oo6xYGjaPYFFsUSZVg6IQwCzwwAxUoc2gAL33FJQTNvNSnrYBJ5HN-Tqan23Pw_bEus7HHZu2N1daFjqtrl4-oOco46phsppUjH3LGhOPJnFSChr-W8tlk80coJ8IK_AsGludKB09WzId9JBtI5cp3Yu1J7N6nSL7nVTrT6Gw_0hitSoeu5ZLPSS9ooAynAXrvB_s0l0L9aFTRuc5IEhgt4bLzbeqimfQemRlBsNz09JGe04gmOOCmjWD52JHWUiVJQNMavrSGtW9Dy1-Z5h0D_BHzhpTia1S7wx7dSdItJ0-Pm1Au_TNkQGm4ffNFsVDQmNkCYyc8yFnYmZMYYEaPmbw7DvQTs1MHoe7aUzMM0DKcaqboSaxqQK9sxymgElvdoYqOMRWzS7s39UQ1O4TfPngfrWdtN2DogGUtyS-vPfNJpdS6jZvJAj8czgl7PU8buwWyPApE1-FVL32wC6a8dkHvJi4p7fbBjmTfFCnuW8G1KBX3VuToctJvidSjzoSUTX3vgKVni2QW-55Sh7DUYy91FGXGB_ui1yuxEnLmymtbWokcWYkIwcAsl8im70V4oK63ypNSYWea_gaDWMFXT_vANB1iAkr-_zE_ECocOXo93QqSR5UdLmfQFvLiDwjUeovkjFS5C2Z8AjEvHvFkedGWOIK5Bpam-0IEFip3Fvg6RgxwTinFXXa8PiRkcLSlt0J81b85ybrKsDj5WtUA-MFuK2Silyofn9BgD_lh9RU4HPFhVoqey7AuEJjHtGvqz4EnE_05y4A_mKgvJBAs4QiYjCopWtheeOGeeoUa636Ewmu30P66C5mimdAIx36-55xlyJBIM7DFFM6RAGvfAmpyNphjwT0y84B4pOhFEZeOQ2me2sfG-xRJbjjgDhP2SwBBEQ-hCLGeqOD-Xo74FZC4lCTvtn2Sbu1kIw0kz2P_vrq6d6SZwEIrhWYhfRVKTrT8nXj8i48Jdc1d1fyKdRL15USgLhAT-QSNcgVYHRLsVlQx5-b51tGg6Atx6vGCxtXBRSaTwZ3IxbdJs0T62H14K5U81EFu-2Vvf-cMwCm4gCQATxvvAsqToxElou9ZjIVMPt_FQUyAMtJke","DataProtected":true} \ No newline at end of file diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingEventMapper.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingEventMapper.cs deleted file mode 100644 index 9743d54..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingEventMapper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using BookingMonolith.Booking.Bookings.Features.CreatingBook.V1; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace BookingMonolith.Booking; - -public sealed class BookingEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - BookingCreatedDomainEvent e => new BookingCreated(e.Id), - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - _ => null - }; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingProjection.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingProjection.cs deleted file mode 100644 index 7cbff91..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingProjection.cs +++ /dev/null @@ -1,53 +0,0 @@ -using BookingMonolith.Booking.Bookings.Features.CreatingBook.V1; -using BookingMonolith.Booking.Bookings.Models; -using BookingMonolith.Booking.Data; -using BuildingBlocks.EventStoreDB.Events; -using BuildingBlocks.EventStoreDB.Projections; -using MassTransit; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Booking; - -public class BookingProjection : IProjectionProcessor -{ - private readonly BookingReadDbContext _bookingReadDbContext; - - public BookingProjection(BookingReadDbContext bookingReadDbContext) - { - _bookingReadDbContext = bookingReadDbContext; - } - - public async Task ProcessEventAsync(StreamEvent streamEvent, CancellationToken cancellationToken = default) - where T : INotification - { - switch (streamEvent.Data) - { - case BookingCreatedDomainEvent bookingCreatedDomainEvent: - await Apply(bookingCreatedDomainEvent, cancellationToken); - break; - } - } - - private async Task Apply(BookingCreatedDomainEvent @event, CancellationToken cancellationToken = default) - { - var reservation = - await _bookingReadDbContext.Booking.AsQueryable().SingleOrDefaultAsync(x => x.Id == @event.Id && !x.IsDeleted, - cancellationToken); - - if (reservation == null) - { - var bookingReadModel = new BookingReadModel - { - Id = NewId.NextGuid(), - Trip = @event.Trip, - BookId = @event.Id, - PassengerInfo = @event.PassengerInfo, - IsDeleted = @event.IsDeleted - }; - - await _bookingReadDbContext.Booking.InsertOneAsync(bookingReadModel, cancellationToken: cancellationToken); - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingRoot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingRoot.cs deleted file mode 100644 index e5df390..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/BookingRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BookingMonolith.Booking; - -public class BookingRoot -{ - -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Dtos/CreateReservation.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Dtos/CreateReservation.cs deleted file mode 100644 index 9d4fe4a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Dtos/CreateReservation.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace BookingMonolith.Booking.Bookings.Dtos; - -public record BookingResponseDto(Guid Id, string Name, string FlightNumber, Guid AircraftId, decimal Price, - DateTime FlightDate, string SeatNumber, Guid DepartureAirportId, Guid ArriveAirportId, string Description); diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/BookingAlreadyExistException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/BookingAlreadyExistException.cs deleted file mode 100644 index 8a47323..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/BookingAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class BookingAlreadyExistException : AppException -{ - public BookingAlreadyExistException(int? code = default) : base("Booking already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/FlightNotFoundException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/FlightNotFoundException.cs deleted file mode 100644 index 7db5c22..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/FlightNotFoundException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class FlightNotFoundException : AppException -{ - public FlightNotFoundException() : base("Flight doesn't exist!", HttpStatusCode.NotFound) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidAircraftIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidAircraftIdException.cs deleted file mode 100644 index 8274ea2..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidAircraftIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidAircraftIdException : DomainException -{ - public InvalidAircraftIdException(Guid aircraftId) - : base($"aircraftId: '{aircraftId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidArriveAirportIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidArriveAirportIdException.cs deleted file mode 100644 index 16ae26a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidArriveAirportIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidArriveAirportIdException : DomainException -{ - public InvalidArriveAirportIdException(Guid arriveAirportId) - : base($"arriveAirportId: '{arriveAirportId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidDepartureAirportIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidDepartureAirportIdException.cs deleted file mode 100644 index caa8162..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidDepartureAirportIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidDepartureAirportIdException : DomainException -{ - public InvalidDepartureAirportIdException(Guid departureAirportId) - : base($"departureAirportId: '{departureAirportId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidFlightDateException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidFlightDateException.cs deleted file mode 100644 index 5a4bc88..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidFlightDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidFlightDateException : DomainException -{ - public InvalidFlightDateException(DateTime flightDate) - : base($"Flight Date: '{flightDate}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidFlightNumberException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidFlightNumberException.cs deleted file mode 100644 index 2609d3e..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidFlightNumberException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidFlightNumberException : DomainException -{ - public InvalidFlightNumberException(string flightNumber) - : base($"Flight Number: '{flightNumber}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidPassengerNameException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidPassengerNameException.cs deleted file mode 100644 index e0e7ad0..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidPassengerNameException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidPassengerNameException : DomainException -{ - public InvalidPassengerNameException(string passengerName) - : base($"Passenger Name: '{passengerName}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidPriceException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidPriceException.cs deleted file mode 100644 index 53806f5..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/InvalidPriceException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class InvalidPriceException : DomainException -{ - public InvalidPriceException(decimal price) - : base($"Price: '{price}' must be grater than or equal 0.") - { - } -} - diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/SeatNumberException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/SeatNumberException.cs deleted file mode 100644 index cb68748..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Exceptions/SeatNumberException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Booking.Bookings.Exceptions; - -public class SeatNumberException : DomainException -{ - public SeatNumberException(string seatNumber) - : base($"Seat Number: '{seatNumber}' is invalid.") - { - } -} - diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Features/BookingMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Features/BookingMappings.cs deleted file mode 100644 index d962240..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Features/BookingMappings.cs +++ /dev/null @@ -1,22 +0,0 @@ -using BookingMonolith.Booking.Bookings.Dtos; -using BookingMonolith.Booking.Bookings.Features.CreatingBook.V1; -using Mapster; - -namespace BookingMonolith.Booking.Bookings.Features; - -public class BookingMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.Default.NameMatchingStrategy(NameMatchingStrategy.Flexible); - - config.NewConfig() - .ConstructUsing(x => new BookingResponseDto(x.Id, x.PassengerInfo.Name, x.Trip.FlightNumber, - x.Trip.AircraftId, x.Trip.Price, x.Trip.FlightDate, x.Trip.SeatNumber, x.Trip.DepartureAirportId, x.Trip.ArriveAirportId, - x.Trip.Description)); - - - config.NewConfig() - .ConstructUsing(x => new CreateBooking(x.PassengerId, x.FlightId, x.Description)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Features/CreatingBook/V1/CreateBooking.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Features/CreatingBook/V1/CreateBooking.cs deleted file mode 100644 index 7d1d6f6..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Features/CreatingBook/V1/CreateBooking.cs +++ /dev/null @@ -1,137 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Booking.Bookings.Exceptions; -using BookingMonolith.Booking.Bookings.ValueObjects; -using BookingMonolith.Flight.Flights.Features.GettingFlightById.V1; -using BookingMonolith.Flight.Seats.Features.GettingAvailableSeats.V1; -using BookingMonolith.Flight.Seats.Features.ReservingSeat.V1; -using BookingMonolith.Passenger.Passengers.Features.GettingPassengerById.V1; -using BuildingBlocks.Core; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Core.Model; -using BuildingBlocks.EventStoreDB.Repository; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; - -namespace BookingMonolith.Booking.Bookings.Features.CreatingBook.V1; - -public record CreateBooking(Guid PassengerId, Guid FlightId, string Description) : ICommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateBookingResult(ulong Id); - -public record BookingCreatedDomainEvent(Guid Id, PassengerInfo PassengerInfo, Trip Trip) : Entity, IDomainEvent; - -public record CreateBookingRequestDto(Guid PassengerId, Guid FlightId, string Description); - -public record CreateBookingResponseDto(ulong Id); - -public class CreateBookingEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/booking", async (CreateBookingRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateBooking") - .WithApiVersionSet(builder.NewApiVersionSet("Booking").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Booking") - .WithDescription("Create Booking") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateBookingValidator : AbstractValidator -{ - public CreateBookingValidator() - { - RuleFor(x => x.FlightId).NotNull().WithMessage("FlightId is required!"); - RuleFor(x => x.PassengerId).NotNull().WithMessage("PassengerId is required!"); - } -} - -internal class CreateBookingCommandHandler : ICommandHandler -{ - private readonly IEventStoreDBRepository _eventStoreDbRepository; - private readonly ICurrentUserProvider _currentUserProvider; - private readonly IEventDispatcher _eventDispatcher; - private readonly IMediator _mediator; - - public CreateBookingCommandHandler(IEventStoreDBRepository eventStoreDbRepository, - ICurrentUserProvider currentUserProvider, - IEventDispatcher eventDispatcher, - IMediator mediator) - { - _eventStoreDbRepository = eventStoreDbRepository; - _currentUserProvider = currentUserProvider; - _eventDispatcher = eventDispatcher; - _mediator = mediator; - } - - public async Task Handle(CreateBooking command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - // Directly call the GetFlightById handler instead of gRPC - var flight = await _mediator.Send(new GetFlightById(command.FlightId), cancellationToken); - - if (flight is null) - { - throw new FlightNotFoundException(); - } - - var passenger = await _mediator.Send(new GetPassengerById(command.PassengerId), cancellationToken); - - var emptySeat = (await _mediator.Send(new GetAvailableSeats(command.FlightId), cancellationToken))?.SeatDtos?.FirstOrDefault(); - - var reservation = await _eventStoreDbRepository.Find(command.Id, cancellationToken); - - if (reservation is not null && !reservation.IsDeleted) - { - throw new BookingAlreadyExistException(); - } - - var aggrigate = Models.Booking.Create(command.Id, PassengerInfo.Of(passenger.PassengerDto?.Name), Trip.Of( - flight.FlightDto.FlightNumber, flight.FlightDto.AircraftId, - flight.FlightDto.DepartureAirportId, - flight.FlightDto.ArriveAirportId, flight.FlightDto.FlightDate, - flight.FlightDto.Price, command.Description, - emptySeat?.SeatNumber), - false, _currentUserProvider.GetCurrentUserId()); - - await _eventDispatcher.SendAsync(aggrigate.DomainEvents, cancellationToken: cancellationToken); - - await _mediator.Send(new ReserveSeat(flight.FlightDto.Id, emptySeat?.SeatNumber), cancellationToken); - - var result = await _eventStoreDbRepository.Add( - aggrigate, - cancellationToken); - - return new CreateBookingResult(result); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Models/Booking.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Models/Booking.cs deleted file mode 100644 index c1b1729..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Models/Booking.cs +++ /dev/null @@ -1,49 +0,0 @@ -using BookingMonolith.Booking.Bookings.Features.CreatingBook.V1; -using BookingMonolith.Booking.Bookings.ValueObjects; -using BuildingBlocks.EventStoreDB.Events; - -namespace BookingMonolith.Booking.Bookings.Models; - -public record Booking : AggregateEventSourcing -{ - public Trip Trip { get; private set; } - public PassengerInfo PassengerInfo { get; private set; } - - public static Booking Create(Guid id, PassengerInfo passengerInfo, Trip trip, bool isDeleted = false, long? userId = null) - { - var booking = new Booking { Id = id, Trip = trip, PassengerInfo = passengerInfo, IsDeleted = isDeleted }; - - var @event = new BookingCreatedDomainEvent(booking.Id, booking.PassengerInfo, booking.Trip) - { - IsDeleted = booking.IsDeleted, - CreatedAt = DateTime.Now, - CreatedBy = userId - }; - - booking.AddDomainEvent(@event); - booking.Apply(@event); - - return booking; - } - - public override void When(object @event) - { - switch (@event) - { - case BookingCreatedDomainEvent bookingCreated: - { - Apply(bookingCreated); - return; - } - } - } - - private void Apply(BookingCreatedDomainEvent @event) - { - Id = @event.Id; - Trip = @event.Trip; - PassengerInfo = @event.PassengerInfo; - IsDeleted = @event.IsDeleted; - Version++; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Models/BookingReadModel.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Models/BookingReadModel.cs deleted file mode 100644 index 730a6bc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/Models/BookingReadModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -using BookingMonolith.Booking.Bookings.ValueObjects; - -namespace BookingMonolith.Booking.Bookings.Models; - -public class BookingReadModel -{ - public required Guid Id { get; init; } - public required Guid BookId { get; init; } - public required Trip Trip { get; init; } - public required PassengerInfo PassengerInfo { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/ValueObjects/PassengerInfo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/ValueObjects/PassengerInfo.cs deleted file mode 100644 index 8a65131..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/ValueObjects/PassengerInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BookingMonolith.Booking.Bookings.Exceptions; - -namespace BookingMonolith.Booking.Bookings.ValueObjects; - -public record PassengerInfo -{ - public string Name { get; } - - private PassengerInfo(string name) - { - Name = name; - } - - public static PassengerInfo Of(string name) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new InvalidPassengerNameException(name); - } - - return new PassengerInfo(name); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/ValueObjects/Trip.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/ValueObjects/Trip.cs deleted file mode 100644 index da43eaa..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Bookings/ValueObjects/Trip.cs +++ /dev/null @@ -1,69 +0,0 @@ -using BookingMonolith.Booking.Bookings.Exceptions; - -namespace BookingMonolith.Booking.Bookings.ValueObjects; - -public record Trip -{ - public string FlightNumber { get; } - public Guid AircraftId { get; } - public Guid DepartureAirportId { get; } - public Guid ArriveAirportId { get; } - public DateTime FlightDate { get; } - public decimal Price { get; } - public string Description { get; } - public string SeatNumber { get; } - - private Trip(string flightNumber, Guid aircraftId, Guid departureAirportId, Guid arriveAirportId, - DateTime flightDate, decimal price, string description, string seatNumber) - { - FlightNumber = flightNumber; - AircraftId = aircraftId; - DepartureAirportId = departureAirportId; - ArriveAirportId = arriveAirportId; - FlightDate = flightDate; - Price = price; - Description = description; - SeatNumber = seatNumber; - } - - public static Trip Of(string flightNumber, Guid aircraftId, Guid departureAirportId, Guid arriveAirportId, - DateTime flightDate, decimal price, string description, string seatNumber) - { - if (string.IsNullOrWhiteSpace(flightNumber)) - { - throw new InvalidFlightNumberException(flightNumber); - } - - if (aircraftId == Guid.Empty) - { - throw new InvalidAircraftIdException(aircraftId); - } - - if (departureAirportId == Guid.Empty) - { - throw new InvalidDepartureAirportIdException(departureAirportId); - } - - if (arriveAirportId == Guid.Empty) - { - throw new InvalidArriveAirportIdException(departureAirportId); - } - - if (flightDate == default) - { - throw new InvalidFlightDateException(flightDate); - } - - if (price < 0) - { - throw new InvalidPriceException(price); - } - - if (string.IsNullOrWhiteSpace(seatNumber)) - { - throw new SeatNumberException(seatNumber); - } - - return new Trip(flightNumber, aircraftId, departureAirportId, arriveAirportId, flightDate, price, description, seatNumber); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Data/BookingReadDbContext.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Data/BookingReadDbContext.cs deleted file mode 100644 index 8c88c0f..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Booking/Data/BookingReadDbContext.cs +++ /dev/null @@ -1,18 +0,0 @@ -using BookingMonolith.Booking.Bookings.Models; -using BuildingBlocks.Mongo; -using Humanizer; -using Microsoft.Extensions.Options; -using MongoDB.Driver; - -namespace BookingMonolith.Booking.Data; - - -public class BookingReadDbContext : MongoDbContext -{ - public BookingReadDbContext(IOptions options) : base(options) - { - Booking = GetCollection(nameof(Booking).Underscore()); - } - - public IMongoCollection Booking { get; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolith.csproj b/1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolith.csproj deleted file mode 100644 index 55c9efb..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolith.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - net9.0 - enable - enable - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolithRoot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolithRoot.cs deleted file mode 100644 index 0f56d2e..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolithRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BookingMonolith; - -public class BookingMonolithRoot -{ - -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Dtos/AircraftDto.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Dtos/AircraftDto.cs deleted file mode 100644 index ec95561..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Dtos/AircraftDto.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace BookingMonolith.Flight.Aircrafts.Dtos; - -public record AircraftDto(long Id, string Name, string Model, int ManufacturingYear); diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs deleted file mode 100644 index a313d41..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Aircrafts.Exceptions; - -public class AircraftAlreadyExistException : AppException -{ - public AircraftAlreadyExistException() : base("Aircraft already exist!", HttpStatusCode.Conflict) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs deleted file mode 100644 index 7e93540..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.Exceptions; - -public class InvalidAircraftIdException : DomainException -{ - public InvalidAircraftIdException(Guid aircraftId) - : base($"AircraftId: '{aircraftId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs deleted file mode 100644 index c608ae7..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.Exceptions; - -public class InvalidManufacturingYearException : DomainException -{ - public InvalidManufacturingYearException() : base("ManufacturingYear must be greater than 1900") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs deleted file mode 100644 index ed4a2e7..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.Exceptions; - -public class InvalidModelException : DomainException -{ - public InvalidModelException() : base("Model cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs deleted file mode 100644 index 00b6435..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/AircraftMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/AircraftMappings.cs deleted file mode 100644 index 633c694..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/AircraftMappings.cs +++ /dev/null @@ -1,24 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Features.CreatingAircraft.V1; -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using Mapster; -using MassTransit; - -namespace BookingMonolith.Flight.Aircrafts.Features; - -public class AircraftMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AircraftId, s => AircraftId.Of(s.Id)); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AircraftId, s => AircraftId.Of(s.Id.Value)); - - config.NewConfig() - .ConstructUsing(x => new CreatingAircraft.V1.CreateAircraft(x.Name, x.Model, x.ManufacturingYear)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs deleted file mode 100644 index d33df28..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs +++ /dev/null @@ -1,104 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Aircrafts.Exceptions; -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using BookingMonolith.Flight.Data; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Aircrafts.Features.CreatingAircraft.V1; - -public record CreateAircraft(string Name, string Model, int ManufacturingYear) : ICommand, - IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateAircraftResult(AircraftId Id); - -public record AircraftCreatedDomainEvent - (Guid Id, string Name, string Model, int ManufacturingYear, bool IsDeleted) : IDomainEvent; - -public record CreateAircraftRequestDto(string Name, string Model, int ManufacturingYear); - -public record CreateAircraftResponseDto(Guid Id); - -public class CreateAircraftEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/aircraft", async (CreateAircraftRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateAircraft") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Aircraft") - .WithDescription("Create Aircraft") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateAircraftValidator : AbstractValidator -{ - public CreateAircraftValidator() - { - RuleFor(x => x.Model).NotEmpty().WithMessage("Model is required"); - RuleFor(x => x.Name).NotEmpty().WithMessage("Name is required"); - RuleFor(x => x.ManufacturingYear).NotEmpty().WithMessage("ManufacturingYear is required"); - } -} - -internal class CreateAircraftHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateAircraftHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateAircraft request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var aircraft = await _flightDbContext.Aircraft.SingleOrDefaultAsync( - a => a.Model.Value == request.Model, cancellationToken); - - if (aircraft is not null) - { - throw new AircraftAlreadyExistException(); - } - - var aircraftEntity = Aircraft.Create(AircraftId.Of(request.Id), Name.Of(request.Name), Model.Of(request.Model), ManufacturingYear.Of(request.ManufacturingYear)); - - var newAircraft = (await _flightDbContext.Aircraft.AddAsync(aircraftEntity, cancellationToken)).Entity; - - return new CreateAircraftResult(newAircraft.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs deleted file mode 100644 index 11e4337..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Aircrafts.Exceptions; -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Data; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Aircrafts.Features.CreatingAircraft.V1; - -public record CreateAircraftMongo(Guid Id, string Name, string Model, int ManufacturingYear, bool IsDeleted = false) : InternalCommand; - -internal class CreateAircraftMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateAircraftMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateAircraftMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var aircraftReadModel = _mapper.Map(request); - - var aircraft = await _flightReadDbContext.Aircraft.AsQueryable() - .FirstOrDefaultAsync(x => x.AircraftId == aircraftReadModel.AircraftId && - !x.IsDeleted, cancellationToken); - - if (aircraft is not null) - { - throw new AircraftAlreadyExistException(); - } - - await _flightReadDbContext.Aircraft.InsertOneAsync(aircraftReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Models/Aircraft.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Models/Aircraft.cs deleted file mode 100644 index bed0ddb..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Models/Aircraft.cs +++ /dev/null @@ -1,34 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Features.CreatingAircraft.V1; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using BuildingBlocks.Core.Model; - -namespace BookingMonolith.Flight.Aircrafts.Models; - -public record Aircraft : Aggregate -{ - public Name Name { get; private set; } = default!; - public Model Model { get; private set; } = default!; - public ManufacturingYear ManufacturingYear { get; private set; } = default!; - - public static Aircraft Create(AircraftId id, Name name, Model model, ManufacturingYear manufacturingYear, bool isDeleted = false) - { - var aircraft = new Aircraft - { - Id = id, - Name = name, - Model = model, - ManufacturingYear = manufacturingYear - }; - - var @event = new AircraftCreatedDomainEvent( - aircraft.Id, - aircraft.Name, - aircraft.Model, - aircraft.ManufacturingYear, - isDeleted); - - aircraft.AddDomainEvent(@event); - - return aircraft; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Models/AircraftReadModel.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Models/AircraftReadModel.cs deleted file mode 100644 index e4c7f3a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/Models/AircraftReadModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace BookingMonolith.Flight.Aircrafts.Models; - -public class AircraftReadModel -{ - public required Guid Id { get; init; } - public required Guid AircraftId { get; init; } - public required string Name { get; init; } - public required string Model { get; init; } - public required int ManufacturingYear { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/AircraftId.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/AircraftId.cs deleted file mode 100644 index 4fbe3cb..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/AircraftId.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.ValueObjects; - -public record AircraftId -{ - public Guid Value { get; } - - private AircraftId(Guid value) - { - Value = value; - } - - public static AircraftId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidAircraftIdException(value); - } - - return new AircraftId(value); - } - - public static implicit operator Guid(AircraftId aircraftId) - { - return aircraftId.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs deleted file mode 100644 index 63951b9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.ValueObjects; - -public record ManufacturingYear -{ - public int Value { get; } - - private ManufacturingYear(int value) - { - Value = value; - } - - public static ManufacturingYear Of(int value) - { - if (value < 1900) - { - throw new InvalidManufacturingYearException(); - } - - return new ManufacturingYear(value); - } - - public static implicit operator int(ManufacturingYear manufacturingYear) - { - return manufacturingYear.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/Model.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/Model.cs deleted file mode 100644 index f13b6af..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/Model.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.ValueObjects; - -public record Model -{ - public string Value { get; } - - private Model(string value) - { - Value = value; - } - - public static Model Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidModelException(); - } - - return new Model(value); - } - - public static implicit operator string(Model model) - { - return model.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/Name.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/Name.cs deleted file mode 100644 index 22136fc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Aircrafts/ValueObjects/Name.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Exceptions; - -namespace BookingMonolith.Flight.Aircrafts.ValueObjects; - -public record Name -{ - public string Value { get; } - - private Name(string value) - { - Value = value; - } - - public static Name Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidNameException(); - } - - return new Name(value); - } - - public static implicit operator string(Name name) - { - return name.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Dtos/AirportDto.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Dtos/AirportDto.cs deleted file mode 100644 index db55c61..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Dtos/AirportDto.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace BookingMonolith.Flight.Airports.Dtos; - -public record AirportDto(long Id, string Name, string Address, string Code); diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs deleted file mode 100644 index 59cebd4..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Airports.Exceptions; - -public class AirportAlreadyExistException : AppException -{ - public AirportAlreadyExistException(int? code = default) : base("Airport already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidAddressException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidAddressException.cs deleted file mode 100644 index 9cdb412..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidAddressException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Airports.Exceptions; - -public class InvalidAddressException : DomainException -{ - public InvalidAddressException() : base("Address cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs deleted file mode 100644 index f13b54b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Airports.Exceptions; - -public class InvalidAirportIdException : DomainException -{ - public InvalidAirportIdException(Guid airportId) - : base($"airportId: '{airportId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidCodeException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidCodeException.cs deleted file mode 100644 index d5f8f35..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidCodeException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Airports.Exceptions; - -public class InvalidCodeException : DomainException -{ - public InvalidCodeException() : base("Code cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidNameException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidNameException.cs deleted file mode 100644 index b4e06c3..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Airports.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/AirportMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/AirportMappings.cs deleted file mode 100644 index ffb4324..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/AirportMappings.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BookingMonolith.Flight.Airports.Features.CreatingAirport.V1; -using BookingMonolith.Flight.Airports.Models; -using Mapster; -using MassTransit; - -namespace BookingMonolith.Flight.Airports.Features; - -public class AirportMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AirportId, s => s.Id); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AirportId, s => s.Id.Value); - - config.NewConfig() - .ConstructUsing(x => new CreateAirport(x.Name, x.Address, x.Code)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs deleted file mode 100644 index 53043f5..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs +++ /dev/null @@ -1,102 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Airports.Exceptions; -using BookingMonolith.Flight.Airports.ValueObjects; -using BookingMonolith.Flight.Data; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Airports.Features.CreatingAirport.V1; - -public record CreateAirport(string Name, string Address, string Code) : ICommand, IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateAirportResult(Guid Id); - -public record AirportCreatedDomainEvent - (Guid Id, string Name, string Address, string Code, bool IsDeleted) : IDomainEvent; - -public record CreateAirportRequestDto(string Name, string Address, string Code); - -public record CreateAirportResponseDto(Guid Id); - -public class CreateAirportEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/airport", async (CreateAirportRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateAirport") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Airport") - .WithDescription("Create Airport") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateAirportValidator : AbstractValidator -{ - public CreateAirportValidator() - { - RuleFor(x => x.Code).NotEmpty().WithMessage("Code is required"); - RuleFor(x => x.Name).NotEmpty().WithMessage("Name is required"); - RuleFor(x => x.Address).NotEmpty().WithMessage("Address is required"); - } -} - -internal class CreateAirportHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateAirportHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateAirport request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var airport = - await _flightDbContext.Airports.SingleOrDefaultAsync(x => x.Code.Value == request.Code, cancellationToken); - - if (airport is not null) - { - throw new AirportAlreadyExistException(); - } - - var airportEntity = Models.Airport.Create(AirportId.Of(request.Id), Name.Of(request.Name), Address.Of(request.Address), Code.Of(request.Code)); - - var newAirport = (await _flightDbContext.Airports.AddAsync(airportEntity, cancellationToken)).Entity; - - return new CreateAirportResult(newAirport.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs deleted file mode 100644 index 1a961c8..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Airports.Exceptions; -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Data; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Airports.Features.CreatingAirport.V1; - -public record CreateAirportMongo(Guid Id, string Name, string Address, string Code, bool IsDeleted = false) : InternalCommand; - -internal class CreateAirportMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateAirportMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateAirportMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var airportReadModel = _mapper.Map(request); - - var aircraft = await _flightReadDbContext.Airport.AsQueryable() - .FirstOrDefaultAsync(x => x.AirportId == airportReadModel.AirportId && - !x.IsDeleted, cancellationToken); - - if (aircraft is not null) - { - throw new AirportAlreadyExistException(); - } - - await _flightReadDbContext.Airport.InsertOneAsync(airportReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Models/Airport.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Models/Airport.cs deleted file mode 100644 index fb25307..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Models/Airport.cs +++ /dev/null @@ -1,34 +0,0 @@ -using BookingMonolith.Flight.Airports.Features.CreatingAirport.V1; -using BookingMonolith.Flight.Airports.ValueObjects; -using BuildingBlocks.Core.Model; - -namespace BookingMonolith.Flight.Airports.Models; - -public record Airport : Aggregate -{ - public Name Name { get; private set; } = default!; - public Address Address { get; private set; } = default!; - public Code Code { get; private set; } = default!; - - public static Airport Create(AirportId id, Name name, Address address, Code code, bool isDeleted = false) - { - var airport = new Airport - { - Id = id, - Name = name, - Address = address, - Code = code - }; - - var @event = new AirportCreatedDomainEvent( - airport.Id, - airport.Name, - airport.Address, - airport.Code, - isDeleted); - - airport.AddDomainEvent(@event); - - return airport; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Models/AirportReadModel.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Models/AirportReadModel.cs deleted file mode 100644 index a0afa00..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/Models/AirportReadModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace BookingMonolith.Flight.Airports.Models; - -public class AirportReadModel -{ - public required Guid Id { get; init; } - public required Guid AirportId { get; init; } - public required string Name { get; init; } - public string Address { get; init; } - public required string Code { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Address.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Address.cs deleted file mode 100644 index b4d1dfd..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Address.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Airports.Exceptions; - -namespace BookingMonolith.Flight.Airports.ValueObjects; - -public class Address -{ - public string Value { get; } - - private Address(string value) - { - Value = value; - } - - public static Address Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidAddressException(); - } - - return new Address(value); - } - - public static implicit operator string(Address address) - { - return address.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/AirportId.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/AirportId.cs deleted file mode 100644 index a203d75..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/AirportId.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Airports.Exceptions; - -namespace BookingMonolith.Flight.Airports.ValueObjects; - -public record AirportId -{ - public Guid Value { get; } - - private AirportId(Guid value) - { - Value = value; - } - - public static AirportId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidAirportIdException(value); - } - - return new AirportId(value); - } - - public static implicit operator Guid(AirportId airportId) - { - return airportId.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Code.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Code.cs deleted file mode 100644 index d6560d9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Code.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Airports.Exceptions; - -namespace BookingMonolith.Flight.Airports.ValueObjects; - -public record Code -{ - public string Value { get; } - - private Code(string value) - { - Value = value; - } - - public static Code Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidCodeException(); - } - - return new Code(value); - } - - public static implicit operator string(Code code) - { - return code.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Name.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Name.cs deleted file mode 100644 index 7e6e1e9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Airports/ValueObjects/Name.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Airports.Exceptions; - -namespace BookingMonolith.Flight.Airports.ValueObjects; - -public record Name -{ - public string Value { get; } - - private Name(string value) - { - Value = value; - } - - public static Name Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidNameException(); - } - - return new Name(value); - } - - public static implicit operator string(Name name) - { - return name.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/AircraftConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/AircraftConfiguration.cs deleted file mode 100644 index 53d6634..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/AircraftConfiguration.cs +++ /dev/null @@ -1,55 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Flight.Data.Configurations; - -[RegisterFlightConfiguration] -public class AircraftConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - - builder.ToTable(nameof(Aircraft)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(aircraftId => aircraftId.Value, dbId => AircraftId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - builder.OwnsOne( - x => x.Name, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Aircraft.Name)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Model, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Aircraft.Model)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.ManufacturingYear, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Aircraft.ManufacturingYear)) - .HasMaxLength(5) - .IsRequired(); - } - ); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/AirportConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/AirportConfiguration.cs deleted file mode 100644 index 24812b6..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/AirportConfiguration.cs +++ /dev/null @@ -1,56 +0,0 @@ -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Airports.ValueObjects; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Flight.Data.Configurations; - -[RegisterFlightConfiguration] -public class AirportConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - - builder.ToTable(nameof(Airport)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(airportId => airportId.Value, dbId => AirportId.Of(dbId)); - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - - - builder.OwnsOne( - x => x.Name, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Airport.Name)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Address, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Airport.Address)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Code, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Airport.Code)) - .HasMaxLength(50) - .IsRequired(); - } - ); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/FlightConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/FlightConfiguration.cs deleted file mode 100644 index b3f3b36..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/FlightConfiguration.cs +++ /dev/null @@ -1,112 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Flights.ValueObjects; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - - -namespace BookingMonolith.Flight.Data.Configurations; - -[RegisterFlightConfiguration] -public class FlightConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - RelationalEntityTypeBuilderExtensions.ToTable((EntityTypeBuilder)builder, nameof(Flight)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(flight => flight.Value, dbId => FlightId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - - builder.OwnsOne( - x => x.FlightNumber, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flights.Models.Flight.FlightNumber)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder - .HasOne() - .WithMany() - .HasForeignKey(p => p.AircraftId) - .IsRequired(); - - builder - .HasOne() - .WithMany() - .HasForeignKey(d => d.DepartureAirportId) - .IsRequired(); - - builder - .HasOne() - .WithMany() - .HasForeignKey(d => d.ArriveAirportId) - .IsRequired(); - - - builder.OwnsOne( - x => x.DurationMinutes, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flights.Models.Flight.DurationMinutes)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.Property(x => x.Status) - .HasDefaultValue(Flights.Enums.FlightStatus.Unknown) - .HasConversion( - x => x.ToString(), - x => (Flights.Enums.FlightStatus)Enum.Parse(typeof(Flights.Enums.FlightStatus), x)); - - builder.OwnsOne( - x => x.Price, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flights.Models.Flight.Price)) - .HasMaxLength(10) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.ArriveDate, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flights.Models.Flight.ArriveDate)) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.DepartureDate, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flights.Models.Flight.DepartureDate)) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.FlightDate, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flights.Models.Flight.FlightDate)) - .IsRequired(); - } - ); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/SeatConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/SeatConfiguration.cs deleted file mode 100644 index e76ed31..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Configurations/SeatConfiguration.cs +++ /dev/null @@ -1,49 +0,0 @@ -using BookingMonolith.Flight.Seats.Models; -using BookingMonolith.Flight.Seats.ValueObjects; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Flight.Data.Configurations; - -[RegisterFlightConfiguration] -public class SeatConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(Seat)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(seatId => seatId.Value, dbId => SeatId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - builder.OwnsOne( - x => x.SeatNumber, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Seat.SeatNumber)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder - .HasOne() - .WithMany() - .HasForeignKey(p => p.FlightId); - - builder.Property(x => x.Class) - .HasDefaultValue(Seats.Enums.SeatClass.Unknown) - .HasConversion( - x => x.ToString(), - x => (Seats.Enums.SeatClass)Enum.Parse(typeof(Seats.Enums.SeatClass), x)); - - builder.Property(x => x.Type) - .HasDefaultValue(Seats.Enums.SeatType.Unknown) - .HasConversion( - x => x.ToString(), - x => (Seats.Enums.SeatType)Enum.Parse(typeof(Seats.Enums.SeatType), x)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/DesignTimeDbContextFactory.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/DesignTimeDbContextFactory.cs deleted file mode 100644 index 018ec62..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/DesignTimeDbContextFactory.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace BookingMonolith.Flight.Data -{ - public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory - { - public FlightDbContext CreateDbContext(string[] args) - { - var builder = new DbContextOptionsBuilder(); - - builder.UseNpgsql("Server=localhost;Port=5432;Database=booking_monolith;User Id=postgres;Password=postgres;Include Error Detail=true") - .UseSnakeCaseNamingConvention(); - return new FlightDbContext(builder.Options); - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/EfTxFlightBehavior.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/EfTxFlightBehavior.cs deleted file mode 100644 index 44c706b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/EfTxFlightBehavior.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Text.Json; -using System.Transactions; -using BuildingBlocks.Core; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.Polly; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace BookingMonolith.Flight.Data; - -public class EfTxFlightBehavior : IPipelineBehavior -where TRequest : notnull, IRequest -where TResponse : notnull -{ - private readonly ILogger> _logger; - private readonly FlightDbContext _flightDbContext; - private readonly IPersistMessageDbContext _persistMessageDbContext; - private readonly IEventDispatcher _eventDispatcher; - - public EfTxFlightBehavior( - ILogger> logger, - FlightDbContext flightDbContext, - IPersistMessageDbContext persistMessageDbContext, - IEventDispatcher eventDispatcher - ) - { - _logger = logger; - _flightDbContext = flightDbContext; - _persistMessageDbContext = persistMessageDbContext; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle( - TRequest request, - RequestHandlerDelegate next, - CancellationToken cancellationToken - ) - { - _logger.LogInformation( - "{Prefix} Handled command {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - _logger.LogDebug( - "{Prefix} Handled command {MediatrRequest} with content {RequestContent}", - GetType().Name, - typeof(TRequest).FullName, - JsonSerializer.Serialize(request)); - - var response = await next(); - - _logger.LogInformation( - "{Prefix} Executed the {MediatrRequest} request", - GetType().Name, - typeof(TRequest).FullName); - - while (true) - { - var domainEvents = _flightDbContext.GetDomainEvents(); - - if (domainEvents is null || !domainEvents.Any()) - { - return response; - } - - _logger.LogInformation( - "{Prefix} Open the transaction for {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - using var scope = new TransactionScope( - TransactionScopeOption.Required, - new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, - TransactionScopeAsyncFlowOption.Enabled); - - await _eventDispatcher.SendAsync( - domainEvents.ToArray(), - typeof(TRequest), - cancellationToken); - - // Save data to database with some retry policy in distributed transaction - await _flightDbContext.RetryOnFailure( - async () => - { - await _flightDbContext.SaveChangesAsync(cancellationToken); - }); - - // Save data to database with some retry policy in distributed transaction - await _persistMessageDbContext.RetryOnFailure( - async () => - { - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - }); - - scope.Complete(); - - return response; - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/FlightDbContext.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/FlightDbContext.cs deleted file mode 100644 index 811848d..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/FlightDbContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Reflection; -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Seats.Models; -using BuildingBlocks.EFCore; -using BuildingBlocks.Web; -using Humanizer; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; - -namespace BookingMonolith.Flight.Data; - -public sealed class FlightDbContext : AppDbContextBase -{ - public FlightDbContext(DbContextOptions options, ICurrentUserProvider? currentUserProvider = null, - ILogger? logger = null) : base( - options, currentUserProvider, logger) - { - } - - public DbSet Flights => Set(); - public DbSet Airports => Set(); - public DbSet Aircraft => Set(); - public DbSet Seats => Set(); - - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - - var types = typeof(FlightRoot).Assembly.GetTypes() - .Where(t => t.GetCustomAttribute() != null) - .ToList(); - - foreach (var type in types) - { - dynamic configuration = Activator.CreateInstance(type)!; - builder.ApplyConfiguration(configuration); - } - - builder.HasDefaultSchema(nameof(Flight).Underscore()); - builder.FilterSoftDeletedProperties(); - builder.ToSnakeCaseTables(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/FlightReadDbContext.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/FlightReadDbContext.cs deleted file mode 100644 index 2fda15d..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/FlightReadDbContext.cs +++ /dev/null @@ -1,26 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Flights.Models; -using BookingMonolith.Flight.Seats.Models; -using BuildingBlocks.Mongo; -using Humanizer; -using Microsoft.Extensions.Options; -using MongoDB.Driver; - -namespace BookingMonolith.Flight.Data; - -public class FlightReadDbContext : MongoDbContext -{ - public FlightReadDbContext(IOptions options) : base(options) - { - Flight = GetCollection(nameof(Flight).Underscore()); - Aircraft = GetCollection(nameof(Aircraft).Underscore()); - Airport = GetCollection(nameof(Airport).Underscore()); - Seat = GetCollection(nameof(Seat).Underscore()); - } - - public IMongoCollection Flight { get; } - public IMongoCollection Aircraft { get; } - public IMongoCollection Airport { get; } - public IMongoCollection Seat { get; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/20250407215512_initial.Designer.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/20250407215512_initial.Designer.cs deleted file mode 100644 index 0a74e59..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/20250407215512_initial.Designer.cs +++ /dev/null @@ -1,584 +0,0 @@ -// -using System; -using BookingMonolith.Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20250407215512_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("flight") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("BookingMonolith.Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_aircraft"); - - b.ToTable("aircraft", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_airport"); - - b.ToTable("airport", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("aircraft_id"); - - b.Property("ArriveAirportId") - .HasColumnType("uuid") - .HasColumnName("arrive_airport_id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("DepartureAirportId") - .HasColumnType("uuid") - .HasColumnName("departure_airport_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("status"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_flight"); - - b.HasIndex("AircraftId") - .HasDatabaseName("ix_flight_aircraft_id"); - - b.HasIndex("ArriveAirportId") - .HasDatabaseName("ix_flight_arrive_airport_id"); - - b.HasIndex("DepartureAirportId") - .HasDatabaseName("ix_flight_departure_airport_id"); - - b.ToTable("flight", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Class") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("class"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("flight_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Type") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_seat"); - - b.HasIndex("FlightId") - .HasDatabaseName("ix_seat_flight_id"); - - b.ToTable("seat", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Aircrafts.Models.Aircraft", b => - { - b.OwnsOne("BookingMonolith.Flight.Aircrafts.ValueObjects.ManufacturingYear", "ManufacturingYear", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(5) - .HasColumnType("integer") - .HasColumnName("manufacturing_year"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft", "flight"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Aircrafts.ValueObjects.Model", "Model", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("model"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft", "flight"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Aircrafts.ValueObjects.Name", "Name", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft", "flight"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.Navigation("ManufacturingYear") - .IsRequired(); - - b.Navigation("Model") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Airports.Models.Airport", b => - { - b.OwnsOne("BookingMonolith.Flight.Airports.ValueObjects.Address", "Address", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("address"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport", "flight"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Airports.ValueObjects.Code", "Code", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("code"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport", "flight"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Airports.ValueObjects.Name", "Name", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport", "flight"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("Code") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Flights.Models.Flight", b => - { - b.HasOne("BookingMonolith.Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_aircraft_aircraft_id"); - - b.HasOne("BookingMonolith.Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_arrive_airport_id"); - - b.HasOne("BookingMonolith.Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("DepartureAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_departure_airport_id"); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.ArriveDate", "ArriveDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("arrive_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.DepartureDate", "DepartureDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("departure_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.DurationMinutes", "DurationMinutes", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(50) - .HasColumnType("numeric") - .HasColumnName("duration_minutes"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.FlightDate", "FlightDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("flight_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.FlightNumber", "FlightNumber", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("flight_number"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.Price", "Price", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(10) - .HasColumnType("numeric") - .HasColumnName("price"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.Navigation("ArriveDate") - .IsRequired(); - - b.Navigation("DepartureDate") - .IsRequired(); - - b.Navigation("DurationMinutes") - .IsRequired(); - - b.Navigation("FlightDate") - .IsRequired(); - - b.Navigation("FlightNumber") - .IsRequired(); - - b.Navigation("Price") - .IsRequired(); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Seats.Models.Seat", b => - { - b.HasOne("BookingMonolith.Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_seat_flight_flight_id"); - - b.OwnsOne("BookingMonolith.Flight.Seats.ValueObjects.SeatNumber", "SeatNumber", b1 => - { - b1.Property("SeatId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("seat_number"); - - b1.HasKey("SeatId") - .HasName("pk_seat"); - - b1.ToTable("seat", "flight"); - - b1.WithOwner() - .HasForeignKey("SeatId") - .HasConstraintName("fk_seat_seat_id"); - }); - - b.Navigation("SeatNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/20250407215512_initial.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/20250407215512_initial.cs deleted file mode 100644 index b53404a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/20250407215512_initial.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace BookingMonolith.Flight.Data.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "flight"); - - migrationBuilder.CreateTable( - name: "aircraft", - schema: "flight", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - model = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - manufacturing_year = table.Column(type: "integer", maxLength: 5, nullable: false), - created_at = table.Column(type: "timestamp with time zone", nullable: true), - created_by = table.Column(type: "bigint", nullable: true), - last_modified = table.Column(type: "timestamp with time zone", nullable: true), - last_modified_by = table.Column(type: "bigint", nullable: true), - is_deleted = table.Column(type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_aircraft", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "airport", - schema: "flight", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - address = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - created_at = table.Column(type: "timestamp with time zone", nullable: true), - created_by = table.Column(type: "bigint", nullable: true), - last_modified = table.Column(type: "timestamp with time zone", nullable: true), - last_modified_by = table.Column(type: "bigint", nullable: true), - is_deleted = table.Column(type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_airport", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "flight", - schema: "flight", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - flight_number = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - aircraft_id = table.Column(type: "uuid", nullable: false), - departure_airport_id = table.Column(type: "uuid", nullable: false), - arrive_airport_id = table.Column(type: "uuid", nullable: false), - duration_minutes = table.Column(type: "numeric", maxLength: 50, nullable: false), - status = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), - price = table.Column(type: "numeric", maxLength: 10, nullable: false), - arrive_date = table.Column(type: "timestamp with time zone", nullable: false), - departure_date = table.Column(type: "timestamp with time zone", nullable: false), - flight_date = table.Column(type: "timestamp with time zone", nullable: false), - created_at = table.Column(type: "timestamp with time zone", nullable: true), - created_by = table.Column(type: "bigint", nullable: true), - last_modified = table.Column(type: "timestamp with time zone", nullable: true), - last_modified_by = table.Column(type: "bigint", nullable: true), - is_deleted = table.Column(type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_flight", x => x.id); - table.ForeignKey( - name: "fk_flight_aircraft_aircraft_id", - column: x => x.aircraft_id, - principalSchema: "flight", - principalTable: "aircraft", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_flight_airport_arrive_airport_id", - column: x => x.arrive_airport_id, - principalSchema: "flight", - principalTable: "airport", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_flight_airport_departure_airport_id", - column: x => x.departure_airport_id, - principalSchema: "flight", - principalTable: "airport", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "seat", - schema: "flight", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - seat_number = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - type = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), - @class = table.Column(name: "class", type: "text", nullable: false, defaultValue: "Unknown"), - flight_id = table.Column(type: "uuid", nullable: false), - created_at = table.Column(type: "timestamp with time zone", nullable: true), - created_by = table.Column(type: "bigint", nullable: true), - last_modified = table.Column(type: "timestamp with time zone", nullable: true), - last_modified_by = table.Column(type: "bigint", nullable: true), - is_deleted = table.Column(type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_seat", x => x.id); - table.ForeignKey( - name: "fk_seat_flight_flight_id", - column: x => x.flight_id, - principalSchema: "flight", - principalTable: "flight", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_flight_aircraft_id", - schema: "flight", - table: "flight", - column: "aircraft_id"); - - migrationBuilder.CreateIndex( - name: "ix_flight_arrive_airport_id", - schema: "flight", - table: "flight", - column: "arrive_airport_id"); - - migrationBuilder.CreateIndex( - name: "ix_flight_departure_airport_id", - schema: "flight", - table: "flight", - column: "departure_airport_id"); - - migrationBuilder.CreateIndex( - name: "ix_seat_flight_id", - schema: "flight", - table: "seat", - column: "flight_id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "seat", - schema: "flight"); - - migrationBuilder.DropTable( - name: "flight", - schema: "flight"); - - migrationBuilder.DropTable( - name: "aircraft", - schema: "flight"); - - migrationBuilder.DropTable( - name: "airport", - schema: "flight"); - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs deleted file mode 100644 index b17cc3c..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs +++ /dev/null @@ -1,581 +0,0 @@ -// -using System; -using BookingMonolith.Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - partial class FlightDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("flight") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("BookingMonolith.Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_aircraft"); - - b.ToTable("aircraft", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_airport"); - - b.ToTable("airport", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("aircraft_id"); - - b.Property("ArriveAirportId") - .HasColumnType("uuid") - .HasColumnName("arrive_airport_id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("DepartureAirportId") - .HasColumnType("uuid") - .HasColumnName("departure_airport_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("status"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_flight"); - - b.HasIndex("AircraftId") - .HasDatabaseName("ix_flight_aircraft_id"); - - b.HasIndex("ArriveAirportId") - .HasDatabaseName("ix_flight_arrive_airport_id"); - - b.HasIndex("DepartureAirportId") - .HasDatabaseName("ix_flight_departure_airport_id"); - - b.ToTable("flight", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Class") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("class"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("flight_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Type") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_seat"); - - b.HasIndex("FlightId") - .HasDatabaseName("ix_seat_flight_id"); - - b.ToTable("seat", "flight"); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Aircrafts.Models.Aircraft", b => - { - b.OwnsOne("BookingMonolith.Flight.Aircrafts.ValueObjects.ManufacturingYear", "ManufacturingYear", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(5) - .HasColumnType("integer") - .HasColumnName("manufacturing_year"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft", "flight"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Aircrafts.ValueObjects.Model", "Model", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("model"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft", "flight"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Aircrafts.ValueObjects.Name", "Name", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft", "flight"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.Navigation("ManufacturingYear") - .IsRequired(); - - b.Navigation("Model") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Airports.Models.Airport", b => - { - b.OwnsOne("BookingMonolith.Flight.Airports.ValueObjects.Address", "Address", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("address"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport", "flight"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Airports.ValueObjects.Code", "Code", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("code"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport", "flight"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Airports.ValueObjects.Name", "Name", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport", "flight"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("Code") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Flights.Models.Flight", b => - { - b.HasOne("BookingMonolith.Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_aircraft_aircraft_id"); - - b.HasOne("BookingMonolith.Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_arrive_airport_id"); - - b.HasOne("BookingMonolith.Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("DepartureAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_departure_airport_id"); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.ArriveDate", "ArriveDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("arrive_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.DepartureDate", "DepartureDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("departure_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.DurationMinutes", "DurationMinutes", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(50) - .HasColumnType("numeric") - .HasColumnName("duration_minutes"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.FlightDate", "FlightDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("flight_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.FlightNumber", "FlightNumber", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("flight_number"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("BookingMonolith.Flight.Flights.ValueObjects.Price", "Price", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(10) - .HasColumnType("numeric") - .HasColumnName("price"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight", "flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.Navigation("ArriveDate") - .IsRequired(); - - b.Navigation("DepartureDate") - .IsRequired(); - - b.Navigation("DurationMinutes") - .IsRequired(); - - b.Navigation("FlightDate") - .IsRequired(); - - b.Navigation("FlightNumber") - .IsRequired(); - - b.Navigation("Price") - .IsRequired(); - }); - - modelBuilder.Entity("BookingMonolith.Flight.Seats.Models.Seat", b => - { - b.HasOne("BookingMonolith.Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_seat_flight_flight_id"); - - b.OwnsOne("BookingMonolith.Flight.Seats.ValueObjects.SeatNumber", "SeatNumber", b1 => - { - b1.Property("SeatId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("seat_number"); - - b1.HasKey("SeatId") - .HasName("pk_seat"); - - b1.ToTable("seat", "flight"); - - b1.WithOwner() - .HasForeignKey("SeatId") - .HasConstraintName("fk_seat_seat_id"); - }); - - b.Navigation("SeatNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/RegisterFlightConfigurationAttribute.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/RegisterFlightConfigurationAttribute.cs deleted file mode 100644 index d0f4259..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/RegisterFlightConfigurationAttribute.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace BookingMonolith.Flight.Data; - -[AttributeUsage(AttributeTargets.Class)] -public class RegisterFlightConfigurationAttribute : Attribute { } diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Seed/FlightDataSeeder.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Seed/FlightDataSeeder.cs deleted file mode 100644 index 8719bd1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Seed/FlightDataSeeder.cs +++ /dev/null @@ -1,88 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Flights.Models; -using BookingMonolith.Flight.Seats.Models; -using BuildingBlocks.EFCore; -using MapsterMapper; -using Microsoft.EntityFrameworkCore; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Data.Seed; - -public class FlightDataSeeder( - FlightDbContext flightDbContext, - FlightReadDbContext flightReadDbContext, - IMapper mapper -) : IDataSeeder -{ - public async Task SeedAllAsync() - { - var pendingMigrations = await flightDbContext.Database.GetPendingMigrationsAsync(); - - if (!pendingMigrations.Any()) - { - await SeedAirportAsync(); - await SeedAircraftAsync(); - await SeedFlightAsync(); - await SeedSeatAsync(); - } - } - - private async Task SeedAirportAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Airports)) - { - await flightDbContext.Airports.AddRangeAsync(InitialData.Airports); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Airport.AsQueryable())) - { - await flightReadDbContext.Airport.InsertManyAsync(mapper.Map>(InitialData.Airports)); - } - } - } - - private async Task SeedAircraftAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Aircraft)) - { - await flightDbContext.Aircraft.AddRangeAsync(InitialData.Aircrafts); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Aircraft.AsQueryable())) - { - await flightReadDbContext.Aircraft.InsertManyAsync(mapper.Map>(InitialData.Aircrafts)); - } - } - } - - - private async Task SeedSeatAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Seats)) - { - await flightDbContext.Seats.AddRangeAsync(InitialData.Seats); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Seat.AsQueryable())) - { - await flightReadDbContext.Seat.InsertManyAsync(mapper.Map>(InitialData.Seats)); - } - } - } - - private async Task SeedFlightAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Flights)) - { - await flightDbContext.Flights.AddRangeAsync(InitialData.Flights); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Flight.AsQueryable())) - { - await flightReadDbContext.Flight.InsertManyAsync(mapper.Map>(InitialData.Flights)); - } - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Seed/InitialData.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Seed/InitialData.cs deleted file mode 100644 index 9256f81..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/Seed/InitialData.cs +++ /dev/null @@ -1,58 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Models; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using BookingMonolith.Flight.Airports.Models; -using BookingMonolith.Flight.Airports.ValueObjects; -using BookingMonolith.Flight.Flights.ValueObjects; -using BookingMonolith.Flight.Seats.Models; -using BookingMonolith.Flight.Seats.ValueObjects; -using MassTransit; - -namespace BookingMonolith.Flight.Data.Seed; - -using AirportName = Airports.ValueObjects.Name; -using Name = Aircrafts.ValueObjects.Name; - -public static class InitialData -{ - public static List Airports { get; } - public static List Aircrafts { get; } - public static List Seats { get; } - public static List Flights { get; } - - - static InitialData() - { - Airports = new List - { - Airport.Create(AirportId.Of(new Guid("3c5c0000-97c6-fc34-a0cb-08db322230c8")), AirportName.Of("Lisbon International Airport"), Address.Of("LIS"), Code.Of("12988")), - Airport.Create(AirportId.Of(new Guid("3c5c0000-97c6-fc34-fc3c-08db322230c8")), AirportName.Of("Sao Paulo International Airport"), Address.Of("BRZ"), Code.Of("11200")) - }; - - Aircrafts = new List - { - Aircraft.Create(AircraftId.Of(new Guid("3c5c0000-97c6-fc34-fcd3-08db322230c8")), Name.Of("Boeing 737"), Model.Of("B737"), ManufacturingYear.Of(2005)), - Aircraft.Create(AircraftId.Of(new Guid("3c5c0000-97c6-fc34-2e04-08db322230c9")), Name.Of("Airbus 300"), Model.Of("A300"), ManufacturingYear.Of(2000)), - Aircraft.Create(AircraftId.Of(new Guid("3c5c0000-97c6-fc34-2e11-08db322230c9")), Name.Of("Airbus 320"), Model.Of("A320"), ManufacturingYear.Of(2003)) - }; - - - Flights = new List - { - Flight.Flights.Models.Flight.Create(FlightId.Of(new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9")), FlightNumber.Of("BD467"), AircraftId.Of(Aircrafts.First().Id.Value), AirportId.Of( Airports.First().Id), DepartureDate.Of(new DateTime(2022, 1, 31, 12, 0, 0)), - ArriveDate.Of(new DateTime(2022, 1, 31, 14, 0, 0)), - AirportId.Of(Airports.Last().Id), DurationMinutes.Of(120m), - FlightDate.Of(new DateTime(2022, 1, 31, 13, 0, 0)), Flight.Flights.Enums.FlightStatus.Completed, - Price.Of(8000)) - }; - - Seats = new List - { - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of( "12A"),Flight.Seats.Enums.SeatType.Window, Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid)Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12B"), Flight.Seats.Enums.SeatType.Window, Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid)Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12C"), Flight.Seats.Enums.SeatType.Middle, Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12D"), Flight.Seats.Enums.SeatType.Middle, Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12E"), Flight.Seats.Enums.SeatType.Aisle, Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12F"), Flight.Seats.Enums.SeatType.Aisle, Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)) - }; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/readme.md b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/readme.md deleted file mode 100644 index 4b712d3..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Data/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -dotnet ef migrations add initial --context FlightDbContext -o "Flight\Data\Migrations" -dotnet ef database update --context FlightDbContext diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/FlightEventMapper.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/FlightEventMapper.cs deleted file mode 100644 index 911683c..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/FlightEventMapper.cs +++ /dev/null @@ -1,49 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.Features.CreatingAircraft.V1; -using BookingMonolith.Flight.Airports.Features.CreatingAirport.V1; -using BookingMonolith.Flight.Flights.Features.CreatingFlight.V1; -using BookingMonolith.Flight.Flights.Features.DeletingFlight.V1; -using BookingMonolith.Flight.Flights.Features.UpdatingFlight.V1; -using BookingMonolith.Flight.Seats.Features.CreatingSeat.V1; -using BookingMonolith.Flight.Seats.Features.ReservingSeat.V1; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace BookingMonolith.Flight; - -// ref: https://www.ledjonbehluli.com/posts/domain_to_integration_event/ -public sealed class FlightEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - FlightCreatedDomainEvent e => new FlightCreated(e.Id), - FlightUpdatedDomainEvent e => new FlightUpdated(e.Id), - FlightDeletedDomainEvent e => new FlightDeleted(e.Id), - AirportCreatedDomainEvent e => new AirportCreated(e.Id), - AircraftCreatedDomainEvent e => new AircraftCreated(e.Id), - SeatCreatedDomainEvent e => new SeatCreated(e.Id), - SeatReservedDomainEvent e => new SeatReserved(e.Id), - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - FlightCreatedDomainEvent e => new CreateFlightMongo(e.Id, e.FlightNumber, e.AircraftId, e.DepartureDate, e.DepartureAirportId, - e.ArriveDate, e.ArriveAirportId, e.DurationMinutes, e.FlightDate, e.Status, e.Price, e.IsDeleted), - FlightUpdatedDomainEvent e => new UpdateFlightMongo(e.Id, e.FlightNumber, e.AircraftId, e.DepartureDate, e.DepartureAirportId, - e.ArriveDate, e.ArriveAirportId, e.DurationMinutes, e.FlightDate, e.Status, e.Price, e.IsDeleted), - FlightDeletedDomainEvent e => new DeleteFlightMongo(e.Id, e.FlightNumber, e.AircraftId, e.DepartureDate, e.DepartureAirportId, - e.ArriveDate, e.ArriveAirportId, e.DurationMinutes, e.FlightDate, e.Status, e.Price, e.IsDeleted), - AircraftCreatedDomainEvent e => new CreateAircraftMongo(e.Id, e.Name, e.Model, e.ManufacturingYear, e.IsDeleted), - AirportCreatedDomainEvent e => new CreateAirportMongo(e.Id, e.Name, e.Address, e.Code, e.IsDeleted), - SeatCreatedDomainEvent e => new CreateSeatMongo(e.Id, e.SeatNumber, e.Type, e.Class, e.FlightId, e.IsDeleted), - SeatReservedDomainEvent e => new ReserveSeatMongo(e.Id, e.SeatNumber, e.Type, e.Class, e.FlightId, e.IsDeleted), - _ => null - }; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/FlightRoot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/FlightRoot.cs deleted file mode 100644 index 634dfb0..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/FlightRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BookingMonolith.Flight; - -public class FlightRoot -{ - -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Dtos/FlightDto.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Dtos/FlightDto.cs deleted file mode 100644 index 7538556..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Dtos/FlightDto.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace BookingMonolith.Flight.Flights.Dtos; -public record FlightDto(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price); diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Enums/FlightStatus.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Enums/FlightStatus.cs deleted file mode 100644 index 1a80693..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Enums/FlightStatus.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace BookingMonolith.Flight.Flights.Enums; - -public enum FlightStatus -{ - Unknown = 0, - Flying = 1, - Delay = 2, - Canceled = 3, - Completed = 4 -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs deleted file mode 100644 index fd3cba1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class FlightAlreadyExistException : AppException -{ - public FlightAlreadyExistException(int? code = default) : base("Flight already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/FlightNotFountException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/FlightNotFountException.cs deleted file mode 100644 index 5e01d30..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/FlightNotFountException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class FlightNotFountException : AppException -{ - public FlightNotFountException() : base("Flight not found!", HttpStatusCode.NotFound) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs deleted file mode 100644 index 34d7b2e..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidArriveDateException : DomainException -{ - public InvalidArriveDateException(DateTime arriveDate) - : base($"Arrive Date: '{arriveDate}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs deleted file mode 100644 index 05d1fd4..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidDepartureDateException : DomainException -{ - public InvalidDepartureDateException(DateTime departureDate) - : base($"Departure Date: '{departureDate}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidDurationException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidDurationException.cs deleted file mode 100644 index 65fc2f9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidDurationException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidDurationException : DomainException -{ - public InvalidDurationException() - : base("Duration cannot be negative.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs deleted file mode 100644 index 4bd659a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidFlightDateException : DomainException -{ - public InvalidFlightDateException(DateTime flightDate) - : base($"Flight Date: '{flightDate}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs deleted file mode 100644 index fb9412b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidFlightIdException : DomainException -{ - public InvalidFlightIdException(Guid flightId) - : base($"flightId: '{flightId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs deleted file mode 100644 index 4f18b19..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidFlightNumberException : DomainException -{ - public InvalidFlightNumberException(string flightNumber) - : base($"Flight Number: '{flightNumber}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidPriceException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidPriceException.cs deleted file mode 100644 index 366a71d..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Exceptions/InvalidPriceException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Flights.Exceptions; - -public class InvalidPriceException : DomainException -{ - public InvalidPriceException() - : base($"Price Cannot be negative.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs deleted file mode 100644 index 33968a1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs +++ /dev/null @@ -1,124 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using BookingMonolith.Flight.Airports.ValueObjects; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Exceptions; -using BookingMonolith.Flight.Flights.ValueObjects; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Flights.Features.CreatingFlight.V1; - -public record CreateFlight(string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, - decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, - decimal Price) : ICommand, IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateFlightResult(Guid Id); - -public record FlightCreatedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, - DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent; - -public record CreateFlightRequestDto(string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, - decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price); - -public record CreateFlightResponseDto(Guid Id); - -public class CreateFlightEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight", async (CreateFlightRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.CreatedAtRoute("GetFlightById", new { id = result.Id }, response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateFlight") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces(StatusCodes.Status201Created) - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Flight") - .WithDescription("Create Flight") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateFlightValidator : AbstractValidator -{ - public CreateFlightValidator() - { - RuleFor(x => x.Price).GreaterThan(0).WithMessage("Price must be greater than 0"); - - RuleFor(x => x.Status).Must(p => (p.GetType().IsEnum && - p == Enums.FlightStatus.Flying) || - p == Enums.FlightStatus.Canceled || - p == Enums.FlightStatus.Delay || - p == Enums.FlightStatus.Completed) - .WithMessage("Status must be Flying, Delay, Canceled or Completed"); - - RuleFor(x => x.AircraftId).NotEmpty().WithMessage("AircraftId must be not empty"); - RuleFor(x => x.DepartureAirportId).NotEmpty().WithMessage("DepartureAirportId must be not empty"); - RuleFor(x => x.ArriveAirportId).NotEmpty().WithMessage("ArriveAirportId must be not empty"); - RuleFor(x => x.DurationMinutes).GreaterThan(0).WithMessage("DurationMinutes must be greater than 0"); - RuleFor(x => x.FlightDate).NotEmpty().WithMessage("FlightDate must be not empty"); - } -} - -internal class CreateFlightHandler : ICommandHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateFlightHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateFlight request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == request.Id, - cancellationToken); - - if (flight is not null) - { - throw new FlightAlreadyExistException(); - } - - var flightEntity = Models.Flight.Create(FlightId.Of(request.Id), FlightNumber.Of(request.FlightNumber), AircraftId.Of(request.AircraftId), - AirportId.Of(request.DepartureAirportId), DepartureDate.Of(request.DepartureDate), - ArriveDate.Of(request.ArriveDate), AirportId.Of(request.ArriveAirportId), DurationMinutes.Of(request.DurationMinutes), FlightDate.Of(request.FlightDate), request.Status, - Price.Of(request.Price)); - - var newFlight = (await _flightDbContext.Flights.AddAsync(flightEntity, cancellationToken)).Entity; - - return new CreateFlightResult(newFlight.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs deleted file mode 100644 index cb1c707..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Exceptions; -using BookingMonolith.Flight.Flights.Models; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Flights.Features.CreatingFlight.V1; - -public record CreateFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price, bool IsDeleted = false) : InternalCommand; - -internal class CreateFlightMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateFlightMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateFlightMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flightReadModel = _mapper.Map(request); - - var flight = await _flightReadDbContext.Flight.AsQueryable() - .FirstOrDefaultAsync(x => x.FlightId == flightReadModel.FlightId && !x.IsDeleted, cancellationToken); - - if (flight is not null) - { - throw new FlightAlreadyExistException(); - } - - await _flightReadDbContext.Flight.InsertOneAsync(flightReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs deleted file mode 100644 index 1ef3177..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Exceptions; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Flights.Features.DeletingFlight.V1; - -public record DeleteFlight(Guid Id) : ICommand, IInternalCommand; - -public record DeleteFlightResult(Guid Id); - -public record FlightDeletedDomainEvent( - Guid Id, - string FlightNumber, - Guid AircraftId, - DateTime DepartureDate, - Guid DepartureAirportId, - DateTime ArriveDate, - Guid ArriveAirportId, - decimal DurationMinutes, - DateTime FlightDate, - Enums.FlightStatus Status, - decimal Price, - bool IsDeleted -) : IDomainEvent; - -public class DeleteFlightEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapDelete( - $"{EndpointConfig.BaseApiPath}/flight/{{id}}", - async (Guid id, IMediator mediator, CancellationToken cancellationToken) => - { - await mediator.Send(new DeleteFlight(id), cancellationToken); - - return Results.NoContent(); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("DeleteFlight") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces(StatusCodes.Status204NoContent) - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Delete Flight") - .WithDescription("Delete Flight") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class DeleteFlightValidator : AbstractValidator -{ - public DeleteFlightValidator() - { - RuleFor(x => x.Id).NotEmpty(); - } -} - -internal class DeleteFlightHandler : ICommandHandler -{ - private readonly FlightDbContext _flightDbContext; - - public DeleteFlightHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle( - DeleteFlight request, - CancellationToken cancellationToken - ) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == request.Id, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - flight.Delete( - flight.Id, - flight.FlightNumber, - flight.AircraftId, - flight.DepartureAirportId, - flight.DepartureDate, - flight.ArriveDate, - flight.ArriveAirportId, - flight.DurationMinutes, - flight.FlightDate, - flight.Status, - flight.Price); - - var deleteFlight = _flightDbContext.Flights.Update(flight).Entity; - - return new DeleteFlightResult(deleteFlight.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs deleted file mode 100644 index c90b49b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Exceptions; -using BookingMonolith.Flight.Flights.Models; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Flights.Features.DeletingFlight.V1; - -public record DeleteFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price, bool IsDeleted = false) : InternalCommand; - -internal class DeleteFlightMongoCommandHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public DeleteFlightMongoCommandHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(DeleteFlightMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flightReadModel = _mapper.Map(request); - - var flight = await _flightReadDbContext.Flight.AsQueryable() - .FirstOrDefaultAsync(x => x.FlightId == flightReadModel.FlightId && !x.IsDeleted, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - await _flightReadDbContext.Flight.UpdateOneAsync( - x => x.FlightId == flightReadModel.FlightId, - Builders.Update - .Set(x => x.IsDeleted, flightReadModel.IsDeleted), - cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/FlightMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/FlightMappings.cs deleted file mode 100644 index ae2b844..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/FlightMappings.cs +++ /dev/null @@ -1,47 +0,0 @@ -using BookingMonolith.Flight.Flights.Features.CreatingFlight.V1; -using BookingMonolith.Flight.Flights.Features.DeletingFlight.V1; -using BookingMonolith.Flight.Flights.Features.UpdatingFlight.V1; -using BookingMonolith.Flight.Flights.Models; -using Mapster; -using MassTransit; - -namespace BookingMonolith.Flight.Flights.Features; - -using FlightDto = Dtos.FlightDto; - -public class FlightMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .ConstructUsing(x => new FlightDto(x.Id, x.FlightNumber, x.AircraftId, x.DepartureAirportId, - x.DepartureDate, - x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.Price)); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.FlightId, s => s.Id); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.FlightId, s => s.Id.Value); - - config.NewConfig() - .Map(d => d.Id, s => s.FlightId); - - config.NewConfig() - .Map(d => d.FlightId, s => s.Id); - - config.NewConfig() - .Map(d => d.FlightId, s => s.Id); - - config.NewConfig() - .ConstructUsing(x => new CreateFlight(x.FlightNumber, x.AircraftId, x.DepartureAirportId, - x.DepartureDate, x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.Price)); - - config.NewConfig() - .ConstructUsing(x => new UpdateFlight(x.Id, x.FlightNumber, x.AircraftId, x.DepartureAirportId, x.DepartureDate, - x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.IsDeleted, x.Price)); - - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs deleted file mode 100644 index 2a3824b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs +++ /dev/null @@ -1,85 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Dtos; -using BookingMonolith.Flight.Flights.Exceptions; -using BuildingBlocks.Caching; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Flights.Features.GettingAvailableFlights.V1; - -public record GetAvailableFlights : IQuery, ICacheRequest -{ - public string CacheKey => "GetAvailableFlights"; - public DateTime? AbsoluteExpirationRelativeToNow => DateTime.Now.AddHours(1); -} - -public record GetAvailableFlightsResult(IEnumerable FlightDtos); - -public record GetAvailableFlightsResponseDto(IEnumerable FlightDtos); - -public class GetAvailableFlightsEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/flight/get-available-flights", - async (IMediator mediator, CancellationToken cancellationToken) => - { - var result = await mediator.Send(new GetAvailableFlights(), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetAvailableFlights") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Available Flights") - .WithDescription("Get Available Flights") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -internal class GetAvailableFlightsHandler : IQueryHandler -{ - private readonly IMapper _mapper; - private readonly FlightReadDbContext _flightReadDbContext; - - public GetAvailableFlightsHandler(IMapper mapper, FlightReadDbContext flightReadDbContext) - { - _mapper = mapper; - _flightReadDbContext = flightReadDbContext; - } - - public async Task Handle(GetAvailableFlights request, - CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = (await _flightReadDbContext.Flight.AsQueryable().ToListAsync(cancellationToken)) - .Where(x => !x.IsDeleted); - - if (!flight.Any()) - { - throw new FlightNotFountException(); - } - - var flightDtos = _mapper.Map>(flight); - - return new GetAvailableFlightsResult(flightDtos); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs deleted file mode 100644 index a77ef7b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Dtos; -using BookingMonolith.Flight.Flights.Exceptions; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Flights.Features.GettingFlightById.V1; - -public record GetFlightById(Guid Id) : IQuery; - -public record GetFlightByIdResult(FlightDto FlightDto); - -public record GetFlightByIdResponseDto(FlightDto FlightDto); - -public class GetFlightByIdEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/flight/{{id}}", - async (Guid id, IMediator mediator, IMapper mapper, CancellationToken cancellationToken) => - { - var result = await mediator.Send(new GetFlightById(id), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetFlightById") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Flight By Id") - .WithDescription("Get Flight By Id") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class GetFlightByIdValidator : AbstractValidator -{ - public GetFlightByIdValidator() - { - RuleFor(x => x.Id).NotNull().WithMessage("Id is required!"); - } -} - -internal class GetFlightByIdHandler : IQueryHandler -{ - private readonly IMapper _mapper; - private readonly FlightReadDbContext _flightReadDbContext; - - public GetFlightByIdHandler(IMapper mapper, FlightReadDbContext flightReadDbContext) - { - _mapper = mapper; - _flightReadDbContext = flightReadDbContext; - } - - public async Task Handle(GetFlightById request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightReadDbContext.Flight.AsQueryable().SingleOrDefaultAsync( - x => x.FlightId == request.Id && - !x.IsDeleted, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - var flightDto = _mapper.Map(flight); - - return new GetFlightByIdResult(flightDto); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs deleted file mode 100644 index b432979..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs +++ /dev/null @@ -1,122 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using BookingMonolith.Flight.Airports.ValueObjects; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Exceptions; -using BookingMonolith.Flight.Flights.Features.CreatingFlight.V1; -using BookingMonolith.Flight.Flights.ValueObjects; -using BuildingBlocks.Caching; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Flights.Features.UpdatingFlight.V1; - -public record UpdateFlight(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, bool IsDeleted, decimal Price) : ICommand, IInternalCommand, - IInvalidateCacheRequest -{ - public string CacheKey => "GetAvailableFlights"; -} - -public record UpdateFlightResult(Guid Id); - -public record FlightUpdatedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, - DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent; - -public record UpdateFlightRequestDto(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, - Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price, - bool IsDeleted); - -public class UpdateFlightEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPut($"{EndpointConfig.BaseApiPath}/flight", async (UpdateFlightRequestDto request, - IMediator mediator, - IMapper mapper, CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - await mediator.Send(command, cancellationToken); - - return Results.NoContent(); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("UpdateFlight") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces(StatusCodes.Status204NoContent) - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Update Flight") - .WithDescription("Update Flight") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class UpdateFlightValidator : AbstractValidator -{ - public UpdateFlightValidator() - { - RuleFor(x => x.Price).GreaterThan(0).WithMessage("Price must be greater than 0"); - - RuleFor(x => x.Status).Must(p => (p.GetType().IsEnum && - p == Enums.FlightStatus.Flying) || - p == Enums.FlightStatus.Canceled || - p == Enums.FlightStatus.Delay || - p == Enums.FlightStatus.Completed) - .WithMessage("Status must be Flying, Delay, Canceled or Completed"); - - RuleFor(x => x.AircraftId).NotEmpty().WithMessage("AircraftId must be not empty"); - RuleFor(x => x.DepartureAirportId).NotEmpty().WithMessage("DepartureAirportId must be not empty"); - RuleFor(x => x.ArriveAirportId).NotEmpty().WithMessage("ArriveAirportId must be not empty"); - RuleFor(x => x.DurationMinutes).GreaterThan(0).WithMessage("DurationMinutes must be greater than 0"); - RuleFor(x => x.FlightDate).NotEmpty().WithMessage("FlightDate must be not empty"); - } -} - -internal class UpdateFlightHandler : ICommandHandler -{ - private readonly FlightDbContext _flightDbContext; - - public UpdateFlightHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(UpdateFlight request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == request.Id, - cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - - flight.Update(FlightId.Of(request.Id), FlightNumber.Of(request.FlightNumber), AircraftId.Of(request.AircraftId), AirportId.Of(request.DepartureAirportId), - DepartureDate.Of(request.DepartureDate), - ArriveDate.Of(request.ArriveDate), AirportId.Of(request.ArriveAirportId), DurationMinutes.Of(request.DurationMinutes), FlightDate.Of(request.FlightDate), request.Status, - Price.Of(request.Price), request.IsDeleted); - - var updateFlight = _flightDbContext.Flights.Update(flight).Entity; - - return new UpdateFlightResult(updateFlight.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs deleted file mode 100644 index 841e20a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.Exceptions; -using BookingMonolith.Flight.Flights.Models; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Flights.Features.UpdatingFlight.V1; - -public record UpdateFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price, bool IsDeleted = false) : InternalCommand; - - -internal class UpdateFlightMongoCommandHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public UpdateFlightMongoCommandHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(UpdateFlightMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flightReadModel = _mapper.Map(request); - - var flight = await _flightReadDbContext.Flight.AsQueryable() - .FirstOrDefaultAsync(x => x.FlightId == flightReadModel.FlightId && !x.IsDeleted, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - await _flightReadDbContext.Flight.UpdateOneAsync( - x => x.FlightId == flightReadModel.FlightId, - Builders.Update - .Set(x => x.Price, flightReadModel.Price) - .Set(x => x.ArriveDate, flightReadModel.ArriveDate) - .Set(x => x.AircraftId, flightReadModel.AircraftId) - .Set(x => x.DurationMinutes, flightReadModel.DurationMinutes) - .Set(x => x.DepartureDate, flightReadModel.DepartureDate) - .Set(x => x.FlightDate, flightReadModel.FlightDate) - .Set(x => x.FlightNumber, flightReadModel.FlightNumber) - .Set(x => x.IsDeleted, flightReadModel.IsDeleted) - .Set(x => x.Status, flightReadModel.Status) - .Set(x => x.ArriveAirportId, flightReadModel.ArriveAirportId) - .Set(x => x.DepartureAirportId, flightReadModel.DepartureAirportId), - cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Models/Flight.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Models/Flight.cs deleted file mode 100644 index 10f3c79..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Models/Flight.cs +++ /dev/null @@ -1,101 +0,0 @@ -using BookingMonolith.Flight.Aircrafts.ValueObjects; -using BookingMonolith.Flight.Airports.ValueObjects; -using BookingMonolith.Flight.Flights.Features.CreatingFlight.V1; -using BookingMonolith.Flight.Flights.Features.DeletingFlight.V1; -using BookingMonolith.Flight.Flights.Features.UpdatingFlight.V1; -using BookingMonolith.Flight.Flights.ValueObjects; -using BuildingBlocks.Core.Model; - -namespace BookingMonolith.Flight.Flights.Models; - -public record Flight : Aggregate -{ - public FlightNumber FlightNumber { get; private set; } = default!; - public AircraftId AircraftId { get; private set; } = default!; - public AirportId DepartureAirportId { get; private set; } = default!; - public AirportId ArriveAirportId { get; private set; } = default!; - public DurationMinutes DurationMinutes { get; private set; } = default!; - public Enums.FlightStatus Status { get; private set; } - public Price Price { get; private set; } = default!; - public ArriveDate ArriveDate { get; private set; } = default!; - public DepartureDate DepartureDate { get; private set; } = default!; - public FlightDate FlightDate { get; private set; } = default!; - - public static Flight Create(FlightId id, FlightNumber flightNumber, AircraftId aircraftId, - AirportId departureAirportId, DepartureDate departureDate, ArriveDate arriveDate, - AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status, - Price price, bool isDeleted = false) - { - var flight = new Flight - { - Id = id, - FlightNumber = flightNumber, - AircraftId = aircraftId, - DepartureAirportId = departureAirportId, - DepartureDate = departureDate, - ArriveDate = arriveDate, - ArriveAirportId = arriveAirportId, - DurationMinutes = durationMinutes, - FlightDate = flightDate, - Status = status, - Price = price, - IsDeleted = isDeleted, - }; - - var @event = new FlightCreatedDomainEvent(flight.Id, flight.FlightNumber, flight.AircraftId, - flight.DepartureDate, flight.DepartureAirportId, - flight.ArriveDate, flight.ArriveAirportId, flight.DurationMinutes, flight.FlightDate, flight.Status, - flight.Price, flight.IsDeleted); - - flight.AddDomainEvent(@event); - - return flight; - } - - - public void Update(FlightId id, FlightNumber flightNumber, AircraftId aircraftId, - AirportId departureAirportId, DepartureDate departureDate, ArriveDate arriveDate, - AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status, - Price price, bool isDeleted = false) - { - this.FlightNumber = flightNumber; - this.AircraftId = aircraftId; - this.DepartureAirportId = departureAirportId; - this.DepartureDate = departureDate; - this.ArriveDate = arriveDate; - this.ArriveAirportId = arriveAirportId; - this.DurationMinutes = durationMinutes; - this.FlightDate = flightDate; - this.Status = status; - this.Price = price; - this.IsDeleted = isDeleted; - - var @event = new FlightUpdatedDomainEvent(id, flightNumber, aircraftId, departureDate, departureAirportId, - arriveDate, arriveAirportId, durationMinutes, flightDate, status, price, isDeleted); - - AddDomainEvent(@event); - } - - public void Delete(FlightId id, FlightNumber flightNumber, AircraftId aircraftId, - AirportId departureAirportId, DepartureDate departureDate, ArriveDate arriveDate, - AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status, - Price price, bool isDeleted = true) - { - FlightNumber = flightNumber; - AircraftId = aircraftId; - DepartureAirportId = departureAirportId; - DepartureDate = departureDate; - ArriveDate = arriveDate; - ArriveAirportId = arriveAirportId; - DurationMinutes = durationMinutes; - FlightDate = flightDate; - Status = status; - Price = price; - IsDeleted = isDeleted; - - var @event = new FlightDeletedDomainEvent(id, flightNumber, aircraftId, departureDate, departureAirportId, - arriveDate, arriveAirportId, durationMinutes, flightDate, status, price, isDeleted); - - AddDomainEvent(@event); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Models/FlightReadModel.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Models/FlightReadModel.cs deleted file mode 100644 index 98a2a4a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/Models/FlightReadModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace BookingMonolith.Flight.Flights.Models; - -public class FlightReadModel -{ - public required Guid Id { get; init; } - public required Guid FlightId { get; init; } - public required string FlightNumber { get; init; } - public required Guid AircraftId { get; init; } - public required DateTime DepartureDate { get; init; } - public required Guid DepartureAirportId { get; init; } - public required DateTime ArriveDate { get; init; } - public required Guid ArriveAirportId { get; init; } - public required decimal DurationMinutes { get; init; } - public required DateTime FlightDate { get; init; } - public required Enums.FlightStatus Status { get; init; } - public required decimal Price { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/ArriveDate.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/ArriveDate.cs deleted file mode 100644 index 805ff36..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/ArriveDate.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public record ArriveDate -{ - public DateTime Value { get; } - - private ArriveDate(DateTime value) - { - Value = value; - } - - public static ArriveDate Of(DateTime value) - { - if (value == default) - { - throw new InvalidArriveDateException(value); - } - - return new ArriveDate(value); - } - - public static implicit operator DateTime(ArriveDate arriveDate) - { - return arriveDate.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/DepartureDate.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/DepartureDate.cs deleted file mode 100644 index 891dc96..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/DepartureDate.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public record DepartureDate -{ - public DateTime Value { get; } - - private DepartureDate(DateTime value) - { - Value = value; - } - - public static DepartureDate Of(DateTime value) - { - if (value == default) - { - throw new InvalidDepartureDateException(value); - } - - return new DepartureDate(value); - } - - public static implicit operator DateTime(DepartureDate departureDate) - { - return departureDate.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/DurationMinutes.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/DurationMinutes.cs deleted file mode 100644 index 97a00e8..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/DurationMinutes.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public class DurationMinutes -{ - public decimal Value { get; } - - private DurationMinutes(decimal value) - { - Value = value; - } - - public static DurationMinutes Of(decimal value) - { - if (value < 0) - { - throw new InvalidDurationException(); - } - - return new DurationMinutes(value); - } - - public static implicit operator decimal(DurationMinutes duration) - { - return duration.Value; - } - - public static explicit operator DurationMinutes(decimal value) - { - return new DurationMinutes(value); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightDate.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightDate.cs deleted file mode 100644 index 35f15c9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightDate.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public record FlightDate -{ - public DateTime Value { get; } - - private FlightDate(DateTime value) - { - Value = value; - } - - public static FlightDate Of(DateTime value) - { - if (value == default) - { - throw new InvalidFlightDateException(value); - } - - return new FlightDate(value); - } - - public static implicit operator DateTime(FlightDate flightDate) - { - return flightDate.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightId.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightId.cs deleted file mode 100644 index 35d74a0..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightId.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public record FlightId -{ - public Guid Value { get; } - - private FlightId(Guid value) - { - Value = value; - } - - public static FlightId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidFlightIdException(value); - } - - return new FlightId(value); - } - - public static implicit operator Guid(FlightId flightId) - { - return flightId.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightNumber.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightNumber.cs deleted file mode 100644 index 25a751d..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/FlightNumber.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public record FlightNumber -{ - public string Value { get; } - - private FlightNumber(string value) - { - Value = value; - } - - public static FlightNumber Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidFlightNumberException(value); - } - - return new FlightNumber(value); - } - - public static implicit operator string(FlightNumber flightNumber) - { - return flightNumber.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/Price.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/Price.cs deleted file mode 100644 index 6229a20..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Flights/ValueObjects/Price.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Flights.Exceptions; - -namespace BookingMonolith.Flight.Flights.ValueObjects; - -public class Price -{ - public decimal Value { get; } - - private Price(decimal value) - { - Value = value; - } - - public static Price Of(decimal value) - { - if (value < 0) - { - throw new InvalidPriceException(); - } - - return new Price(value); - } - - public static implicit operator decimal(Price price) - { - return price.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Dtos/SeatDto.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Dtos/SeatDto.cs deleted file mode 100644 index 00f0c1f..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Dtos/SeatDto.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace BookingMonolith.Flight.Seats.Dtos; - -public record SeatDto(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId); diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Enums/SeatClass.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Enums/SeatClass.cs deleted file mode 100644 index b1498b1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Enums/SeatClass.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BookingMonolith.Flight.Seats.Enums; - -public enum SeatClass -{ - Unknown = 0, - FirstClass, - Business, - Economy -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Enums/SeatType.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Enums/SeatType.cs deleted file mode 100644 index c0adabe..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Enums/SeatType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BookingMonolith.Flight.Seats.Enums; - -public enum SeatType -{ - Unknown = 0, - Window, - Middle, - Aisle -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/AllSeatsFullException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/AllSeatsFullException.cs deleted file mode 100644 index 360a70d..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/AllSeatsFullException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Seats.Exceptions; - -public class AllSeatsFullException : AppException -{ - public AllSeatsFullException() : base("All seats are full!") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs deleted file mode 100644 index 66ec831..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Seats.Exceptions; - -public class InvalidSeatIdException : DomainException -{ - public InvalidSeatIdException(Guid seatId) - : base($"seatId: '{seatId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs deleted file mode 100644 index 4835e8b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Flight.Seats.Exceptions; - -public class InvalidSeatNumberException : DomainException -{ - public InvalidSeatNumberException() : base("SeatNumber Cannot be null or negative") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs deleted file mode 100644 index 157ba25..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Seats.Exceptions; - -public class SeatAlreadyExistException : AppException -{ - public SeatAlreadyExistException(int? code = default) : base("Seat already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs deleted file mode 100644 index 3a5743f..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using BuildingBlocks.Exception; - -namespace BookingMonolith.Flight.Seats.Exceptions; - -public class SeatNumberIncorrectException : AppException -{ - public SeatNumberIncorrectException() : base("Seat number is incorrect!") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs deleted file mode 100644 index 8cd7878..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Flights.ValueObjects; -using BookingMonolith.Flight.Seats.Exceptions; -using BookingMonolith.Flight.Seats.Models; -using BookingMonolith.Flight.Seats.ValueObjects; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Seats.Features.CreatingSeat.V1; - -public record CreateSeat - (string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId) : ICommand, - IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateSeatResult(Guid Id); - -public record SeatCreatedDomainEvent(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, - Guid FlightId, bool IsDeleted) : IDomainEvent; - -public record CreateSeatRequestDto(string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId); - -public record CreateSeatResponseDto(Guid Id); - -public class CreateSeatEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/seat", CreateSeat) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateSeat") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Seat") - .WithDescription("Create Seat") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } - - private async Task CreateSeat(CreateSeatRequestDto request, IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - } -} - -public class CreateSeatValidator : AbstractValidator -{ - public CreateSeatValidator() - { - RuleFor(x => x.SeatNumber).NotEmpty().WithMessage("SeatNumber is required"); - RuleFor(x => x.FlightId).NotEmpty().WithMessage("FlightId is required"); - RuleFor(x => x.Class).Must(p => (p.GetType().IsEnum && - p == Enums.SeatClass.FirstClass) || - p == Enums.SeatClass.Business || - p == Enums.SeatClass.Economy) - .WithMessage("Status must be FirstClass, Business or Economy"); - } -} - -internal class CreateSeatCommandHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateSeatCommandHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateSeat command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.Id == command.Id, cancellationToken); - - if (seat is not null) - { - throw new SeatAlreadyExistException(); - } - - var seatEntity = Seat.Create(SeatId.Of(command.Id), SeatNumber.Of(command.SeatNumber), command.Type, command.Class, FlightId.Of(command.FlightId)); - - var newSeat = (await _flightDbContext.Seats.AddAsync(seatEntity, cancellationToken)).Entity; - - return new CreateSeatResult(newSeat.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs deleted file mode 100644 index 7bcbfed..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Seats.Exceptions; -using BookingMonolith.Flight.Seats.Models; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Seats.Features.CreatingSeat.V1; - -public record CreateSeatMongo(Guid Id, string SeatNumber, Enums.SeatType Type, - Enums.SeatClass Class, Guid FlightId, bool IsDeleted = false) : InternalCommand; - -internal class CreateSeatMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateSeatMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateSeatMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var seatReadModel = _mapper.Map(request); - - var seat = await _flightReadDbContext.Seat.AsQueryable() - .FirstOrDefaultAsync(x => x.SeatId == seatReadModel.SeatId && - !x.IsDeleted, cancellationToken); - - if (seat is not null) - { - throw new SeatAlreadyExistException(); - } - - await _flightReadDbContext.Seat.InsertOneAsync(seatReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs deleted file mode 100644 index 65b3608..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Seats.Dtos; -using BookingMonolith.Flight.Seats.Exceptions; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Flight.Seats.Features.GettingAvailableSeats.V1; - -public record GetAvailableSeats(Guid FlightId) : IQuery; - -public record GetAvailableSeatsResult(IEnumerable SeatDtos); - -public record GetAvailableSeatsResponseDto(IEnumerable SeatDtos); - -public class GetAvailableSeatsEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/flight/get-available-seats/{{id}}", GetAvailableSeats) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetAvailableSeats") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Available Seats") - .WithDescription("Get Available Seats") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } - - private async Task GetAvailableSeats(Guid id, IMediator mediator, CancellationToken cancellationToken) - { - var result = await mediator.Send(new GetAvailableSeats(id), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - } -} - -public class GetAvailableSeatsValidator : AbstractValidator -{ - public GetAvailableSeatsValidator() - { - RuleFor(x => x.FlightId).NotNull().WithMessage("FlightId is required!"); - } -} - -internal class GetAvailableSeatsQueryHandler : IRequestHandler -{ - private readonly IMapper _mapper; - private readonly FlightReadDbContext _flightReadDbContext; - - public GetAvailableSeatsQueryHandler(IMapper mapper, FlightReadDbContext flightReadDbContext) - { - _mapper = mapper; - _flightReadDbContext = flightReadDbContext; - } - - - public async Task Handle(GetAvailableSeats query, CancellationToken cancellationToken) - { - Guard.Against.Null(query, nameof(query)); - - var seats = (await _flightReadDbContext.Seat.AsQueryable().ToListAsync(cancellationToken)) - .Where(x => x.FlightId == query.FlightId && !x.IsDeleted); - - if (!seats.Any()) - { - throw new AllSeatsFullException(); - } - - var seatDtos = _mapper.Map>(seats); - - return new GetAvailableSeatsResult(seatDtos); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs deleted file mode 100644 index 6e57e61..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs +++ /dev/null @@ -1,98 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Seats.Exceptions; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Flight.Seats.Features.ReservingSeat.V1; - -public record ReserveSeat(Guid FlightId, string SeatNumber) : ICommand, IInternalCommand; - -public record ReserveSeatResult(Guid Id); - -public record SeatReservedDomainEvent(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, - Guid FlightId, bool IsDeleted) : IDomainEvent; - -public record ReserveSeatRequestDto(Guid FlightId, string SeatNumber); - -public record ReserveSeatResponseDto(Guid Id); - -public class ReserveSeatEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/reserve-seat", ReserveSeat) - .RequireAuthorization(nameof(ApiScope)) - .WithName("ReserveSeat") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Reserve Seat") - .WithDescription("Reserve Seat") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } - - private async Task ReserveSeat(ReserveSeatRequestDto request, IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - } -} - -public class ReserveSeatValidator : AbstractValidator -{ - public ReserveSeatValidator() - { - RuleFor(x => x.FlightId).NotEmpty().WithMessage("FlightId must not be empty"); - RuleFor(x => x.SeatNumber).NotEmpty().WithMessage("SeatNumber must not be empty"); - } -} - -internal class ReserveSeatCommandHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public ReserveSeatCommandHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(ReserveSeat command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var seat = await _flightDbContext.Seats.SingleOrDefaultAsync( - x => x.SeatNumber.Value == command.SeatNumber && - x.FlightId == command.FlightId, cancellationToken); - - if (seat is null) - { - throw new SeatNumberIncorrectException(); - } - - seat.ReserveSeat(); - - var updatedSeat = _flightDbContext.Seats.Update(seat).Entity; - - return new ReserveSeatResult(updatedSeat.Id); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs deleted file mode 100644 index 09c7cb9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Flight.Data; -using BookingMonolith.Flight.Seats.Models; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; - -namespace BookingMonolith.Flight.Seats.Features.ReservingSeat.V1; - -public record ReserveSeatMongo(Guid Id, string SeatNumber, Enums.SeatType Type, - Enums.SeatClass Class, Guid FlightId, bool IsDeleted = false) : InternalCommand; - -internal class ReserveSeatMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public ReserveSeatMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(ReserveSeatMongo command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var seatReadModel = _mapper.Map(command); - - await _flightReadDbContext.Seat.UpdateOneAsync( - x => x.SeatId == seatReadModel.SeatId, - Builders.Update - .Set(x => x.IsDeleted, seatReadModel.IsDeleted), - cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/SeatMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/SeatMappings.cs deleted file mode 100644 index 4d23097..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Features/SeatMappings.cs +++ /dev/null @@ -1,34 +0,0 @@ -using BookingMonolith.Flight.Seats.Dtos; -using BookingMonolith.Flight.Seats.Features.CreatingSeat.V1; -using BookingMonolith.Flight.Seats.Features.ReservingSeat.V1; -using BookingMonolith.Flight.Seats.Models; -using Mapster; -using MassTransit; - -namespace BookingMonolith.Flight.Seats.Features; - -public class SeatMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .ConstructUsing(x => new SeatDto(x.Id.Value, x.SeatNumber.Value, x.Type, x.Class, x.FlightId.Value)); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.SeatId, s => s.Id); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.SeatId, s => s.Id.Value); - - config.NewConfig() - .Map(d => d.SeatId, s => s.Id); - - config.NewConfig() - .ConstructUsing(x => new CreateSeat(x.SeatNumber, x.Type, x.Class, x.FlightId)); - - config.NewConfig() - .ConstructUsing(x => new ReserveSeat(x.FlightId, x.SeatNumber)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Models/Seat.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Models/Seat.cs deleted file mode 100644 index 485b884..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Models/Seat.cs +++ /dev/null @@ -1,58 +0,0 @@ -using BookingMonolith.Flight.Flights.ValueObjects; -using BookingMonolith.Flight.Seats.Features.CreatingSeat.V1; -using BookingMonolith.Flight.Seats.Features.ReservingSeat.V1; -using BookingMonolith.Flight.Seats.ValueObjects; -using BuildingBlocks.Core.Model; - -namespace BookingMonolith.Flight.Seats.Models; - -public record Seat : Aggregate -{ - public SeatNumber SeatNumber { get; private set; } = default!; - public Enums.SeatType Type { get; private set; } - public Enums.SeatClass Class { get; private set; } - public FlightId FlightId { get; private set; } = default!; - - public static Seat Create(SeatId id, SeatNumber seatNumber, Enums.SeatType type, Enums.SeatClass @class, - FlightId flightId, - bool isDeleted = false) - { - var seat = new Seat() - { - Id = id, - Class = @class, - Type = type, - SeatNumber = seatNumber, - FlightId = flightId, - IsDeleted = isDeleted - }; - - var @event = new SeatCreatedDomainEvent( - seat.Id, - seat.SeatNumber, - seat.Type, - seat.Class, - seat.FlightId, - isDeleted); - - seat.AddDomainEvent(@event); - - return seat; - } - - public void ReserveSeat() - { - this.IsDeleted = true; - this.LastModified = DateTime.Now; - - var @event = new SeatReservedDomainEvent( - this.Id, - this.SeatNumber, - this.Type, - this.Class, - this.FlightId, - this.IsDeleted); - - this.AddDomainEvent(@event); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Models/SeatReadModel.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Models/SeatReadModel.cs deleted file mode 100644 index 6be9235..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/Models/SeatReadModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace BookingMonolith.Flight.Seats.Models; - -public class SeatReadModel -{ - public required Guid Id { get; init; } - public required Guid SeatId { get; init; } - public required string SeatNumber { get; init; } - public required Enums.SeatType Type { get; init; } - public required Enums.SeatClass Class { get; init; } - public required Guid FlightId { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/ValueObjects/SeatId.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/ValueObjects/SeatId.cs deleted file mode 100644 index ff0ac33..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/ValueObjects/SeatId.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Seats.Exceptions; - -namespace BookingMonolith.Flight.Seats.ValueObjects; - -public record SeatId -{ - public Guid Value { get; } - - private SeatId(Guid value) - { - Value = value; - } - - public static SeatId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidSeatIdException(value); - } - - return new SeatId(value); - } - - public static implicit operator Guid(SeatId seatId) - { - return seatId.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/ValueObjects/SeatNumber.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/ValueObjects/SeatNumber.cs deleted file mode 100644 index dc551b1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Flight/Seats/ValueObjects/SeatNumber.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Flight.Seats.Exceptions; - -namespace BookingMonolith.Flight.Seats.ValueObjects; - -public record SeatNumber -{ - public string Value { get; } - - private SeatNumber(string value) - { - Value = value; - } - - public static SeatNumber Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidSeatNumberException(); - } - - return new SeatNumber(value); - } - - public static implicit operator string(SeatNumber seatNumber) - { - return seatNumber.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/AuthOptions.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/AuthOptions.cs deleted file mode 100644 index bf201bd..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/AuthOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BookingMonolith.Identity.Configurations; - -public class AuthOptions -{ - public string IssuerUri { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/Config.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/Config.cs deleted file mode 100644 index 3043823..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/Config.cs +++ /dev/null @@ -1,83 +0,0 @@ -using BookingMonolith.Identity.Identities.Constants; -using Duende.IdentityServer; -using Duende.IdentityServer.Models; -using IdentityModel; - -namespace BookingMonolith.Identity.Configurations; - -public static class Config -{ - public static IEnumerable IdentityResources => - new List - { - new IdentityResources.OpenId(), - new IdentityResources.Profile(), - new IdentityResources.Email() - }; - - - public static IEnumerable ApiScopes => - new List - { - new(Constants.StandardScopes.FlightApi), - new(Constants.StandardScopes.PassengerApi), - new(Constants.StandardScopes.BookingApi), - new(Constants.StandardScopes.IdentityApi), - new(Constants.StandardScopes.BookingMonolith), - new(JwtClaimTypes.Role, new List {"role"}) - }; - - - public static IList ApiResources => - new List - { - new(Constants.StandardScopes.FlightApi) - { - Scopes = { Constants.StandardScopes.FlightApi } - }, - new(Constants.StandardScopes.PassengerApi) - { - Scopes = { Constants.StandardScopes.PassengerApi } - }, - new(Constants.StandardScopes.BookingApi) - { - Scopes = { Constants.StandardScopes.BookingApi } - }, - new(Constants.StandardScopes.IdentityApi) - { - Scopes = { Constants.StandardScopes.IdentityApi } - }, - new(Constants.StandardScopes.BookingMonolith) - { - Scopes = { Constants.StandardScopes.BookingMonolith } - }, - }; - - public static IEnumerable Clients => - new List - { - new() - { - ClientId = "client", - AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, - ClientSecrets = - { - new Secret("secret".Sha256()) - }, - AllowedScopes = - { - IdentityServerConstants.StandardScopes.OpenId, - IdentityServerConstants.StandardScopes.Profile, - JwtClaimTypes.Role, // Include roles scope - Constants.StandardScopes.FlightApi, - Constants.StandardScopes.PassengerApi, - Constants.StandardScopes.BookingApi, - Constants.StandardScopes.IdentityApi, - Constants.StandardScopes.BookingMonolith, - }, - AccessTokenLifetime = 3600, // authorize the client to access protected resources - IdentityTokenLifetime = 3600, // authenticate the user, - AlwaysIncludeUserClaimsInIdToken = true // Include claims in ID token - } - }; -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/UserValidator.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/UserValidator.cs deleted file mode 100644 index 4ab41a9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Configurations/UserValidator.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Security.Claims; -using BookingMonolith.Identity.Identities.Models; -using Duende.IdentityServer.Models; -using Duende.IdentityServer.Validation; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Configurations; - -public class UserValidator : IResourceOwnerPasswordValidator -{ - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - - public UserValidator(SignInManager signInManager, - UserManager userManager) - { - _signInManager = signInManager; - _userManager = userManager; - } - - public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context) - { - var user = await _userManager.FindByNameAsync(context.UserName); - - var signIn = await _signInManager.PasswordSignInAsync( - user, - context.Password, - isPersistent: true, - lockoutOnFailure: true); - - if (signIn.Succeeded) - { - var userId = user!.Id.ToString(); - - // context set to success - context.Result = new GrantValidationResult( - subject: userId, - authenticationMethod: "custom", - claims: new Claim[] - { - new Claim(ClaimTypes.NameIdentifier, userId), - new Claim(ClaimTypes.Name, user.UserName) - } - ); - - return; - } - - // context set to Failure - context.Result = new GrantValidationResult( - TokenRequestErrors.UnauthorizedClient, "Invalid Credentials"); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/RoleClaimConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/RoleClaimConfiguration.cs deleted file mode 100644 index f662e0a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/RoleClaimConfiguration.cs +++ /dev/null @@ -1,22 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class RoleClaimConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(RoleClaim)); - - builder.HasKey(r => r.Id); - - builder.Property(r => r.Id) - .ValueGeneratedOnAdd(); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/RoleConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/RoleConfiguration.cs deleted file mode 100644 index 1e075b9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/RoleConfiguration.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class RoleConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(Role)); - - builder.HasKey(r => r.Id); - - builder.Property(r => r.Id) - .IsRequired() - .ValueGeneratedOnAdd(); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserClaimConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserClaimConfiguration.cs deleted file mode 100644 index 0288a07..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserClaimConfiguration.cs +++ /dev/null @@ -1,22 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class UserClaimConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserClaim)); - - builder.HasKey(r => r.Id); - - builder.Property(r => r.Id) - .ValueGeneratedOnAdd(); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserConfiguration.cs deleted file mode 100644 index 1d06eb1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserConfiguration.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class UserConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(User)); - - builder.HasKey(r => r.Id); - - builder.Property(r => r.Id) - .IsRequired() - .ValueGeneratedOnAdd(); // Auto-generate GUID on add - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserLoginConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserLoginConfiguration.cs deleted file mode 100644 index 815e40a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserLoginConfiguration.cs +++ /dev/null @@ -1,20 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class UserLoginConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserLogin)); - - builder.HasKey(r => new { r.LoginProvider, r.ProviderKey }); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} - diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserRoleConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserRoleConfiguration.cs deleted file mode 100644 index 8842616..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserRoleConfiguration.cs +++ /dev/null @@ -1,19 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class UserRoleConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserRole)); - - builder.HasKey(r => new { r.UserId, r.RoleId }); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserTokenConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserTokenConfiguration.cs deleted file mode 100644 index 35885a1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Configurations/UserTokenConfiguration.cs +++ /dev/null @@ -1,19 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Identity.Data.Configurations; - -[RegisterIdentityConfiguration] -public class UserTokenConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserToken)); - - builder.HasKey(r => new { r.UserId, r.LoginProvider, r.Name }); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/DesignTimeDbContextFactory.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/DesignTimeDbContextFactory.cs deleted file mode 100644 index e1b32a6..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/DesignTimeDbContextFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace BookingMonolith.Identity.Data; - -public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory -{ - public IdentityContext CreateDbContext(string[] args) - { - var builder = new DbContextOptionsBuilder(); - - builder.UseNpgsql("Server=localhost;Port=5432;Database=booking_monolith;User Id=postgres;Password=postgres;Include Error Detail=true") - .UseSnakeCaseNamingConvention(); - return new IdentityContext(builder.Options); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/EfTxIdentityBehavior.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/EfTxIdentityBehavior.cs deleted file mode 100644 index 9c64951..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/EfTxIdentityBehavior.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Text.Json; -using System.Transactions; -using BuildingBlocks.Core; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.Polly; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace BookingMonolith.Identity.Data; - -public class EfTxIdentityBehavior : IPipelineBehavior -where TRequest : notnull, IRequest -where TResponse : notnull -{ - private readonly ILogger> _logger; - private readonly IdentityContext _identityContext; - private readonly IPersistMessageDbContext _persistMessageDbContext; - private readonly IEventDispatcher _eventDispatcher; - - public EfTxIdentityBehavior( - ILogger> logger, - IdentityContext identityContext, - IPersistMessageDbContext persistMessageDbContext, - IEventDispatcher eventDispatcher - ) - { - _logger = logger; - _identityContext = identityContext; - _persistMessageDbContext = persistMessageDbContext; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle( - TRequest request, - RequestHandlerDelegate next, - CancellationToken cancellationToken - ) - { - _logger.LogInformation( - "{Prefix} Handled command {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - _logger.LogDebug( - "{Prefix} Handled command {MediatrRequest} with content {RequestContent}", - GetType().Name, - typeof(TRequest).FullName, - JsonSerializer.Serialize(request)); - - var response = await next(); - - _logger.LogInformation( - "{Prefix} Executed the {MediatrRequest} request", - GetType().Name, - typeof(TRequest).FullName); - - while (true) - { - var domainEvents = _identityContext.GetDomainEvents(); - - if (domainEvents is null || !domainEvents.Any()) - { - return response; - } - - _logger.LogInformation( - "{Prefix} Open the transaction for {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - using var scope = new TransactionScope( - TransactionScopeOption.Required, - new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, - TransactionScopeAsyncFlowOption.Enabled); - - await _eventDispatcher.SendAsync( - domainEvents.ToArray(), - typeof(TRequest), - cancellationToken); - - // Save data to database with some retry policy in distributed transaction - await _identityContext.RetryOnFailure( - async () => - { - await _identityContext.SaveChangesAsync(cancellationToken); - }); - - // Save data to database with some retry policy in distributed transaction - await _persistMessageDbContext.RetryOnFailure( - async () => - { - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - }); - - scope.Complete(); - - return response; - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/IdentityContext.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/IdentityContext.cs deleted file mode 100644 index cdc95b1..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/IdentityContext.cs +++ /dev/null @@ -1,176 +0,0 @@ -using System.Collections.Immutable; -using System.Data; -using System.Reflection; -using BookingMonolith.Identity.Identities.Models; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Core.Model; -using BuildingBlocks.EFCore; -using Humanizer; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Logging; - -namespace BookingMonolith.Identity.Data; - -public sealed class IdentityContext : IdentityDbContext, IDbContext -{ - private readonly ILogger? _logger; - private IDbContextTransaction _currentTransaction; - - public IdentityContext(DbContextOptions options, ILogger? logger = null) : base(options) - { - _logger = logger; - } - - protected override void OnModelCreating(ModelBuilder builder) - { - var types = typeof(IdentityRoot).Assembly.GetTypes() - .Where(t => t.GetCustomAttribute() != null) - .ToList(); - - foreach (var type in types) - { - dynamic configuration = Activator.CreateInstance(type)!; - builder.ApplyConfiguration(configuration); - } - - builder.HasDefaultSchema(nameof(Identity).Underscore()); - base.OnModelCreating(builder); - builder.FilterSoftDeletedProperties(); - builder.ToSnakeCaseTables(); - } - - public IExecutionStrategy CreateExecutionStrategy() => Database.CreateExecutionStrategy(); - - public async Task BeginTransactionAsync(CancellationToken cancellationToken = default) - { - if (_currentTransaction != null) - return; - - _currentTransaction = await Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken); - } - - public async Task CommitTransactionAsync(CancellationToken cancellationToken = default) - { - try - { - await SaveChangesAsync(cancellationToken); - await _currentTransaction?.CommitAsync(cancellationToken)!; - } - catch - { - await RollbackTransactionAsync(cancellationToken); - throw; - } - finally - { - _currentTransaction?.Dispose(); - _currentTransaction = null; - } - } - - public async Task RollbackTransactionAsync(CancellationToken cancellationToken = default) - { - try - { - await _currentTransaction?.RollbackAsync(cancellationToken)!; - } - finally - { - _currentTransaction?.Dispose(); - _currentTransaction = null; - } - } - - //ref: https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency#execution-strategies-and-transactions - public Task ExecuteTransactionalAsync(CancellationToken cancellationToken = default) - { - var strategy = CreateExecutionStrategy(); - return strategy.ExecuteAsync(async () => - { - await using var transaction = - await Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken); - try - { - await SaveChangesAsync(cancellationToken); - await transaction.CommitAsync(cancellationToken); - } - catch - { - await transaction.RollbackAsync(cancellationToken); - throw; - } - }); - } - - public override async Task SaveChangesAsync(CancellationToken cancellationToken = default) - { - OnBeforeSaving(); - try - { - return await base.SaveChangesAsync(cancellationToken); - } - //ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations#resolving-concurrency-conflicts - catch (DbUpdateConcurrencyException ex) - { - foreach (var entry in ex.Entries) - { - var databaseValues = await entry.GetDatabaseValuesAsync(cancellationToken); - - if (databaseValues == null) - { - _logger.LogError("The record no longer exists in the database, The record has been deleted by another user."); - throw; - } - - // Refresh the original values to bypass next concurrency check - entry.OriginalValues.SetValues(databaseValues); - } - - return await base.SaveChangesAsync(cancellationToken); - } - } - - public IReadOnlyList GetDomainEvents() - { - var domainEntities = ChangeTracker - .Entries() - .Where(x => x.Entity.DomainEvents.Any()) - .Select(x => x.Entity) - .ToList(); - - var domainEvents = domainEntities - .SelectMany(x => x.DomainEvents) - .ToImmutableList(); - - domainEntities.ForEach(entity => entity.ClearDomainEvents()); - - return domainEvents.ToImmutableList(); - } - - private void OnBeforeSaving() - { - try - { - foreach (var entry in ChangeTracker.Entries()) - { - switch (entry.State) - { - case EntityState.Modified: - entry.Entity.Version++; - break; - - case EntityState.Deleted: - entry.Entity.Version++; - break; - } - } - } - catch (Exception ex) - { - throw new Exception("try for find IVersion", ex); - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/20250407214345_initial.Designer.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/20250407214345_initial.Designer.cs deleted file mode 100644 index 797fa60..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/20250407214345_initial.Designer.cs +++ /dev/null @@ -1,381 +0,0 @@ -// -using System; -using BookingMonolith.Identity.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Identity.Data.Migrations -{ - [DbContext(typeof(IdentityContext))] - [Migration("20250407214345_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("identity") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("name"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_roles"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("asp_net_roles", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.RoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_role_claims"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_role_claims_role_id"); - - b.ToTable("asp_net_role_claims", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AccessFailedCount") - .HasColumnType("integer") - .HasColumnName("access_failed_count"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("email"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean") - .HasColumnName("email_confirmed"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean") - .HasColumnName("lockout_enabled"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone") - .HasColumnName("lockout_end"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_email"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_user_name"); - - b.Property("PassPortNumber") - .IsRequired() - .HasColumnType("text") - .HasColumnName("pass_port_number"); - - b.Property("PasswordHash") - .HasColumnType("text") - .HasColumnName("password_hash"); - - b.Property("PhoneNumber") - .HasColumnType("text") - .HasColumnName("phone_number"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean") - .HasColumnName("phone_number_confirmed"); - - b.Property("SecurityStamp") - .HasColumnType("text") - .HasColumnName("security_stamp"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean") - .HasColumnName("two_factor_enabled"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("user_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_users"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("asp_net_users", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_user_claims"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_claims_user_id"); - - b.ToTable("asp_net_user_claims", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("ProviderKey") - .HasColumnType("text") - .HasColumnName("provider_key"); - - b.Property("ProviderDisplayName") - .HasColumnType("text") - .HasColumnName("provider_display_name"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("LoginProvider", "ProviderKey") - .HasName("pk_asp_net_user_logins"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_logins_user_id"); - - b.ToTable("asp_net_user_logins", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserRole", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "RoleId") - .HasName("pk_asp_net_user_roles"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_user_roles_role_id"); - - b.ToTable("asp_net_user_roles", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserToken", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Value") - .HasColumnType("text") - .HasColumnName("value"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "LoginProvider", "Name") - .HasName("pk_asp_net_user_tokens"); - - b.ToTable("asp_net_user_tokens", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.RoleClaim", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_role_claims_asp_net_roles_role_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserClaim", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_claims_asp_net_users_user_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserLogin", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_logins_asp_net_users_user_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserRole", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_roles_role_id"); - - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_users_user_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserToken", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_tokens_asp_net_users_user_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/20250407214345_initial.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/20250407214345_initial.cs deleted file mode 100644 index 56680b5..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/20250407214345_initial.cs +++ /dev/null @@ -1,263 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Identity.Data.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "identity"); - - migrationBuilder.CreateTable( - name: "asp_net_roles", - schema: "identity", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - version = table.Column(type: "bigint", nullable: false), - name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - normalized_name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - concurrency_stamp = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_roles", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "asp_net_users", - schema: "identity", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - first_name = table.Column(type: "text", nullable: false), - last_name = table.Column(type: "text", nullable: false), - pass_port_number = table.Column(type: "text", nullable: false), - version = table.Column(type: "bigint", nullable: false), - user_name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - normalized_user_name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - normalized_email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - email_confirmed = table.Column(type: "boolean", nullable: false), - password_hash = table.Column(type: "text", nullable: true), - security_stamp = table.Column(type: "text", nullable: true), - concurrency_stamp = table.Column(type: "text", nullable: true), - phone_number = table.Column(type: "text", nullable: true), - phone_number_confirmed = table.Column(type: "boolean", nullable: false), - two_factor_enabled = table.Column(type: "boolean", nullable: false), - lockout_end = table.Column(type: "timestamp with time zone", nullable: true), - lockout_enabled = table.Column(type: "boolean", nullable: false), - access_failed_count = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_users", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "asp_net_role_claims", - schema: "identity", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - version = table.Column(type: "bigint", nullable: false), - role_id = table.Column(type: "uuid", nullable: false), - claim_type = table.Column(type: "text", nullable: true), - claim_value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_role_claims", x => x.id); - table.ForeignKey( - name: "fk_asp_net_role_claims_asp_net_roles_role_id", - column: x => x.role_id, - principalSchema: "identity", - principalTable: "asp_net_roles", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_claims", - schema: "identity", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - version = table.Column(type: "bigint", nullable: false), - user_id = table.Column(type: "uuid", nullable: false), - claim_type = table.Column(type: "text", nullable: true), - claim_value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_claims", x => x.id); - table.ForeignKey( - name: "fk_asp_net_user_claims_asp_net_users_user_id", - column: x => x.user_id, - principalSchema: "identity", - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_logins", - schema: "identity", - columns: table => new - { - login_provider = table.Column(type: "text", nullable: false), - provider_key = table.Column(type: "text", nullable: false), - version = table.Column(type: "bigint", nullable: false), - provider_display_name = table.Column(type: "text", nullable: true), - user_id = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_logins", x => new { x.login_provider, x.provider_key }); - table.ForeignKey( - name: "fk_asp_net_user_logins_asp_net_users_user_id", - column: x => x.user_id, - principalSchema: "identity", - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_roles", - schema: "identity", - columns: table => new - { - user_id = table.Column(type: "uuid", nullable: false), - role_id = table.Column(type: "uuid", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_roles", x => new { x.user_id, x.role_id }); - table.ForeignKey( - name: "fk_asp_net_user_roles_asp_net_roles_role_id", - column: x => x.role_id, - principalSchema: "identity", - principalTable: "asp_net_roles", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_asp_net_user_roles_asp_net_users_user_id", - column: x => x.user_id, - principalSchema: "identity", - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_tokens", - schema: "identity", - columns: table => new - { - user_id = table.Column(type: "uuid", nullable: false), - login_provider = table.Column(type: "text", nullable: false), - name = table.Column(type: "text", nullable: false), - version = table.Column(type: "bigint", nullable: false), - value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_tokens", x => new { x.user_id, x.login_provider, x.name }); - table.ForeignKey( - name: "fk_asp_net_user_tokens_asp_net_users_user_id", - column: x => x.user_id, - principalSchema: "identity", - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_role_claims_role_id", - schema: "identity", - table: "asp_net_role_claims", - column: "role_id"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - schema: "identity", - table: "asp_net_roles", - column: "normalized_name", - unique: true); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_user_claims_user_id", - schema: "identity", - table: "asp_net_user_claims", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_user_logins_user_id", - schema: "identity", - table: "asp_net_user_logins", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_user_roles_role_id", - schema: "identity", - table: "asp_net_user_roles", - column: "role_id"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - schema: "identity", - table: "asp_net_users", - column: "normalized_email"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - schema: "identity", - table: "asp_net_users", - column: "normalized_user_name", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "asp_net_role_claims", - schema: "identity"); - - migrationBuilder.DropTable( - name: "asp_net_user_claims", - schema: "identity"); - - migrationBuilder.DropTable( - name: "asp_net_user_logins", - schema: "identity"); - - migrationBuilder.DropTable( - name: "asp_net_user_roles", - schema: "identity"); - - migrationBuilder.DropTable( - name: "asp_net_user_tokens", - schema: "identity"); - - migrationBuilder.DropTable( - name: "asp_net_roles", - schema: "identity"); - - migrationBuilder.DropTable( - name: "asp_net_users", - schema: "identity"); - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs deleted file mode 100644 index f80a1af..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs +++ /dev/null @@ -1,378 +0,0 @@ -// -using System; -using BookingMonolith.Identity.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Identity.Data.Migrations -{ - [DbContext(typeof(IdentityContext))] - partial class IdentityContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("identity") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("name"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_roles"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("asp_net_roles", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.RoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_role_claims"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_role_claims_role_id"); - - b.ToTable("asp_net_role_claims", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AccessFailedCount") - .HasColumnType("integer") - .HasColumnName("access_failed_count"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("email"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean") - .HasColumnName("email_confirmed"); - - b.Property("FirstName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property("LastName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean") - .HasColumnName("lockout_enabled"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone") - .HasColumnName("lockout_end"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_email"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_user_name"); - - b.Property("PassPortNumber") - .IsRequired() - .HasColumnType("text") - .HasColumnName("pass_port_number"); - - b.Property("PasswordHash") - .HasColumnType("text") - .HasColumnName("password_hash"); - - b.Property("PhoneNumber") - .HasColumnType("text") - .HasColumnName("phone_number"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean") - .HasColumnName("phone_number_confirmed"); - - b.Property("SecurityStamp") - .HasColumnType("text") - .HasColumnName("security_stamp"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean") - .HasColumnName("two_factor_enabled"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("user_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_users"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("asp_net_users", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_user_claims"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_claims_user_id"); - - b.ToTable("asp_net_user_claims", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("ProviderKey") - .HasColumnType("text") - .HasColumnName("provider_key"); - - b.Property("ProviderDisplayName") - .HasColumnType("text") - .HasColumnName("provider_display_name"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("LoginProvider", "ProviderKey") - .HasName("pk_asp_net_user_logins"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_logins_user_id"); - - b.ToTable("asp_net_user_logins", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserRole", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "RoleId") - .HasName("pk_asp_net_user_roles"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_user_roles_role_id"); - - b.ToTable("asp_net_user_roles", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserToken", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Value") - .HasColumnType("text") - .HasColumnName("value"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "LoginProvider", "Name") - .HasName("pk_asp_net_user_tokens"); - - b.ToTable("asp_net_user_tokens", "identity"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.RoleClaim", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_role_claims_asp_net_roles_role_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserClaim", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_claims_asp_net_users_user_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserLogin", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_logins_asp_net_users_user_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserRole", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_roles_role_id"); - - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_users_user_id"); - }); - - modelBuilder.Entity("BookingMonolith.Identity.Identities.Models.UserToken", b => - { - b.HasOne("BookingMonolith.Identity.Identities.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_tokens_asp_net_users_user_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/RegisterIdentityConfigurationAttribute.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/RegisterIdentityConfigurationAttribute.cs deleted file mode 100644 index af4542b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/RegisterIdentityConfigurationAttribute.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace BookingMonolith.Identity.Data; - -[AttributeUsage(AttributeTargets.Class)] -public class RegisterIdentityConfigurationAttribute : Attribute { } diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Seed/IdentityDataSeeder.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Seed/IdentityDataSeeder.cs deleted file mode 100644 index 37af59e..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Seed/IdentityDataSeeder.cs +++ /dev/null @@ -1,100 +0,0 @@ -using BookingMonolith.Identity.Identities.Constants; -using BookingMonolith.Identity.Identities.Models; -using BuildingBlocks.Constants; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.EFCore; -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Identity.Data.Seed; - -public class IdentityDataSeeder : IDataSeeder -{ - private readonly UserManager _userManager; - private readonly RoleManager _roleManager; - private readonly IEventDispatcher _eventDispatcher; - private readonly IdentityContext _identityContext; - - public IdentityDataSeeder( - UserManager userManager, - RoleManager roleManager, - IEventDispatcher eventDispatcher, - IdentityContext identityContext - ) - { - _userManager = userManager; - _roleManager = roleManager; - _eventDispatcher = eventDispatcher; - _identityContext = identityContext; - } - - public async Task SeedAllAsync() - { - var pendingMigrations = await _identityContext.Database.GetPendingMigrationsAsync(); - - if (!pendingMigrations.Any()) - { - await SeedRoles(); - await SeedUsers(); - } - } - - private async Task SeedRoles() - { - if (!await _identityContext.Roles.AnyAsync()) - { - if (await _roleManager.RoleExistsAsync(IdentityConstant.Role.Admin) == false) - { - await _roleManager.CreateAsync(new Role { Name = IdentityConstant.Role.Admin }); - } - - if (await _roleManager.RoleExistsAsync(IdentityConstant.Role.User) == false) - { - await _roleManager.CreateAsync(new Role { Name = IdentityConstant.Role.User }); - } - } - } - - private async Task SeedUsers() - { - if (!await _identityContext.Users.AnyAsync()) - { - if (await _userManager.FindByNameAsync("samh") == null) - { - var result = await _userManager.CreateAsync(InitialData.Users.First(), "Admin@123456"); - - if (result.Succeeded) - { - await _userManager.AddToRoleAsync(InitialData.Users.First(), IdentityConstant.Role.Admin); - - await _eventDispatcher.SendAsync( - new UserCreated( - InitialData.Users.First().Id, - InitialData.Users.First().FirstName + - " " + - InitialData.Users.First().LastName, - InitialData.Users.First().PassPortNumber)); - } - } - - if (await _userManager.FindByNameAsync("meysamh2") == null) - { - var result = await _userManager.CreateAsync(InitialData.Users.Last(), "User@123456"); - - if (result.Succeeded) - { - await _userManager.AddToRoleAsync(InitialData.Users.Last(), IdentityConstant.Role.User); - - await _eventDispatcher.SendAsync( - new UserCreated( - InitialData.Users.Last().Id, - InitialData.Users.Last().FirstName + - " " + - InitialData.Users.Last().LastName, - InitialData.Users.Last().PassPortNumber)); - } - } - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Seed/InitialData.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Seed/InitialData.cs deleted file mode 100644 index 59dc3df..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/Seed/InitialData.cs +++ /dev/null @@ -1,36 +0,0 @@ -using BookingMonolith.Identity.Identities.Models; -using MassTransit; - -namespace BookingMonolith.Identity.Data.Seed; - -public static class InitialData -{ - public static List Users { get; } - - static InitialData() - { - Users = new List - { - new User - { - Id = NewId.NextGuid(), - FirstName = "Sam", - LastName = "H", - UserName = "samh", - PassPortNumber = "12345678", - Email = "sam@test.com", - SecurityStamp = Guid.NewGuid().ToString() - }, - new User - { - Id = NewId.NextGuid(), - FirstName = "Sam2", - LastName = "H2", - UserName = "samh2", - PassPortNumber = "87654321", - Email = "sam2@test.com", - SecurityStamp = Guid.NewGuid().ToString() - } - }; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/readme.md b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/readme.md deleted file mode 100644 index ef05f2e..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Data/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -dotnet ef migrations add initial --context IdentityContext -o "Identity\Data\Migrations" -dotnet ef database update --context IdentityContext diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs deleted file mode 100644 index fd78740..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs +++ /dev/null @@ -1,64 +0,0 @@ -using BookingMonolith.Identity.Configurations; -using BookingMonolith.Identity.Data; -using BookingMonolith.Identity.Identities.Models; -using BuildingBlocks.Web; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.DependencyInjection; - -namespace BookingMonolith.Identity.Extensions.Infrastructure; - -public static class IdentityServerExtensions -{ - public static WebApplicationBuilder AddCustomIdentityServer(this WebApplicationBuilder builder) - { - builder.Services.AddValidateOptions(); - var authOptions = builder.Services.GetOptions(nameof(AuthOptions)); - - builder.Services.AddIdentity(config => - { - config.Password.RequiredLength = 6; - config.Password.RequireDigit = false; - config.Password.RequireNonAlphanumeric = false; - config.Password.RequireUppercase = false; - }) - .AddEntityFrameworkStores() - .AddDefaultTokenProviders(); - - var identityServerBuilder = builder.Services.AddIdentityServer(options => - { - options.Events.RaiseErrorEvents = true; - options.Events.RaiseInformationEvents = true; - options.Events.RaiseFailureEvents = true; - options.Events.RaiseSuccessEvents = true; - options.IssuerUri = authOptions.IssuerUri; - }) - .AddInMemoryIdentityResources(Config.IdentityResources) - .AddInMemoryApiResources(Config.ApiResources) - .AddInMemoryApiScopes(Config.ApiScopes) - .AddInMemoryClients(Config.Clients) - .AddAspNetIdentity() - .AddResourceOwnerValidator(); - - //ref: https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html - identityServerBuilder.AddDeveloperSigningCredential(); - - builder.Services.ConfigureApplicationCookie(options => - { - options.Events.OnRedirectToLogin = context => - { - context.Response.StatusCode = StatusCodes.Status401Unauthorized; - return Task.CompletedTask; - }; - - options.Events.OnRedirectToAccessDenied = context => - { - context.Response.StatusCode = StatusCodes.Status403Forbidden; - return Task.CompletedTask; - }; - }); - - return builder; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Constants/Constants.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Constants/Constants.cs deleted file mode 100644 index 28f3edf..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Constants/Constants.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace BookingMonolith.Identity.Identities.Constants; - -public static class Constants -{ - public static class StandardScopes - { - public const string Roles = "roles"; - public const string FlightApi = "flight-api"; - public const string PassengerApi = "passenger-api"; - public const string BookingApi = "booking-api"; - public const string IdentityApi = "identity-api"; - public const string BookingMonolith = "booking-monolith"; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Exceptions/RegisterIdentityUserException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Exceptions/RegisterIdentityUserException.cs deleted file mode 100644 index 5fec14a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Exceptions/RegisterIdentityUserException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using BuildingBlocks.Exception; - -namespace BookingMonolith.Identity.Identities.Exceptions; - -public class RegisterIdentityUserException : AppException -{ - public RegisterIdentityUserException(string message) : base(message) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Features/IdentityMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Features/IdentityMappings.cs deleted file mode 100644 index aac0e04..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Features/IdentityMappings.cs +++ /dev/null @@ -1,14 +0,0 @@ -using BookingMonolith.Identity.Identities.Features.RegisteringNewUser.V1; -using Mapster; - -namespace BookingMonolith.Identity.Identities.Features; - -public class IdentityMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .ConstructUsing(x => new RegisterNewUser(x.FirstName, x.LastName, x.Username, x.Email, - x.Password, x.ConfirmPassword, x.PassportNumber)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Features/RegisteringNewUser/V1/RegisterNewUser.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Features/RegisteringNewUser/V1/RegisterNewUser.cs deleted file mode 100644 index 8551dc8..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Features/RegisteringNewUser/V1/RegisterNewUser.cs +++ /dev/null @@ -1,132 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Identity.Identities.Exceptions; -using BookingMonolith.Identity.Identities.Models; -using BuildingBlocks.Constants; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Routing; - -namespace BookingMonolith.Identity.Identities.Features.RegisteringNewUser.V1; - -public record RegisterNewUser(string FirstName, string LastName, string Username, string Email, - string Password, string ConfirmPassword, string PassportNumber) : ICommand; - -public record RegisterNewUserResult(Guid Id, string FirstName, string LastName, string Username, string PassportNumber); - -public record RegisterNewUserRequestDto(string FirstName, string LastName, string Username, string Email, - string Password, string ConfirmPassword, string PassportNumber); - -public record RegisterNewUserResponseDto(Guid Id, string FirstName, string LastName, string Username, - string PassportNumber); - -public class RegisterNewUserEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/identity/register-user", async ( - RegisterNewUserRequestDto request, IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("RegisterUser") - .WithApiVersionSet(builder.NewApiVersionSet("Identity").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Register User") - .WithDescription("Register User") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class RegisterNewUserValidator : AbstractValidator -{ - public RegisterNewUserValidator() - { - RuleFor(x => x.Password).NotEmpty().WithMessage("Please enter the password"); - RuleFor(x => x.ConfirmPassword).NotEmpty().WithMessage("Please enter the confirmation password"); - - RuleFor(x => x).Custom((x, context) => - { - if (x.Password != x.ConfirmPassword) - { - context.AddFailure(nameof(x.Password), "Passwords should match"); - } - }); - - RuleFor(x => x.Username).NotEmpty().WithMessage("Please enter the username"); - RuleFor(x => x.FirstName).NotEmpty().WithMessage("Please enter the first name"); - RuleFor(x => x.LastName).NotEmpty().WithMessage("Please enter the last name"); - RuleFor(x => x.Email).NotEmpty().WithMessage("Please enter the last email") - .EmailAddress().WithMessage("A valid email is required"); - } -} - -internal class RegisterNewUserHandler : ICommandHandler -{ - private readonly IEventDispatcher _eventDispatcher; - private readonly UserManager _userManager; - - public RegisterNewUserHandler(UserManager userManager, - IEventDispatcher eventDispatcher) - { - _userManager = userManager; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle(RegisterNewUser request, - CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var applicationUser = new User() - { - FirstName = request.FirstName, - LastName = request.LastName, - UserName = request.Username, - Email = request.Email, - PasswordHash = request.Password, - PassPortNumber = request.PassportNumber - }; - - var identityResult = await _userManager.CreateAsync(applicationUser, request.Password); - var roleResult = await _userManager.AddToRoleAsync(applicationUser, IdentityConstant.Role.User); - - if (identityResult.Succeeded == false) - { - throw new RegisterIdentityUserException(string.Join(',', identityResult.Errors.Select(e => e.Description))); - } - - if (roleResult.Succeeded == false) - { - throw new RegisterIdentityUserException(string.Join(',', roleResult.Errors.Select(e => e.Description))); - } - - await _eventDispatcher.SendAsync(new UserCreated(applicationUser.Id, - applicationUser.FirstName + " " + applicationUser.LastName, - applicationUser.PassPortNumber), cancellationToken: cancellationToken); - - return new RegisterNewUserResult(applicationUser.Id, applicationUser.FirstName, applicationUser.LastName, - applicationUser.UserName, applicationUser.PassPortNumber); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/Role.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/Role.cs deleted file mode 100644 index 348ed68..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/Role.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class Role : IdentityRole, IVersion -{ - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/RoleClaim.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/RoleClaim.cs deleted file mode 100644 index fb2b3e6..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/RoleClaim.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class RoleClaim : IdentityRoleClaim, IVersion -{ - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/User.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/User.cs deleted file mode 100644 index 01607e2..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/User.cs +++ /dev/null @@ -1,12 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class User : IdentityUser, IVersion -{ - public required string FirstName { get; init; } - public required string LastName { get; init; } - public required string PassPortNumber { get; init; } - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserClaim.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserClaim.cs deleted file mode 100644 index a6d60dc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserClaim.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class UserClaim : IdentityUserClaim, IVersion -{ - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserLogin.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserLogin.cs deleted file mode 100644 index 778cff6..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserLogin.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class UserLogin : IdentityUserLogin, IVersion -{ - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserRole.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserRole.cs deleted file mode 100644 index e1cb34b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserRole.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class UserRole : IdentityUserRole, IVersion -{ - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserToken.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserToken.cs deleted file mode 100644 index f40c404..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/Identities/Models/UserToken.cs +++ /dev/null @@ -1,9 +0,0 @@ -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -namespace BookingMonolith.Identity.Identities.Models; - -public class UserToken : IdentityUserToken, IVersion -{ - public long Version { get; set; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/IdentityEventMapper.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/IdentityEventMapper.cs deleted file mode 100644 index 824abae..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/IdentityEventMapper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace BookingMonolith.Identity; - -public sealed class IdentityEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - _ => null - }; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/IdentityRoot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Identity/IdentityRoot.cs deleted file mode 100644 index 56ee66a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Identity/IdentityRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BookingMonolith.Identity; - -public class IdentityRoot -{ - -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Configurations/PassengerConfiguration.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Configurations/PassengerConfiguration.cs deleted file mode 100644 index d5dc1fc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Configurations/PassengerConfiguration.cs +++ /dev/null @@ -1,60 +0,0 @@ -using BookingMonolith.Passenger.Passengers.ValueObjects; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace BookingMonolith.Passenger.Data.Configurations; - -[RegisterPassengerConfiguration] -public class PassengerConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - RelationalEntityTypeBuilderExtensions.ToTable((EntityTypeBuilder)builder, nameof(Passengers.Models.Passenger)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(passengerId => passengerId.Value, dbId => PassengerId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - builder.OwnsOne( - x => x.Name, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Passengers.Models.Passenger.Name)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.PassportNumber, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Passengers.Models.Passenger.PassportNumber)) - .HasMaxLength(10) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Age, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Passengers.Models.Passenger.Age)) - .HasMaxLength(3) - .IsRequired(); - } - ); - - builder.Property(x => x.PassengerType) - .IsRequired() - .HasDefaultValue(Passengers.Enums.PassengerType.Unknown) - .HasConversion( - x => x.ToString(), - x => (Passengers.Enums.PassengerType)Enum.Parse(typeof(Passengers.Enums.PassengerType), x)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/DesignTimeDbContextFactory.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/DesignTimeDbContextFactory.cs deleted file mode 100644 index fd31e61..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/DesignTimeDbContextFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace BookingMonolith.Passenger.Data; - -public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory -{ - public PassengerDbContext CreateDbContext(string[] args) - { - var builder = new DbContextOptionsBuilder(); - - builder.UseNpgsql("Server=localhost;Port=5432;Database=booking_monolith;User Id=postgres;Password=postgres;Include Error Detail=true") - .UseSnakeCaseNamingConvention(); - return new PassengerDbContext(builder.Options); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/EfTxPassengerBehavior.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/EfTxPassengerBehavior.cs deleted file mode 100644 index de628d3..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/EfTxPassengerBehavior.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Text.Json; -using System.Transactions; -using BuildingBlocks.Core; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.Polly; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace BookingMonolith.Passenger.Data; - -public class EfTxPassengerBehavior : IPipelineBehavior -where TRequest : notnull, IRequest -where TResponse : notnull -{ - private readonly ILogger> _logger; - private readonly PassengerDbContext _passengerDbContext; - private readonly IPersistMessageDbContext _persistMessageDbContext; - private readonly IEventDispatcher _eventDispatcher; - - public EfTxPassengerBehavior( - ILogger> logger, - PassengerDbContext passengerDbContext, - IPersistMessageDbContext persistMessageDbContext, - IEventDispatcher eventDispatcher - ) - { - _logger = logger; - _passengerDbContext = passengerDbContext; - _persistMessageDbContext = persistMessageDbContext; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle( - TRequest request, - RequestHandlerDelegate next, - CancellationToken cancellationToken - ) - { - _logger.LogInformation( - "{Prefix} Handled command {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - _logger.LogDebug( - "{Prefix} Handled command {MediatrRequest} with content {RequestContent}", - GetType().Name, - typeof(TRequest).FullName, - JsonSerializer.Serialize(request)); - - var response = await next(); - - _logger.LogInformation( - "{Prefix} Executed the {MediatrRequest} request", - GetType().Name, - typeof(TRequest).FullName); - - while (true) - { - var domainEvents = _passengerDbContext.GetDomainEvents(); - - if (domainEvents is null || !domainEvents.Any()) - { - return response; - } - - _logger.LogInformation( - "{Prefix} Open the transaction for {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - using var scope = new TransactionScope( - TransactionScopeOption.Required, - new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, - TransactionScopeAsyncFlowOption.Enabled); - - await _eventDispatcher.SendAsync( - domainEvents.ToArray(), - typeof(TRequest), - cancellationToken); - - // Save data to database with some retry policy in distributed transaction - await _passengerDbContext.RetryOnFailure( - async () => - { - await _passengerDbContext.SaveChangesAsync(cancellationToken); - }); - - // Save data to database with some retry policy in distributed transaction - await _persistMessageDbContext.RetryOnFailure( - async () => - { - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - }); - - scope.Complete(); - - return response; - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/20250407215445_initial.Designer.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/20250407215445_initial.Designer.cs deleted file mode 100644 index a0592ac..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/20250407215445_initial.Designer.cs +++ /dev/null @@ -1,151 +0,0 @@ -// -using System; -using BookingMonolith.Passenger.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Passenger.Data.Migrations -{ - [DbContext(typeof(PassengerDbContext))] - [Migration("20250407215445_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("passenger") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("BookingMonolith.Passenger.Passengers.Models.Passenger", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("PassengerType") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("passenger_type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_passenger"); - - b.ToTable("passenger", "passenger"); - }); - - modelBuilder.Entity("BookingMonolith.Passenger.Passengers.Models.Passenger", b => - { - b.OwnsOne("BookingMonolith.Passenger.Passengers.ValueObjects.Age", "Age", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(3) - .HasColumnType("integer") - .HasColumnName("age"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger", "passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("BookingMonolith.Passenger.Passengers.ValueObjects.Name", "Name", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger", "passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("BookingMonolith.Passenger.Passengers.ValueObjects.PassportNumber", "PassportNumber", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("passport_number"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger", "passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.Navigation("Age"); - - b.Navigation("Name") - .IsRequired(); - - b.Navigation("PassportNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/20250407215445_initial.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/20250407215445_initial.cs deleted file mode 100644 index bca083f..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/20250407215445_initial.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace BookingMonolith.Passenger.Data.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "passenger"); - - migrationBuilder.CreateTable( - name: "passenger", - schema: "passenger", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - passport_number = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), - name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - passenger_type = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), - age = table.Column(type: "integer", maxLength: 3, nullable: true), - created_at = table.Column(type: "timestamp with time zone", nullable: true), - created_by = table.Column(type: "bigint", nullable: true), - last_modified = table.Column(type: "timestamp with time zone", nullable: true), - last_modified_by = table.Column(type: "bigint", nullable: true), - is_deleted = table.Column(type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_passenger", x => x.id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "passenger", - schema: "passenger"); - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs deleted file mode 100644 index 7e5a887..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -using System; -using BookingMonolith.Passenger.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace BookingMonolith.Passenger.Data.Migrations -{ - [DbContext(typeof(PassengerDbContext))] - partial class PassengerDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasDefaultSchema("passenger") - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("BookingMonolith.Passenger.Passengers.Models.Passenger", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("PassengerType") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("passenger_type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_passenger"); - - b.ToTable("passenger", "passenger"); - }); - - modelBuilder.Entity("BookingMonolith.Passenger.Passengers.Models.Passenger", b => - { - b.OwnsOne("BookingMonolith.Passenger.Passengers.ValueObjects.Age", "Age", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(3) - .HasColumnType("integer") - .HasColumnName("age"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger", "passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("BookingMonolith.Passenger.Passengers.ValueObjects.Name", "Name", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger", "passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("BookingMonolith.Passenger.Passengers.ValueObjects.PassportNumber", "PassportNumber", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("passport_number"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger", "passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.Navigation("Age"); - - b.Navigation("Name") - .IsRequired(); - - b.Navigation("PassportNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/PassengerDbContext.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/PassengerDbContext.cs deleted file mode 100644 index e9b2f16..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/PassengerDbContext.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Reflection; -using BuildingBlocks.EFCore; -using BuildingBlocks.Web; -using Humanizer; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; - -namespace BookingMonolith.Passenger.Data; - -public sealed class PassengerDbContext : AppDbContextBase -{ - public PassengerDbContext(DbContextOptions options, - ICurrentUserProvider? currentUserProvider = null, ILogger? logger = null) : - base(options, currentUserProvider, logger) - { - } - - public DbSet Passengers => Set(); - - protected override void OnModelCreating(ModelBuilder builder) - { - var types = typeof(PassengerRoot).Assembly.GetTypes() - .Where(t => t.GetCustomAttribute() != null) - .ToList(); - - foreach (var type in types) - { - dynamic configuration = Activator.CreateInstance(type)!; - builder.ApplyConfiguration(configuration); - } - - builder.HasDefaultSchema(nameof(Passenger).Underscore()); - base.OnModelCreating(builder); - builder.FilterSoftDeletedProperties(); - builder.ToSnakeCaseTables(); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/PassengerReadDbContext.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/PassengerReadDbContext.cs deleted file mode 100644 index c828e73..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/PassengerReadDbContext.cs +++ /dev/null @@ -1,17 +0,0 @@ -using BookingMonolith.Passenger.Passengers.Models; -using BuildingBlocks.Mongo; -using Humanizer; -using Microsoft.Extensions.Options; -using MongoDB.Driver; - -namespace BookingMonolith.Passenger.Data; - -public class PassengerReadDbContext : MongoDbContext -{ - public PassengerReadDbContext(IOptions options) : base(options) - { - Passenger = GetCollection(nameof(Passenger).Underscore()); - } - - public IMongoCollection Passenger { get; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/RegisterPassengerConfigurationAttribute.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/RegisterPassengerConfigurationAttribute.cs deleted file mode 100644 index 571ece9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/RegisterPassengerConfigurationAttribute.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace BookingMonolith.Passenger.Data; - -[AttributeUsage(AttributeTargets.Class)] -public class RegisterPassengerConfigurationAttribute : Attribute { } diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/readme.md b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/readme.md deleted file mode 100644 index 6f6d486..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Data/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -dotnet ef migrations add initial --context PassengerDbContext -o "Passenger\Data\Migrations" -dotnet ef database update --context PassengerDbContext diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidAgeException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidAgeException.cs deleted file mode 100644 index 659f2cc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidAgeException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Exceptions; - -public class InvalidAgeException : DomainException -{ - public InvalidAgeException() : base("Age Cannot be null or negative") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidNameException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidNameException.cs deleted file mode 100644 index 0710b25..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidPassengerIdException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidPassengerIdException.cs deleted file mode 100644 index aac5145..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidPassengerIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Exceptions; - -public class InvalidPassengerIdException : DomainException -{ - public InvalidPassengerIdException(Guid passengerId) - : base($"PassengerId: '{passengerId}' is invalid.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidPassportNumberException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidPassportNumberException.cs deleted file mode 100644 index 4d788cc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/InvalidPassportNumberException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Exceptions; - -public class InvalidPassportNumberException : DomainException -{ - public InvalidPassportNumberException() : base("Passport number cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/PassengerAlreadyExist.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/PassengerAlreadyExist.cs deleted file mode 100644 index e903cb5..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/PassengerAlreadyExist.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Passenger.Exceptions; - -public class PassengerNotExist : AppException -{ - public PassengerNotExist() : base("Please register before!", HttpStatusCode.NotFound) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/PassengerNotFoundException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/PassengerNotFoundException.cs deleted file mode 100644 index f91053b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Exceptions/PassengerNotFoundException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Passenger.Exceptions; - -public class PassengerNotFoundException : AppException -{ - public PassengerNotFoundException() : base("Passenger not found!", HttpStatusCode.NotFound) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs deleted file mode 100644 index 8775abf..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs +++ /dev/null @@ -1,5 +0,0 @@ -using BuildingBlocks.Core.Event; - -namespace BookingMonolith.Passenger.Identity.Consumers.RegisteringNewUser.V1; - -public record PassengerCreatedDomainEvent(Guid Id, string Name, string PassportNumber, bool IsDeleted = false) : IDomainEvent; diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs deleted file mode 100644 index 4979697..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Passenger.Data; -using BookingMonolith.Passenger.Passengers.ValueObjects; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Humanizer; -using MassTransit; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace BookingMonolith.Passenger.Identity.Consumers.RegisteringNewUser.V1; - -public class RegisterNewUserHandler : IConsumer -{ - private readonly PassengerDbContext _passengerDbContext; - private readonly IEventDispatcher _eventDispatcher; - private readonly ILogger _logger; - private readonly AppOptions _options; - - public RegisterNewUserHandler(PassengerDbContext passengerDbContext, - IEventDispatcher eventDispatcher, - ILogger logger, - IOptions options) - { - _passengerDbContext = passengerDbContext; - _eventDispatcher = eventDispatcher; - _logger = logger; - _options = options.Value; - } - - public async Task Consume(ConsumeContext context) - { - Guard.Against.Null(context.Message, nameof(UserCreated)); - - _logger.LogInformation($"consumer for {nameof(UserCreated).Underscore()} in {_options.Name}"); - - var passengerExist = - await _passengerDbContext.Passengers.AnyAsync(x => x.PassportNumber.Value == context.Message.PassportNumber); - - if (passengerExist) - { - return; - } - - var passenger = Passengers.Models.Passenger.Create(PassengerId.Of(NewId.NextGuid()), Name.Of(context.Message.Name), - PassportNumber.Of(context.Message.PassportNumber)); - - await _passengerDbContext.AddAsync(passenger); - - await _passengerDbContext.SaveChangesAsync(); - - await _eventDispatcher.SendAsync( - new PassengerCreatedDomainEvent(passenger.Id, passenger.Name, passenger.PassportNumber), - typeof(IInternalCommand)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/PassengerEventMapper.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/PassengerEventMapper.cs deleted file mode 100644 index 4e1ba18..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/PassengerEventMapper.cs +++ /dev/null @@ -1,32 +0,0 @@ -using BookingMonolith.Passenger.Identity.Consumers.RegisteringNewUser.V1; -using BookingMonolith.Passenger.Passengers.Features.CompletingRegisterPassenger.V1; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace BookingMonolith.Passenger; - -public sealed class PassengerEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - PassengerRegistrationCompletedDomainEvent e => new PassengerRegistrationCompleted(e.Id), - PassengerCreatedDomainEvent e => new PassengerCreated(e.Id), - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - PassengerRegistrationCompletedDomainEvent e => new CompleteRegisterPassengerMongoCommand(e.Id, e.PassportNumber, e.Name, e.PassengerType, - e.Age, e.IsDeleted), - PassengerCreatedDomainEvent e => new CompleteRegisterPassengerMongoCommand(e.Id, e.PassportNumber, e.Name, Passengers.Enums.PassengerType.Unknown, - 0, e.IsDeleted), - _ => null - }; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/PassengerRoot.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/PassengerRoot.cs deleted file mode 100644 index 9cfe57a..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/PassengerRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BookingMonolith.Passenger; - -public class PassengerRoot -{ - -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Dtos/PassengerDto.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Dtos/PassengerDto.cs deleted file mode 100644 index d521741..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Dtos/PassengerDto.cs +++ /dev/null @@ -1,2 +0,0 @@ -namespace BookingMonolith.Passenger.Passengers.Dtos; -public record PassengerDto(Guid Id, string Name, string PassportNumber, Enums.PassengerType PassengerType, int Age); diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Enums/PassengerType.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Enums/PassengerType.cs deleted file mode 100644 index b13abc3..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Enums/PassengerType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BookingMonolith.Passenger.Passengers.Enums; - -public enum PassengerType -{ - Unknown = 0, - Male, - Female, - Baby -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs deleted file mode 100644 index e6147f5..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.Exceptions; - -public class InvalidAgeException : DomainException -{ - public InvalidAgeException() : base("Age Cannot be null or negative") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidNameException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidNameException.cs deleted file mode 100644 index 7c72c56..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs deleted file mode 100644 index 1f5a1f0..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.Exceptions; - -public class InvalidPassportNumberException : DomainException -{ - public InvalidPassportNumberException() : base("Passport number cannot be empty or whitespace.") - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs deleted file mode 100644 index 3a3d14e..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Passenger.Passengers.Exceptions; - -public class PassengerNotExist : AppException -{ - public PassengerNotExist() : base("Please register before!", HttpStatusCode.NotFound) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs deleted file mode 100644 index a6b8057..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace BookingMonolith.Passenger.Passengers.Exceptions; - -public class PassengerNotFoundException : AppException -{ - public PassengerNotFoundException() : base("Passenger not found!", HttpStatusCode.NotFound) - { - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs deleted file mode 100644 index 7da4ef2..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs +++ /dev/null @@ -1,117 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Passenger.Data; -using BookingMonolith.Passenger.Passengers.Dtos; -using BookingMonolith.Passenger.Passengers.Exceptions; -using BookingMonolith.Passenger.Passengers.ValueObjects; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace BookingMonolith.Passenger.Passengers.Features.CompletingRegisterPassenger.V1; - -public record CompleteRegisterPassenger - (string PassportNumber, Enums.PassengerType PassengerType, int Age) : ICommand, - IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record PassengerRegistrationCompletedDomainEvent(Guid Id, string Name, string PassportNumber, - Enums.PassengerType PassengerType, int Age, bool IsDeleted = false) : IDomainEvent; - -public record CompleteRegisterPassengerResult(PassengerDto PassengerDto); - -public record CompleteRegisterPassengerRequestDto(string PassportNumber, Enums.PassengerType PassengerType, int Age); - -public record CompleteRegisterPassengerResponseDto(PassengerDto PassengerDto); - -public class CompleteRegisterPassengerEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/passenger/complete-registration", async ( - CompleteRegisterPassengerRequestDto request, IMapper mapper, - IMediator mediator, CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CompleteRegisterPassenger") - .WithApiVersionSet(builder.NewApiVersionSet("Passenger").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Complete Register Passenger") - .WithDescription("Complete Register Passenger") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CompleteRegisterPassengerValidator : AbstractValidator -{ - public CompleteRegisterPassengerValidator() - { - RuleFor(x => x.PassportNumber).NotNull().WithMessage("The PassportNumber is required!"); - RuleFor(x => x.Age).GreaterThan(0).WithMessage("The Age must be greater than 0!"); - RuleFor(x => x.PassengerType).Must(p => p.GetType().IsEnum && - p == Enums.PassengerType.Baby || - p == Enums.PassengerType.Female || - p == Enums.PassengerType.Male || - p == Enums.PassengerType.Unknown) - .WithMessage("PassengerType must be Male, Female, Baby or Unknown"); - } -} - -internal class CompleteRegisterPassengerCommandHandler : ICommandHandler -{ - private readonly IMapper _mapper; - private readonly PassengerDbContext _passengerDbContext; - - public CompleteRegisterPassengerCommandHandler(IMapper mapper, PassengerDbContext passengerDbContext) - { - _mapper = mapper; - _passengerDbContext = passengerDbContext; - } - - public async Task Handle(CompleteRegisterPassenger request, - CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var passenger = await _passengerDbContext.Passengers.SingleOrDefaultAsync( - x => x.PassportNumber.Value == request.PassportNumber, cancellationToken); - - if (passenger is null) - { - throw new PassengerNotExist(); - } - - passenger.CompleteRegistrationPassenger(passenger.Id, passenger.Name, - passenger.PassportNumber, request.PassengerType, Age.Of(request.Age)); - - var updatePassenger = _passengerDbContext.Passengers.Update(passenger).Entity; - - var passengerDto = _mapper.Map(updatePassenger); - - return new CompleteRegisterPassengerResult(passengerDto); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs deleted file mode 100644 index d067dcf..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Passenger.Data; -using BookingMonolith.Passenger.Passengers.Models; -using BookingMonolith.Passenger.Passengers.ValueObjects; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Passenger.Passengers.Features.CompletingRegisterPassenger.V1; - -public record CompleteRegisterPassengerMongoCommand(Guid Id, string PassportNumber, string Name, - Enums.PassengerType PassengerType, int Age, bool IsDeleted = false) : InternalCommand; - - -internal class CompleteRegisterPassengerMongoHandler : ICommandHandler -{ - private readonly PassengerReadDbContext _passengerReadDbContext; - private readonly IMapper _mapper; - - public CompleteRegisterPassengerMongoHandler( - PassengerReadDbContext passengerReadDbContext, - IMapper mapper) - { - _passengerReadDbContext = passengerReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CompleteRegisterPassengerMongoCommand request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var passengerReadModel = _mapper.Map(request); - - var passenger = await _passengerReadDbContext.Passenger.AsQueryable() - .FirstOrDefaultAsync(x => x.PassengerId == passengerReadModel.PassengerId && !x.IsDeleted, cancellationToken); - - if (passenger is not null) - { - await _passengerReadDbContext.Passenger.UpdateOneAsync( - x => x.PassengerId == PassengerId.Of(passengerReadModel.PassengerId), - Builders.Update - .Set(x => x.PassengerId, PassengerId.Of(passengerReadModel.PassengerId)) - .Set(x => x.Age, passengerReadModel.Age) - .Set(x => x.Name, passengerReadModel.Name) - .Set(x => x.IsDeleted, passengerReadModel.IsDeleted) - .Set(x => x.PassengerType, passengerReadModel.PassengerType) - .Set(x => x.PassportNumber, passengerReadModel.PassportNumber), - cancellationToken: cancellationToken); - } - else - { - await _passengerReadDbContext.Passenger.InsertOneAsync(passengerReadModel, - cancellationToken: cancellationToken); - } - - return Unit.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs deleted file mode 100644 index b70788b..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs +++ /dev/null @@ -1,89 +0,0 @@ -using Ardalis.GuardClauses; -using BookingMonolith.Passenger.Data; -using BookingMonolith.Passenger.Passengers.Dtos; -using BookingMonolith.Passenger.Passengers.Exceptions; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace BookingMonolith.Passenger.Passengers.Features.GettingPassengerById.V1; - -public record GetPassengerById(Guid Id) : IQuery; - -public record GetPassengerByIdResult(PassengerDto PassengerDto); - -public record GetPassengerByIdResponseDto(PassengerDto PassengerDto); - -public class GetPassengerByIdEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/passenger/{{id}}", - async (Guid id, IMediator mediator, CancellationToken cancellationToken) => - { - var result = await mediator.Send(new GetPassengerById(id), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetPassengerById") - .WithApiVersionSet(builder.NewApiVersionSet("Passenger").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Passenger By Id") - .WithDescription("Get Passenger By Id") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class GetPassengerByIdValidator : AbstractValidator -{ - public GetPassengerByIdValidator() - { - RuleFor(x => x.Id).NotNull().WithMessage("Id is required!"); - } -} - -internal class GetPassengerByIdHandler : IQueryHandler -{ - private readonly IMapper _mapper; - private readonly PassengerReadDbContext _passengerReadDbContext; - - public GetPassengerByIdHandler(IMapper mapper, PassengerReadDbContext passengerReadDbContext) - { - _mapper = mapper; - _passengerReadDbContext = passengerReadDbContext; - } - - public async Task Handle(GetPassengerById query, CancellationToken cancellationToken) - { - Guard.Against.Null(query, nameof(query)); - - var passenger = - await _passengerReadDbContext.Passenger.AsQueryable() - .SingleOrDefaultAsync(x => x.PassengerId == query.Id && x.IsDeleted == false, cancellationToken); - - if (passenger is null) - { - throw new PassengerNotFoundException(); - } - - var passengerDto = _mapper.Map(passenger); - - return new GetPassengerByIdResult(passengerDto); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/PassengerMappings.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/PassengerMappings.cs deleted file mode 100644 index 6ef4013..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Features/PassengerMappings.cs +++ /dev/null @@ -1,27 +0,0 @@ -using BookingMonolith.Passenger.Passengers.Dtos; -using BookingMonolith.Passenger.Passengers.Features.CompletingRegisterPassenger.V1; -using BookingMonolith.Passenger.Passengers.Models; -using BookingMonolith.Passenger.Passengers.ValueObjects; -using Mapster; -using MassTransit; - -namespace BookingMonolith.Passenger.Passengers.Features; - -public class PassengerMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.PassengerId, s => PassengerId.Of(s.Id)); - - config.NewConfig() - .ConstructUsing(x => new CompleteRegisterPassenger(x.PassportNumber, x.PassengerType, x.Age)); - - config.NewConfig() - .ConstructUsing(x => new PassengerDto(x.PassengerId, x.Name, x.PassportNumber, x.PassengerType, x.Age)); - - config.NewConfig() - .ConstructUsing(x => new PassengerDto(x.Id.Value, x.Name.Value, x.PassportNumber.Value, x.PassengerType, x.Age.Value)); - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Models/Passenger.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Models/Passenger.cs deleted file mode 100644 index 79754f9..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Models/Passenger.cs +++ /dev/null @@ -1,44 +0,0 @@ -using BookingMonolith.Passenger.Identity.Consumers.RegisteringNewUser.V1; -using BookingMonolith.Passenger.Passengers.Features.CompletingRegisterPassenger.V1; -using BookingMonolith.Passenger.Passengers.ValueObjects; -using BuildingBlocks.Core.Model; - -namespace BookingMonolith.Passenger.Passengers.Models; - -public record Passenger : Aggregate -{ - public PassportNumber PassportNumber { get; private set; } = default!; - public Name Name { get; private set; } = default!; - public Enums.PassengerType PassengerType { get; private set; } - public Age? Age { get; private set; } - - public void CompleteRegistrationPassenger(PassengerId id, Name name, PassportNumber passportNumber, - Enums.PassengerType passengerType, Age age, bool isDeleted = false) - { - this.Id = id; - this.Name = name; - this.PassportNumber = passportNumber; - this.PassengerType = passengerType; - this.Age = age; - this.IsDeleted = isDeleted; - - var @event = new PassengerRegistrationCompletedDomainEvent(this.Id, this.Name, - this.PassportNumber, - this.PassengerType, this.Age, this.IsDeleted); - - this.AddDomainEvent(@event); - } - - - public static Passenger Create(PassengerId id, Name name, PassportNumber passportNumber, bool isDeleted = false) - { - var passenger = new Passenger { Id = id, Name = name, PassportNumber = passportNumber, IsDeleted = isDeleted }; - - var @event = new PassengerCreatedDomainEvent(passenger.Id, passenger.Name, passenger.PassportNumber, - passenger.IsDeleted); - - passenger.AddDomainEvent(@event); - - return passenger; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Models/PassengerReadModel.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Models/PassengerReadModel.cs deleted file mode 100644 index 76f2e30..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/Models/PassengerReadModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace BookingMonolith.Passenger.Passengers.Models; -public class PassengerReadModel -{ - public required Guid Id { get; init; } - public required Guid PassengerId { get; init; } - public required string PassportNumber { get; init; } - public required string Name { get; init; } - public required Enums.PassengerType PassengerType { get; init; } - public int Age { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/Age.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/Age.cs deleted file mode 100644 index 76bca74..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/Age.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Passenger.Passengers.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.ValueObjects; - -public record Age -{ - public int Value { get; } - - private Age(int value) - { - Value = value; - } - - public static Age Of(int value) - { - if (value <= 0) - { - throw new InvalidAgeException(); - } - - return new Age(value); - } - - public static implicit operator int(Age age) - { - return age.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/Name.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/Name.cs deleted file mode 100644 index 3b11f8f..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/Name.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Passenger.Passengers.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.ValueObjects; - -public record Name -{ - public string Value { get; } - - private Name(string value) - { - Value = value; - } - - public static Name Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidNameException(); - } - - return new Name(value); - } - - public static implicit operator string(Name name) - { - return name.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/PassengerId.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/PassengerId.cs deleted file mode 100644 index 7e7a243..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/PassengerId.cs +++ /dev/null @@ -1,28 +0,0 @@ -using BookingMonolith.Passenger.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.ValueObjects; - -public record PassengerId -{ - public Guid Value { get; } - - private PassengerId(Guid value) - { - Value = value; - } - - public static PassengerId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidPassengerIdException(value); - } - - return new PassengerId(value); - } - - public static implicit operator Guid(PassengerId passengerId) - { - return passengerId.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/PassportNumber.cs b/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/PassportNumber.cs deleted file mode 100644 index ea664fc..0000000 --- a/1-monolith-architecture-style/src/BookingMonolith/src/Passenger/Passengers/ValueObjects/PassportNumber.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BookingMonolith.Passenger.Passengers.Exceptions; - -namespace BookingMonolith.Passenger.Passengers.ValueObjects; - -public record PassportNumber -{ - public string Value { get; } - - public override string ToString() - { - return Value; - } - - private PassportNumber(string value) - { - Value = value; - } - - public static PassportNumber Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidPassportNumberException(); - } - - return new PassportNumber(value); - } - - public static implicit operator string(PassportNumber passportNumber) - { - return passportNumber.Value; - } -} diff --git a/1-monolith-architecture-style/src/BookingMonolith/tests/.gitkeep b/1-monolith-architecture-style/src/BookingMonolith/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/2-modular-monolith-architecture-style/README.md b/2-modular-monolith-architecture-style/README.md deleted file mode 100644 index 9650bb5..0000000 --- a/2-modular-monolith-architecture-style/README.md +++ /dev/null @@ -1,111 +0,0 @@ -# 🪁 Modular Monolith Architecture Style - -> In **Modular Monolith Architecture**, the application is divided into modules, each responsible for a specific functionality. However, the entire application is still deployed as a single unit. - -# Table of Contents - -- [Key Features](#key-features) -- [When to Use](#when-to-use) -- [Challenges](#challenges) -- [Modular Monolith Architecture Design](#modular-monolith-architecture-design) -- [Development Setup](#development-setup) - - [Dotnet Tools Packages](#dotnet-tools-packages) - - [Husky](#husky) - - [Upgrade Nuget Packages](#upgrade-nuget-packages) -- [How to Run](#how-to-run) - - [Docker Compose](#docker-compose) - - [Build](#build) - - [Run](#run) - - [Test](#test) -- [Documentation Apis](#documentation-apis) - - -## Key Features -1. **Modular Design**: The application is divided into modules, each responsible for a specific functionality. -2. **Loose Coupling**: Modules interact through well-defined interfaces, improving maintainability. -3. **Single Deployment**: The entire application is still deployed as one unit. -4. **Shared Database**: Typically uses a single database, but modules can have their own schemas or tables. - - -## When to Use -1. **Medium to Large Projects**: Suitable for applications with growing complexity but not ready for microservices. -2. **Better Maintainability**: Ideal for teams wanting a more organized and maintainable codebase than a traditional monolith. -3. **Future-Proofing**: A stepping stone toward microservices, allowing teams to prepare for future scalability. -4. **Single Team or Small Teams**: Works well for teams that want modularity without the overhead of distributed systems. - - -## Challenges -- Still a single deployment unit, so scaling is limited. -- Requires careful design to avoid tight coupling between modules. -- Not as scalable or fault-tolerant as microservices. - - -## Modular Monolith Architecture Design - -![](./assets/booking-modular-monolith.png) - - -## Development Setup - -### Dotnet Tools Packages -For installing our requirement packages with .NET cli tools, we need to install `dotnet tool manifest`. -```bash -dotnet new tool-manifest -``` -And after that we can restore our dotnet tools packages with .NET cli tools from `.config` folder and `dotnet-tools.json` file. -``` -dotnet tool restore -``` - -### Husky -Here we use `husky` to handel some pre commit rules and we used `conventional commits` rules and `formatting` as pre commit rules, here in [package.json](.././package.json). of course, we can add more rules for pre commit in future. (find more about husky in the [documentation](https://typicode.github.io/husky/get-started.html)) -We need to install `husky` package for `manage` `pre commits hooks` and also I add two packages `@commitlint/cli` and `@commitlint/config-conventional` for handling conventional commits rules in [package.json](.././package.json). -Run the command bellow in the root of project to install all npm dependencies related to husky: - -```bash -npm install -``` - -> Note: In the root of project we have `.husky` folder and it has `commit-msg` file for handling conventional commits rules with provide user friendly message and `pre-commit` file that we can run our `scripts` as a `pre-commit` hooks. that here we call `format` script from [package.json](./package.json) for formatting purpose. - -### Upgrade Nuget Packages -For upgrading our nuget packages to last version, we use the great package [dotnet-outdated](https://github.com/dotnet-outdated/dotnet-outdated). -Run the command below in the root of project to upgrade all of packages to last version: -```bash -dotnet outdated -u -``` - -## How to Run - -> ### Docker Compose - -To run this app in `Docker`, use the [docker-compose.yaml](./deployments/docker-compose/docker-compose.yaml) and execute the below command at the `root` of the application: - -```bash -docker-compose -f ./deployments/docker-compose/docker-compose.yaml up -d -``` - -> ### Build -To `build` all modules, run this command in the `root` of the project: -```bash -dotnet build -``` - -> ### Run -To `run` all modules, run this command in the root of the `Api` folder where the `csproj` file is located: -```bash -dotnet run -``` - -> ### Test - -To `test` all modules, run this command in the `root` of the project: -```bash -dotnet test -``` - -> ### Documentation Apis - -Each microservice provides `API documentation` and navigate to `/swagger` for `Swagger OpenAPI` or `/scalar/v1` for `Scalar OpenAPI` to visit list of endpoints. - -As part of API testing, I created the [booking.rest](./booking.rest) file which can be run with the [REST Client](https://github.com/Huachao/vscode-restclient) `VSCode plugin`. diff --git a/2-modular-monolith-architecture-style/assets/booking-modular-monolith.drawio b/2-modular-monolith-architecture-style/assets/booking-modular-monolith.drawio deleted file mode 100644 index 1cfebb4..0000000 --- a/2-modular-monolith-architecture-style/assets/booking-modular-monolith.drawio +++ /dev/null @@ -1,363 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/2-modular-monolith-architecture-style/assets/booking-modular-monolith.png b/2-modular-monolith-architecture-style/assets/booking-modular-monolith.png deleted file mode 100644 index 7e9a60a..0000000 Binary files a/2-modular-monolith-architecture-style/assets/booking-modular-monolith.png and /dev/null differ diff --git a/2-modular-monolith-architecture-style/booking.rest b/2-modular-monolith-architecture-style/booking.rest deleted file mode 100644 index 3f7b5a0..0000000 --- a/2-modular-monolith-architecture-style/booking.rest +++ /dev/null @@ -1,230 +0,0 @@ - -@booking-modular-monolith-api=https://localhost:3000 - -@contentType = application/json -@flightid = "3c5c0000-97c6-fc34-2eb9-08db322230c9" -@passengerId = "8c9c0000-97c6-fc34-2eb9-66db322230c9" - -################################# Identity API ################################# - -### -# @name Authenticate -POST {{booking-modular-monolith-api}}/connect/token -Content-Type: application/x-www-form-urlencoded - -grant_type=password -&client_id=client -&client_secret=secret -&username=samh -&password=Admin@123456 -&scope=booking-modular-monolith role -### - - - -### -# @name Register_New_User -POST {{booking-modular-monolith-api}}/api/v1/identity/register-user -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "firstName": "John", - "lastName": "Do", - "username": "admin", - "passportNumber": "41290000", - "email": "admin@admin.com", - "password": "Admin@12345", - "confirmPassword": "Admin@12345" -} -### - -################################# Flight API ################################# - -### -# @name Create_Seat -Post {{booking-modular-monolith-api}}/api/v1/flight/seat -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "seatNumber": "1255", - "type": 1, - "class": 1, - "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9" -} -### - - -### -# @name Reserve_Seat -Post {{booking-modular-monolith-api}}/api/v1/flight/reserve-seat -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9", - "seatNumber": "1255" -} -### - - -### -# @name Get_Available_Seats -GET {{booking-modular-monolith-api}}/api/v1/flight/get-available-seats/{{flightid}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Get_Flight_By_Id -GET {{booking-modular-monolith-api}}/api/v1/flight/{{flightid}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Get_Available_Flights -GET {{booking-modular-monolith-api}}/api/v1/flight/get-available-flights -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Create_Flights -POST {{booking-modular-monolith-api}}/api/v1/flight -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "flightNumber": "12BB", - "aircraftId": "3c5c0000-97c6-fc34-fcd3-08db322230c8", - "departureAirportId": "3c5c0000-97c6-fc34-a0cb-08db322230c8", - "departureDate": "2022-03-01T14:55:41.255Z", - "arriveDate": "2022-03-01T14:55:41.255Z", - "arriveAirportId": "3c5c0000-97c6-fc34-fc3c-08db322230c8", - "durationMinutes": 120, - "flightDate": "2022-03-01T14:55:41.255Z", - "status": 1, - "price": 8000 -} -### - - -### -# @name Update_Flights -PUT {{booking-modular-monolith-api}}/api/v1/flight -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "id": 1, - "flightNumber": "BD467", - "aircraftId": "3c5c0000-97c6-fc34-fcd3-08db322230c8", - "departureAirportId": "3c5c0000-97c6-fc34-a0cb-08db322230c8", - "departureDate": "2022-04-23T12:17:45.140Z", - "arriveDate": "2022-04-23T12:17:45.140Z", - "arriveAirportId": "3c5c0000-97c6-fc34-fc3c-08db322230c8", - "durationMinutes": 120, - "flightDate": "2022-04-23T12:17:45.140Z", - "status": 4, - "isDeleted": false, - "price": 99000 -} -### - - -### -# @name Delete_Flights -DELETE {{booking-modular-monolith-api}}/api/v1/flight/{{flightid}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -### -# @name Create_Airport -POST {{booking-modular-monolith-api}}/api/v1/flight/airport -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "name": "mehrabad", - "address": "tehran", - "code": "12YD" -} -### - - - -### -# @name Create_Aircraft -POST {{booking-modular-monolith-api}}/api/v1/flight/aircraft -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "name": "airbus2", - "model": "322", - "manufacturingYear": 2012 -} -### - - -################################# Passenger API ################################# - - -### -# @name Complete_Registration_Passenger -POST {{booking-modular-monolith-api}}/api/v1/passenger/complete-registration -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "passportNumber": "41290000", - "passengerType": 1, - "age": 30 -} -### - - -### -# @name Get_Passenger_By_Id -GET {{booking-modular-monolith-api}}/api/v1/passenger/{{passengerId}} -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} -### - - -################################# Booking API ################################# - - -### -# @name Create_Booking -POST {{booking-modular-monolith-api}}/api/v1/booking -accept: application/json -Content-Type: application/json -authorization: bearer {{Authenticate.response.body.access_token}} - -{ - "passengerId": "8c9c0000-97c6-fc34-2eb9-66db322230c9", - "flightId": "3c5c0000-97c6-fc34-2eb9-08db322230c9", - "description": "I want to fly to iran" -} -### diff --git a/2-modular-monolith-architecture-style/deployments/.gitkeep b/2-modular-monolith-architecture-style/deployments/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/2-modular-monolith-architecture-style/deployments/configs/dashboards.md b/2-modular-monolith-architecture-style/deployments/configs/dashboards.md deleted file mode 100644 index 999b1d8..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/dashboards.md +++ /dev/null @@ -1,8 +0,0 @@ -# Dashboards - -- [Introducing ASP.NET Core metrics and Grafana dashboards in .NET 8](https://devblogs.microsoft.com/dotnet/introducing-aspnetcore-metrics-and-grafana-dashboards-in-dotnet-8/) -- [ASP.NET Core](https://grafana.com/grafana/dashboards/19924-asp-net-core/) -- [ASP.NET Core Endpoint](https://grafana.com/grafana/dashboards/19925-asp-net-core-endpoint/) -- [Node Exporter Quickstart and Dashboard](https://grafana.com/grafana/dashboards/13978-node-exporter-quickstart-and-dashboard/) -- [PostgreSQL Exporter Quickstart and Dashboard](https://grafana.com/grafana/dashboards/14114-postgres-overview/) -- [RabbitMQ-Overview](https://grafana.com/grafana/dashboards/10991-rabbitmq-overview/) \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json b/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json deleted file mode 100644 index 9859cc9..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json +++ /dev/null @@ -1,908 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY", - "label": "Managed_Prometheus_jamesnk-telemetry", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "9.4.8" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 0, - "id": null, - "links": [ - { - "asDropdown": false, - "icon": "dashboard", - "includeVars": false, - "keepTime": true, - "tags": [], - "targetBlank": false, - "title": " ASP.NET Core", - "tooltip": "", - "type": "link", - "url": "/d/KdDACDp4z/asp-net-core-metrics" - } - ], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "dark-green", - "mode": "continuous-GrYlRd", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMin": 0, - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "s" - }, - "overrides": [ - { - "__systemRef": "hideSeriesFrom", - "matcher": { - "id": "byNames", - "options": { - "mode": "exclude", - "names": [ - "p50" - ], - "prefix": "All except:", - "readOnly": true - } - }, - "properties": [ - { - "id": "custom.hideFrom", - "value": { - "legend": false, - "tooltip": false, - "viz": false - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 0, - "y": 0 - }, - "id": 40, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.50, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "legendFormat": "p50", - "range": true, - "refId": "p50" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.75, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p75", - "range": true, - "refId": "p75" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.90, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p90", - "range": true, - "refId": "p90" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.95, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p95", - "range": true, - "refId": "p95" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.98, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p98", - "range": true, - "refId": "p98" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.99, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p99", - "range": true, - "refId": "p99" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.999, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p99.9", - "range": true, - "refId": "p99.9" - } - ], - "title": "Requests Duration - $method $route", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "percentunit" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "All" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "4XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "5XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 12, - "y": 0 - }, - "id": 46, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\", status_code=~\"4..|5..\"}[5m]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m]))", - "legendFormat": "All", - "range": true, - "refId": "All" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\", status_code=~\"4..\"}[5m]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m]))", - "hide": false, - "legendFormat": "4XX", - "range": true, - "refId": "4XX" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\", status_code=~\"5..\"}[5m]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m]))", - "hide": false, - "legendFormat": "5XX", - "range": true, - "refId": "5XX" - } - ], - "title": "Errors Rate - $method $route", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Requests" - }, - "properties": [ - { - "id": "custom.width", - "value": 300 - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "color", - "value": { - "mode": "continuous-YlRd" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Route" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "title": "", - "url": "/d/NagEsjE4z/asp-net-core-endpoint-details?var-route=${__data.fields.Route}&var-method=${__data.fields.Method}&${__url_time_range}" - } - ] - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 9 - }, - "hideTimeOverride": false, - "id": 44, - "options": { - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Value" - } - ] - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": "sum by (exception_name) (\r\n max_over_time(http_server_request_duration_s_count{route=\"$route\", method=\"$method\", exception_name!=\"\"}[$__rate_interval])\r\n)", - "format": "table", - "instant": true, - "interval": "", - "legendFormat": "{{route}}", - "range": false, - "refId": "A" - } - ], - "title": "Unhandled Exceptions", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "method": false - }, - "indexByName": { - "Time": 0, - "Value": 2, - "exception_name": 1 - }, - "renameByName": { - "Value": "Requests", - "exception_name": "Exception", - "method": "Method", - "route": "Route" - } - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "blue", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 12, - "x": 12, - "y": 9 - }, - "id": 42, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (status_code) (\r\n max_over_time(http_server_request_duration_s_count{route=\"$route\", method=\"$method\"}[$__rate_interval])\r\n )", - "legendFormat": "Status {{status_code}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests HTTP Status Code", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "green", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 12, - "y": 13 - }, - "id": 48, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (scheme) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[$__rate_interval])\r\n )", - "legendFormat": "{{scheme}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests Secured", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "purple", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 18, - "y": 13 - }, - "id": 50, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (protocol) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[$__rate_interval])\r\n )", - "legendFormat": "{{protocol}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests HTTP Protocol", - "type": "stat" - } - ], - "refresh": "", - "revision": 1, - "schemaVersion": 38, - "style": "dark", - "tags": [ - "dotnet", - "prometheus", - "aspnetcore" - ], - "templating": { - "list": [ - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests, job)", - "hide": 0, - "includeAll": false, - "label": "Job", - "multi": false, - "name": "job", - "options": [], - "query": { - "query": "label_values(http_server_current_requests, job)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "hide": 0, - "includeAll": false, - "label": "Instance", - "multi": false, - "name": "instance", - "options": [], - "query": { - "query": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_request_duration_s_count, route)", - "description": "Route", - "hide": 0, - "includeAll": false, - "label": "Route", - "multi": false, - "name": "route", - "options": [], - "query": { - "query": "label_values(http_server_request_duration_s_count, route)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_request_duration_s_count{route=~\"$route\"}, method)", - "hide": 0, - "includeAll": false, - "label": "Method", - "multi": false, - "name": "method", - "options": [], - "query": { - "query": "label_values(http_server_request_duration_s_count{route=~\"$route\"}, method)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - } - ] - }, - "time": { - "from": "now-30m", - "to": "now" - }, - "timepicker": {}, - "timezone": "", - "title": "ASP.NET Core Endpoint", - "uid": "NagEsjE4z", - "version": 10, - "weekStart": "" -} \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json b/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json deleted file mode 100644 index b435130..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json +++ /dev/null @@ -1,1307 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY", - "label": "Managed_Prometheus_jamesnk-telemetry", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "9.4.8" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "description": "ASP.NET Core metrics from OpenTelemetry NuGet", - "editable": true, - "fiscalYearStartMonth": 0, - "gnetId": 17706, - "graphTooltip": 0, - "id": null, - "links": [], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "dark-green", - "mode": "continuous-GrYlRd", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMin": 0, - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "s" - }, - "overrides": [ - { - "__systemRef": "hideSeriesFrom", - "matcher": { - "id": "byNames", - "options": { - "mode": "exclude", - "names": [ - "p50" - ], - "prefix": "All except:", - "readOnly": true - } - }, - "properties": [ - { - "id": "custom.hideFrom", - "value": { - "legend": false, - "tooltip": false, - "viz": false - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 0, - "y": 0 - }, - "id": 40, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.50, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "legendFormat": "p50", - "range": true, - "refId": "p50" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.75, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p75", - "range": true, - "refId": "p75" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.90, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p90", - "range": true, - "refId": "p90" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.95, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p95", - "range": true, - "refId": "p95" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.98, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p98", - "range": true, - "refId": "p98" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.99, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p99", - "range": true, - "refId": "p99" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.999, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\"}[$__rate_interval])) by (le))", - "hide": false, - "legendFormat": "p99.9", - "range": true, - "refId": "p99.9" - } - ], - "title": "Requests Duration", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "percentunit" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "All" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "4XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "5XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 12, - "y": 0 - }, - "id": 47, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", status_code=~\"4..|5..\"}[$__rate_interval]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval]))", - "legendFormat": "All", - "range": true, - "refId": "All" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", status_code=~\"4..\"}[$__rate_interval]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval]))", - "hide": false, - "legendFormat": "4XX", - "range": true, - "refId": "4XX" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", status_code=~\"5..\"}[$__rate_interval]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval]))", - "hide": false, - "legendFormat": "5XX", - "range": true, - "refId": "5XX" - } - ], - "title": "Errors Rate", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 6, - "x": 0, - "y": 9 - }, - "id": 49, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(kestrel_current_connections{job=\"$job\", instance=\"$instance\"})", - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Current Connections", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "auto", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 8, - "w": 6, - "x": 6, - "y": 9 - }, - "id": 55, - "options": { - "legend": { - "calcs": [], - "displayMode": "list", - "placement": "bottom", - "showLegend": false - }, - "tooltip": { - "mode": "single", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(http_server_current_requests{job=\"$job\", instance=\"$instance\"})", - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Current Requests", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "blue", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 12, - "y": 9 - }, - "id": 58, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "center", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "value" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": "sum(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"})", - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Total Requests", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "dark-red", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 18, - "y": 9 - }, - "id": 59, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "center", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "text": {}, - "textMode": "value" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": "sum(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", exception_name!=\"\"})", - "instant": false, - "legendFormat": "__auto", - "range": true, - "refId": "A" - } - ], - "title": "Total Unhandled Exceptions", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "green", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 12, - "y": 13 - }, - "id": 60, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (scheme) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval])\r\n )", - "legendFormat": "{{scheme}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests Secured", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "purple", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 18, - "y": 13 - }, - "id": 42, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (protocol) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\"}[$__rate_interval])\r\n )", - "legendFormat": "{{protocol}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests HTTP Protocol", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Requests" - }, - "properties": [ - { - "id": "custom.width", - "value": 300 - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "color", - "value": { - "mode": "continuous-BlPu" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Endpoint" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "targetBlank": false, - "title": "Test", - "url": "/d/NagEsjE4z/asp-net-core-endpoint-details?var-route=${__data.fields.route}&var-method=${__data.fields.method}&${__url_time_range}" - } - ] - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "route" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "method" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 17 - }, - "hideTimeOverride": false, - "id": 51, - "options": { - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Value" - } - ] - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": " topk(10,\r\n sum by (route, method, method_route) (\r\n label_join(max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route!=\"\"}[$__rate_interval]), \"method_route\", \" \", \"method\", \"route\")\r\n ))", - "format": "table", - "instant": true, - "interval": "", - "legendFormat": "{{route}}", - "range": false, - "refId": "A" - } - ], - "title": "Top 10 Requested Endpoints", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "method": false, - "route": false - }, - "indexByName": { - "Time": 0, - "Value": 4, - "method": 2, - "method_route": 3, - "route": 1 - }, - "renameByName": { - "Value": "Requests", - "method": "", - "method_route": "Endpoint", - "route": "" - } - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Requests" - }, - "properties": [ - { - "id": "custom.width", - "value": 300 - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "color", - "value": { - "mode": "continuous-YlRd" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Endpoint" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "title": "", - "url": "/d/NagEsjE4z/asp-net-core-endpoint-details?var-route=${__data.fields.route}&var-method=${__data.fields.method}&${__url_time_range}" - } - ] - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "route" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "method" - }, - "properties": [ - { - "id": "custom.hidden", - "value": true - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 17 - }, - "hideTimeOverride": false, - "id": 54, - "options": { - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Value" - } - ] - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": " topk(10,\r\n sum by (route, method, method_route) (\r\n label_join(max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route!=\"\", exception_name!=\"\"}[$__rate_interval]), \"method_route\", \" \", \"method\", \"route\")\r\n ))", - "format": "table", - "instant": true, - "interval": "", - "legendFormat": "{{route}}", - "range": false, - "refId": "A" - } - ], - "title": "Top 10 Unhandled Exception Endpoints", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "method": false - }, - "indexByName": { - "Time": 0, - "Value": 4, - "method": 2, - "method_route": 3, - "route": 1 - }, - "renameByName": { - "Value": "Requests", - "method": "", - "method_route": "Endpoint", - "route": "" - } - } - } - ], - "type": "table" - } - ], - "refresh": "", - "revision": 1, - "schemaVersion": 38, - "style": "dark", - "tags": [ - "dotnet", - "prometheus", - "aspnetcore" - ], - "templating": { - "list": [ - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests, job)", - "hide": 0, - "includeAll": false, - "label": "Job", - "multi": false, - "name": "job", - "options": [], - "query": { - "query": "label_values(http_server_current_requests, job)", - "refId": "StandardVariableQuery" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "hide": 0, - "includeAll": false, - "label": "Instance", - "multi": false, - "name": "instance", - "options": [], - "query": { - "query": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "refId": "StandardVariableQuery" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - } - ] - }, - "time": { - "from": "now-30m", - "to": "now" - }, - "timepicker": {}, - "timezone": "", - "title": "ASP.NET Core", - "uid": "KdDACDp4z", - "version": 5, - "weekStart": "" -} \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/postgresql.json b/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/postgresql.json deleted file mode 100644 index d1d696f..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/postgresql.json +++ /dev/null @@ -1,1459 +0,0 @@ -{ - "__inputs": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "7.2.0" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "description": "A quickstart to setup the Prometheus PostgreSQL Exporter with preconfigured dashboards, alerting rules, and recording rules.", - "editable": true, - "gnetId": 14114, - "graphTooltip": 0, - "id": 1, - "iteration": 1603191461722, - "links": [], - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 20, - "x": 0, - "y": 0 - }, - "hiddenSeries": false, - "id": 1, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "max": true, - "min": true, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_fetched{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "fetched", - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_returned{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "returned", - "measurement": "postgresql", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_inserted{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "inserted", - "measurement": "postgresql", - "policy": "default", - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_updated{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "updated", - "measurement": "postgresql", - "policy": "default", - "refId": "D", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "fetched", - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_deleted{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "deleted", - "measurement": "postgresql", - "policy": "default", - "refId": "E", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "tup_fetched" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 120, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Rows", - "tooltip": { - "msResolution": true, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "datasource": "$datasource", - "decimals": 0, - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 0 - }, - "height": "55px", - "id": 11, - "interval": null, - "isNew": true, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": true, - "lineColor": "rgb(31, 120, 193)", - "show": true - }, - "tableColumn": "", - "targets": [ - { - "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_xact_commit{datname=~\"$db\",instance=~\"$instance\"}[5m])) + sum(irate(pg_stat_database_xact_rollback{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "xact_commit" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [ - "10s" - ], - "type": "non_negative_derivative" - } - ] - ], - "step": 1800, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": "", - "title": "QPS", - "transparent": true, - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "decimals": 1, - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 7 - }, - "hiddenSeries": false, - "id": 2, - "isNew": true, - "legend": { - "alignAsTable": true, - "avg": true, - "current": false, - "hideZero": true, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_alloc{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_alloc", - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_backend_fsync{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_backend_fsync", - "measurement": "postgresql", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_backend{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_backend", - "measurement": "postgresql", - "policy": "default", - "refId": "C", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_clean{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_clean", - "measurement": "postgresql", - "policy": "default", - "refId": "D", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "Buffers Allocated", - "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_checkpoint{instance=~'$instance'}[5m])", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "buffers_checkpoint", - "measurement": "postgresql", - "policy": "default", - "refId": "E", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "buffers_alloc" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Buffers", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 7 - }, - "hiddenSeries": false, - "id": 3, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "conflicts", - "dsType": "prometheus", - "expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "deadlocks", - "measurement": "postgresql", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "conflicts" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - }, - { - "alias": "deadlocks", - "dsType": "prometheus", - "expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",instance=~\"$instance\"}[5m]))", - "format": "time_series", - "groupBy": [ - { - "params": [ - "$interval" - ], - "type": "time" - }, - { - "params": [ - "null" - ], - "type": "fill" - } - ], - "intervalFactor": 2, - "legendFormat": "conflicts", - "measurement": "postgresql", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "deadlocks" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "step": 240, - "tags": [ - { - "key": "instance", - "operator": "=~", - "value": "/^$instance$/" - } - ] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Conflicts/Deadlocks", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 0, - "y": 14 - }, - "hiddenSeries": false, - "id": 12, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": true, - "pluginVersion": "7.2.1", - "pointradius": 1, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) / (sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) + sum(pg_stat_database_blks_read{datname=~\"$db\",instance=~\"$instance\"}))", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "cache hit rate", - "refId": "A", - "step": 240 - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Cache hit ratio", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percentunit", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "editable": true, - "error": false, - "fieldConfig": { - "defaults": { - "custom": {} - }, - "overrides": [] - }, - "fill": 1, - "fillGradient": 0, - "grid": {}, - "gridPos": { - "h": 7, - "w": 12, - "x": 12, - "y": 14 - }, - "hiddenSeries": false, - "id": 13, - "isNew": true, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 2, - "links": [], - "nullPointMode": "connected", - "options": { - "alertThreshold": true - }, - "percentage": false, - "pluginVersion": "7.2.1", - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "pg_stat_database_numbackends{datname=~\"$db\",instance=~\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "{{__name__}}", - "refId": "A", - "step": 240 - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Number of active connections", - "tooltip": { - "msResolution": false, - "shared": true, - "sort": 0, - "value_type": "cumulative" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "refresh": false, - "schemaVersion": 26, - "style": "dark", - "tags": [ - "postgres" - ], - "templating": { - "list": [ - { - "allValue": ".*", - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "$datasource", - "definition": "", - "hide": 0, - "includeAll": true, - "label": null, - "multi": false, - "name": "instance", - "options": [], - "query": "label_values(up{job=~\"postgres.*\"},instance)", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "allValue": ".*", - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "$datasource", - "definition": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)", - "hide": 0, - "includeAll": true, - "label": "db", - "multi": false, - "name": "db", - "options": [], - "query": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "current": { - "selected": false, - "text": "Postgres Overview", - "value": "Postgres Overview" - }, - "hide": 0, - "includeAll": false, - "label": "datasource", - "multi": false, - "name": "datasource", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" - }, - { - "allValue": null, - "current": { - "selected": true, - "text": "postgres", - "value": "postgres" - }, - "datasource": "$datasource", - "definition": "label_values(pg_up, job)", - "hide": 0, - "includeAll": false, - "label": "job", - "multi": false, - "name": "job", - "options": [ - { - "selected": true, - "text": "postgres", - "value": "postgres" - } - ], - "query": "label_values(pg_up, job)", - "refresh": 0, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-1h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "browser", - "title": "PostgreSQL Exporter Quickstart and Dashboard", - "uid": "wGgaPlciz", - "version": 5 -} \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json b/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json deleted file mode 100644 index b199b4b..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json +++ /dev/null @@ -1,8209 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "8.3.4" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "description": "A new RabbitMQ Management Overview", - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 1, - "id": null, - "iteration": 1659711638455, - "links": [ - { - "icon": "doc", - "tags": [], - "targetBlank": true, - "title": "Monitoring with Prometheus & Grafana", - "tooltip": "", - "type": "link", - "url": "https://www.rabbitmq.com/prometheus.html" - } - ], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#37872D", - "value": null - }, - { - "color": "#1F60C4", - "value": 10000 - }, - { - "color": "#C4162A", - "value": 100000 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "id": 64, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_ready * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "hide": false, - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Ready messages", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": -1 - }, - { - "color": "#37872D", - "value": 50 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 6, - "y": 0 - }, - "id": 62, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_received_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Incoming messages / s", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 12, - "y": 0 - }, - "id": 66, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_global_publishers * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Publishers", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 16, - "y": 0 - }, - "id": 37, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_connections * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Connections", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 0 - }, - "id": 40, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queues * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Queues", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#37872D", - "value": null - }, - { - "color": "#1F60C4", - "value": 100 - }, - { - "color": "#C4162A", - "value": 500 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 0, - "y": 3 - }, - "id": 65, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_unacked * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "hide": false, - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Unacknowledged messages", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": -1 - }, - { - "color": "#37872D", - "value": 50 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 6, - "y": 3 - }, - "id": 63, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_redelivered_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_consume_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_consume_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_get_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_get_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "hide": false, - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Outgoing messages / s", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 12, - "y": 3 - }, - "id": 41, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_consumers * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Consumers", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 16, - "y": 3 - }, - "id": 38, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_channels * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Channels", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#1F60C4", - "value": null - }, - { - "color": "#37872D", - "value": 3 - }, - { - "color": "#C4162A", - "value": 8 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 3 - }, - "id": 67, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_build_info * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Nodes", - "type": "stat" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 6 - }, - "id": 4, - "panels": [], - "title": "NODES", - "type": "row" - }, - { - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "displayMode": "auto" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "erlang_version" - }, - "properties": [ - { - "id": "displayName", - "value": "Erlang/OTP" - }, - { - "id": "unit", - "value": "none" - }, - { - "id": "custom.align" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(50, 172, 45, 0.97)", - "value": null - }, - { - "color": "rgba(237, 129, 40, 0.89)" - } - ] - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "rabbitmq_version" - }, - "properties": [ - { - "id": "displayName", - "value": "RabbitMQ" - }, - { - "id": "unit", - "value": "none" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(245, 54, 54, 0.9)", - "value": null - }, - { - "color": "rgba(237, 129, 40, 0.89)" - } - ] - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "instance" - }, - "properties": [ - { - "id": "displayName", - "value": "Host" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "rabbitmq_node" - }, - "properties": [ - { - "id": "displayName", - "value": "Node name" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(245, 54, 54, 0.9)", - "value": null - }, - { - "color": "rgba(237, 129, 40, 0.89)" - } - ] - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Time" - }, - "properties": [ - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Value" - }, - "properties": [ - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "job" - }, - "properties": [ - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "rabbitmq_cluster" - }, - "properties": [ - { - "id": "displayName", - "value": "Cluster" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "prometheus_client_version" - }, - "properties": [ - { - "id": "displayName", - "value": "prometheus.erl" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "prometheus_plugin_version" - }, - "properties": [ - { - "id": "displayName", - "value": "rabbitmq_prometheus" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - } - ] - }, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 7 - }, - "id": 69, - "links": [], - "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": false, - "expr": "rabbitmq_build_info * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "table", - "instant": true, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "transformations": [ - { - "id": "merge", - "options": { - "reducers": [] - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "If the value is zero or less, the memory alarm will be triggered and all publishing connections across all cluster nodes will be blocked.\n\nThis value can temporarily go negative because the memory alarm is triggered with a slight delay.\n\nThe kernel's view of the amount of memory used by the node can differ from what the node itself can observe. This means that this value can be negative for a sustained period of time.\n\nBy default nodes use resident set size (RSS) to compute how much memory they use. This strategy can be changed (see the guides below).\n\n* [Alarms](https://www.rabbitmq.com/alarms.html)\n* [Memory Alarms](https://www.rabbitmq.com/memory.html)\n* [Reasoning About Memory Use](https://www.rabbitmq.com/memory-use.html)\n* [Blocked Connection Notifications](https://www.rabbitmq.com/connection-blocked.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "decimals": 1, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 0 - }, - { - "color": "transparent", - "value": 536870912 - } - ] - }, - "unit": "bytes" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 11 - }, - "id": 7, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "(rabbitmq_resident_memory_limit_bytes * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) -\n(rabbitmq_process_resident_memory_bytes * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Memory available before publishers blocked", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "This metric is reported for the partition where the RabbitMQ data directory is stored.\n\nIf the value is zero or less, the disk alarm will be triggered and all publishing connections across all cluster nodes will be blocked.\n\nThis value can temporarily go negative because the free disk space alarm is triggered with a slight delay.\n\n* [Alarms](https://www.rabbitmq.com/alarms.html)\n* [Disk Space Alarms](https://www.rabbitmq.com/disk-alarms.html)\n* [Disk Space](https://www.rabbitmq.com/production-checklist.html#resource-limits-disk-space)\n* [Persistence Configuration](https://www.rabbitmq.com/persistence-conf.html)\n* [Blocked Connection Notifications](https://www.rabbitmq.com/connection-blocked.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "decimals": 1, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 1073741824 - }, - { - "color": "transparent", - "value": 5368709120 - } - ] - }, - "unit": "bytes" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 8, - "x": 12, - "y": 11 - }, - "id": 8, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_disk_space_available_bytes * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Disk space available before publishers blocked", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "When this value reaches zero, new connections will not be accepted and disk write operations may fail.\n\nClient libraries, peer nodes and CLI tools will not be able to connect when the node runs out of available file descriptors.\n\n* [Open File Handles Limit](https://www.rabbitmq.com/production-checklist.html#resource-limits-file-handle-limit)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 500 - }, - { - "color": "transparent", - "value": 1000 - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 4, - "w": 4, - "x": 20, - "y": 11 - }, - "id": 2, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "(rabbitmq_process_max_fds * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) -\n(rabbitmq_process_open_fds * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "File descriptors available", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "When this value reaches zero, new connections will not be accepted.\n\nClient libraries, peer nodes and CLI tools will not be able to connect when the node runs out of available file descriptors.\n\n* [Networking and RabbitMQ](https://www.rabbitmq.com/networking.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 500 - }, - { - "color": "transparent", - "value": 1000 - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 4, - "w": 4, - "x": 20, - "y": 15 - }, - "id": 5, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "(rabbitmq_process_max_tcp_sockets * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) -\n(rabbitmq_process_open_tcp_sockets * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "TCP sockets available", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 19 - }, - "id": 27, - "panels": [], - "title": "QUEUED MESSAGES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of ready messages ready to be delivered to consumers.\n\nAim to keep this value as low as possible. RabbitMQ behaves best when messages are flowing through it. It's OK for publishers to occasionally outpace consumers, but the expectation is that consumers will eventually process all ready messages.\n\nIf this metric keeps increasing, your system will eventually run out of memory and/or disk space. Consider using TTL or Queue Length Limit to prevent unbounded message growth.\n\n* [Queues](https://www.rabbitmq.com/queues.html)\n* [Consumers](https://www.rabbitmq.com/consumers.html)\n* [Queue Length Limit](https://www.rabbitmq.com/maxlength.html)\n* [Time-To-Live and Expiration](https://www.rabbitmq.com/ttl.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 20 - }, - "id": 9, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_ready * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages ready to be delivered to consumers", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The total number of messages that are either in-flight to consumers, currently being processed by consumers or simply waiting for the consumer acknowledgements to be processed by the queue. Until the queue processes the message acknowledgement, the message will remain unacknowledged.\n\n* [Queues](https://www.rabbitmq.com/queues.html)\n* [Confirms and Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [Consumer Prefetch](https://www.rabbitmq.com/consumer-prefetch.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 20 - }, - "id": 19, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_unacked * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages pending consumer acknowledgement", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 25 - }, - "id": 11, - "panels": [], - "title": "INCOMING MESSAGES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The incoming message rate before any routing rules are applied.\n\nIf this value is lower than the number of messages published to queues, it may indicate that some messages are delivered to more than one queue.\n\nIf this value is higher than the number of messages published to queues, messages cannot be routed and will either be dropped or returned to publishers.\n\n* [Publishers](https://www.rabbitmq.com/publishers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 26 - }, - "id": 13, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_received_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages published / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages confirmed by the broker to publishers. Publishers must opt-in to receive message confirmations.\n\nIf this metric is consistently at zero it may suggest that publisher confirms are not used by clients. The safety of published messages is likely to be at risk.\n\n* [Publisher Confirms](https://www.rabbitmq.com/confirms.html#publisher-confirms)\n* [Publisher Confirms and Data Safety](https://www.rabbitmq.com/publishers.html#data-safety)\n* [When Will Published Messages Be Confirmed by the Broker?](https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 26 - }, - "id": 18, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_confirmed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages confirmed to publishers / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages received from publishers and successfully routed to the master queue replicas.\n\n* [Queues](https://www.rabbitmq.com/queues.html)\n* [Publishers](https://www.rabbitmq.com/publishers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 31 - }, - "id": 61, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_routed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages routed to queues / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages received from publishers that have publisher confirms enabled and the broker has not confirmed yet.\n\n* [Publishers](https://www.rabbitmq.com/publishers.html)\n* [Confirms and Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [When Will Published Messages Be Confirmed by the Broker?](https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 31 - }, - "id": 12, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_received_confirm_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"} - \nrate(rabbitmq_global_messages_confirmed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}\n) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages unconfirmed to publishers / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages that cannot be routed and are dropped. \n\nAny value above zero means message loss and likely suggests a routing problem on the publisher end.\n\n* [Unroutable Message Handling](https://www.rabbitmq.com/publishers.html#unroutable)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 36 - }, - "id": 34, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_unroutable_dropped_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Unroutable messages dropped / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages that cannot be routed and are returned back to publishers.\n\nSustained values above zero may indicate a routing problem on the publisher end.\n\n* [Unroutable Message Handling](https://www.rabbitmq.com/publishers.html#unroutable)\n* [When Will Published Messages Be Confirmed by the Broker?](https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 36 - }, - "id": 16, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_unroutable_returned_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Unroutable messages returned to publishers / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 41 - }, - "id": 29, - "panels": [], - "title": "OUTGOING MESSAGES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages delivered to consumers. It includes messages that have been redelivered.\n\nThis metric does not include messages that have been fetched by consumers using `basic.get` (consumed by polling).\n\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 42 - }, - "id": 14, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(\n (rate(rabbitmq_global_messages_delivered_consume_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\n (rate(rabbitmq_global_messages_delivered_consume_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})\n) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages delivered / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages that have been redelivered to consumers. It includes messages that have been requeued automatically and redelivered due to channel exceptions or connection closures.\n\nHaving some redeliveries is expected, but if this metric is consistently non-zero, it is worth investigating why.\n\n* [Negative Acknowledgement and Requeuing of Deliveries](https://www.rabbitmq.com/confirms.html#consumer-nacks-requeue)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 20 - }, - { - "color": "red", - "value": 100 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 42 - }, - "id": 15, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_redelivered_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages redelivered / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of message deliveries to consumers that use manual acknowledgement mode.\n\nWhen this mode is used, RabbitMQ waits for consumers to acknowledge messages before more messages can be delivered.\n\nThis is the safest way of consuming messages.\n\n* [Consumer Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [Consumer Prefetch](https://www.rabbitmq.com/consumer-prefetch.html)\n* [Consumer Acknowledgement Modes, Prefetch and Throughput](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 47 - }, - "id": 20, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_consume_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages delivered with manual ack / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of message deliveries to consumers that use automatic acknowledgement mode.\n\nWhen this mode is used, RabbitMQ does not wait for consumers to acknowledge message deliveries.\n\nThis mode is fire-and-forget and does not offer any delivery safety guarantees. It tends to provide higher throughput and it may lead to consumer overload and higher consumer memory usage.\n\n* [Consumer Acknowledgement Modes, Prefetch and Throughput](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 47 - }, - "id": 21, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_consume_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages delivered auto ack / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of message acknowledgements coming from consumers that use manual acknowledgement mode.\n\n* [Consumer Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [Consumer Prefetch](https://www.rabbitmq.com/consumer-prefetch.html)\n* [Consumer Acknowledgement Modes, Prefetch and Throughput](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 52 - }, - "id": 22, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_acknowledged_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages acknowledged / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages delivered to polling consumers that use automatic acknowledgement mode.\n\nThe use of polling consumers is highly inefficient and therefore strongly discouraged.\n\n* [Fetching individual messages](https://www.rabbitmq.com/consumers.html#fetching)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 52 - }, - "id": 24, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_get_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Polling operations with auto ack / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of polling consumer operations that yield no result.\n\nAny value above zero means that RabbitMQ resources are wasted by polling consumers.\n\nCompare this metric to the other polling consumer metrics to see the inefficiency rate.\n\nThe use of polling consumers is highly inefficient and therefore strongly discouraged.\n\n* [Fetching individual messages](https://www.rabbitmq.com/consumers.html#fetching)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 57 - }, - "id": 25, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_get_empty_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Polling operations that yield no result / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages delivered to polling consumers that use manual acknowledgement mode.\n\nThe use of polling consumers is highly inefficient and therefore strongly discouraged.\n\n* [Fetching individual messages](https://www.rabbitmq.com/consumers.html#fetching)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 57 - }, - "id": 23, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_get_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Polling operations with manual ack / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 62 - }, - "id": 53, - "panels": [], - "title": "QUEUES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of queue masters per node. \n\nThis metric makes it easy to see sub-optimal queue distribution in a cluster.\n\n* [Queue Masters, Data Locality](https://www.rabbitmq.com/ha.html#master-migration-data-locality)\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 63 - }, - "id": 57, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_queues * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Total queues", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of queue declarations performed by clients.\n\nLow sustained values above zero are to be expected. High rates may be indicative of queue churn or high rates of connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 4, - "x": 12, - "y": 63 - }, - "id": 58, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_queues_declared_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Queues declared / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of new queues created (as opposed to redeclarations).\n\nLow sustained values above zero are to be expected. High rates may be indicative of queue churn or high rates of connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 4, - "x": 16, - "y": 63 - }, - "id": 60, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_queues_created_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Queues created / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of queues deleted.\n\nLow sustained values above zero are to be expected. High rates may be indicative of queue churn or high rates of connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 4, - "x": 20, - "y": 63 - }, - "id": 59, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_queues_deleted_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Queues deleted / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 68 - }, - "id": 51, - "panels": [], - "title": "CHANNELS", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of channels on all currently opened connections.\n\nIf this metric grows monotonically it is highly likely a channel leak in one of the applications. Confirm channel leaks by using the _Channels opened_ and _Channels closed_ metrics.\n\n* [Channel Leak](https://www.rabbitmq.com/channels.html#channel-leaks)\n* [Channels](https://www.rabbitmq.com/channels.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 69 - }, - "id": 54, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_channels * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Total channels", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of new channels opened by applications across all connections. Channels are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of channel churn or mass connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [High Channel Churn](https://www.rabbitmq.com/channels.html#high-channel-churn)\n* [Channels](https://www.rabbitmq.com/channels.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 12, - "y": 69 - }, - "id": 55, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_channels_opened_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Channels opened / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of channels closed by applications across all connections. Channels are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of channel churn or mass connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [High Channel Churn](https://www.rabbitmq.com/channels.html#high-channel-churn)\n* [Channels](https://www.rabbitmq.com/channels.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 18, - "y": 69 - }, - "id": 56, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_channels_closed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Channels closed / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 74 - }, - "id": 46, - "panels": [], - "title": "CONNECTIONS", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of client connections.\n\nIf this metric grows monotonically it is highly likely a connection leak in one of the applications. Confirm connection leaks by using the _Connections opened_ and _Connections closed_ metrics.\n\n* [Connection Leak](https://www.rabbitmq.com/connections.html#monitoring)\n* [Connections](https://www.rabbitmq.com/connections.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 75 - }, - "id": 47, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_connections * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Total connections", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of new connections opened by clients. Connections are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of connection churn or mass connection recovery.\n\n* [Connection Leak](https://www.rabbitmq.com/connections.html#monitoring)\n* [Connections](https://www.rabbitmq.com/connections.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 12, - "y": 75 - }, - "id": 48, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_connections_opened_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Connections opened / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of connections closed. Connections are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of connection churn or mass connection recovery.\n\n* [Connections](https://www.rabbitmq.com/connections.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 18, - "y": 75 - }, - "id": 49, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_connections_closed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Connections closed / s", - "type": "timeseries" - } - ], - "refresh": "15s", - "schemaVersion": 34, - "style": "dark", - "tags": [ - "rabbitmq-prometheus" - ], - "templating": { - "list": [ - { - "current": { - "selected": false, - "text": "default", - "value": "default" - }, - "datasource": "PBFA97CFB590B2093", - "hide": 2, - "includeAll": false, - "label": "datasource", - "multi": false, - "name": "DS_PROMETHEUS", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "definition": "label_values(rabbitmq_identity_info, namespace)", - "hide": 0, - "includeAll": false, - "label": "Namespace", - "multi": false, - "name": "namespace", - "options": [], - "query": { - "query": "label_values(rabbitmq_identity_info, namespace)", - "refId": "Prometheus-namespace-Variable-Query" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "tagValuesQuery": "", - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "definition": "label_values(rabbitmq_identity_info{namespace=\"$namespace\"}, rabbitmq_cluster)", - "hide": 0, - "includeAll": false, - "label": "RabbitMQ Cluster", - "multi": false, - "name": "rabbitmq_cluster", - "options": [], - "query": { - "query": "label_values(rabbitmq_identity_info{namespace=\"$namespace\"}, rabbitmq_cluster)", - "refId": "Prometheus-rabbitmq_cluster-Variable-Query" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "tagValuesQuery": "", - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "15s", - "30s", - "1m", - "5m", - "10m" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "", - "title": "RabbitMQ-Overview", - "uid": "Kn5xm-gZk", - "version": 20220805, - "weekStart": "", - "gnetId": 10991 -} \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml b/2-modular-monolith-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml deleted file mode 100644 index 5b04359..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml +++ /dev/null @@ -1,88 +0,0 @@ -# https://grafana.com/docs/grafana/latest/administration/provisioning/ -# https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/grafana-datasources.yaml -# https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - -apiVersion: 1 - -datasources: - # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/grafana-datasources.yaml - - name: Prometheus - type: prometheus - typeName: Prometheus - uid: prometheus-uid - access: proxy - orgId: 1 - url: http://prometheus:9090 - basicAuth: false - isDefault: true - readOnly: false - user: '' - database: '' - version: 1 - editable: false - jsonData: - httpMethod: GET - - - name: Jaeger - type: jaeger - access: proxy - url: http://jaeger-all-in-one:16686 - editable: false - uid: jaeger-uid - - - name: Zipkin - type: zipkin - access: proxy - url: http://zipkin-all-in-one:9411 - editable: false - uid: zipkin-uid - - # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/grafana-datasources.yaml - - name: Tempo - type: tempo - access: proxy - orgId: 1 - url: http://tempo:3200 - basicAuth: false - isDefault: false - version: 1 - editable: false - apiVersion: 1 - uid: tempo-uid - jsonData: - httpMethod: GET - serviceMap: - datasourceUid: prometheus-uid - streamingEnabled: - search: true - - #https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - - name: Loki - type: loki - access: proxy - uid: loki-uid - url: http://loki:3100 - user: '' - database: '' - readOnly: false - jsonData: - derivedFields: - - datasourceUid: tempo-uid - matcherRegex: "^.*?traceI[d|D]=(\\w+).*$" - name: traceId - url: '$${__value.raw}' - - - name: Kibana - type: elasticsearch - url: http://elasticsearch:9200 - access: proxy - isDefault: false - uid: kibana-uid - jsonData: - esVersion: 7 - timeField: "@timestamp" - maxConcurrentShardRequests: 256 - interval: Daily - logMessageField: "message" # Optional: Field for log messages - logLevelField: "level" # Optional: Field for log levels - editable: true \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/loki-config.yaml b/2-modular-monolith-architecture-style/deployments/configs/loki-config.yaml deleted file mode 100644 index 414d762..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/loki-config.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# https://grafana.com/docs/loki/latest/configure/examples/configuration-examples/ -# https://github.com/grafana/loki/issues/2018#issuecomment-970789233 -# https://grafana.com/docs/opentelemetry/collector/send-logs-to-loki/ -# https://github.com/grafana/loki/blob/main/examples/getting-started/loki-config.yaml -# https://github.com/grafana/loki/blob/main/cmd/loki/loki-local-config.yaml -# https://grafana.com/docs/loki/latest/configure/examples/configuration-examples/#1-local-configuration-exampleyaml - ---- -# https://grafana.com/docs/loki/latest/configure/examples/configuration-examples/#1-local-configuration-exampleyaml -auth_enabled: false - -# This is a complete configuration to deploy Loki backed by the filesystem. -# The index will be shipped to the storage via tsdb-shipper. -server: - http_listen_port: 3100 - -common: - ring: - instance_addr: 127.0.0.1 - kvstore: - store: inmemory - replication_factor: 1 - path_prefix: /tmp/loki - -schema_config: - configs: - - from: 2020-05-15 - store: tsdb - object_store: filesystem - schema: v13 - index: - prefix: index_ - period: 24h - -storage_config: - filesystem: - directory: /tmp/loki/chunks - -# https://grafana.com/docs/loki/latest/send-data/otel/ -# https://grafana.com/docs/loki/latest/send-data/otel/#changing-the-default-mapping-of-otlp-to-loki-format -limits_config: - # this attribute should be `true` when we use `otlphttp/loki`, but if we want to use `loki component` from `opentelemetry-collector-contrib` it should be false. - allow_structured_metadata: true - diff --git a/2-modular-monolith-architecture-style/deployments/configs/prometheus.yaml b/2-modular-monolith-architecture-style/deployments/configs/prometheus.yaml deleted file mode 100644 index 1928aaf..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/prometheus.yaml +++ /dev/null @@ -1,48 +0,0 @@ -# ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/examples/demo/prometheus.yaml -# https://prometheus.io/docs/introduction/first_steps/ -# https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - -global: - scrape_interval: 5s - -scrape_configs: - # when we use otel-collector we should comment other jobs in prometheus config, and we read configs from `otel-collector-config` - - job_name: "otel-collector" - scrape_interval: 10s - static_configs: - # otel-collector Prometheus exporter metrics - - targets: [ 'otel-collector:8889' ] - - targets: [ 'otel-collector:8888' ] - - - job_name: "prometheus" - static_configs: - - targets: ["prometheus:9090"] - -# # https://prometheus.io/docs/guides/node-exporter/ -# # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ -# - job_name: "node-exporter" -# static_configs: -# - targets: [ 'node-exporter:9100' ] - -# # if we don't use otel collector we should uncomment this -# # scrap application metrics -# # http://localhost:4000/metrics by AddPrometheusExporter() -# - job_name: vertical-slice-template-api -# scrape_interval: 10s -# metrics_path: /metrics -# static_configs: -# - targets: ['host.docker.internal:4000'] -# -# # if we don't use otel collector we should uncomment this -# # scrap application health metrics -# # http://localhost:4000/health/metrics by AddPrometheusExporter() -# - job_name: vertical-slice-template-api-healthchecks -# scrape_interval: 10s -# metrics_path: /health/metrics -# static_configs: -# - targets: ['host.docker.internal:4000'] - -## https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/prometheus.yaml -# - job_name: 'tempo' -# static_configs: -# - targets: [ 'tempo:3200' ] \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/configs/tempo.yaml b/2-modular-monolith-architecture-style/deployments/configs/tempo.yaml deleted file mode 100644 index fcb2ed3..0000000 --- a/2-modular-monolith-architecture-style/deployments/configs/tempo.yaml +++ /dev/null @@ -1,49 +0,0 @@ -# https://grafana.com/docs/tempo/latest/configuration/ -# https://github.com/grafana/tempo/blob/main/example/docker-compose/local/tempo.yaml - -# https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/tempo.yaml -stream_over_http_enabled: true -server: - http_listen_port: 3200 - log_level: info - -distributor: - receivers: - otlp: - protocols: - grpc: - endpoint: "tempo:4317" - -ingester: - max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally - -compactor: - compaction: - block_retention: 1h # overall Tempo trace retention. set for demo purposes - -metrics_generator: - registry: - external_labels: - source: tempo - cluster: docker-compose - storage: - path: /var/tempo/generator/wal - remote_write: - - url: http://prometheus:9090/api/v1/write - send_exemplars: true - traces_storage: - path: /var/tempo/generator/traces - -storage: - trace: - backend: local # backend configuration to use - wal: - path: /var/tempo/wal # where to store the wal locally - local: - path: /var/tempo/blocks - -overrides: - defaults: - metrics_generator: - processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator - generate_native_histograms: both \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml b/2-modular-monolith-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml deleted file mode 100644 index f0423e1..0000000 --- a/2-modular-monolith-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml +++ /dev/null @@ -1,361 +0,0 @@ -# ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/examples/demo/docker-compose.yaml -# ref: https://github.com/joaofbantunes/DotNetMicroservicesObservabilitySample/blob/main/docker-compose.yml -# ref: https://github.com/oskardudycz/EventSourcing.NetCore/blob/main/docker-compose.yml -# https://github.com/grafana/intro-to-mltp -# https://stackoverflow.com/questions/65272764/ports-are-not-available-listen-tcp-0-0-0-0-50070-bind-an-attempt-was-made-to - - -name: booking-modular-monolith-infrastructure - -services: - ####################################################### - # rabbitmq - ####################################################### - rabbitmq: - image: rabbitmq:management - container_name: rabbitmq - restart: unless-stopped - ports: - - "5672:5672" - - "15672:15672" - # volumes: - # - rabbitmq:/var/lib/rabbitmq - networks: - - infrastructure - - ####################################################### - # postgres - ####################################################### - postgres: - image: postgres:latest - container_name: postgres - restart: unless-stopped - ports: - - '5432:5432' - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - command: - - "postgres" - - "-c" - - "wal_level=logical" - - "-c" - - "max_prepared_transactions=10" - volumes: - - postgres-data:/var/lib/postgresql/data - networks: - - infrastructure - - - ####################################################### - # EventStoreDB - ####################################################### - eventstore: - container_name: eventstore - image: eventstore/eventstore:latest - restart: unless-stopped - environment: - - EVENTSTORE_CLUSTER_SIZE=1 - - EVENTSTORE_RUN_PROJECTIONS=All - - EVENTSTORE_START_STANDARD_PROJECTIONS=True - - EVENTSTORE_HTTP_PORT=2113 - - EVENTSTORE_INSECURE=True - - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=True - ports: - - "2113:2113" - networks: - - infrastructure - - - # ####################################################### - # # Mongo - # ####################################################### - mongo: - image: mongo:latest - container_name: mongo - restart: unless-stopped - # environment: - # - MONGO_INITDB_ROOT_USERNAME=root - # - MONGO_INITDB_ROOT_PASSWORD=secret - ports: - - 27017:27017 - networks: - - infrastructure - - - # ####################################################### - # # Redis - # ####################################################### - redis: - image: redis - container_name: redis - restart: unless-stopped - ports: - - 6379:6379 - networks: - - infrastructure - - - # ####################################################### - # # jaeger - # # https://www.jaegertracing.io/docs/1.64/deployment/ - # # https://www.jaegertracing.io/docs/1.6/deployment/ - # ####################################################### - jaeger-all-in-one: - image: jaegertracing/all-in-one:latest - container_name: jaeger-all-in-one - restart: unless-stopped - ports: - - "6831:6831/udp" # UDP port for Jaeger agent - - "16686:16686" # endpoints and Jaeger UI - - "14268:14268" # HTTP port for accept trace spans directly from clients - - "14317:4317" # OTLP gRPC receiver for jaeger - - "14318:4318" # OTLP http receiver for jaeger - # - "9411" # Accepts Zipkin spans - /api/v2/spans - networks: - - infrastructure - - - # ####################################################### - # # zipkin - # # https://zipkin.io/pages/quickstart - # ####################################################### - zipkin-all-in-one: - image: openzipkin/zipkin:latest - container_name: zipkin-all-in-one - restart: unless-stopped - ports: - - "9411:9411" - networks: - - infrastructure - - - # ####################################################### - # # otel-collector - # # https://opentelemetry.io/docs/collector/installation/ - # # https://github.com/open-telemetry/opentelemetry-collector - # # https://github.com/open-telemetry/opentelemetry-collector-contrib - # # we can use none contrib docker `otel/opentelemetry-collector` version from `https://github.com/open-telemetry/opentelemetry-collector` repository but, - # # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. - # ####################################################### - otel-collector: - image: otel/opentelemetry-collector-contrib:latest - container_name: otel-collector - restart: unless-stopped - command: ["--config=/etc/otelcol-contrib/config.yaml"] - volumes: - - ./../configs/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml - ports: - - "11888:1888" # pprof extension - - "8888:8888" # Prometheus metrics exposed by the Collector - - "8889:8889" # Prometheus exporter metrics - - "13133:13133" # health_check extension - - "4317:4317" # OTLP gRPC receiver - - "4318:4318" # OTLP http receiver - - "55679:55679" # zpages extension - networks: - - infrastructure - - - # ####################################################### - # # prometheus - # # https://prometheus.io/docs/introduction/first_steps/ - # # https://prometheus.io/docs/prometheus/3.1/installation/ - # # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - # ####################################################### - prometheus: - image: prom/prometheus:latest - restart: unless-stopped - ports: - - "9090:9090" - volumes: - - ./../configs/prometheus.yaml:/etc/prometheus/prometheus.yml - # to passe one flag, such as "--log.level=debug" or "--web.enable-remote-write-receiver", we need to override the whole command, as we can't just pass one extra argument - command: - - "--config.file=/etc/prometheus/prometheus.yml" - - "--storage.tsdb.path=/prometheus" - - "--web.console.libraries=/usr/share/prometheus/console_libraries" - - "--web.console.templates=/usr/share/prometheus/consoles" - # need this for the OpenTelemetry collector to be able to put metrics into Prometheus - - "--web.enable-remote-write-receiver" - # - "--log.level=debug" - networks: - - infrastructure - - - # ####################################################### - # # node-exporter - # # https://prometheus.io/docs/guides/node-exporter/ - # # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - # ####################################################### - node-exporter: - image: prom/node-exporter:latest - container_name: node-exporter - restart: unless-stopped - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - '--path.procfs=/host/proc' - - '--path.rootfs=/rootfs' - - '--path.sysfs=/host/sys' - ports: - - "9101:9100" - networks: - - infrastructure - - - # ####################################################### - # # grafana - # # https://grafana.com/docs/grafana/latest/administration/provisioning/ - # # https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ - # # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ - # # https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - # ####################################################### - grafana: - image: grafana/grafana:latest - container_name: grafana - restart: unless-stopped - environment: - - GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource - - GF_SECURITY_ADMIN_USER=admin - - GF_SECURITY_ADMIN_PASSWORD=admin - - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor - # - GF_AUTH_ANONYMOUS_ENABLED=true - # - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - # - GF_AUTH_DISABLE_LOGIN_FORM=true - depends_on: - - prometheus - ports: - - "3000:3000" - volumes: - - ./../configs/grafana/provisioning:/etc/grafana/provisioning - - ./../configs/grafana/dashboards:/var/lib/grafana/dashboards - ## https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/ - # - ./../configs/grafana/grafana.ini:/etc/grafana/grafana.ini - networks: - - infrastructure - - - # ####################################################### - # # tempo - # # https://github.com/grafana/tempo/blob/main/example/docker-compose/otel-collector/docker-compose.yaml - # # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared - # # https://github.com/grafana/tempo/blob/main/example/docker-compose/local - # # https://github.com/grafana/tempo/tree/main/example/docker-compose - # ####################################################### - tempo: - image: grafana/tempo:latest - container_name: tempo - restart: unless-stopped - command: [ "-config.file=/etc/tempo.yaml" ] - volumes: - - ./../configs/tempo.yaml:/etc/tempo.yaml - ports: - - "3200" # tempo - - "24317:4317" # otlp grpc - - "24318:4318" # otlp http - networks: - - infrastructure - - - # ####################################################### - # # loki - # # https://grafana.com/docs/opentelemetry/collector/send-logs-to-loki/ - # # https://github.com/grafana/loki/blob/main/production/docker-compose.yaml - # # https://github.com/grafana/loki/blob/main/examples/getting-started/docker-compose.yaml - # ####################################################### - loki: - image: grafana/loki:latest - hostname: loki - container_name: loki - ports: - - "3100:3100" - command: -config.file=/etc/loki/local-config.yaml - volumes: - - ./../configs/loki-config.yaml:/etc/loki/local-config.yaml - networks: - - infrastructure - - - # ####################################################### - # # elasticsearch - # # https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docker.html#docker-compose-file - # ####################################################### - elasticsearch: - container_name: elasticsearch - restart: unless-stopped - image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0 - environment: - - discovery.type=single-node - - cluster.name=docker-cluster - - node.name=docker-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - xpack.security.enabled=false - - xpack.security.http.ssl.enabled=false - - xpack.security.transport.ssl.enabled=false - - network.host=0.0.0.0 - - http.port=9200 - - transport.host=localhost - - bootstrap.memory_lock=true - - cluster.routing.allocation.disk.threshold_enabled=false - ulimits: - memlock: - soft: -1 - hard: -1 - volumes: - - elastic-data:/usr/share/elasticsearch/data - ports: - - ${ELASTIC_HOST_PORT:-9200}:${ELASTIC_PORT:-9200} - - 9300:9300 - networks: - - infrastructure - - - # ####################################################### - # # kibana - # # https://www.elastic.co/guide/en/kibana/current/docker.html - # ####################################################### - kibana: - image: docker.elastic.co/kibana/kibana:8.17.0 - container_name: kibana - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - ports: - - ${KIBANA_HOST_PORT:-5601}:${KIBANA_PORT:-5601} - depends_on: - - elasticsearch - networks: - - infrastructure - - - # ####################################################### - # # cadvisor - # ####################################################### - cadvisor: - image: gcr.io/cadvisor/cadvisor:latest - container_name: cadvisor - restart: unless-stopped - ports: - - "8080:8080" - volumes: - - /:/rootfs:ro - - /var/run:/var/run:ro - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - - /dev/disk/:/dev/disk:ro - devices: - - /dev/kmsg - networks: - - infrastructure - - -networks: - infrastructure: - name: infrastructure - driver: bridge - -volumes: - postgres-data: \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/deployments/docker-compose/docker-compose.yaml b/2-modular-monolith-architecture-style/deployments/docker-compose/docker-compose.yaml deleted file mode 100644 index 171b72f..0000000 --- a/2-modular-monolith-architecture-style/deployments/docker-compose/docker-compose.yaml +++ /dev/null @@ -1,365 +0,0 @@ -name: booking-modular-monolith - -services: - - ####################################################### - # EventStoreDB - ####################################################### - eventstore: - container_name: eventstore - image: eventstore/eventstore:latest - restart: unless-stopped - environment: - - EVENTSTORE_CLUSTER_SIZE=1 - - EVENTSTORE_RUN_PROJECTIONS=All - - EVENTSTORE_START_STANDARD_PROJECTIONS=True - - EVENTSTORE_HTTP_PORT=2113 - - EVENTSTORE_INSECURE=True - - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=True - ports: - - "2113:2113" - networks: - - booking - - ####################################################### - # postgres - ####################################################### - postgres: - image: postgres:latest - container_name: postgres - restart: unless-stopped - ports: - - '5432:5432' - environment: - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - command: - - "postgres" - - "-c" - - "wal_level=logical" - - "-c" - - "max_prepared_transactions=10" - volumes: - - postgres-data:/var/lib/postgresql/data - networks: - - booking - - ####################################################### - # Mongo - ####################################################### - mongo: - image: mongo:latest - container_name: mongo - restart: unless-stopped - # environment: - # - MONGO_INITDB_ROOT_USERNAME=root - # - MONGO_INITDB_ROOT_PASSWORD=secret - ports: - - 27017:27017 - networks: - - booking - - ####################################################### - # jaeger - # https://www.jaegertracing.io/docs/1.64/deployment/ - # https://www.jaegertracing.io/docs/1.6/deployment/ - ####################################################### - jaeger-all-in-one: - image: jaegertracing/all-in-one:latest - container_name: jaeger-all-in-one - restart: unless-stopped - ports: - - "6831:6831/udp" # UDP port for Jaeger agent - - "16686:16686" # endpoints and Jaeger UI - - "14268:14268" # HTTP port for accept trace spans directly from clients - - "14317:4317" # OTLP gRPC receiver for jaeger - - "14318:4318" # OTLP http receiver for jaeger - # - "9411" # Accepts Zipkin spans - /api/v2/spans - networks: - - booking - - ####################################################### - # zipkin - # https://zipkin.io/pages/quickstart - ####################################################### - zipkin-all-in-one: - image: openzipkin/zipkin:latest - container_name: zipkin-all-in-one - restart: unless-stopped - ports: - - "9411:9411" - networks: - - booking - - ####################################################### - # prometheus - # https://prometheus.io/docs/introduction/first_steps/ - # https://prometheus.io/docs/prometheus/3.1/installation/ - # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - ####################################################### - prometheus: - image: prom/prometheus:latest - restart: unless-stopped - ports: - - "9090:9090" - volumes: - - ./../configs/prometheus.yaml:/etc/prometheus/prometheus.yml - # to passe one flag, such as "--log.level=debug" or "--web.enable-remote-write-receiver", we need to override the whole command, as we can't just pass one extra argument - command: - - "--config.file=/etc/prometheus/prometheus.yml" - - "--storage.tsdb.path=/prometheus" - - "--web.console.libraries=/usr/share/prometheus/console_libraries" - - "--web.console.templates=/usr/share/prometheus/consoles" - # need this for the OpenTelemetry collector to be able to put metrics into Prometheus - - "--web.enable-remote-write-receiver" - # - "--log.level=debug" - networks: - - booking - - ####################################################### - # otel-collector - # https://opentelemetry.io/docs/collector/installation/ - # https://github.com/open-telemetry/opentelemetry-collector - # https://github.com/open-telemetry/opentelemetry-collector-contrib - # we can use none contrib docker `otel/opentelemetry-collector` version from `https://github.com/open-telemetry/opentelemetry-collector` repository but, - # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. - ####################################################### - otel-collector: - image: otel/opentelemetry-collector-contrib:latest - container_name: otel-collector - restart: unless-stopped - command: ["--config=/etc/otelcol-contrib/config.yaml"] - volumes: - - ./../configs/otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml - ports: - - "11888:1888" # pprof extension - - "8888:8888" # Prometheus metrics exposed by the Collector - - "8889:8889" # Prometheus exporter metrics - - "13133:13133" # health_check extension - - "4317:4317" # OTLP gRPC receiver - - "4318:4318" # OTLP http receiver - - "55679:55679" # zpages extension - networks: - - booking - - ####################################################### - # rabbitmq - ####################################################### - rabbitmq: - image: rabbitmq:management - container_name: rabbitmq - restart: unless-stopped - ports: - - "5672:5672" - - "15672:15672" - # volumes: - # - rabbitmq:/var/lib/rabbitmq - networks: - - booking - - ####################################################### - # Redis - ####################################################### - redis: - image: redis - container_name: redis - restart: unless-stopped - ports: - - 6379:6379 - networks: - - booking - - ####################################################### - # node-exporter - # https://prometheus.io/docs/guides/node-exporter/ - # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - ####################################################### - node-exporter: - image: prom/node-exporter:latest - container_name: node-exporter - restart: unless-stopped - volumes: - - /proc:/host/proc:ro - - /sys:/host/sys:ro - - /:/rootfs:ro - command: - - '--path.procfs=/host/proc' - - '--path.rootfs=/rootfs' - - '--path.sysfs=/host/sys' - ports: - - "9101:9100" - networks: - - booking - - ####################################################### - # grafana - # https://grafana.com/docs/grafana/latest/administration/provisioning/ - # https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ - # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ - # https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - ####################################################### - grafana: - image: grafana/grafana:latest - container_name: grafana - restart: unless-stopped - environment: - - GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource - - GF_SECURITY_ADMIN_USER=admin - - GF_SECURITY_ADMIN_PASSWORD=admin - - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor - # - GF_AUTH_ANONYMOUS_ENABLED=true - # - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - # - GF_AUTH_DISABLE_LOGIN_FORM=true - depends_on: - - prometheus - ports: - - "3000:3000" - volumes: - - ./../configs/grafana/provisioning:/etc/grafana/provisioning - - ./../configs/grafana/dashboards:/var/lib/grafana/dashboards - networks: - - booking - - ####################################################### - # tempo - # https://github.com/grafana/tempo/blob/main/example/docker-compose/otel-collector/docker-compose.yaml - # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared - # https://github.com/grafana/tempo/blob/main/example/docker-compose/local - # https://github.com/grafana/tempo/tree/main/example/docker-compose - ####################################################### - tempo: - image: grafana/tempo:latest - container_name: tempo - restart: unless-stopped - command: [ "-config.file=/etc/tempo.yaml" ] - volumes: - - ./../configs/tempo.yaml:/etc/tempo.yaml - ports: - - "3200" # tempo - - "24317:4317" # otlp grpc - - "24318:4318" # otlp http - networks: - - booking - - ####################################################### - # loki - # https://grafana.com/docs/opentelemetry/collector/send-logs-to-loki/ - # https://github.com/grafana/loki/blob/main/production/docker-compose.yaml - # https://github.com/grafana/loki/blob/main/examples/getting-started/docker-compose.yaml - ####################################################### - loki: - image: grafana/loki:latest - hostname: loki - container_name: loki - ports: - - "3100:3100" - command: -config.file=/etc/loki/local-config.yaml - volumes: - - ./../configs/loki-config.yaml:/etc/loki/local-config.yaml - networks: - - booking - - ####################################################### - # elasticsearch - # https://www.elastic.co/guide/en/elasticsearch/reference/7.17/docker.html#docker-compose-file - ####################################################### - elasticsearch: - container_name: elasticsearch - restart: unless-stopped - image: docker.elastic.co/elasticsearch/elasticsearch:8.17.0 - environment: - - discovery.type=single-node - - cluster.name=docker-cluster - - node.name=docker-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - - xpack.security.enabled=false - - xpack.security.http.ssl.enabled=false - - xpack.security.transport.ssl.enabled=false - - network.host=0.0.0.0 - - http.port=9200 - - transport.host=localhost - - bootstrap.memory_lock=true - - cluster.routing.allocation.disk.threshold_enabled=false - ulimits: - memlock: - soft: -1 - hard: -1 - volumes: - - elastic-data:/usr/share/elasticsearch/data - ports: - - ${ELASTIC_HOST_PORT:-9200}:${ELASTIC_PORT:-9200} - - 9300:9300 - networks: - - booking - - ####################################################### - # kibana - # https://www.elastic.co/guide/en/kibana/current/docker.html - ####################################################### - kibana: - image: docker.elastic.co/kibana/kibana:8.17.0 - container_name: kibana - restart: unless-stopped - environment: - - ELASTICSEARCH_HOSTS=http://elasticsearch:9200 - ports: - - ${KIBANA_HOST_PORT:-5601}:${KIBANA_PORT:-5601} - depends_on: - - elasticsearch - networks: - - booking - - ####################################################### - # cadvisor - ####################################################### - cadvisor: - image: gcr.io/cadvisor/cadvisor:latest - container_name: cadvisor - restart: unless-stopped - ports: - - "8080:8080" - volumes: - - /:/rootfs:ro - - /var/run:/var/run:ro - - /sys:/sys:ro - - /var/lib/docker/:/var/lib/docker:ro - - /dev/disk/:/dev/disk:ro - devices: - - /dev/kmsg - networks: - - booking - - ####################################################### - # booking-modular-monolith - ####################################################### - booking_modular_monolith: - image: booking-modular-monolith - build: - args: - Version: "1" - context: ../../../ - dockerfile: 2-modular-monolith-architecture-style/src/Api/dev.Dockerfile - container_name: booking_modular_monolith - ports: - - 3001:80 - - 3000:443 - volumes: - - ~/.aspnet/https:/https:ro - environment: - - ASPNETCORE_ENVIRONMENT=docker - - ASPNETCORE_URLS=https://+;http://+ - - ASPNETCORE_HTTPS_PORT=3000 - - ASPNETCORE_HTTP_PORT=3001 - - ASPNETCORE_Kestrel__Certificates__Default__Password=password - - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx - networks: - - booking - -networks: - booking: - name: booking - driver: bridge - -volumes: - elastic-data: - postgres-data: \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/src/Api/dev.Dockerfile b/2-modular-monolith-architecture-style/src/Api/dev.Dockerfile deleted file mode 100644 index 0982e59..0000000 --- a/2-modular-monolith-architecture-style/src/Api/dev.Dockerfile +++ /dev/null @@ -1,54 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking.csproj ./2-modular-monolith-architecture-style/src/Modules/Booking/src/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Flight/src/Flight.csproj ./2-modular-monolith-architecture-style/src/Modules/Flight/src/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity.csproj ./2-modular-monolith-architecture-style/src/Modules/Identity/src/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passenger.csproj ./2-modular-monolith-architecture-style/src/Modules/Passenger/src/ -COPY ./2-modular-monolith-architecture-style/src/Api/src/Api.csproj ./2-modular-monolith-architecture-style/src/Api/src/ - -# Restore nuget packages -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages \ - dotnet restore ./2-modular-monolith-architecture-style/src/Api/src/Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Booking/src/ ./2-modular-monolith-architecture-style/src/Modules/Booking/src/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Flight/src/ ./2-modular-monolith-architecture-style/src/Modules/Flight/src/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Identity/src/ ./2-modular-monolith-architecture-style/src/Modules/Identity/src/ -COPY ./2-modular-monolith-architecture-style/src/Modules/Passenger/src/ ./2-modular-monolith-architecture-style/src/Modules/Passenger/src/ -COPY ./2-modular-monolith-architecture-style/src/Api/src/ ./2-modular-monolith-architecture-style/src/Api/src/ - -# Build project with Release configuration -# and no restore, as we did it already -RUN ls -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\ - dotnet build -c Release --no-restore ./2-modular-monolith-architecture-style/src/Api/src/Api.csproj - -WORKDIR /2-modular-monolith-architecture-style/src/Api/src - -# Publish project to output folder -# and no build, as we did it already -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\ - dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /2-modular-monolith-architecture-style/src/Api/src/out . - -ENV ASPNETCORE_URLS="https://*:443, http://*:80" -ENV ASPNETCORE_ENVIRONMENT=docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Api.dll"] - diff --git a/2-modular-monolith-architecture-style/src/Api/src/Api.csproj b/2-modular-monolith-architecture-style/src/Api/src/Api.csproj deleted file mode 100644 index 2e573a8..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/Api.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - Api - - - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Api/src/Extensions/SharedInfrastructureExtensions.cs b/2-modular-monolith-architecture-style/src/Api/src/Extensions/SharedInfrastructureExtensions.cs deleted file mode 100644 index 1dbb918..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/Extensions/SharedInfrastructureExtensions.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System.Threading.RateLimiting; -using Booking; -using BuildingBlocks.Core; -using BuildingBlocks.Exception; -using BuildingBlocks.HealthCheck; -using BuildingBlocks.Jwt; -using BuildingBlocks.Logging; -using BuildingBlocks.MassTransit; -using BuildingBlocks.OpenApi; -using BuildingBlocks.OpenTelemetryCollector; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.ProblemDetails; -using BuildingBlocks.Web; -using Figgle; -using Flight; -using Identity; -using Microsoft.AspNetCore.Mvc; -using Passenger; -using Serilog; - -namespace Api.Extensions; - -public static class SharedInfrastructureExtensions -{ - public static WebApplicationBuilder AddSharedInfrastructure(this WebApplicationBuilder builder) - { - builder.Host.UseDefaultServiceProvider( - (context, options) => - { - // Service provider validation - // ref: https://andrewlock.net/new-in-asp-net-core-3-service-provider-validation/ - options.ValidateScopes = context.HostingEnvironment.IsDevelopment() || - context.HostingEnvironment.IsStaging() || - context.HostingEnvironment.IsEnvironment("tests"); - - options.ValidateOnBuild = true; - }); - - var appOptions = builder.Services.GetOptions(nameof(AppOptions)); - Console.WriteLine(FiggleFonts.Standard.Render(appOptions.Name)); - - builder.AddCustomSerilog(builder.Environment); - builder.Services.AddJwt(); - builder.Services.AddScoped(); - builder.Services.AddTransient(); - builder.Services.AddPersistMessageProcessor(); - - builder.Services.AddEndpointsApiExplorer(); - builder.Services.AddControllers(); - builder.Services.AddAspnetOpenApi(); - builder.Services.AddCustomVersioning(); - builder.Services.AddHttpContextAccessor(); - builder.Services.AddScoped(); - - builder.Services.AddCustomMassTransit( - builder.Environment, - TransportType.InMemory, - AppDomain.CurrentDomain.GetAssemblies()); - - builder.Services.Configure( - options => options.SuppressModelStateInvalidFilter = true); - - builder.Services.AddRateLimiter( - options => - { - options.GlobalLimiter = PartitionedRateLimiter.Create( - httpContext => - RateLimitPartition.GetFixedWindowLimiter( - partitionKey: httpContext.User.Identity?.Name ?? - httpContext.Request.Headers.Host.ToString(), - factory: partition => new FixedWindowRateLimiterOptions - { - AutoReplenishment = true, - PermitLimit = 10, - QueueLimit = 0, - Window = TimeSpan.FromMinutes(1) - })); - }); - - builder.AddCustomObservability(); - builder.Services.AddCustomHealthCheck(); - - builder.Services.AddGrpc( - options => - { - options.Interceptors.Add(); - }); - - builder.Services.AddEasyCaching(options => { options.UseInMemory(builder.Configuration, "mem"); }); - builder.Services.AddProblemDetails(); - - builder.Services.AddScoped(sp => - { - var mappers = new IEventMapper[] { - sp.GetRequiredService(), - sp.GetRequiredService(), - sp.GetRequiredService(), - sp.GetRequiredService(), - }; - - return new CompositeEventMapper(mappers); - }); - - - return builder; - } - - - public static WebApplication UserSharedInfrastructure(this WebApplication app) - { - var appOptions = app.Configuration.GetOptions(nameof(AppOptions)); - - app.UseCustomProblemDetails(); - app.UseCustomObservability(); - app.UseCustomHealthCheck(); - - app.UseSerilogRequestLogging( - options => - { - options.EnrichDiagnosticContext = LogEnrichHelper.EnrichFromRequest; - }); - - app.UseCorrelationId(); - app.UseRateLimiter(); - app.MapGet("/", x => x.Response.WriteAsync(appOptions.Name)); - - if (app.Environment.IsDevelopment()) - { - app.UseAspnetOpenApi(); - } - - return app; - } -} diff --git a/2-modular-monolith-architecture-style/src/Api/src/Program.cs b/2-modular-monolith-architecture-style/src/Api/src/Program.cs deleted file mode 100644 index 8fffce4..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Api.Extensions; -using Booking.Extensions.Infrastructure; -using BuildingBlocks.Web; -using Flight.Extensions.Infrastructure; -using Identity.Extensions.Infrastructure; -using Passenger.Extensions.Infrastructure; - -var builder = WebApplication.CreateBuilder(args); - -builder.AddSharedInfrastructure(); - -builder.AddIdentityModules(); -builder.AddPassengerModules(); -builder.AddBookingModules(); -builder.AddFlightModules(); - -var app = builder.Build(); - -// ref: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-7.0#routing-basics -app.UseAuthentication(); -app.UseAuthorization(); - -app.UseFlightModules(); -app.UseIdentityModules(); -app.UsePassengerModules(); -app.UseBookingModules(); - -app.UserSharedInfrastructure(); -app.MapMinimalEndpoints(); - -app.Run(); - -namespace Api -{ - public partial class Program - { - } -} diff --git a/2-modular-monolith-architecture-style/src/Api/src/Properties/launchSettings.json b/2-modular-monolith-architecture-style/src/Api/src/Properties/launchSettings.json deleted file mode 100644 index 3e641ce..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/Properties/launchSettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "profiles": { - "Modular.Monolith.Api": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchUrl": "swagger", - "launchBrowser": true, - "applicationUrl": "https://localhost:3000;http://localhost:3001", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Api/src/appsettings.Development.json b/2-modular-monolith-architecture-style/src/Api/src/appsettings.Development.json deleted file mode 100644 index 0c208ae..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Api/src/appsettings.docker.json b/2-modular-monolith-architecture-style/src/Api/src/appsettings.docker.json deleted file mode 100644 index 2c63c08..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/appsettings.docker.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/2-modular-monolith-architecture-style/src/Api/src/appsettings.json b/2-modular-monolith-architecture-style/src/Api/src/appsettings.json deleted file mode 100644 index 8b3f77e..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/appsettings.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "AppOptions": { - "Name": "Booking-Modular-Monolith" - }, - "LogOptions": { - "Level": "information", - "LogTemplate": "{Timestamp:HH:mm:ss} [{Level:u4}] {Message:lj}{NewLine}{Exception}", - "File": { - "Enabled": false, - "Path": "logs/logs.txt", - "Interval": "day" - } - }, - "PostgresOptions": { - "ConnectionString": { - "Flight": "Server=localhost;Port=5432;Database=flight_modular_monolith;User Id=postgres;Password=postgres;Include Error Detail=true", - "Identity": "Server=localhost;Port=5432;Database=identity_modular_monolith;User Id=postgres;Password=postgres;Include Error Detail=true", - "Passenger": "Server=localhost;Port=5432;Database=passenger_modular_monolith;User Id=postgres;Password=postgres;Include Error Detail=true" - } - }, - "MongoOptions": { - "ConnectionString": "mongodb://localhost:27017", - "DatabaseName": "booking_modular_monolith_read" - }, - "EventStoreOptions": { - "ConnectionString": "esdb://localhost:2113?tls=false" - }, - "Jwt": { - "Authority": "https://localhost:3000", - "Audience": "booking-modular-monolith" - }, - "PersistMessageOptions": { - "Interval": 30, - "Enabled": true, - "ConnectionString": "Server=localhost;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true" - }, - "HealthOptions": { - "Enabled": false - }, - "ObservabilityOptions": { - "InstrumentationName": "booking_modular_monolith_service", - "OTLPOptions": { - "OTLPGrpExporterEndpoint": "http://localhost:4317" - }, - "AspireDashboardOTLPOptions": { - "OTLPGrpExporterEndpoint": "http://localhost:4319" - }, - "ZipkinOptions": { - "HttpExporterEndpoint": "http://localhost:9411/api/v2/spans" - }, - "JaegerOptions": { - "OTLPGrpcExporterEndpoint": "http://localhost:14317", - "HttpExporterEndpoint": "http://localhost:14268/api/traces" - }, - "UsePrometheusExporter": true, - "UseOTLPExporter": true, - "UseAspireOTLPExporter": true, - "UseGrafanaExporter": false, - "ServiceName": "Booking Modular Monolith Service" - }, - "AllowedHosts": "*" -} diff --git a/2-modular-monolith-architecture-style/src/Api/src/appsettings.test.json b/2-modular-monolith-architecture-style/src/Api/src/appsettings.test.json deleted file mode 100644 index 7a73a41..0000000 --- a/2-modular-monolith-architecture-style/src/Api/src/appsettings.test.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Features/CreatingBook/V1/CreateBooking.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Features/CreatingBook/V1/CreateBooking.cs deleted file mode 100644 index 9e83db0..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Features/CreatingBook/V1/CreateBooking.cs +++ /dev/null @@ -1,146 +0,0 @@ -namespace Booking.Booking.Features.CreatingBook.V1; - -using Ardalis.GuardClauses; -using BookingFlight; -using BookingPassenger; -using BuildingBlocks.Core; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Core.Model; -using BuildingBlocks.EventStoreDB.Repository; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using ValueObjects; - -public record CreateBooking(Guid PassengerId, Guid FlightId, string Description) : ICommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateBookingResult(ulong Id); - -public record BookingCreatedDomainEvent(Guid Id, PassengerInfo PassengerInfo, Trip Trip) : Entity, IDomainEvent; - -public record CreateBookingRequestDto(Guid PassengerId, Guid FlightId, string Description); - -public record CreateBookingResponseDto(ulong Id); - -public class CreateBookingEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/booking", async (CreateBookingRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateBooking") - .WithApiVersionSet(builder.NewApiVersionSet("Booking").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Booking") - .WithDescription("Create Booking") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateBookingValidator : AbstractValidator -{ - public CreateBookingValidator() - { - RuleFor(x => x.FlightId).NotNull().WithMessage("FlightId is required!"); - RuleFor(x => x.PassengerId).NotNull().WithMessage("PassengerId is required!"); - } -} - -internal class CreateBookingCommandHandler : ICommandHandler -{ - private readonly IEventStoreDBRepository _eventStoreDbRepository; - private readonly ICurrentUserProvider _currentUserProvider; - private readonly IEventDispatcher _eventDispatcher; - private readonly FlightGrpcService.FlightGrpcServiceClient _flightGrpcServiceClient; - private readonly PassengerGrpcService.PassengerGrpcServiceClient _passengerGrpcServiceClient; - - public CreateBookingCommandHandler(IEventStoreDBRepository eventStoreDbRepository, - ICurrentUserProvider currentUserProvider, - IEventDispatcher eventDispatcher, - FlightGrpcService.FlightGrpcServiceClient flightGrpcServiceClient, - PassengerGrpcService.PassengerGrpcServiceClient passengerGrpcServiceClient) - { - _eventStoreDbRepository = eventStoreDbRepository; - _currentUserProvider = currentUserProvider; - _eventDispatcher = eventDispatcher; - _flightGrpcServiceClient = flightGrpcServiceClient; - _passengerGrpcServiceClient = passengerGrpcServiceClient; - } - - public async Task Handle(CreateBooking command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var flight = - await _flightGrpcServiceClient.GetByIdAsync(new BookingFlight.GetByIdRequest { Id = command.FlightId.ToString() }, cancellationToken: cancellationToken); - - if (flight is null) - { - throw new FlightNotFoundException(); - } - - var passenger = - await _passengerGrpcServiceClient.GetByIdAsync(new BookingPassenger.GetByIdRequest { Id = command.PassengerId.ToString() }, cancellationToken: cancellationToken); - - var emptySeat = (await _flightGrpcServiceClient - .GetAvailableSeatsAsync(new GetAvailableSeatsRequest { FlightId = command.FlightId.ToString() }, cancellationToken: cancellationToken) - .ResponseAsync) - ?.SeatDtos?.FirstOrDefault(); - - var reservation = await _eventStoreDbRepository.Find(command.Id, cancellationToken); - - if (reservation is not null && !reservation.IsDeleted) - { - throw new BookingAlreadyExistException(); - } - - var aggrigate = Models.Booking.Create(command.Id, PassengerInfo.Of(passenger.PassengerDto?.Name), Trip.Of( - flight.FlightDto.FlightNumber, new Guid(flight.FlightDto.AircraftId), - new Guid(flight.FlightDto.DepartureAirportId), - new Guid(flight.FlightDto.ArriveAirportId), flight.FlightDto.FlightDate.ToDateTime(), - (decimal)flight.FlightDto.Price, command.Description, - emptySeat?.SeatNumber), - false, _currentUserProvider.GetCurrentUserId()); - - await _eventDispatcher.SendAsync(aggrigate.DomainEvents, cancellationToken: cancellationToken); - - await _flightGrpcServiceClient.ReserveSeatAsync(new ReserveSeatRequest - { - FlightId = flight.FlightDto.Id, - SeatNumber = emptySeat?.SeatNumber - }, cancellationToken: cancellationToken); - - var result = await _eventStoreDbRepository.Add( - aggrigate, - cancellationToken); - - return new CreateBookingResult(result); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/GrpcClientExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/GrpcClientExtensions.cs deleted file mode 100644 index 12a98cf..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/GrpcClientExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Booking.Configuration; -using BookingFlight; -using BookingPassenger; -using BuildingBlocks.Web; -using Microsoft.Extensions.DependencyInjection; - -namespace Booking.Extensions.Infrastructure; - -using BuildingBlocks.Polly; - -public static class GrpcClientExtensions -{ - public static IServiceCollection AddGrpcClients(this IServiceCollection services) - { - var grpcOptions = services.GetOptions("Grpc"); - - services.AddGrpcClient(o => - { - o.Address = new Uri(grpcOptions.FlightAddress); - }) - .AddGrpcRetryPolicyHandler() - .AddGrpcCircuitBreakerPolicyHandler(); - - services.AddGrpcClient(o => - { - o.Address = new Uri(grpcOptions.PassengerAddress); - }) - .AddGrpcRetryPolicyHandler() - .AddGrpcCircuitBreakerPolicyHandler(); - - return services; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/InfrastructureExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/InfrastructureExtensions.cs deleted file mode 100644 index 60ef44d..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/InfrastructureExtensions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Booking.Data; -using BuildingBlocks.EventStoreDB; -using BuildingBlocks.Mapster; -using BuildingBlocks.Mongo; -using BuildingBlocks.Web; -using FluentValidation; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace Booking.Extensions.Infrastructure; - -public static class InfrastructureExtensions -{ - public static WebApplicationBuilder AddBookingModules(this WebApplicationBuilder builder) - { - builder.Services.AddScoped(); - builder.AddMinimalEndpoints(assemblies: typeof(BookingRoot).Assembly); - builder.Services.AddValidatorsFromAssembly(typeof(BookingRoot).Assembly); - builder.Services.AddCustomMapster(typeof(BookingRoot).Assembly); - builder.AddMongoDbContext(); - - // ref: https://github.com/oskardudycz/EventSourcing.NetCore/tree/main/Sample/EventStoreDB/ECommerce - builder.Services.AddEventStore(builder.Configuration, typeof(BookingRoot).Assembly) - .AddEventStoreDBSubscriptionToAll(); - - builder.Services.AddGrpcClients(); - - builder.Services.AddCustomMediatR(); - - return builder; - } - - - public static WebApplication UseBookingModules(this WebApplication app) - { - return app; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/MediatRExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/MediatRExtensions.cs deleted file mode 100644 index 6b131a8..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Extensions/Infrastructure/MediatRExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using BuildingBlocks.Caching; -using BuildingBlocks.Logging; -using BuildingBlocks.Validation; -using MediatR; -using Microsoft.Extensions.DependencyInjection; - -namespace Booking.Extensions.Infrastructure; - -public static class MediatRExtensions -{ - public static IServiceCollection AddCustomMediatR(this IServiceCollection services) - { - services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(BookingRoot).Assembly)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(InvalidateCachingBehavior<,>)); - - return services; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/GrpcClient/Protos/flight.proto b/2-modular-monolith-architecture-style/src/Modules/Booking/src/GrpcClient/Protos/flight.proto deleted file mode 100644 index 19b57ca..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/GrpcClient/Protos/flight.proto +++ /dev/null @@ -1,85 +0,0 @@ -syntax = "proto3"; - -package bookingFlight; -import "google/protobuf/timestamp.proto"; - -service FlightGrpcService { - - rpc GetById (GetByIdRequest) returns (GetFlightByIdResult); - rpc GetAvailableSeats (GetAvailableSeatsRequest) returns (GetAvailableSeatsResult); - rpc ReserveSeat (ReserveSeatRequest) returns (ReserveSeatResult); -} - -message GetByIdRequest { - string Id = 1; -} - -message GetFlightByIdResult{ - FlightResponse FlightDto = 1; -} - -message GetAvailableSeatsResult{ -repeated SeatDtoResponse SeatDtos = 1; -} - -message ReserveSeatResult{ - string Id = 1; -} - -message FlightResponse { - string Id = 1; - string FlightNumber = 2; - string AircraftId = 3; - string DepartureAirportId = 4; - google.protobuf.Timestamp DepartureDate = 5; - google.protobuf.Timestamp ArriveDate = 6; - string ArriveAirportId = 7; - double DurationMinutes = 8; - google.protobuf.Timestamp FlightDate = 9; - FlightStatus Status = 10; - double Price = 11; - string FlightId = 12; -} - -message GetAvailableSeatsRequest { - string FlightId = 1; -} - -message SeatDtoResponse { - string Id = 1; - string SeatNumber = 2; - SeatType Type = 3; - SeatClass Class = 4; - string FlightId = 5; -} - - -message ReserveSeatRequest { - string FlightId = 1; - string SeatNumber = 2; -} - - - enum FlightStatus { - FLIGHT_STATUS_UNKNOWN = 0; - FLIGHT_STATUS_FLYING = 1; - FLIGHT_STATUS_DELAY = 2; - FLIGHT_STATUS_CANCELED = 3; - FLIGHT_STATUS_COMPLETED = 4; - } - - - enum SeatType { - SEAT_TYPE_UNKNOWN = 0; - SEAT_TYPE_WINDOW = 1; - SEAT_TYPE_MIDDLE = 2; - SEAT_TYPE_AISLE = 3; - } - - - enum SeatClass { - SEAT_CLASS_UNKNOWN = 0; - SEAT_CLASS_FIRST_CLASS = 1; - SEAT_CLASS_BUSINESS = 2; - SEAT_CLASS_ECONOMY = 3; - } diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/GrpcClient/Protos/passenger.proto b/2-modular-monolith-architecture-style/src/Modules/Booking/src/GrpcClient/Protos/passenger.proto deleted file mode 100644 index 7750311..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/GrpcClient/Protos/passenger.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; - -package bookingPassenger; - -service PassengerGrpcService { - - rpc GetById (GetByIdRequest) returns (GetPassengerByIdResult); -} - -message GetByIdRequest { - string Id = 1; -} - -message GetPassengerByIdResult { - PassengerResponse PassengerDto = 1; -} - -message PassengerResponse { - string Id = 1; - string Name = 2; - string PassportNumber = 3; - PassengerType PassengerType = 4; - int32 Age = 5; - string Email = 6; -} - - - enum PassengerType { - PASSENGER_TYPE_UNKNOWN = 0; - PASSENGER_TYPE_MALE = 1; - PASSENGER_TYPE_FEMALE = 2; - PASSENGER_TYPE_BABY = 3; - } - diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/.gitkeep b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Booking/Features/CreateBookingTests.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Booking/Features/CreateBookingTests.cs deleted file mode 100644 index 669664b..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Booking/Features/CreateBookingTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System.Threading.Tasks; -using Api; -using Booking.Data; -using BookingFlight; -using BookingPassenger; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using FluentAssertions; -using Grpc.Core; -using Grpc.Core.Testing; -using Integration.Test.Fakes; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using NSubstitute; -using Xunit; -using GetByIdRequest = BookingFlight.GetByIdRequest; - -namespace Integration.Test.Booking.Features -{ - public class CreateBookingTests : BookingIntegrationTestBase - { - public CreateBookingTests(TestReadFixture integrationTestFixture) : base( - integrationTestFixture) - { - } - - protected override void RegisterTestsServices(IServiceCollection services) - { - MockFlightGrpcServices(services); - MockPassengerGrpcServices(services); - } - - [Fact] - public async Task should_create_booking_to_event_store_currectly() - { - // Arrange - var command = new FakeCreateBookingCommand().Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response?.Id.Should().BeGreaterOrEqualTo(0); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } - - - private void MockPassengerGrpcServices(IServiceCollection services) - { - services.Replace(ServiceDescriptor.Singleton(x => - { - var mockPassenger = Substitute.For(); - - mockPassenger.GetByIdAsync(Arg.Any()) - .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakePassengerResponse.Generate()), - Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { })); - - return mockPassenger; - })); - } - - private void MockFlightGrpcServices(IServiceCollection services) - { - services.Replace(ServiceDescriptor.Singleton(x => - { - var mockFlight = Substitute.For(); - - mockFlight.GetByIdAsync(Arg.Any()) - .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeFlightResponse.Generate()), - Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { })); - - mockFlight.GetAvailableSeatsAsync(Arg.Any()) - .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeGetAvailableSeatsResponse.Generate()), - Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { })); - - mockFlight.ReserveSeatAsync(Arg.Any()) - .Returns(TestCalls.AsyncUnaryCall(Task.FromResult(FakeReserveSeatResponse.Generate()), - Task.FromResult(new Metadata()), () => Status.DefaultSuccess, () => new Metadata(), () => { })); - - return mockFlight; - })); - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/BookingIntegrationTestBase.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/BookingIntegrationTestBase.cs deleted file mode 100644 index acbcbae..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/BookingIntegrationTestBase.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Api; -using Booking.Data; -using BuildingBlocks.TestBase; -using Xunit; - -namespace Integration.Test; - -[Collection(IntegrationTestCollection.Name)] -public class BookingIntegrationTestBase : TestReadBase -{ - public BookingIntegrationTestBase(TestReadFixture integrationTestFixture) : base(integrationTestFixture) - { - } -} - -[CollectionDefinition(Name)] -public class IntegrationTestCollection : ICollectionFixture> -{ - public const string Name = "Booking Integration Test"; -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeFlightResponse.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeFlightResponse.cs deleted file mode 100644 index da25e1d..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeFlightResponse.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using AutoBogus; -using BookingFlight; -using Google.Protobuf.WellKnownTypes; - -namespace Integration.Test.Fakes; - -public static class FakeFlightResponse -{ - public static GetFlightByIdResult Generate() - { - var flightMock = new GetFlightByIdResult - { - FlightDto = new FlightResponse - { - Id = new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9").ToString(), - Price = 100, - Status = FlightStatus.Completed, - AircraftId = new Guid("3c5c0000-97c6-fc34-fcd3-08db322230c8").ToString(), - ArriveAirportId = new Guid("3c5c0000-97c6-fc34-a0cb-08db322230c8").ToString(), - ArriveDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp(), - DepartureDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp(), - FlightDate = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc).ToTimestamp(), - FlightNumber = "1500B", - DepartureAirportId = new Guid("3c5c0000-97c6-fc34-fc3c-08db322230c8").ToString() - } - }; - - return flightMock; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeGetAvailableSeatsResponse.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeGetAvailableSeatsResponse.cs deleted file mode 100644 index 4c1e431..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeGetAvailableSeatsResponse.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Collections.Generic; -using BookingFlight; - -namespace Integration.Test.Fakes; - -using System; -using MassTransit; - -public static class FakeGetAvailableSeatsResponse -{ - public static GetAvailableSeatsResult Generate() - { - var result = new GetAvailableSeatsResult(); - result.SeatDtos.AddRange(new List - { - new SeatDtoResponse() - { - FlightId = new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9").ToString(), - Class = SeatClass.Economy, - Type = SeatType.Aisle, - SeatNumber = "33F", - Id = NewId.NextGuid().ToString() - }, - new SeatDtoResponse() - { - FlightId = new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9").ToString(), - Class = SeatClass.Economy, - Type = SeatType.Window, - SeatNumber = "22D", - Id = NewId.NextGuid().ToString() - } - }); - - return result; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakePassengerResponse.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakePassengerResponse.cs deleted file mode 100644 index bce13be..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakePassengerResponse.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Integration.Test.Fakes; - -using BookingPassenger; -using MassTransit; - -public static class FakePassengerResponse -{ - public static GetPassengerByIdResult Generate() - { - var result = new GetPassengerByIdResult - { - PassengerDto = new PassengerResponse() - { - Id = NewId.NextGuid().ToString(), - Name = "Test", - PassportNumber = "121618" - } - }; - - return result; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeReserveSeatResponse.cs b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeReserveSeatResponse.cs deleted file mode 100644 index 290b104..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeReserveSeatResponse.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Integration.Test.Fakes; -using BookingFlight; -using MassTransit; - -public static class FakeReserveSeatResponse -{ - public static ReserveSeatResult Generate() - { - var result = new ReserveSeatResult(); - result.Id = NewId.NextGuid().ToString(); - - return result; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Integration.Test.csproj b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Integration.Test.csproj deleted file mode 100644 index d28f617..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Integration.Test.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - PreserveNewest - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/tests.sln b/2-modular-monolith-architecture-style/src/Modules/Booking/tests/tests.sln deleted file mode 100644 index 05ce8b7..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/tests.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.35906.104 d17.14 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "Integration.Test\Integration.Test.csproj", "{A0D4B2AE-53E4-454D-A1CB-E51168D016F3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF30A2EF-A06D-4A7E-B99B-304221C5FC0C} - EndGlobalSection -EndGlobal diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/EfTxFlightBehavior.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/EfTxFlightBehavior.cs deleted file mode 100644 index 33df7c6..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/EfTxFlightBehavior.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Text.Json; -using System.Transactions; -using BuildingBlocks.Core; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.Polly; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace Flight.Data; - -public class EfTxFlightBehavior : IPipelineBehavior -where TRequest : notnull, IRequest -where TResponse : notnull -{ - private readonly ILogger> _logger; - private readonly FlightDbContext _flightDbContext; - private readonly IPersistMessageDbContext _persistMessageDbContext; - private readonly IEventDispatcher _eventDispatcher; - - public EfTxFlightBehavior( - ILogger> logger, - FlightDbContext flightDbContext, - IPersistMessageDbContext persistMessageDbContext, - IEventDispatcher eventDispatcher - ) - { - _logger = logger; - _flightDbContext = flightDbContext; - _persistMessageDbContext = persistMessageDbContext; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle( - TRequest request, - RequestHandlerDelegate next, - CancellationToken cancellationToken - ) - { - _logger.LogInformation( - "{Prefix} Handled command {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - _logger.LogDebug( - "{Prefix} Handled command {MediatrRequest} with content {RequestContent}", - GetType().Name, - typeof(TRequest).FullName, - JsonSerializer.Serialize(request)); - - var response = await next(); - - _logger.LogInformation( - "{Prefix} Executed the {MediatrRequest} request", - GetType().Name, - typeof(TRequest).FullName); - - while (true) - { - var domainEvents = _flightDbContext.GetDomainEvents(); - - if (domainEvents is null || !domainEvents.Any()) - { - return response; - } - - _logger.LogInformation( - "{Prefix} Open the transaction for {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - using var scope = new TransactionScope( - TransactionScopeOption.Required, - new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, - TransactionScopeAsyncFlowOption.Enabled); - - await _eventDispatcher.SendAsync( - domainEvents.ToArray(), - typeof(TRequest), - cancellationToken); - - // Save data to database with some retry policy in distributed transaction - await _flightDbContext.RetryOnFailure( - async () => - { - await _flightDbContext.SaveChangesAsync(cancellationToken); - }); - - // Save data to database with some retry policy in distributed transaction - await _persistMessageDbContext.RetryOnFailure( - async () => - { - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - }); - - scope.Complete(); - - return response; - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/FlightDbContext.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/FlightDbContext.cs deleted file mode 100644 index 759240c..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/FlightDbContext.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using BuildingBlocks.EFCore; -using Flight.Aircrafts.Models; -using Flight.Airports.Models; -using Flight.Seats.Models; -using Microsoft.EntityFrameworkCore; - -namespace Flight.Data; - -using BuildingBlocks.Web; -using Microsoft.Extensions.Logging; - -public sealed class FlightDbContext : AppDbContextBase -{ - public FlightDbContext(DbContextOptions options, ICurrentUserProvider? currentUserProvider = null, - ILogger? logger = null) : base( - options, currentUserProvider, logger) - { - } - - public DbSet Flights => Set(); - public DbSet Airports => Set(); - public DbSet Aircraft => Set(); - public DbSet Seats => Set(); - - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); - builder.FilterSoftDeletedProperties(); - builder.ToSnakeCaseTables(); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Extensions/Infrastructure/InfrastructureExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/src/Extensions/Infrastructure/InfrastructureExtensions.cs deleted file mode 100644 index f54c81e..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Extensions/Infrastructure/InfrastructureExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using BuildingBlocks.EFCore; -using BuildingBlocks.Mapster; -using BuildingBlocks.Mongo; -using BuildingBlocks.Web; -using Flight.Data; -using Flight.Data.Seed; -using Flight.GrpcServer.Services; -using FluentValidation; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; - -namespace Flight.Extensions.Infrastructure; - - -public static class InfrastructureExtensions -{ - public static WebApplicationBuilder AddFlightModules(this WebApplicationBuilder builder) - { - builder.Services.AddScoped(); - builder.AddMinimalEndpoints(assemblies: typeof(FlightRoot).Assembly); - builder.Services.AddValidatorsFromAssembly(typeof(FlightRoot).Assembly); - builder.Services.AddCustomMapster(typeof(FlightRoot).Assembly); - builder.AddCustomDbContext(nameof(Flight)); - builder.Services.AddScoped(); - builder.AddMongoDbContext(); - - builder.Services.AddCustomMediatR(); - - return builder; - } - - - public static WebApplication UseFlightModules(this WebApplication app) - { - app.UseMigration(); - app.MapGrpcService(); - - return app; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Extensions/Infrastructure/MediatRExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/src/Extensions/Infrastructure/MediatRExtensions.cs deleted file mode 100644 index 7fe8ac0..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Extensions/Infrastructure/MediatRExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BuildingBlocks.Caching; -using BuildingBlocks.Logging; -using BuildingBlocks.Validation; -using Flight.Data; -using MediatR; -using Microsoft.Extensions.DependencyInjection; - -namespace Flight.Extensions.Infrastructure; - -public static class MediatRExtensions -{ - public static IServiceCollection AddCustomMediatR(this IServiceCollection services) - { - services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(FlightRoot).Assembly)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); - services.AddScoped(typeof(IPipelineBehavior<,>), typeof(EfTxFlightBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(InvalidateCachingBehavior<,>)); - - return services; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flight.csproj b/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flight.csproj deleted file mode 100644 index 3ddedde..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flight.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/.gitkeep b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/EndToEnd.Test.csproj b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/EndToEnd.Test.csproj deleted file mode 100644 index a0c6e9f..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/EndToEnd.Test.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - PreserveNewest - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Flight/Features/CreateFlightTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Flight/Features/CreateFlightTests.cs deleted file mode 100644 index 9e64a7c..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Flight/Features/CreateFlightTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Net; -using System.Net.Http.Json; -using Api; -using BuildingBlocks.TestBase; -using EndToEnd.Test.Fakes; -using EndToEnd.Test.Routes; -using Flight.Data; -using FluentAssertions; -using Xunit; - -namespace EndToEnd.Test.Flight.Features; - -public class CreateFlightTests : FlightEndToEndTestBase -{ - public CreateFlightTests(TestFixture integrationTestFixture) : base(integrationTestFixture) - { - } - - - [Fact] - public async Task should_create_new_flight_to_db_and_publish_message_to_broker() - { - //Arrange - var command = new FakeCreateFlightCommand().Generate(); - - // Act - var route = ApiRoutes.Flight.CreateFlight; - var result = await Fixture.HttpClient.PostAsJsonAsync(route, command); - - // Assert - result.StatusCode.Should().Be(HttpStatusCode.Created); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Flight/Features/GetFlightByIdTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Flight/Features/GetFlightByIdTests.cs deleted file mode 100644 index 609b039..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Flight/Features/GetFlightByIdTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Net; -using Api; -using BuildingBlocks.TestBase; -using EndToEnd.Test.Fakes; -using EndToEnd.Test.Routes; -using Flight.Data; -using FluentAssertions; -using Xunit; - -namespace EndToEnd.Test.Flight.Features; - -public class GetFlightByIdTests : FlightEndToEndTestBase -{ - public GetFlightByIdTests(TestFixture integrationTestFixture) : base(integrationTestFixture) - { - } - - - [Fact] - public async Task should_retrive_a_flight_by_id_currectly() - { - //Arrange - var command = new FakeCreateFlightMongoCommand().Generate(); - - await Fixture.SendAsync(command); - - // Act - var route = ApiRoutes.Flight.GetFlightById.Replace(ApiRoutes.Flight.Id, command.Id.ToString(), StringComparison.CurrentCulture); - var result = await Fixture.HttpClient.GetAsync(route); - - // Assert - result.StatusCode.Should().Be(HttpStatusCode.OK); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/FlightEndToEndTestBase.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/FlightEndToEndTestBase.cs deleted file mode 100644 index ba8dad5..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/FlightEndToEndTestBase.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Api; -using BuildingBlocks.TestBase; -using Flight.Data; -using Xunit; - -namespace EndToEnd.Test; - -[Collection(EndToEndTestCollection.Name)] -public class FlightEndToEndTestBase : TestBase -{ - public FlightEndToEndTestBase(TestFixture integrationTestFixture) : base(integrationTestFixture) - { - } -} - -[CollectionDefinition(Name)] -public class EndToEndTestCollection : ICollectionFixture> -{ - public const string Name = "Flight EndToEnd Test"; -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Aircraft/Features/CreateAircraftTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Aircraft/Features/CreateAircraftTests.cs deleted file mode 100644 index 433fe29..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Aircraft/Features/CreateAircraftTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Aircraft.Features; - -public class CreateAircraftTests : FlightIntegrationTestBase -{ - public CreateAircraftTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_create_new_aircraft_to_db_and_publish_message_to_broker() - { - // Arrange - var command = new FakeCreateAircraftCommand().Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response?.Id.Value.Should().Be(command.Id); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Airport/Features/CreateAirportTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Airport/Features/CreateAirportTests.cs deleted file mode 100644 index 59d6cfb..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Airport/Features/CreateAirportTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Airport.Features; - -public class CreateAirportTests : FlightIntegrationTestBase -{ - public CreateAirportTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_create_new_airport_to_db_and_publish_message_to_broker() - { - // Arrange - var command = new FakeCreateAirportCommand().Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response?.Id.Should().Be(command.Id); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/CreateFlightTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/CreateFlightTests.cs deleted file mode 100644 index a1c2a33..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/CreateFlightTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Flight.Features; - -public class CreateFlightTests : FlightIntegrationTestBase -{ - public CreateFlightTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_create_new_flight_to_db_and_publish_message_to_broker() - { - //Arrange - var command = new FakeCreateFlightCommand().Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response.Should().NotBeNull(); - response?.Id.Should().Be(command.Id); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/DeleteFlightTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/DeleteFlightTests.cs deleted file mode 100644 index e5c17de..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/DeleteFlightTests.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using Flight.Data; -using FluentAssertions; -using Microsoft.EntityFrameworkCore; -using Xunit; - -namespace Integration.Test.Flight.Features; - -using global::Flight.Data.Seed; -using global::Flight.Flights.Features.DeletingFlight.V1; -using global::Flight.Flights.Models; -using global::Flight.Flights.ValueObjects; - -public class DeleteFlightTests : FlightIntegrationTestBase -{ - public DeleteFlightTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_delete_flight_from_db() - { - // Arrange - var flightEntity = await Fixture.FindAsync(InitialData.Flights.First().Id); - var command = new DeleteFlight(flightEntity.Id.Value); - - // Act - await Fixture.SendAsync(command); - var deletedFlight = (await Fixture.ExecuteDbContextAsync(db => db.Flights - .Where(x => x.Id == FlightId.Of(command.Id)) - .IgnoreQueryFilters() - .ToListAsync()) - ).FirstOrDefault(); - - // Assert - deletedFlight?.IsDeleted.Should().BeTrue(); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/GetAvailableFlightsTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/GetAvailableFlightsTests.cs deleted file mode 100644 index 660fa0d..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/GetAvailableFlightsTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Api; -using BuildingBlocks.TestBase; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Flight.Features; - -using global::Flight.Flights.Features.CreatingFlight.V1; -using global::Flight.Flights.Features.GettingAvailableFlights.V1; - -public class GetAvailableFlightsTests : FlightIntegrationTestBase -{ - public GetAvailableFlightsTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_return_available_flights() - { - // Arrange - var command = new FakeCreateFlightMongoCommand().Generate(); - - await Fixture.SendAsync(command); - - var query = new GetAvailableFlights(); - - // Act - var response = (await Fixture.SendAsync(query))?.FlightDtos?.ToList(); - - // Assert - response?.Should().NotBeNull(); - response?.Count.Should().BeGreaterOrEqualTo(2); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/GetFlightByIdTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/GetFlightByIdTests.cs deleted file mode 100644 index b34fda1..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/GetFlightByIdTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.TestBase; -using Flight; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Flight.Features; - -using global::Flight.Flights.Features.GettingFlightById.V1; - -public class GetFlightByIdTests : FlightIntegrationTestBase -{ - public GetFlightByIdTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_retrive_a_flight_by_id_currectly() - { - //Arrange - var command = new FakeCreateFlightMongoCommand().Generate(); - - await Fixture.SendAsync(command); - - var query = new GetFlightById(command.Id); - - // Act - var response = await Fixture.SendAsync(query); - - // Assert - response.Should().NotBeNull(); - response?.FlightDto?.Id.Should().Be(command.Id); - } - - [Fact] - public async Task should_retrive_a_flight_by_id_from_grpc_service() - { - //Arrange - var command = new FakeCreateFlightMongoCommand().Generate(); - - await Fixture.SendAsync(command); - - var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel); - - // Act - var response = await flightGrpcClient.GetByIdAsync(new GetByIdRequest { Id = command.Id.ToString() }).ResponseAsync; - - // Assert - response?.Should().NotBeNull(); - response?.FlightDto.Id.Should().Be(command.Id.ToString()); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/UpdateFlightTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/UpdateFlightTests.cs deleted file mode 100644 index 6ae6e6a..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Flight/Features/UpdateFlightTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Flight.Features; - -using System.Linq; -using global::Flight.Data.Seed; -using global::Flight.Flights.Models; -using global::Flight.Flights.ValueObjects; - -public class UpdateFlightTests : FlightIntegrationTestBase -{ - public UpdateFlightTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_update_flight_to_db_and_publish_message_to_broker() - { - // Arrange - var flightEntity = await Fixture.FindAsync(InitialData.Flights.First().Id); - var command = new FakeUpdateFlightCommand(flightEntity).Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response.Should().NotBeNull(); - response?.Id.Should().Be(flightEntity.Id); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/FlightIntegrationTestBase.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/FlightIntegrationTestBase.cs deleted file mode 100644 index b51f114..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/FlightIntegrationTestBase.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Api; -using BuildingBlocks.TestBase; -using Flight.Data; -using Xunit; - -namespace Integration.Test; - -[Collection(IntegrationTestCollection.Name)] -public class FlightIntegrationTestBase : TestBase -{ - public FlightIntegrationTestBase(TestFixture integrationTestFixture) : base(integrationTestFixture) - { - } -} - -[CollectionDefinition(Name)] -public class IntegrationTestCollection : ICollectionFixture> -{ - public const string Name = "Flight Integration Test"; -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Integration.Test.csproj b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Integration.Test.csproj deleted file mode 100644 index a0c6e9f..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Integration.Test.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - PreserveNewest - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Seat/Features/GetAvailableSeatsTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Seat/Features/GetAvailableSeatsTests.cs deleted file mode 100644 index 9a3fe1c..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Seat/Features/GetAvailableSeatsTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using BuildingBlocks.TestBase; -using Flight; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Seat.Features; - -using Api; - -public class GetAvailableSeatsTests : FlightIntegrationTestBase -{ - public GetAvailableSeatsTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_return_available_seats_from_grpc_service() - { - // Arrange - var flightCommand = new FakeCreateFlightMongoCommand().Generate(); - - await Fixture.SendAsync(flightCommand); - - var seatCommand = new FakeCreateSeatMongoCommand(flightCommand.Id).Generate(); - - await Fixture.SendAsync(seatCommand); - - var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel); - - // Act - var response = await flightGrpcClient.GetAvailableSeatsAsync(new GetAvailableSeatsRequest { FlightId = flightCommand.Id.ToString() }); - - // Assert - response?.Should().NotBeNull(); - response?.SeatDtos?.Count.Should().BeGreaterOrEqualTo(1); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Seat/Features/ReserveSeatTests.cs b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Seat/Features/ReserveSeatTests.cs deleted file mode 100644 index 7e994cf..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Seat/Features/ReserveSeatTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Api; -using BuildingBlocks.TestBase; -using Flight; -using Flight.Data; -using FluentAssertions; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Seat.Features; -public class ReserveSeatTests : FlightIntegrationTestBase -{ - public ReserveSeatTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_return_valid_reserve_seat_from_grpc_service() - { - // Arrange - var flightCommand = new FakeCreateFlightCommand().Generate(); - - await Fixture.SendAsync(flightCommand); - - var seatCommand = new FakeCreateSeatCommand(flightCommand.Id).Generate(); - - await Fixture.SendAsync(seatCommand); - - var flightGrpcClient = new FlightGrpcService.FlightGrpcServiceClient(Fixture.Channel); - - // Act - var response = await flightGrpcClient.ReserveSeatAsync(new ReserveSeatRequest() - { - FlightId = seatCommand.FlightId.ToString(), - SeatNumber = seatCommand.SeatNumber - }); - - // Assert - response?.Should().NotBeNull(); - response?.Id.Should().Be(seatCommand?.Id.ToString()); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Unit.Test.csproj b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Unit.Test.csproj deleted file mode 100644 index be2a92d..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Unit.Test.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - - PreserveNewest - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/tests.sln b/2-modular-monolith-architecture-style/src/Modules/Flight/tests/tests.sln deleted file mode 100644 index fbb8945..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/tests.sln +++ /dev/null @@ -1,37 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.13.35931.197 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit.Test", "Unit.Test\Unit.Test.csproj", "{9FF9D3A3-D316-461F-90D8-A51226796AB8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "Integration.Test\Integration.Test.csproj", "{7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndToEnd.Test", "EndToEnd.Test\EndToEnd.Test.csproj", "{52AB66AF-F024-F2C2-5B1B-29218D5BB25E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9FF9D3A3-D316-461F-90D8-A51226796AB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9FF9D3A3-D316-461F-90D8-A51226796AB8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9FF9D3A3-D316-461F-90D8-A51226796AB8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9FF9D3A3-D316-461F-90D8-A51226796AB8}.Release|Any CPU.Build.0 = Release|Any CPU - {7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CD2A0EF-7505-43D5-A428-8F8EB4C8004F}.Release|Any CPU.Build.0 = Release|Any CPU - {52AB66AF-F024-F2C2-5B1B-29218D5BB25E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52AB66AF-F024-F2C2-5B1B-29218D5BB25E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52AB66AF-F024-F2C2-5B1B-29218D5BB25E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52AB66AF-F024-F2C2-5B1B-29218D5BB25E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4EB6EA31-EAFC-4770-A32B-52E5EFF62E05} - EndGlobalSection -EndGlobal diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/Config.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/Config.cs deleted file mode 100644 index fd832e3..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/Config.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Duende.IdentityServer; -using Duende.IdentityServer.Models; -using Identity.Identity.Constants; -using IdentityModel; - -namespace Identity.Configurations; - -public static class Config -{ - public static IEnumerable IdentityResources => - new List - { - new IdentityResources.OpenId(), - new IdentityResources.Profile(), - new IdentityResources.Email() - }; - - - public static IEnumerable ApiScopes => - new List - { - new(Constants.StandardScopes.FlightApi), - new(Constants.StandardScopes.PassengerApi), - new(Constants.StandardScopes.BookingApi), - new(Constants.StandardScopes.IdentityApi), - new(Constants.StandardScopes.BookingModularMonolith), - new(JwtClaimTypes.Role, new List {"role"}) - }; - - - public static IList ApiResources => - new List - { - new(Constants.StandardScopes.FlightApi) - { - Scopes = { Constants.StandardScopes.FlightApi } - }, - new(Constants.StandardScopes.PassengerApi) - { - Scopes = { Constants.StandardScopes.PassengerApi } - }, - new(Constants.StandardScopes.BookingApi) - { - Scopes = { Constants.StandardScopes.BookingApi } - }, - new(Constants.StandardScopes.IdentityApi) - { - Scopes = { Constants.StandardScopes.IdentityApi } - }, - new(Constants.StandardScopes.BookingModularMonolith) - { - Scopes = { Constants.StandardScopes.BookingModularMonolith } - }, - }; - - public static IEnumerable Clients => - new List - { - new() - { - ClientId = "client", - AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, - ClientSecrets = - { - new Secret("secret".Sha256()) - }, - AllowedScopes = - { - IdentityServerConstants.StandardScopes.OpenId, - IdentityServerConstants.StandardScopes.Profile, - JwtClaimTypes.Role, // Include roles scope - Constants.StandardScopes.FlightApi, - Constants.StandardScopes.PassengerApi, - Constants.StandardScopes.BookingApi, - Constants.StandardScopes.IdentityApi, - Constants.StandardScopes.BookingModularMonolith, - }, - AccessTokenLifetime = 3600, // authorize the client to access protected resources - IdentityTokenLifetime = 3600, // authenticate the user, - AlwaysIncludeUserClaimsInIdToken = true // Include claims in ID token - } - }; -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/EfTxIdentityBehavior.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/EfTxIdentityBehavior.cs deleted file mode 100644 index d611b40..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/EfTxIdentityBehavior.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Text.Json; -using System.Transactions; -using BuildingBlocks.Core; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.Polly; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace Identity.Data; - -public class EfTxIdentityBehavior : IPipelineBehavior -where TRequest : notnull, IRequest -where TResponse : notnull -{ - private readonly ILogger> _logger; - private readonly IdentityContext _identityContext; - private readonly IPersistMessageDbContext _persistMessageDbContext; - private readonly IEventDispatcher _eventDispatcher; - - public EfTxIdentityBehavior( - ILogger> logger, - IdentityContext identityContext, - IPersistMessageDbContext persistMessageDbContext, - IEventDispatcher eventDispatcher - ) - { - _logger = logger; - _identityContext = identityContext; - _persistMessageDbContext = persistMessageDbContext; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle( - TRequest request, - RequestHandlerDelegate next, - CancellationToken cancellationToken - ) - { - _logger.LogInformation( - "{Prefix} Handled command {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - _logger.LogDebug( - "{Prefix} Handled command {MediatrRequest} with content {RequestContent}", - GetType().Name, - typeof(TRequest).FullName, - JsonSerializer.Serialize(request)); - - var response = await next(); - - _logger.LogInformation( - "{Prefix} Executed the {MediatrRequest} request", - GetType().Name, - typeof(TRequest).FullName); - - while (true) - { - var domainEvents = _identityContext.GetDomainEvents(); - - if (domainEvents is null || !domainEvents.Any()) - { - return response; - } - - _logger.LogInformation( - "{Prefix} Open the transaction for {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - using var scope = new TransactionScope( - TransactionScopeOption.Required, - new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, - TransactionScopeAsyncFlowOption.Enabled); - - await _eventDispatcher.SendAsync( - domainEvents.ToArray(), - typeof(TRequest), - cancellationToken); - - // Save data to database with some retry policy in distributed transaction - await _identityContext.RetryOnFailure( - async () => - { - await _identityContext.SaveChangesAsync(cancellationToken); - }); - - // Save data to database with some retry policy in distributed transaction - await _persistMessageDbContext.RetryOnFailure( - async () => - { - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - }); - - scope.Complete(); - - return response; - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Seed/IdentityDataSeeder.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Seed/IdentityDataSeeder.cs deleted file mode 100644 index f1780d4..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Seed/IdentityDataSeeder.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System; -using System.Threading.Tasks; -using BuildingBlocks.Constants; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.EFCore; -using Identity.Identity.Constants; -using Identity.Identity.Models; -using Microsoft.AspNetCore.Identity; -using Microsoft.EntityFrameworkCore; - -namespace Identity.Data.Seed; - -using System.Linq; - -public class IdentityDataSeeder : IDataSeeder -{ - private readonly UserManager _userManager; - private readonly RoleManager _roleManager; - private readonly IEventDispatcher _eventDispatcher; - private readonly IdentityContext _identityContext; - - public IdentityDataSeeder( - UserManager userManager, - RoleManager roleManager, - IEventDispatcher eventDispatcher, - IdentityContext identityContext - ) - { - _userManager = userManager; - _roleManager = roleManager; - _eventDispatcher = eventDispatcher; - _identityContext = identityContext; - } - - public async Task SeedAllAsync() - { - var pendingMigrations = await _identityContext.Database.GetPendingMigrationsAsync(); - - if (!pendingMigrations.Any()) - { - await SeedRoles(); - await SeedUsers(); - } - } - - private async Task SeedRoles() - { - if (!await _identityContext.Roles.AnyAsync()) - { - if (await _roleManager.RoleExistsAsync(IdentityConstant.Role.Admin) == false) - { - await _roleManager.CreateAsync(new Role { Name = IdentityConstant.Role.Admin }); - } - - if (await _roleManager.RoleExistsAsync(IdentityConstant.Role.User) == false) - { - await _roleManager.CreateAsync(new Role { Name = IdentityConstant.Role.User }); - } - } - } - - private async Task SeedUsers() - { - if (!await _identityContext.Users.AnyAsync()) - { - if (await _userManager.FindByNameAsync("samh") == null) - { - var result = await _userManager.CreateAsync(InitialData.Users.First(), "Admin@123456"); - - if (result.Succeeded) - { - await _userManager.AddToRoleAsync(InitialData.Users.First(), IdentityConstant.Role.Admin); - - await _eventDispatcher.SendAsync( - new UserCreated( - InitialData.Users.First().Id, - InitialData.Users.First().FirstName + - " " + - InitialData.Users.First().LastName, - InitialData.Users.First().PassPortNumber)); - } - } - - if (await _userManager.FindByNameAsync("meysamh2") == null) - { - var result = await _userManager.CreateAsync(InitialData.Users.Last(), "User@123456"); - - if (result.Succeeded) - { - await _userManager.AddToRoleAsync(InitialData.Users.Last(), IdentityConstant.Role.User); - - await _eventDispatcher.SendAsync( - new UserCreated( - InitialData.Users.Last().Id, - InitialData.Users.Last().FirstName + - " " + - InitialData.Users.Last().LastName, - InitialData.Users.Last().PassPortNumber)); - } - } - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/InfrastructureExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/InfrastructureExtensions.cs deleted file mode 100644 index 900be81..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/InfrastructureExtensions.cs +++ /dev/null @@ -1,45 +0,0 @@ -using BuildingBlocks.EFCore; -using BuildingBlocks.Mapster; -using BuildingBlocks.Web; -using FluentValidation; -using Identity.Data; -using Identity.Data.Seed; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.HttpOverrides; -using Microsoft.Extensions.DependencyInjection; - -namespace Identity.Extensions.Infrastructure; - - -public static class InfrastructureExtensions -{ - public static WebApplicationBuilder AddIdentityModules(this WebApplicationBuilder builder) - { - builder.Services.AddScoped(); - builder.AddMinimalEndpoints(assemblies: typeof(IdentityRoot).Assembly); - builder.Services.AddValidatorsFromAssembly(typeof(IdentityRoot).Assembly); - builder.Services.AddCustomMapster(typeof(IdentityRoot).Assembly); - builder.AddCustomDbContext(nameof(Identity)); - builder.Services.AddScoped(); - builder.AddCustomIdentityServer(); - - builder.Services.Configure(options => - { - options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; - }); - - builder.Services.AddCustomMediatR(); - - return builder; - } - - - public static WebApplication UseIdentityModules(this WebApplication app) - { - app.UseForwardedHeaders(); - app.UseIdentityServer(); - app.UseMigration(); - - return app; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/MediatRExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/MediatRExtensions.cs deleted file mode 100644 index a43a3d4..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/MediatRExtensions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using BuildingBlocks.Caching; -using BuildingBlocks.Logging; -using BuildingBlocks.Validation; -using Identity.Data; -using MediatR; -using Microsoft.Extensions.DependencyInjection; - -namespace Identity.Extensions.Infrastructure; - -using Configurations; - -public static class MediatRExtensions -{ - public static IServiceCollection AddCustomMediatR(this IServiceCollection services) - { - services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(IdentityRoot).Assembly)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); - services.AddScoped(typeof(IPipelineBehavior<,>), typeof(EfTxIdentityBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(InvalidateCachingBehavior<,>)); - - return services; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Constants/Constants.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Constants/Constants.cs deleted file mode 100644 index e893f7a..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Constants/Constants.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Identity.Identity.Constants; - -public static class Constants -{ - public static class StandardScopes - { - public const string Roles = "roles"; - public const string FlightApi = "flight-api"; - public const string PassengerApi = "passenger-api"; - public const string BookingApi = "booking-api"; - public const string IdentityApi = "identity-api"; - public const string BookingModularMonolith = "booking-modular-monolith"; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs deleted file mode 100644 index 9864a06..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs +++ /dev/null @@ -1,137 +0,0 @@ -using BuildingBlocks.Constants; -using Duende.IdentityServer.EntityFramework.Entities; - -namespace Identity.Identity.Features.RegisteringNewUser.V1; - -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Routing; -using Models; - -public record RegisterNewUser(string FirstName, string LastName, string Username, string Email, - string Password, string ConfirmPassword, string PassportNumber) : ICommand; - -public record RegisterNewUserResult(Guid Id, string FirstName, string LastName, string Username, string PassportNumber); - -public record RegisterNewUserRequestDto(string FirstName, string LastName, string Username, string Email, - string Password, string ConfirmPassword, string PassportNumber); - -public record RegisterNewUserResponseDto(Guid Id, string FirstName, string LastName, string Username, - string PassportNumber); - -public class RegisterNewUserEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/identity/register-user", async ( - RegisterNewUserRequestDto request, IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("RegisterUser") - .WithApiVersionSet(builder.NewApiVersionSet("Identity").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Register User") - .WithDescription("Register User") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class RegisterNewUserValidator : AbstractValidator -{ - public RegisterNewUserValidator() - { - RuleFor(x => x.Password).NotEmpty().WithMessage("Please enter the password"); - RuleFor(x => x.ConfirmPassword).NotEmpty().WithMessage("Please enter the confirmation password"); - - RuleFor(x => x).Custom((x, context) => - { - if (x.Password != x.ConfirmPassword) - { - context.AddFailure(nameof(x.Password), "Passwords should match"); - } - }); - - RuleFor(x => x.Username).NotEmpty().WithMessage("Please enter the username"); - RuleFor(x => x.FirstName).NotEmpty().WithMessage("Please enter the first name"); - RuleFor(x => x.LastName).NotEmpty().WithMessage("Please enter the last name"); - RuleFor(x => x.Email).NotEmpty().WithMessage("Please enter the last email") - .EmailAddress().WithMessage("A valid email is required"); - } -} - -internal class RegisterNewUserHandler : ICommandHandler -{ - private readonly IEventDispatcher _eventDispatcher; - private readonly UserManager _userManager; - - public RegisterNewUserHandler(UserManager userManager, - IEventDispatcher eventDispatcher) - { - _userManager = userManager; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle(RegisterNewUser request, - CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var applicationUser = new User() - { - FirstName = request.FirstName, - LastName = request.LastName, - UserName = request.Username, - Email = request.Email, - PasswordHash = request.Password, - PassPortNumber = request.PassportNumber - }; - - var identityResult = await _userManager.CreateAsync(applicationUser, request.Password); - var roleResult = await _userManager.AddToRoleAsync(applicationUser, IdentityConstant.Role.User); - - if (identityResult.Succeeded == false) - { - throw new RegisterIdentityUserException(string.Join(',', identityResult.Errors.Select(e => e.Description))); - } - - if (roleResult.Succeeded == false) - { - throw new RegisterIdentityUserException(string.Join(',', roleResult.Errors.Select(e => e.Description))); - } - - await _eventDispatcher.SendAsync(new UserCreated(applicationUser.Id, - applicationUser.FirstName + " " + applicationUser.LastName, - applicationUser.PassPortNumber), cancellationToken: cancellationToken); - - return new RegisterNewUserResult(applicationUser.Id, applicationUser.FirstName, applicationUser.LastName, - applicationUser.UserName, applicationUser.PassPortNumber); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/.gitkeep b/2-modular-monolith-architecture-style/src/Modules/Identity/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Identity/Features/RegisterNewUserTests.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Identity/Features/RegisterNewUserTests.cs deleted file mode 100644 index e74a528..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Identity/Features/RegisterNewUserTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using FluentAssertions; -using Identity.Data; -using Integration.Test.Fakes; -using Xunit; - -namespace Integration.Test.Identity.Features; - -public class RegisterNewUserTests : IdentityIntegrationTestBase -{ - public RegisterNewUserTests( - TestWriteFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_create_new_user_to_db_and_publish_message_to_broker() - { - // Arrange - var command = new FakeRegisterNewUserCommand().Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response?.Should().NotBeNull(); - response?.Username.Should().Be(command.Username); - - (await Fixture.WaitForPublishing()).Should().Be(true); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/IdentityIntegrationTestBase.cs b/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/IdentityIntegrationTestBase.cs deleted file mode 100644 index 1eb690c..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/IdentityIntegrationTestBase.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Api; -using BuildingBlocks.TestBase; -using Identity.Data; -using Xunit; - -namespace Integration.Test; - -[Collection(IntegrationTestCollection.Name)] -public class IdentityIntegrationTestBase : TestWriteBase -{ - public IdentityIntegrationTestBase(TestWriteFixture integrationTestFactory) - : base(integrationTestFactory) - { - } -} - -[CollectionDefinition(Name)] -public class IntegrationTestCollection : ICollectionFixture> -{ - public const string Name = "Identity Integration Test"; -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Integration.Test.csproj b/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Integration.Test.csproj deleted file mode 100644 index d28f617..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Integration.Test.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - PreserveNewest - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/tests.sln b/2-modular-monolith-architecture-style/src/Modules/Identity/tests/tests.sln deleted file mode 100644 index 05ce8b7..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/tests.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.35906.104 d17.14 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "Integration.Test\Integration.Test.csproj", "{A0D4B2AE-53E4-454D-A1CB-E51168D016F3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF30A2EF-A06D-4A7E-B99B-304221C5FC0C} - EndGlobalSection -EndGlobal diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/AssemblyInfo.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/src/AssemblyInfo.cs deleted file mode 100644 index 60fedfd..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Unit.Test")] -[assembly: InternalsVisibleTo("Integration.Test")] -[assembly: InternalsVisibleTo("EndToEnd.Test")] - diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/EfTxPassengerBehavior.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/EfTxPassengerBehavior.cs deleted file mode 100644 index 970dd0f..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/EfTxPassengerBehavior.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Text.Json; -using System.Transactions; -using BuildingBlocks.Core; -using BuildingBlocks.PersistMessageProcessor; -using BuildingBlocks.Polly; -using MediatR; -using Microsoft.Extensions.Logging; - -namespace Passenger.Data; - -public class EfTxPassengerBehavior : IPipelineBehavior -where TRequest : notnull, IRequest -where TResponse : notnull -{ - private readonly ILogger> _logger; - private readonly PassengerDbContext _passengerDbContext; - private readonly IPersistMessageDbContext _persistMessageDbContext; - private readonly IEventDispatcher _eventDispatcher; - - public EfTxPassengerBehavior( - ILogger> logger, - PassengerDbContext passengerDbContext, - IPersistMessageDbContext persistMessageDbContext, - IEventDispatcher eventDispatcher - ) - { - _logger = logger; - _passengerDbContext = passengerDbContext; - _persistMessageDbContext = persistMessageDbContext; - _eventDispatcher = eventDispatcher; - } - - public async Task Handle( - TRequest request, - RequestHandlerDelegate next, - CancellationToken cancellationToken - ) - { - _logger.LogInformation( - "{Prefix} Handled command {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - _logger.LogDebug( - "{Prefix} Handled command {MediatrRequest} with content {RequestContent}", - GetType().Name, - typeof(TRequest).FullName, - JsonSerializer.Serialize(request)); - - var response = await next(); - - _logger.LogInformation( - "{Prefix} Executed the {MediatrRequest} request", - GetType().Name, - typeof(TRequest).FullName); - - while (true) - { - var domainEvents = _passengerDbContext.GetDomainEvents(); - - if (domainEvents is null || !domainEvents.Any()) - { - return response; - } - - _logger.LogInformation( - "{Prefix} Open the transaction for {MediatrRequest}", - GetType().Name, - typeof(TRequest).FullName); - - using var scope = new TransactionScope( - TransactionScopeOption.Required, - new TransactionOptions { IsolationLevel = IsolationLevel.ReadCommitted }, - TransactionScopeAsyncFlowOption.Enabled); - - await _eventDispatcher.SendAsync( - domainEvents.ToArray(), - typeof(TRequest), - cancellationToken); - - // Save data to database with some retry policy in distributed transaction - await _passengerDbContext.RetryOnFailure( - async () => - { - await _passengerDbContext.SaveChangesAsync(cancellationToken); - }); - - // Save data to database with some retry policy in distributed transaction - await _persistMessageDbContext.RetryOnFailure( - async () => - { - await _persistMessageDbContext.SaveChangesAsync(cancellationToken); - }); - - scope.Complete(); - - return response; - } - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Extensions/Infrastructure/InfrastructureExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Extensions/Infrastructure/InfrastructureExtensions.cs deleted file mode 100644 index 3487d26..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Extensions/Infrastructure/InfrastructureExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using BuildingBlocks.EFCore; -using BuildingBlocks.Mapster; -using BuildingBlocks.Mongo; -using BuildingBlocks.Web; -using FluentValidation; -using Microsoft.AspNetCore.Builder; -using Microsoft.Extensions.DependencyInjection; -using Passenger.Data; -using Passenger.GrpcServer.Services; - -namespace Passenger.Extensions.Infrastructure; - -public static class InfrastructureExtensions -{ - public static WebApplicationBuilder AddPassengerModules(this WebApplicationBuilder builder) - { - builder.Services.AddScoped(); - builder.AddMinimalEndpoints(assemblies: typeof(PassengerRoot).Assembly); - builder.Services.AddValidatorsFromAssembly(typeof(PassengerRoot).Assembly); - builder.Services.AddCustomMapster(typeof(PassengerRoot).Assembly); - builder.AddCustomDbContext(nameof(Passenger)); - builder.AddMongoDbContext(); - - builder.Services.AddCustomMediatR(); - - return builder; - } - - - public static WebApplication UsePassengerModules(this WebApplication app) - { - app.UseMigration(); - app.MapGrpcService(); - - return app; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Extensions/Infrastructure/MediatRExtensions.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Extensions/Infrastructure/MediatRExtensions.cs deleted file mode 100644 index e39a970..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Extensions/Infrastructure/MediatRExtensions.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BuildingBlocks.Caching; -using BuildingBlocks.Logging; -using BuildingBlocks.Validation; -using MediatR; -using Microsoft.Extensions.DependencyInjection; -using Passenger.Data; - -namespace Passenger.Extensions.Infrastructure; - -public static class MediatRExtensions -{ - public static IServiceCollection AddCustomMediatR(this IServiceCollection services) - { - services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblies(typeof(PassengerRoot).Assembly)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>)); - services.AddScoped(typeof(IPipelineBehavior<,>), typeof(EfTxPassengerBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(CachingBehavior<,>)); - services.AddTransient(typeof(IPipelineBehavior<,>), typeof(InvalidateCachingBehavior<,>)); - - return services; - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs deleted file mode 100644 index 1bd257d..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs +++ /dev/null @@ -1,117 +0,0 @@ -namespace Passenger.Passengers.Features.CompletingRegisterPassenger.V1; - -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Dtos; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; -using Passenger.Passengers.ValueObjects; - -public record CompleteRegisterPassenger - (string PassportNumber, Enums.PassengerType PassengerType, int Age) : ICommand, - IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record PassengerRegistrationCompletedDomainEvent(Guid Id, string Name, string PassportNumber, - Enums.PassengerType PassengerType, int Age, bool IsDeleted = false) : IDomainEvent; - -public record CompleteRegisterPassengerResult(PassengerDto PassengerDto); - -public record CompleteRegisterPassengerRequestDto(string PassportNumber, Enums.PassengerType PassengerType, int Age); - -public record CompleteRegisterPassengerResponseDto(PassengerDto PassengerDto); - -public class CompleteRegisterPassengerEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/passenger/complete-registration", async ( - CompleteRegisterPassengerRequestDto request, IMapper mapper, - IMediator mediator, CancellationToken cancellationToken, IHttpContextAccessor httpContextAccessor) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CompleteRegisterPassenger") - .WithApiVersionSet(builder.NewApiVersionSet("Passenger").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Complete Register Passenger") - .WithDescription("Complete Register Passenger") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CompleteRegisterPassengerValidator : AbstractValidator -{ - public CompleteRegisterPassengerValidator() - { - RuleFor(x => x.PassportNumber).NotNull().WithMessage("The PassportNumber is required!"); - RuleFor(x => x.Age).GreaterThan(0).WithMessage("The Age must be greater than 0!"); - RuleFor(x => x.PassengerType).Must(p => p.GetType().IsEnum && - p == Enums.PassengerType.Baby || - p == Enums.PassengerType.Female || - p == Enums.PassengerType.Male || - p == Enums.PassengerType.Unknown) - .WithMessage("PassengerType must be Male, Female, Baby or Unknown"); - } -} - -internal class CompleteRegisterPassengerCommandHandler : ICommandHandler -{ - private readonly IMapper _mapper; - private readonly PassengerDbContext _passengerDbContext; - - public CompleteRegisterPassengerCommandHandler(IMapper mapper, PassengerDbContext passengerDbContext) - { - _mapper = mapper; - _passengerDbContext = passengerDbContext; - } - - public async Task Handle(CompleteRegisterPassenger request, - CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var passenger = await _passengerDbContext.Passengers.SingleOrDefaultAsync( - x => x.PassportNumber.Value == request.PassportNumber, cancellationToken); - - if (passenger is null) - { - throw new PassengerNotExist(); - } - - passenger.CompleteRegistrationPassenger(passenger.Id, passenger.Name, - passenger.PassportNumber, request.PassengerType, Age.Of(request.Age)); - - var updatePassenger = _passengerDbContext.Passengers.Update(passenger).Entity; - - var passengerDto = _mapper.Map(updatePassenger); - - return new CompleteRegisterPassengerResult(passengerDto); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/.gitkeep b/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Integration.Test.csproj b/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Integration.Test.csproj deleted file mode 100644 index 9dbbc5b..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Integration.Test.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - PreserveNewest - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Passenger/Features/CompleteRegisterPassengerTests.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Passenger/Features/CompleteRegisterPassengerTests.cs deleted file mode 100644 index a183018..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Passenger/Features/CompleteRegisterPassengerTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.TestBase; -using FluentAssertions; -using Integration.Test.Fakes; -using Passenger.Data; -using Xunit; - -namespace Integration.Test.Passenger.Features; -public class CompleteRegisterPassengerTests : PassengerIntegrationTestBase -{ - - public CompleteRegisterPassengerTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_complete_register_passenger_and_update_to_db() - { - // Arrange - var userCreated = new FakeUserCreated().Generate(); - - await Fixture.Publish(userCreated); - (await Fixture.WaitForPublishing()).Should().Be(true); - (await Fixture.WaitForConsuming()).Should().Be(true); - - var command = new FakeCompleteRegisterPassengerCommand(userCreated.PassportNumber).Generate(); - - // Act - var response = await Fixture.SendAsync(command); - - // Assert - response.Should().NotBeNull(); - response?.PassengerDto?.Name.Should().Be(userCreated.Name); - response?.PassengerDto?.PassportNumber.Should().Be(command.PassportNumber); - response?.PassengerDto?.PassengerType.ToString().Should().Be(command.PassengerType.ToString()); - response?.PassengerDto?.Age.Should().Be(command.Age); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Passenger/Features/GetPassengerByIdTests.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Passenger/Features/GetPassengerByIdTests.cs deleted file mode 100644 index f2c35ee..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Passenger/Features/GetPassengerByIdTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Threading.Tasks; -using Api; -using BuildingBlocks.TestBase; -using FluentAssertions; -using Integration.Test.Fakes; -using Passenger; -using Passenger.Data; -using Xunit; - -namespace Integration.Test.Passenger.Features; - -using global::Passenger.Passengers.Features.GettingPassengerById.V1; - -public class GetPassengerByIdTests : PassengerIntegrationTestBase -{ - public GetPassengerByIdTests( - TestFixture integrationTestFactory) : base(integrationTestFactory) - { - } - - [Fact] - public async Task should_retrive_a_passenger_by_id_currectly() - { - // Arrange - var command = new FakeCompleteRegisterPassengerMongoCommand().Generate(); - - await Fixture.SendAsync(command); - - var query = new GetPassengerById(command.Id); - - // Act - var response = await Fixture.SendAsync(query); - - // Assert - response.Should().NotBeNull(); - response?.PassengerDto?.Id.Should().Be(command.Id); - } - - [Fact] - public async Task should_retrive_a_passenger_by_id_from_grpc_service() - { - // Arrange - var command = new FakeCompleteRegisterPassengerMongoCommand().Generate(); - - await Fixture.SendAsync(command); - - var passengerGrpcClient = new PassengerGrpcService.PassengerGrpcServiceClient(Fixture.Channel); - - // Act - var response = await passengerGrpcClient.GetByIdAsync(new GetByIdRequest { Id = command.Id.ToString() }); - - // Assert - response?.Should().NotBeNull(); - response?.PassengerDto?.Id.Should().Be(command.Id.ToString()); - } -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/PassengerIntegrationTestBase.cs b/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/PassengerIntegrationTestBase.cs deleted file mode 100644 index a67a2fa..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/PassengerIntegrationTestBase.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Api; -using BuildingBlocks.TestBase; -using Passenger.Data; -using Xunit; - -namespace Integration.Test; - -[Collection(IntegrationTestCollection.Name)] -public class PassengerIntegrationTestBase : TestBase -{ - public PassengerIntegrationTestBase(TestFixture integrationTestFactory) - : base(integrationTestFactory) - { - } -} - -[CollectionDefinition(Name)] -public class IntegrationTestCollection : ICollectionFixture> -{ - public const string Name = "Passenger Integration Test"; -} diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/tests.sln b/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/tests.sln deleted file mode 100644 index 05ce8b7..0000000 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/tests.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.14.35906.104 d17.14 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "Integration.Test\Integration.Test.csproj", "{A0D4B2AE-53E4-454D-A1CB-E51168D016F3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A0D4B2AE-53E4-454D-A1CB-E51168D016F3}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF30A2EF-A06D-4A7E-B99B-304221C5FC0C} - EndGlobalSection -EndGlobal diff --git a/3-microservices-architecture-style/README.md b/3-microservices-architecture-style/README.md deleted file mode 100644 index 90cdab9..0000000 --- a/3-microservices-architecture-style/README.md +++ /dev/null @@ -1,143 +0,0 @@ -# 🪁 Microservices Architecture Style - -> In **Microservices Architecture**, the application is broken down into small, independent services, each responsible for a specific business capability. Each service can be developed, deployed, and scaled independently. - -# Table of Contents - -- [Key Features](#key-features) -- [When to Use](#when-to-use) -- [Challenges](#challenges) -- [Microservices Architecture Design](#microservices-architecture-design) -- [Development Setup](#development-setup) - - [Dotnet Tools Packages](#dotnet-tools-packages) - - [Husky](#husky) - - [Upgrade Nuget Packages](#upgrade-nuget-packages) -- [How to Run](#how-to-run) - - [Config Certificate](#config-certificate) - - [Docker Compose](#docker-compose) - - [Kubernetes](#kubernetes) - - [Build](#build) - - [Run](#run) - - [Test](#test) -- [Documentation Apis](#documentation-apis) - - -## Key Features -1. **Independent Services**: Each service is a separate project with its own database and deployment pipeline, enabling independent development and deployment. -2. **Decentralized Communication**: Services communicate via APIs (REST, gRPC) or message brokers (RabbitMQ, Kafka), ensuring loose coupling and resilience. -3. **Scalability**: Services can be scaled independently based on demand, allowing efficient resource utilization. -4. **Fault Tolerance**: Failures are isolated, preventing cascading failures and ensuring high availability. -5. **Technology Agnostic**: Services can use different technologies, frameworks, or databases, providing flexibility. - - -## When to Use -1. **Large and Complex Projects**: Ideal for applications with complex business logic that can be broken into smaller, manageable services. -2. **High Scalability Needs**: Suitable for applications requiring independent scaling of components. -3. **Fault Tolerance and High Availability**: Perfect for systems where failure isolation and uptime are critical. -4. **Distributed Teams**: Enables teams to work independently on different services. -5. **Frequent Updates**: Supports continuous deployment and A/B testing for individual services. -6. **Technology Diversity**: Allows the use of different technologies for different services. - - -## Challenges -- Increased complexity in management, DevOps overhead, data consistency, latency, and higher costs. - - -## Microservices Architecture Design - -![](./assets/booking-microservices.png) - - -## Development Setup - -### Dotnet Tools Packages -For installing our requirement packages with .NET cli tools, we need to install `dotnet tool manifest`. -```bash -dotnet new tool-manifest -``` -And after that we can restore our dotnet tools packages with .NET cli tools from `.config` folder and `dotnet-tools.json` file. -``` -dotnet tool restore -``` - -### Husky -Here we use `husky` to handel some pre commit rules and we used `conventional commits` rules and `formatting` as pre commit rules, here in [package.json](.././package.json). of course, we can add more rules for pre commit in future. (find more about husky in the [documentation](https://typicode.github.io/husky/get-started.html)) -We need to install `husky` package for `manage` `pre commits hooks` and also I add two packages `@commitlint/cli` and `@commitlint/config-conventional` for handling conventional commits rules in [package.json](.././package.json). -Run the command bellow in the root of project to install all npm dependencies related to husky: - -```bash -npm install -``` - -> Note: In the root of project we have `.husky` folder and it has `commit-msg` file for handling conventional commits rules with provide user friendly message and `pre-commit` file that we can run our `scripts` as a `pre-commit` hooks. that here we call `format` script from [package.json](./package.json) for formatting purpose. - -### Upgrade Nuget Packages -For upgrading our nuget packages to last version, we use the great package [dotnet-outdated](https://github.com/dotnet-outdated/dotnet-outdated). -Run the command below in the root of project to upgrade all of packages to last version: -```bash -dotnet outdated -u -``` - -## How to Run - -> ### Config Certificate -Run the following commands to [Config SSL](https://docs.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-6.0) in your system: - -#### Windows using Linux containers -```bash -dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p password -dotnet dev-certs https --trust -``` -***Note:** for running this command in `powershell` use `$env:USERPROFILE` instead of `%USERPROFILE%`* - -#### macOS or Linux -```bash -dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p $CREDENTIAL_PLACEHOLDER$ -dotnet dev-certs https --trust -``` -> ### Docker Compose - - -To run this app in `Docker`, use the [docker-compose.yaml](./deployments/docker-compose/docker-compose.yaml) and execute the below command at the `root` of the application: - -```bash -docker-compose -f ./deployments/docker-compose/docker-compose.yaml up -d -``` - -> ### Kubernetes -To `configure TLS` in the `Kubernetes cluster`, we need to install `cert-manager` based on the [docs](https://cert-manager.io/docs/installation) and run the following commands to apply TLS in our application. Here, we use [Let's Encrypt](https://letsencrypt.org/) to encrypt our certificate. - -```bash -kubectl apply -f ./deployments/kubernetes/booking-cert-manager.yml -``` - -To apply all necessary `deployments`, `pods`, `services`, `ingress`, and `config maps`, please run the following command: - -```bash -kubectl apply -f ./deployments/kubernetes/booking-microservices.yml -``` - -> ### Build -To `build` all microservices, run this command in the `root` of the project: -```bash -dotnet build -``` - -> ### Run -To `run` each microservice, run this command in the root of the `Api` folder of each microservice where the `csproj` file is located: -```bash -dotnet run -``` - -> ### Test - -To `test` all microservices, run this command in the `root` of the project: -```bash -dotnet test -``` - -> ### Documentation Apis - -Each microservice provides `API documentation` and navigate to `/swagger` for `Swagger OpenAPI` or `/scalar/v1` for `Scalar OpenAPI` to visit list of endpoints. - -As part of API testing, I created the [booking.rest](./booking.rest) file which can be run with the [REST Client](https://github.com/Huachao/vscode-restclient) `VSCode plugin`. diff --git a/3-microservices-architecture-style/deployments/configs/dashboards.md b/3-microservices-architecture-style/deployments/configs/dashboards.md deleted file mode 100644 index 999b1d8..0000000 --- a/3-microservices-architecture-style/deployments/configs/dashboards.md +++ /dev/null @@ -1,8 +0,0 @@ -# Dashboards - -- [Introducing ASP.NET Core metrics and Grafana dashboards in .NET 8](https://devblogs.microsoft.com/dotnet/introducing-aspnetcore-metrics-and-grafana-dashboards-in-dotnet-8/) -- [ASP.NET Core](https://grafana.com/grafana/dashboards/19924-asp-net-core/) -- [ASP.NET Core Endpoint](https://grafana.com/grafana/dashboards/19925-asp-net-core-endpoint/) -- [Node Exporter Quickstart and Dashboard](https://grafana.com/grafana/dashboards/13978-node-exporter-quickstart-and-dashboard/) -- [PostgreSQL Exporter Quickstart and Dashboard](https://grafana.com/grafana/dashboards/14114-postgres-overview/) -- [RabbitMQ-Overview](https://grafana.com/grafana/dashboards/10991-rabbitmq-overview/) \ No newline at end of file diff --git a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json b/3-microservices-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json deleted file mode 100644 index 9859cc9..0000000 --- a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json +++ /dev/null @@ -1,908 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY", - "label": "Managed_Prometheus_jamesnk-telemetry", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": {}, - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "9.4.8" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": { - "type": "grafana", - "uid": "-- Grafana --" - }, - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 0, - "id": null, - "links": [ - { - "asDropdown": false, - "icon": "dashboard", - "includeVars": false, - "keepTime": true, - "tags": [], - "targetBlank": false, - "title": " ASP.NET Core", - "tooltip": "", - "type": "link", - "url": "/d/KdDACDp4z/asp-net-core-metrics" - } - ], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "dark-green", - "mode": "continuous-GrYlRd", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "axisSoftMin": 0, - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "s" - }, - "overrides": [ - { - "__systemRef": "hideSeriesFrom", - "matcher": { - "id": "byNames", - "options": { - "mode": "exclude", - "names": [ - "p50" - ], - "prefix": "All except:", - "readOnly": true - } - }, - "properties": [ - { - "id": "custom.hideFrom", - "value": { - "legend": false, - "tooltip": false, - "viz": false - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 0, - "y": 0 - }, - "id": 40, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.50, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "legendFormat": "p50", - "range": true, - "refId": "p50" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.75, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p75", - "range": true, - "refId": "p75" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.90, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p90", - "range": true, - "refId": "p90" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.95, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p95", - "range": true, - "refId": "p95" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.98, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p98", - "range": true, - "refId": "p98" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.99, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p99", - "range": true, - "refId": "p99" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "histogram_quantile(0.999, sum(rate(http_server_request_duration_s_bucket{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m])) by (le))", - "hide": false, - "legendFormat": "p99.9", - "range": true, - "refId": "p99.9" - } - ], - "title": "Requests Duration - $method $route", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic", - "seriesBy": "max" - }, - "custom": { - "axisCenteredZero": false, - "axisColorMode": "text", - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 50, - "gradientMode": "opacity", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "smooth", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - } - ] - }, - "unit": "percentunit" - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "All" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-orange", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "4XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "yellow", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "5XX" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "dark-red", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 9, - "w": 12, - "x": 12, - "y": 0 - }, - "id": 46, - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "min", - "max" - ], - "displayMode": "table", - "placement": "right", - "showLegend": true - }, - "tooltip": { - "mode": "multi", - "sort": "none" - } - }, - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\", status_code=~\"4..|5..\"}[5m]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m]))", - "legendFormat": "All", - "range": true, - "refId": "All" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\", status_code=~\"4..\"}[5m]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m]))", - "hide": false, - "legendFormat": "4XX", - "range": true, - "refId": "4XX" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\", status_code=~\"5..\"}[5m]) or vector(0)) / sum(rate(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[5m]))", - "hide": false, - "legendFormat": "5XX", - "range": true, - "refId": "5XX" - } - ], - "title": "Errors Rate - $method $route", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "cellOptions": { - "type": "auto" - }, - "inspect": false - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "Requests" - }, - "properties": [ - { - "id": "custom.width", - "value": 300 - }, - { - "id": "custom.cellOptions", - "value": { - "mode": "gradient", - "type": "gauge" - } - }, - { - "id": "color", - "value": { - "mode": "continuous-YlRd" - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Route" - }, - "properties": [ - { - "id": "links", - "value": [ - { - "title": "", - "url": "/d/NagEsjE4z/asp-net-core-endpoint-details?var-route=${__data.fields.Route}&var-method=${__data.fields.Method}&${__url_time_range}" - } - ] - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 9 - }, - "hideTimeOverride": false, - "id": 44, - "options": { - "footer": { - "countRows": false, - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true, - "sortBy": [ - { - "desc": true, - "displayName": "Value" - } - ] - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "exemplar": false, - "expr": "sum by (exception_name) (\r\n max_over_time(http_server_request_duration_s_count{route=\"$route\", method=\"$method\", exception_name!=\"\"}[$__rate_interval])\r\n)", - "format": "table", - "instant": true, - "interval": "", - "legendFormat": "{{route}}", - "range": false, - "refId": "A" - } - ], - "title": "Unhandled Exceptions", - "transformations": [ - { - "id": "organize", - "options": { - "excludeByName": { - "Time": true, - "method": false - }, - "indexByName": { - "Time": 0, - "Value": 2, - "exception_name": 1 - }, - "renameByName": { - "Value": "Requests", - "exception_name": "Exception", - "method": "Method", - "route": "Route" - } - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "blue", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 12, - "x": 12, - "y": 9 - }, - "id": 42, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (status_code) (\r\n max_over_time(http_server_request_duration_s_count{route=\"$route\", method=\"$method\"}[$__rate_interval])\r\n )", - "legendFormat": "Status {{status_code}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests HTTP Status Code", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "green", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 12, - "y": 13 - }, - "id": 48, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (scheme) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[$__rate_interval])\r\n )", - "legendFormat": "{{scheme}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests Secured", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "fixedColor": "purple", - "mode": "fixed" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [] - }, - "gridPos": { - "h": 4, - "w": 6, - "x": 18, - "y": 13 - }, - "id": 50, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "auto", - "reduceOptions": { - "calcs": [ - "max" - ], - "fields": "", - "values": false - }, - "textMode": "value_and_name" - }, - "pluginVersion": "9.4.8", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "editorMode": "code", - "expr": "sum by (protocol) (\r\n max_over_time(http_server_request_duration_s_count{job=\"$job\", instance=\"$instance\", route=\"$route\", method=\"$method\"}[$__rate_interval])\r\n )", - "legendFormat": "{{protocol}}", - "range": true, - "refId": "A" - } - ], - "title": "Requests HTTP Protocol", - "type": "stat" - } - ], - "refresh": "", - "revision": 1, - "schemaVersion": 38, - "style": "dark", - "tags": [ - "dotnet", - "prometheus", - "aspnetcore" - ], - "templating": { - "list": [ - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests, job)", - "hide": 0, - "includeAll": false, - "label": "Job", - "multi": false, - "name": "job", - "options": [], - "query": { - "query": "label_values(http_server_current_requests, job)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "hide": 0, - "includeAll": false, - "label": "Instance", - "multi": false, - "name": "instance", - "options": [], - "query": { - "query": "label_values(http_server_current_requests{job=~\"$job\"}, instance)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_request_duration_s_count, route)", - "description": "Route", - "hide": 0, - "includeAll": false, - "label": "Route", - "multi": false, - "name": "route", - "options": [], - "query": { - "query": "label_values(http_server_request_duration_s_count, route)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_MANAGED_PROMETHEUS_JAMESNK-TELEMETRY}" - }, - "definition": "label_values(http_server_request_duration_s_count{route=~\"$route\"}, method)", - "hide": 0, - "includeAll": false, - "label": "Method", - "multi": false, - "name": "method", - "options": [], - "query": { - "query": "label_values(http_server_request_duration_s_count{route=~\"$route\"}, method)", - "refId": "StandardVariableQuery" - }, - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "type": "query" - } - ] - }, - "time": { - "from": "now-30m", - "to": "now" - }, - "timepicker": {}, - "timezone": "", - "title": "ASP.NET Core Endpoint", - "uid": "NagEsjE4z", - "version": 10, - "weekStart": "" -} \ No newline at end of file diff --git a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json b/3-microservices-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json deleted file mode 100644 index 4839d46..0000000 --- a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json +++ /dev/null @@ -1,892 +0,0 @@ -{ - "__inputs": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "7.4.3" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - } - ], - "annotations": { - "list": [] - }, - "editable": false, - "gnetId": 13978, - "graphTooltip": 0, - "hideControls": false, - "id": null, - "links": [], - "refresh": "", - "rows": [ - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 1, - "fillGradient": 0, - "gridPos": {}, - "id": 2, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "(\n (1 - rate(node_cpu_seconds_total{job=\"node\", mode=\"idle\", instance=\"$instance\"}[$__interval]))\n/ ignoring(cpu) group_left\n count without (cpu)( node_cpu_seconds_total{job=\"node\", mode=\"idle\", instance=\"$instance\"})\n)\n", - "format": "time_series", - "interval": "1m", - "intervalFactor": 5, - "legendFormat": "{{cpu}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "CPU Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "percentunit", - "label": null, - "logBase": 1, - "max": 1, - "min": 0, - "show": true - }, - { - "format": "percentunit", - "label": null, - "logBase": 1, - "max": 1, - "min": 0, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 3, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "node_load1{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "1m load average", - "refId": "A" - }, - { - "expr": "node_load5{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "5m load average", - "refId": "B" - }, - { - "expr": "node_load15{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "15m load average", - "refId": "C" - }, - { - "expr": "count(node_cpu_seconds_total{job=\"node\", instance=\"$instance\", mode=\"idle\"})", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "logical cores", - "refId": "D" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Load Average", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - }, - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 1, - "fillGradient": 0, - "gridPos": {}, - "id": 4, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 9, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "(\n node_memory_MemTotal_bytes{job=\"node\", instance=\"$instance\"}\n-\n node_memory_MemFree_bytes{job=\"node\", instance=\"$instance\"}\n-\n node_memory_Buffers_bytes{job=\"node\", instance=\"$instance\"}\n-\n node_memory_Cached_bytes{job=\"node\", instance=\"$instance\"}\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory used", - "refId": "A" - }, - { - "expr": "node_memory_Buffers_bytes{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory buffers", - "refId": "B" - }, - { - "expr": "node_memory_Cached_bytes{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory cached", - "refId": "C" - }, - { - "expr": "node_memory_MemFree_bytes{job=\"node\", instance=\"$instance\"}", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "memory free", - "refId": "D" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Memory Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "rgba(50, 172, 45, 0.97)", - "rgba(237, 129, 40, 0.89)", - "rgba(245, 54, 54, 0.9)" - ], - "datasource": "$datasource", - "format": "percent", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": true, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": {}, - "id": 5, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "span": 3, - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": false - }, - "tableColumn": "", - "targets": [ - { - "expr": "100 -\n(\n avg(node_memory_MemAvailable_bytes{job=\"node\", instance=\"$instance\"})\n/\n avg(node_memory_MemTotal_bytes{job=\"node\", instance=\"$instance\"})\n* 100\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "", - "refId": "A" - } - ], - "thresholds": "80, 90", - "title": "Memory Usage", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "current" - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - }, - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 6, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [ - { - "alias": "/ read| written/", - "yaxis": 1 - }, - { - "alias": "/ io time/", - "yaxis": 2 - } - ], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_disk_read_bytes_total{job=\"node\", instance=\"$instance\", device!=\"\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}} read", - "refId": "A" - }, - { - "expr": "rate(node_disk_written_bytes_total{job=\"node\", instance=\"$instance\", device!=\"\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}} written", - "refId": "B" - }, - { - "expr": "rate(node_disk_io_time_seconds_total{job=\"node\", instance=\"$instance\", device!=\"\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}} io time", - "refId": "C" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk I/O", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "s", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 1, - "fillGradient": 0, - "gridPos": {}, - "id": 7, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [ - { - "alias": "used", - "color": "#E0B400" - }, - { - "alias": "available", - "color": "#73BF69" - } - ], - "spaceLength": 10, - "span": 6, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "sum(\n max by (device) (\n node_filesystem_size_bytes{job=\"node\", instance=\"$instance\", fstype!=\"\"}\n -\n node_filesystem_avail_bytes{job=\"node\", instance=\"$instance\", fstype!=\"\"}\n )\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "used", - "refId": "A" - }, - { - "expr": "sum(\n max by (device) (\n node_filesystem_avail_bytes{job=\"node\", instance=\"$instance\", fstype!=\"\"}\n )\n)\n", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "available", - "refId": "B" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Disk Space Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - }, - { - "collapse": false, - "collapsed": false, - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 8, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_network_receive_bytes_total{job=\"node\", instance=\"$instance\", device!=\"lo\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Network Received", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "$datasource", - "fill": 0, - "fillGradient": 0, - "gridPos": {}, - "id": 9, - "legend": { - "alignAsTable": false, - "avg": false, - "current": false, - "max": false, - "min": false, - "rightSide": false, - "show": true, - "sideWidth": null, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "repeat": null, - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "rate(node_network_transmit_bytes_total{job=\"node\", instance=\"$instance\", device!=\"lo\"}[$__interval])", - "format": "time_series", - "interval": "1m", - "intervalFactor": 2, - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Network Transmitted", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - }, - { - "format": "bytes", - "label": null, - "logBase": 1, - "max": null, - "min": 0, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6", - "type": "row" - } - ], - "schemaVersion": 14, - "style": "dark", - "tags": [], - "templating": { - "list": [ - { - "current": { - "text": "Prometheus", - "value": "Prometheus" - }, - "hide": 0, - "label": null, - "name": "datasource", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "type": "datasource" - }, - { - "allValue": null, - "current": {}, - "datasource": "$datasource", - "hide": 0, - "includeAll": false, - "label": null, - "multi": false, - "name": "instance", - "options": [], - "query": "label_values(node_exporter_build_info{job=\"node\"}, instance)", - "refresh": 2, - "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-1h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "browser", - "title": "Node Exporter Quickstart and Dashboard", - "version": 0, - "description": "A quickstart to setup Prometheus Node Exporter with preconfigured dashboards, alerting rules, and recording rules." -} \ No newline at end of file diff --git a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json b/3-microservices-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json deleted file mode 100644 index b199b4b..0000000 --- a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json +++ /dev/null @@ -1,8209 +0,0 @@ -{ - "__inputs": [ - { - "name": "DS_PROMETHEUS", - "label": "prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__elements": [], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "8.3.4" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - }, - { - "type": "panel", - "id": "stat", - "name": "Stat", - "version": "" - }, - { - "type": "panel", - "id": "table", - "name": "Table", - "version": "" - }, - { - "type": "panel", - "id": "timeseries", - "name": "Time series", - "version": "" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "target": { - "limit": 100, - "matchAny": false, - "tags": [], - "type": "dashboard" - }, - "type": "dashboard" - } - ] - }, - "description": "A new RabbitMQ Management Overview", - "editable": true, - "fiscalYearStartMonth": 0, - "graphTooltip": 1, - "id": null, - "iteration": 1659711638455, - "links": [ - { - "icon": "doc", - "tags": [], - "targetBlank": true, - "title": "Monitoring with Prometheus & Grafana", - "tooltip": "", - "type": "link", - "url": "https://www.rabbitmq.com/prometheus.html" - } - ], - "liveNow": false, - "panels": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#37872D", - "value": null - }, - { - "color": "#1F60C4", - "value": 10000 - }, - { - "color": "#C4162A", - "value": 100000 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "id": 64, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_ready * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "hide": false, - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Ready messages", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": -1 - }, - { - "color": "#37872D", - "value": 50 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 6, - "y": 0 - }, - "id": 62, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_received_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Incoming messages / s", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 12, - "y": 0 - }, - "id": 66, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_global_publishers * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Publishers", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 16, - "y": 0 - }, - "id": 37, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_connections * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Connections", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 0 - }, - "id": 40, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queues * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Queues", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#37872D", - "value": null - }, - { - "color": "#1F60C4", - "value": 100 - }, - { - "color": "#C4162A", - "value": 500 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 0, - "y": 3 - }, - "id": 65, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_unacked * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "hide": false, - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Unacknowledged messages", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": -1 - }, - { - "color": "#37872D", - "value": 50 - } - ] - }, - "unit": "short" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 6, - "x": 6, - "y": 3 - }, - "id": 63, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_redelivered_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_consume_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_consume_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_get_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\nsum(rate(rabbitmq_global_messages_delivered_get_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "hide": false, - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Outgoing messages / s", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 12, - "y": 3 - }, - "id": 41, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_consumers * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Consumers", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#C4162A", - "value": null - }, - { - "color": "#1F60C4", - "value": 0 - }, - { - "color": "#37872D", - "value": 10 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 16, - "y": 3 - }, - "id": 38, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_channels * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Channels", - "type": "stat" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "", - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "mappings": [ - { - "options": { - "match": "null", - "result": { - "text": "N/A" - } - }, - "type": "special" - } - ], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "#1F60C4", - "value": null - }, - { - "color": "#37872D", - "value": 3 - }, - { - "color": "#C4162A", - "value": 8 - } - ] - }, - "unit": "none" - }, - "overrides": [] - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 3 - }, - "id": 67, - "links": [], - "maxDataPoints": 100, - "options": { - "colorMode": "background", - "graphMode": "area", - "justifyMode": "auto", - "orientation": "horizontal", - "reduceOptions": { - "calcs": [ - "lastNotNull" - ], - "fields": "", - "values": false - }, - "textMode": "auto" - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_build_info * on(instance, job) group_left(rabbitmq_cluster) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "title": "Nodes", - "type": "stat" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 6 - }, - "id": 4, - "panels": [], - "title": "NODES", - "type": "row" - }, - { - "fieldConfig": { - "defaults": { - "color": { - "mode": "thresholds" - }, - "custom": { - "align": "auto", - "displayMode": "auto" - }, - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - } - }, - "overrides": [ - { - "matcher": { - "id": "byName", - "options": "erlang_version" - }, - "properties": [ - { - "id": "displayName", - "value": "Erlang/OTP" - }, - { - "id": "unit", - "value": "none" - }, - { - "id": "custom.align" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(50, 172, 45, 0.97)", - "value": null - }, - { - "color": "rgba(237, 129, 40, 0.89)" - } - ] - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "rabbitmq_version" - }, - "properties": [ - { - "id": "displayName", - "value": "RabbitMQ" - }, - { - "id": "unit", - "value": "none" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(245, 54, 54, 0.9)", - "value": null - }, - { - "color": "rgba(237, 129, 40, 0.89)" - } - ] - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "instance" - }, - "properties": [ - { - "id": "displayName", - "value": "Host" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "rabbitmq_node" - }, - "properties": [ - { - "id": "displayName", - "value": "Node name" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - }, - { - "id": "thresholds", - "value": { - "mode": "absolute", - "steps": [ - { - "color": "rgba(245, 54, 54, 0.9)", - "value": null - }, - { - "color": "rgba(237, 129, 40, 0.89)" - } - ] - } - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Time" - }, - "properties": [ - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "Value" - }, - "properties": [ - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "job" - }, - "properties": [ - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "rabbitmq_cluster" - }, - "properties": [ - { - "id": "displayName", - "value": "Cluster" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "prometheus_client_version" - }, - "properties": [ - { - "id": "displayName", - "value": "prometheus.erl" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - }, - { - "matcher": { - "id": "byName", - "options": "prometheus_plugin_version" - }, - "properties": [ - { - "id": "displayName", - "value": "rabbitmq_prometheus" - }, - { - "id": "unit", - "value": "short" - }, - { - "id": "decimals", - "value": 2 - }, - { - "id": "custom.align" - } - ] - } - ] - }, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 7 - }, - "id": 69, - "links": [], - "options": { - "footer": { - "fields": "", - "reducer": [ - "sum" - ], - "show": false - }, - "showHeader": true - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "exemplar": false, - "expr": "rabbitmq_build_info * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "table", - "instant": true, - "interval": "", - "intervalFactor": 1, - "legendFormat": "", - "refId": "A" - } - ], - "transformations": [ - { - "id": "merge", - "options": { - "reducers": [] - } - } - ], - "type": "table" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "If the value is zero or less, the memory alarm will be triggered and all publishing connections across all cluster nodes will be blocked.\n\nThis value can temporarily go negative because the memory alarm is triggered with a slight delay.\n\nThe kernel's view of the amount of memory used by the node can differ from what the node itself can observe. This means that this value can be negative for a sustained period of time.\n\nBy default nodes use resident set size (RSS) to compute how much memory they use. This strategy can be changed (see the guides below).\n\n* [Alarms](https://www.rabbitmq.com/alarms.html)\n* [Memory Alarms](https://www.rabbitmq.com/memory.html)\n* [Reasoning About Memory Use](https://www.rabbitmq.com/memory-use.html)\n* [Blocked Connection Notifications](https://www.rabbitmq.com/connection-blocked.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "decimals": 1, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 0 - }, - { - "color": "transparent", - "value": 536870912 - } - ] - }, - "unit": "bytes" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 11 - }, - "id": 7, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "(rabbitmq_resident_memory_limit_bytes * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) -\n(rabbitmq_process_resident_memory_bytes * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Memory available before publishers blocked", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "This metric is reported for the partition where the RabbitMQ data directory is stored.\n\nIf the value is zero or less, the disk alarm will be triggered and all publishing connections across all cluster nodes will be blocked.\n\nThis value can temporarily go negative because the free disk space alarm is triggered with a slight delay.\n\n* [Alarms](https://www.rabbitmq.com/alarms.html)\n* [Disk Space Alarms](https://www.rabbitmq.com/disk-alarms.html)\n* [Disk Space](https://www.rabbitmq.com/production-checklist.html#resource-limits-disk-space)\n* [Persistence Configuration](https://www.rabbitmq.com/persistence-conf.html)\n* [Blocked Connection Notifications](https://www.rabbitmq.com/connection-blocked.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "decimals": 1, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 1073741824 - }, - { - "color": "transparent", - "value": 5368709120 - } - ] - }, - "unit": "bytes" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 8, - "w": 8, - "x": 12, - "y": 11 - }, - "id": 8, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_disk_space_available_bytes * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Disk space available before publishers blocked", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "When this value reaches zero, new connections will not be accepted and disk write operations may fail.\n\nClient libraries, peer nodes and CLI tools will not be able to connect when the node runs out of available file descriptors.\n\n* [Open File Handles Limit](https://www.rabbitmq.com/production-checklist.html#resource-limits-file-handle-limit)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 500 - }, - { - "color": "transparent", - "value": 1000 - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 4, - "w": 4, - "x": 20, - "y": 11 - }, - "id": 2, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "(rabbitmq_process_max_fds * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) -\n(rabbitmq_process_open_fds * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "File descriptors available", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "When this value reaches zero, new connections will not be accepted.\n\nClient libraries, peer nodes and CLI tools will not be able to connect when the node runs out of available file descriptors.\n\n* [Networking and RabbitMQ](https://www.rabbitmq.com/networking.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 0, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "none" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "red", - "value": null - }, - { - "color": "orange", - "value": 500 - }, - { - "color": "transparent", - "value": 1000 - } - ] - }, - "unit": "none" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 4, - "w": 4, - "x": 20, - "y": 15 - }, - "id": 5, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "(rabbitmq_process_max_tcp_sockets * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) -\n(rabbitmq_process_open_tcp_sockets * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "TCP sockets available", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 19 - }, - "id": 27, - "panels": [], - "title": "QUEUED MESSAGES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of ready messages ready to be delivered to consumers.\n\nAim to keep this value as low as possible. RabbitMQ behaves best when messages are flowing through it. It's OK for publishers to occasionally outpace consumers, but the expectation is that consumers will eventually process all ready messages.\n\nIf this metric keeps increasing, your system will eventually run out of memory and/or disk space. Consider using TTL or Queue Length Limit to prevent unbounded message growth.\n\n* [Queues](https://www.rabbitmq.com/queues.html)\n* [Consumers](https://www.rabbitmq.com/consumers.html)\n* [Queue Length Limit](https://www.rabbitmq.com/maxlength.html)\n* [Time-To-Live and Expiration](https://www.rabbitmq.com/ttl.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 20 - }, - "id": 9, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_ready * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages ready to be delivered to consumers", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The total number of messages that are either in-flight to consumers, currently being processed by consumers or simply waiting for the consumer acknowledgements to be processed by the queue. Until the queue processes the message acknowledgement, the message will remain unacknowledged.\n\n* [Queues](https://www.rabbitmq.com/queues.html)\n* [Confirms and Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [Consumer Prefetch](https://www.rabbitmq.com/consumer-prefetch.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 20 - }, - "id": 19, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rabbitmq_queue_messages_unacked * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages pending consumer acknowledgement", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 25 - }, - "id": 11, - "panels": [], - "title": "INCOMING MESSAGES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The incoming message rate before any routing rules are applied.\n\nIf this value is lower than the number of messages published to queues, it may indicate that some messages are delivered to more than one queue.\n\nIf this value is higher than the number of messages published to queues, messages cannot be routed and will either be dropped or returned to publishers.\n\n* [Publishers](https://www.rabbitmq.com/publishers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 26 - }, - "id": 13, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_received_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages published / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages confirmed by the broker to publishers. Publishers must opt-in to receive message confirmations.\n\nIf this metric is consistently at zero it may suggest that publisher confirms are not used by clients. The safety of published messages is likely to be at risk.\n\n* [Publisher Confirms](https://www.rabbitmq.com/confirms.html#publisher-confirms)\n* [Publisher Confirms and Data Safety](https://www.rabbitmq.com/publishers.html#data-safety)\n* [When Will Published Messages Be Confirmed by the Broker?](https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 26 - }, - "id": 18, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_confirmed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages confirmed to publishers / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages received from publishers and successfully routed to the master queue replicas.\n\n* [Queues](https://www.rabbitmq.com/queues.html)\n* [Publishers](https://www.rabbitmq.com/publishers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 31 - }, - "id": 61, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_routed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages routed to queues / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages received from publishers that have publisher confirms enabled and the broker has not confirmed yet.\n\n* [Publishers](https://www.rabbitmq.com/publishers.html)\n* [Confirms and Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [When Will Published Messages Be Confirmed by the Broker?](https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": true, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 31 - }, - "id": 12, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_received_confirm_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"} - \nrate(rabbitmq_global_messages_confirmed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}\n) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages unconfirmed to publishers / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages that cannot be routed and are dropped. \n\nAny value above zero means message loss and likely suggests a routing problem on the publisher end.\n\n* [Unroutable Message Handling](https://www.rabbitmq.com/publishers.html#unroutable)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 36 - }, - "id": 34, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_unroutable_dropped_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Unroutable messages dropped / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages that cannot be routed and are returned back to publishers.\n\nSustained values above zero may indicate a routing problem on the publisher end.\n\n* [Unroutable Message Handling](https://www.rabbitmq.com/publishers.html#unroutable)\n* [When Will Published Messages Be Confirmed by the Broker?](https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 36 - }, - "id": 16, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_unroutable_returned_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Unroutable messages returned to publishers / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 41 - }, - "id": 29, - "panels": [], - "title": "OUTGOING MESSAGES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages delivered to consumers. It includes messages that have been redelivered.\n\nThis metric does not include messages that have been fetched by consumers using `basic.get` (consumed by polling).\n\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 42 - }, - "id": 14, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(\n (rate(rabbitmq_global_messages_delivered_consume_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) +\n (rate(rabbitmq_global_messages_delivered_consume_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"})\n) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages delivered / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages that have been redelivered to consumers. It includes messages that have been requeued automatically and redelivered due to channel exceptions or connection closures.\n\nHaving some redeliveries is expected, but if this metric is consistently non-zero, it is worth investigating why.\n\n* [Negative Acknowledgement and Requeuing of Deliveries](https://www.rabbitmq.com/confirms.html#consumer-nacks-requeue)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 20 - }, - { - "color": "red", - "value": 100 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 42 - }, - "id": 15, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_redelivered_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages redelivered / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of message deliveries to consumers that use manual acknowledgement mode.\n\nWhen this mode is used, RabbitMQ waits for consumers to acknowledge messages before more messages can be delivered.\n\nThis is the safest way of consuming messages.\n\n* [Consumer Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [Consumer Prefetch](https://www.rabbitmq.com/consumer-prefetch.html)\n* [Consumer Acknowledgement Modes, Prefetch and Throughput](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 47 - }, - "id": 20, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_consume_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages delivered with manual ack / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of message deliveries to consumers that use automatic acknowledgement mode.\n\nWhen this mode is used, RabbitMQ does not wait for consumers to acknowledge message deliveries.\n\nThis mode is fire-and-forget and does not offer any delivery safety guarantees. It tends to provide higher throughput and it may lead to consumer overload and higher consumer memory usage.\n\n* [Consumer Acknowledgement Modes, Prefetch and Throughput](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 47 - }, - "id": 21, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_consume_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages delivered auto ack / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of message acknowledgements coming from consumers that use manual acknowledgement mode.\n\n* [Consumer Acknowledgements](https://www.rabbitmq.com/confirms.html)\n* [Consumer Prefetch](https://www.rabbitmq.com/consumer-prefetch.html)\n* [Consumer Acknowledgement Modes, Prefetch and Throughput](https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "decimals": 0, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 52 - }, - "id": 22, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_acknowledged_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Messages acknowledged / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages delivered to polling consumers that use automatic acknowledgement mode.\n\nThe use of polling consumers is highly inefficient and therefore strongly discouraged.\n\n* [Fetching individual messages](https://www.rabbitmq.com/consumers.html#fetching)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 52 - }, - "id": 24, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_get_auto_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Polling operations with auto ack / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of polling consumer operations that yield no result.\n\nAny value above zero means that RabbitMQ resources are wasted by polling consumers.\n\nCompare this metric to the other polling consumer metrics to see the inefficiency rate.\n\nThe use of polling consumers is highly inefficient and therefore strongly discouraged.\n\n* [Fetching individual messages](https://www.rabbitmq.com/consumers.html#fetching)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 57 - }, - "id": 25, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_get_empty_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Polling operations that yield no result / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of messages delivered to polling consumers that use manual acknowledgement mode.\n\nThe use of polling consumers is highly inefficient and therefore strongly discouraged.\n\n* [Fetching individual messages](https://www.rabbitmq.com/consumers.html#fetching)\n* [Consumers](https://www.rabbitmq.com/consumers.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "red", - "value": 0 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/rabbit/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#C4162A", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 12, - "y": 57 - }, - "id": 23, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_global_messages_delivered_get_manual_ack_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Polling operations with manual ack / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 62 - }, - "id": 53, - "panels": [], - "title": "QUEUES", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of queue masters per node. \n\nThis metric makes it easy to see sub-optimal queue distribution in a cluster.\n\n* [Queue Masters, Data Locality](https://www.rabbitmq.com/ha.html#master-migration-data-locality)\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 63 - }, - "id": 57, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_queues * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Total queues", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of queue declarations performed by clients.\n\nLow sustained values above zero are to be expected. High rates may be indicative of queue churn or high rates of connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 4, - "x": 12, - "y": 63 - }, - "id": 58, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_queues_declared_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Queues declared / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of new queues created (as opposed to redeclarations).\n\nLow sustained values above zero are to be expected. High rates may be indicative of queue churn or high rates of connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 4, - "x": 16, - "y": 63 - }, - "id": 60, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_queues_created_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Queues created / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of queues deleted.\n\nLow sustained values above zero are to be expected. High rates may be indicative of queue churn or high rates of connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [Queues](https://www.rabbitmq.com/queues.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 4, - "x": 20, - "y": 63 - }, - "id": 59, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_queues_deleted_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Queues deleted / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 68 - }, - "id": 51, - "panels": [], - "title": "CHANNELS", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of channels on all currently opened connections.\n\nIf this metric grows monotonically it is highly likely a channel leak in one of the applications. Confirm channel leaks by using the _Channels opened_ and _Channels closed_ metrics.\n\n* [Channel Leak](https://www.rabbitmq.com/channels.html#channel-leaks)\n* [Channels](https://www.rabbitmq.com/channels.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 69 - }, - "id": 54, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_channels * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Total channels", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of new channels opened by applications across all connections. Channels are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of channel churn or mass connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [High Channel Churn](https://www.rabbitmq.com/channels.html#high-channel-churn)\n* [Channels](https://www.rabbitmq.com/channels.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 12, - "y": 69 - }, - "id": 55, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_channels_opened_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Channels opened / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of channels closed by applications across all connections. Channels are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of channel churn or mass connection recovery. Confirm connection recovery rates by using the _Connections opened_ metric.\n\n* [High Channel Churn](https://www.rabbitmq.com/channels.html#high-channel-churn)\n* [Channels](https://www.rabbitmq.com/channels.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 18, - "y": 69 - }, - "id": 56, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_channels_closed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Channels closed / s", - "type": "timeseries" - }, - { - "collapsed": false, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "gridPos": { - "h": 1, - "w": 24, - "x": 0, - "y": 74 - }, - "id": 46, - "panels": [], - "title": "CONNECTIONS", - "type": "row" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "Total number of client connections.\n\nIf this metric grows monotonically it is highly likely a connection leak in one of the applications. Confirm connection leaks by using the _Connections opened_ and _Connections closed_ metrics.\n\n* [Connection Leak](https://www.rabbitmq.com/connections.html#monitoring)\n* [Connections](https://www.rabbitmq.com/connections.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "off" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 12, - "x": 0, - "y": 75 - }, - "id": 47, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "rabbitmq_connections * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Total connections", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of new connections opened by clients. Connections are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of connection churn or mass connection recovery.\n\n* [Connection Leak](https://www.rabbitmq.com/connections.html#monitoring)\n* [Connections](https://www.rabbitmq.com/connections.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 12, - "y": 75 - }, - "id": 48, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_connections_opened_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "interval": "", - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Connections opened / s", - "type": "timeseries" - }, - { - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "description": "The rate of connections closed. Connections are expected to be long-lived.\n\nLow sustained values above zero are to be expected. High rates may be indicative of connection churn or mass connection recovery.\n\n* [Connections](https://www.rabbitmq.com/connections.html)", - "fieldConfig": { - "defaults": { - "color": { - "mode": "palette-classic" - }, - "custom": { - "axisLabel": "", - "axisPlacement": "auto", - "barAlignment": 0, - "drawStyle": "line", - "fillOpacity": 100, - "gradientMode": "none", - "hideFrom": { - "legend": false, - "tooltip": false, - "viz": false - }, - "lineInterpolation": "linear", - "lineWidth": 1, - "pointSize": 5, - "scaleDistribution": { - "type": "linear" - }, - "showPoints": "never", - "spanNulls": false, - "stacking": { - "group": "A", - "mode": "normal" - }, - "thresholdsStyle": { - "mode": "line+area" - } - }, - "links": [], - "mappings": [], - "min": 0, - "thresholds": { - "mode": "absolute", - "steps": [ - { - "color": "transparent", - "value": null - }, - { - "color": "orange", - "value": 2 - }, - { - "color": "red", - "value": 10 - } - ] - }, - "unit": "short" - }, - "overrides": [ - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?0(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#56A64B", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?1(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#F2CC0C", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?2(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#3274D9", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?3(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#A352CC", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?4(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FF780A", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?5(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#96D98D", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?6(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFEE52", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?7(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#8AB8FF", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?8(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#CA95E5", - "mode": "fixed" - } - } - ] - }, - { - "matcher": { - "id": "byRegexp", - "options": "/^rabbit@[a-zA-Z\\.\\-]*?9(\\b|\\.)/" - }, - "properties": [ - { - "id": "color", - "value": { - "fixedColor": "#FFB357", - "mode": "fixed" - } - } - ] - } - ] - }, - "gridPos": { - "h": 5, - "w": 6, - "x": 18, - "y": 75 - }, - "id": 49, - "links": [], - "options": { - "legend": { - "calcs": [ - "lastNotNull", - "max", - "min" - ], - "displayMode": "hidden", - "placement": "bottom" - }, - "tooltip": { - "mode": "multi" - } - }, - "pluginVersion": "8.3.4", - "targets": [ - { - "expr": "sum(rate(rabbitmq_connections_closed_total[60s]) * on(instance, job) group_left(rabbitmq_cluster, rabbitmq_node) rabbitmq_identity_info{rabbitmq_cluster=\"$rabbitmq_cluster\", namespace=\"$namespace\"}) by(rabbitmq_node)", - "format": "time_series", - "instant": false, - "intervalFactor": 1, - "legendFormat": "{{rabbitmq_node}}", - "refId": "A" - } - ], - "title": "Connections closed / s", - "type": "timeseries" - } - ], - "refresh": "15s", - "schemaVersion": 34, - "style": "dark", - "tags": [ - "rabbitmq-prometheus" - ], - "templating": { - "list": [ - { - "current": { - "selected": false, - "text": "default", - "value": "default" - }, - "datasource": "PBFA97CFB590B2093", - "hide": 2, - "includeAll": false, - "label": "datasource", - "multi": false, - "name": "DS_PROMETHEUS", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "definition": "label_values(rabbitmq_identity_info, namespace)", - "hide": 0, - "includeAll": false, - "label": "Namespace", - "multi": false, - "name": "namespace", - "options": [], - "query": { - "query": "label_values(rabbitmq_identity_info, namespace)", - "refId": "Prometheus-namespace-Variable-Query" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "tagValuesQuery": "", - "tagsQuery": "", - "type": "query", - "useTags": false - }, - { - "current": {}, - "datasource": { - "type": "prometheus", - "uid": "${DS_PROMETHEUS}" - }, - "definition": "label_values(rabbitmq_identity_info{namespace=\"$namespace\"}, rabbitmq_cluster)", - "hide": 0, - "includeAll": false, - "label": "RabbitMQ Cluster", - "multi": false, - "name": "rabbitmq_cluster", - "options": [], - "query": { - "query": "label_values(rabbitmq_identity_info{namespace=\"$namespace\"}, rabbitmq_cluster)", - "refId": "Prometheus-rabbitmq_cluster-Variable-Query" - }, - "refresh": 2, - "regex": "", - "skipUrlSync": false, - "sort": 1, - "tagValuesQuery": "", - "tagsQuery": "", - "type": "query", - "useTags": false - } - ] - }, - "time": { - "from": "now-15m", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "15s", - "30s", - "1m", - "5m", - "10m" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "", - "title": "RabbitMQ-Overview", - "uid": "Kn5xm-gZk", - "version": 20220805, - "weekStart": "", - "gnetId": 10991 -} \ No newline at end of file diff --git a/3-microservices-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml b/3-microservices-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml deleted file mode 100644 index f1fb0bb..0000000 --- a/3-microservices-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml +++ /dev/null @@ -1,14 +0,0 @@ -# https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards -apiVersion: 1 - -providers: - - name: "default" - orgId: 1 - folder: "" - type: file - disableDeletion: false - editable: true - allowUiUpdates: true - updateIntervalSeconds: 5 # how often Grafana will scan for changed dashboards - options: - path: /var/lib/grafana/dashboards # path to dashboards on disk \ No newline at end of file diff --git a/3-microservices-architecture-style/deployments/configs/loki-config.yaml b/3-microservices-architecture-style/deployments/configs/loki-config.yaml deleted file mode 100644 index 414d762..0000000 --- a/3-microservices-architecture-style/deployments/configs/loki-config.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# https://grafana.com/docs/loki/latest/configure/examples/configuration-examples/ -# https://github.com/grafana/loki/issues/2018#issuecomment-970789233 -# https://grafana.com/docs/opentelemetry/collector/send-logs-to-loki/ -# https://github.com/grafana/loki/blob/main/examples/getting-started/loki-config.yaml -# https://github.com/grafana/loki/blob/main/cmd/loki/loki-local-config.yaml -# https://grafana.com/docs/loki/latest/configure/examples/configuration-examples/#1-local-configuration-exampleyaml - ---- -# https://grafana.com/docs/loki/latest/configure/examples/configuration-examples/#1-local-configuration-exampleyaml -auth_enabled: false - -# This is a complete configuration to deploy Loki backed by the filesystem. -# The index will be shipped to the storage via tsdb-shipper. -server: - http_listen_port: 3100 - -common: - ring: - instance_addr: 127.0.0.1 - kvstore: - store: inmemory - replication_factor: 1 - path_prefix: /tmp/loki - -schema_config: - configs: - - from: 2020-05-15 - store: tsdb - object_store: filesystem - schema: v13 - index: - prefix: index_ - period: 24h - -storage_config: - filesystem: - directory: /tmp/loki/chunks - -# https://grafana.com/docs/loki/latest/send-data/otel/ -# https://grafana.com/docs/loki/latest/send-data/otel/#changing-the-default-mapping-of-otlp-to-loki-format -limits_config: - # this attribute should be `true` when we use `otlphttp/loki`, but if we want to use `loki component` from `opentelemetry-collector-contrib` it should be false. - allow_structured_metadata: true - diff --git a/3-microservices-architecture-style/deployments/configs/otel-collector-config.yaml b/3-microservices-architecture-style/deployments/configs/otel-collector-config.yaml deleted file mode 100644 index ea6ef40..0000000 --- a/3-microservices-architecture-style/deployments/configs/otel-collector-config.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/examples/demo/otel-collector-config.yaml -# https://opentelemetry.io/docs/collector/configuration/ -# https://opentelemetry.io/docs/collector/architecture/ -# https://betterstack.com/community/guides/observability/opentelemetry-collector/ -# https://signoz.io/blog/opentelemetry-collector-complete-guide/ - -# This configuration sets up an OpenTelemetry Collector that receives trace data via the OTLP protocol over HTTP on port 4318, applies batch processing, and then exports the processed traces -# to exporter components like `Jaeger` endpoint located at `jaeger-all-in-one:4317`. It also includes a health_check extension for monitoring the collector's status. - -# Receivers in the OpenTelemetry Collector are components that collect telemetry data (traces, metrics, and logs) from various sources, such as instrumented applications or agents. -# They act as entry points, converting incoming data into OpenTelemetry's internal format for processing and export. -# https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components -# https://opentelemetry.io/docs/collector/architecture/#receivers -# https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/README.md -# https://opentelemetry.io/docs/collector/configuration/#receivers -receivers: - # supported receivers - # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver - # instead of specifying details explicitly we can just use `otlp` and it uses both grpc and http - otlp: - protocols: - grpc: - endpoint: 0.0.0.0:4317 - http: - endpoint: 0.0.0.0:4318 -# prometheus: -# config: -# scrape_configs: -# - job_name: 'node-exporter' -# scrape_interval: 10s -# static_configs: -# - targets: [ 'node-exporter:9100' ] - - -# Processors in the OpenTelemetry Collector modify and enhance telemetry data by filtering, transforming, enriching, or batching it to prepare it for export. -# https://github.com/open-telemetry/opentelemetry-collector/tree/main/processor -processors: - batch: # Batches logs for better performance - -# - Exporters in the OpenTelemetry Collector send processed telemetry data to backend systems like observability platforms, databases, or cloud services for storage, visualization, and analysis. -# - The `key` follows the `type/name` format, where `type` specifies the exporter `type` (e.g., otlp, kafka, prometheus), and `name` (optional) can be appended to provide a unique name for multiple instance of the same type -# https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components -# https://opentelemetry.io/docs/collector/architecture/#exporters -# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter -# https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter -# https://opentelemetry.io/docs/collector/configuration/#exporters -exporters: - - # valid values: [prometheusremotewrite zipkin otlphttp file kafka prometheus debug nop otlp opencensus] - - # Prometheus exporter metrics - prometheus: - endpoint: "0.0.0.0:8889" - - prometheusremotewrite: - endpoint: "http://prometheus:9090/api/v1/write" - - # https://grafana.com/docs/loki/latest/send-data/otel/ - # https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/lokiexporter/README.md - otlphttp/loki: - endpoint: "http://loki:3100/otlp" - tls: - insecure: true - - # # we can also use `loki component` from `opentelemetry-collector-contrib` if we don't want to use builtin `otlphttp` exporter type and `http://loki:3100/otlp` loki endpoint - # loki: - # endpoint: "http://loki:3100/loki/api/v1/push" - # tls: - # insecure: true - - debug: - - # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/elasticsearchexporter - # using `elasticsearch` from `opentelemetry-collector-contrib` components because it doesn't exist in `opentelemetry-collector` - elasticsearch: - endpoint: "http://elasticsearch:9200" - - zipkin: - endpoint: "http://zipkin-all-in-one:9411/api/v2/spans" - format: proto - - # export collected telemetry traces to jaeger OTLP grpc port, we can send data to other available endpoints and ports on jaeger as well - otlp/jaeger: - endpoint: "http://jaeger-all-in-one:4317" - tls: - insecure: true - - otlp/tempo: - endpoint: "http://tempo:4317" - tls: - insecure: true - - # seq-otlp: - # endpoint: "http://seq:5341/ingest/otlp" - -# https://opentelemetry.io/docs/collector/configuration/#extensions -# https://github.com/open-telemetry/opentelemetry-collector/blob/main/extension/README.md -extensions: - pprof: - endpoint: 0.0.0.0:1888 - zpages: - endpoint: 0.0.0.0:55679 - health_check: - endpoint: 0.0.0.0:13133 - -# - The service section is used to configure what components are enabled in the Collector based on the configuration found in the receivers, processors, exporters, and extensions sections. -# - If a component is configured, but not defined within the service section, then it’s not enabled. -# https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components -# https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/README.md -# https://opentelemetry.io/docs/collector/architecture/ -# https://opentelemetry.io/docs/collector/configuration/#service -service: - # The `service.extensions` subsection determines which of the configured extensions will be enabled - extensions: [pprof, zpages, health_check] - # The `service.pipeline` Each pipeline starts with one or more receivers collecting data, which is then processed sequentially by processors (applying transformations, filtering, or sampling). - # The processed data is finally sent to all configured exporters, ensuring each receives a copy. Components must be pre-configured in their respective sections before being used in a pipeline. - # pipeline activate predefined components, defined components are disabled by default - pipelines: - traces: - receivers: [otlp] - processors: [batch] - # https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exporter-selection - exporters: [debug, zipkin, otlp/jaeger, otlp/tempo] - metrics: - receivers: [otlp] - processors: [batch] - exporters: [debug, prometheusremotewrite, prometheus] - logs: - receivers: [otlp] - processors: [batch] - exporters: [otlphttp/loki, elasticsearch] \ No newline at end of file diff --git a/3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj b/3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj deleted file mode 100644 index 161a9d9..0000000 --- a/3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/3-microservices-architecture-style/src/ApiGateway/src/appsettings.Development.json b/3-microservices-architecture-style/src/ApiGateway/src/appsettings.Development.json deleted file mode 100644 index 0c208ae..0000000 --- a/3-microservices-architecture-style/src/ApiGateway/src/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/Dockerfile b/3-microservices-architecture-style/src/Services/Booking/Dockerfile deleted file mode 100644 index a3ded71..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking.csproj ./3-microservices-architecture-style/src/Services/Booking/src/Booking/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/ - - -# Restore nuget packages -RUN dotnet restore ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking/ ./3-microservices-architecture-style/src/Services/Booking/src/Booking/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/ ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Booking/src/Booking.Api - -# Publish project to output folder -# and no build, as we did it already -RUN dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/out . - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Booking.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Booking/dev.Dockerfile b/3-microservices-architecture-style/src/Services/Booking/dev.Dockerfile deleted file mode 100644 index eb3e2da..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/dev.Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking.csproj ./3-microservices-architecture-style/src/Services/Booking/src/Booking/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/ - - -# Restore nuget packages -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages \ - dotnet restore ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking/ ./3-microservices-architecture-style/src/Services/Booking/src/Booking/ -COPY ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/ ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\ - dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Booking/src/Booking.Api - -# Publish project to output folder -# and no build, as we did it already -RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\ - dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/out . - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Booking.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/AssemblyInfo.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/AssemblyInfo.cs deleted file mode 100644 index 60fedfd..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Unit.Test")] -[assembly: InternalsVisibleTo("Integration.Test")] -[assembly: InternalsVisibleTo("EndToEnd.Test")] - diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking.csproj b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking.csproj deleted file mode 100644 index 69ca1ab..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs deleted file mode 100644 index 56c4a89..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace Booking.Booking.Dtos; - -public record BookingResponseDto(Guid Id, string Name, string FlightNumber, Guid AircraftId, decimal Price, - DateTime FlightDate, string SeatNumber, Guid DepartureAirportId, Guid ArriveAirportId, string Description); diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/BookingAlreadyExistException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/BookingAlreadyExistException.cs deleted file mode 100644 index 81ed2f6..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/BookingAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Booking.Booking.Exceptions; - -public class BookingAlreadyExistException : AppException -{ - public BookingAlreadyExistException(int? code = default) : base("Booking already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/FlightNotFoundException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/FlightNotFoundException.cs deleted file mode 100644 index e803ca1..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/FlightNotFoundException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Booking.Booking.Exceptions; - -public class FlightNotFoundException : AppException -{ - public FlightNotFoundException() : base("Flight doesn't exist!", HttpStatusCode.NotFound) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidAircraftIdException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidAircraftIdException.cs deleted file mode 100644 index bfa7cee..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidAircraftIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidAircraftIdException : DomainException -{ - public InvalidAircraftIdException(Guid aircraftId) - : base($"aircraftId: '{aircraftId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidArriveAirportIdException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidArriveAirportIdException.cs deleted file mode 100644 index e138c0a..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidArriveAirportIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidArriveAirportIdException : DomainException -{ - public InvalidArriveAirportIdException(Guid arriveAirportId) - : base($"arriveAirportId: '{arriveAirportId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidDepartureAirportIdException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidDepartureAirportIdException.cs deleted file mode 100644 index 6c8ad7a..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidDepartureAirportIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidDepartureAirportIdException : DomainException -{ - public InvalidDepartureAirportIdException(Guid departureAirportId) - : base($"departureAirportId: '{departureAirportId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightDateException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightDateException.cs deleted file mode 100644 index a22c300..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidFlightDateException : DomainException -{ - public InvalidFlightDateException(DateTime flightDate) - : base($"Flight Date: '{flightDate}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightNumberException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightNumberException.cs deleted file mode 100644 index 764d782..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightNumberException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidFlightNumberException : DomainException -{ - public InvalidFlightNumberException(string flightNumber) - : base($"Flight Number: '{flightNumber}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPassengerNameException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPassengerNameException.cs deleted file mode 100644 index b575066..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPassengerNameException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidPassengerNameException : DomainException -{ - public InvalidPassengerNameException(string passengerName) - : base($"Passenger Name: '{passengerName}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPriceException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPriceException.cs deleted file mode 100644 index 66ae7c9..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPriceException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class InvalidPriceException : DomainException -{ - public InvalidPriceException(decimal price) - : base($"Price: '{price}' must be grater than or equal 0.") - { - } -} - diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/SeatNumberException.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/SeatNumberException.cs deleted file mode 100644 index 4c4ad58..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Exceptions/SeatNumberException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Booking.Booking.Exceptions; - -public class SeatNumberException : DomainException -{ - public SeatNumberException(string seatNumber) - : base($"Seat Number: '{seatNumber}' is invalid.") - { - } -} - diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Features/BookingMappings.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Features/BookingMappings.cs deleted file mode 100644 index feaa98e..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Features/BookingMappings.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Booking.Booking.Dtos; -using Mapster; - -namespace Booking.Booking.Features; - -using CreatingBook.V1; - -public class BookingMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.Default.NameMatchingStrategy(NameMatchingStrategy.Flexible); - - config.NewConfig() - .ConstructUsing(x => new BookingResponseDto(x.Id, x.PassengerInfo.Name, x.Trip.FlightNumber, - x.Trip.AircraftId, x.Trip.Price, x.Trip.FlightDate, x.Trip.SeatNumber, x.Trip.DepartureAirportId, x.Trip.ArriveAirportId, - x.Trip.Description)); - - - config.NewConfig() - .ConstructUsing(x => new CreateBooking(x.PassengerId, x.FlightId, x.Description)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Models/Booking.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Models/Booking.cs deleted file mode 100644 index 354f743..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Models/Booking.cs +++ /dev/null @@ -1,50 +0,0 @@ -using BuildingBlocks.EventStoreDB.Events; - -namespace Booking.Booking.Models; - -using Features.CreatingBook.V1; -using ValueObjects; - -public record Booking : AggregateEventSourcing -{ - public Trip Trip { get; private set; } - public PassengerInfo PassengerInfo { get; private set; } - - public static Booking Create(Guid id, PassengerInfo passengerInfo, Trip trip, bool isDeleted = false, long? userId = null) - { - var booking = new Booking { Id = id, Trip = trip, PassengerInfo = passengerInfo, IsDeleted = isDeleted }; - - var @event = new BookingCreatedDomainEvent(booking.Id, booking.PassengerInfo, booking.Trip) - { - IsDeleted = booking.IsDeleted, - CreatedAt = DateTime.Now, - CreatedBy = userId - }; - - booking.AddDomainEvent(@event); - booking.Apply(@event); - - return booking; - } - - public override void When(object @event) - { - switch (@event) - { - case BookingCreatedDomainEvent bookingCreated: - { - Apply(bookingCreated); - return; - } - } - } - - private void Apply(BookingCreatedDomainEvent @event) - { - Id = @event.Id; - Trip = @event.Trip; - PassengerInfo = @event.PassengerInfo; - IsDeleted = @event.IsDeleted; - Version++; - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs deleted file mode 100644 index 57d2018..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Booking.Booking.Models; - -using ValueObjects; - -public class BookingReadModel -{ - public required Guid Id { get; init; } - public required Guid BookId { get; init; } - public required Trip Trip { get; init; } - public required PassengerInfo PassengerInfo { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/ValueObjects/PassengerInfo.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/ValueObjects/PassengerInfo.cs deleted file mode 100644 index 9cbedc6..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/ValueObjects/PassengerInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Booking.Booking.ValueObjects; - -using Exceptions; - -public record PassengerInfo -{ - public string Name { get; } - - private PassengerInfo(string name) - { - Name = name; - } - - public static PassengerInfo Of(string name) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new InvalidPassengerNameException(name); - } - - return new PassengerInfo(name); - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/ValueObjects/Trip.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/ValueObjects/Trip.cs deleted file mode 100644 index fb1b0d4..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/ValueObjects/Trip.cs +++ /dev/null @@ -1,69 +0,0 @@ -namespace Booking.Booking.ValueObjects; - -using Exceptions; - -public record Trip -{ - public string FlightNumber { get; } - public Guid AircraftId { get; } - public Guid DepartureAirportId { get; } - public Guid ArriveAirportId { get; } - public DateTime FlightDate { get; } - public decimal Price { get; } - public string Description { get; } - public string SeatNumber { get; } - - private Trip(string flightNumber, Guid aircraftId, Guid departureAirportId, Guid arriveAirportId, - DateTime flightDate, decimal price, string description, string seatNumber) - { - FlightNumber = flightNumber; - AircraftId = aircraftId; - DepartureAirportId = departureAirportId; - ArriveAirportId = arriveAirportId; - FlightDate = flightDate; - Price = price; - Description = description; - SeatNumber = seatNumber; - } - - public static Trip Of(string flightNumber, Guid aircraftId, Guid departureAirportId, Guid arriveAirportId, - DateTime flightDate, decimal price, string description, string seatNumber) - { - if (string.IsNullOrWhiteSpace(flightNumber)) - { - throw new InvalidFlightNumberException(flightNumber); - } - - if (aircraftId == Guid.Empty) - { - throw new InvalidAircraftIdException(aircraftId); - } - - if (departureAirportId == Guid.Empty) - { - throw new InvalidDepartureAirportIdException(departureAirportId); - } - - if (arriveAirportId == Guid.Empty) - { - throw new InvalidArriveAirportIdException(departureAirportId); - } - - if (flightDate == default) - { - throw new InvalidFlightDateException(flightDate); - } - - if (price < 0) - { - throw new InvalidPriceException(price); - } - - if (string.IsNullOrWhiteSpace(seatNumber)) - { - throw new SeatNumberException(seatNumber); - } - - return new Trip(flightNumber, aircraftId, departureAirportId, arriveAirportId, flightDate, price, description, seatNumber); - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingEventMapper.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingEventMapper.cs deleted file mode 100644 index ecfc0e6..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingEventMapper.cs +++ /dev/null @@ -1,27 +0,0 @@ -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace Booking; - -using Booking.Features.CreatingBook.V1; - -public sealed class BookingEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - BookingCreatedDomainEvent e => new BookingCreated(e.Id), - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - _ => null - }; - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingProjection.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingProjection.cs deleted file mode 100644 index ba4d2db..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingProjection.cs +++ /dev/null @@ -1,54 +0,0 @@ -using Booking.Data; -using BuildingBlocks.EventStoreDB.Events; -using BuildingBlocks.EventStoreDB.Projections; -using MediatR; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace Booking; - -using Booking.Features.CreatingBook.V1; -using Booking.Models; -using MassTransit; - -public class BookingProjection : IProjectionProcessor -{ - private readonly BookingReadDbContext _bookingReadDbContext; - - public BookingProjection(BookingReadDbContext bookingReadDbContext) - { - _bookingReadDbContext = bookingReadDbContext; - } - - public async Task ProcessEventAsync(StreamEvent streamEvent, CancellationToken cancellationToken = default) - where T : INotification - { - switch (streamEvent.Data) - { - case BookingCreatedDomainEvent bookingCreatedDomainEvent: - await Apply(bookingCreatedDomainEvent, cancellationToken); - break; - } - } - - private async Task Apply(BookingCreatedDomainEvent @event, CancellationToken cancellationToken = default) - { - var reservation = - await _bookingReadDbContext.Booking.AsQueryable().SingleOrDefaultAsync(x => x.Id == @event.Id && !x.IsDeleted, - cancellationToken); - - if (reservation == null) - { - var bookingReadModel = new BookingReadModel - { - Id = NewId.NextGuid(), - Trip = @event.Trip, - BookId = @event.Id, - PassengerInfo = @event.PassengerInfo, - IsDeleted = @event.IsDeleted - }; - - await _bookingReadDbContext.Booking.InsertOneAsync(bookingReadModel, cancellationToken: cancellationToken); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingRoot.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingRoot.cs deleted file mode 100644 index 73eb27c..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/BookingRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Booking; - -public class BookingRoot -{ - -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Configuration/GrpcOptions.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Configuration/GrpcOptions.cs deleted file mode 100644 index 4f4adf7..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Configuration/GrpcOptions.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Booking.Configuration; - -public class GrpcOptions -{ - public string FlightAddress { get; set; } - public string PassengerAddress { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs b/3-microservices-architecture-style/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs deleted file mode 100644 index e35b256..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs +++ /dev/null @@ -1,18 +0,0 @@ -using BuildingBlocks.Mongo; -using Humanizer; -using Microsoft.Extensions.Options; -using MongoDB.Driver; - -namespace Booking.Data; - -using Booking.Models; - -public class BookingReadDbContext : MongoDbContext -{ - public BookingReadDbContext(IOptions options) : base(options) - { - Booking = GetCollection(nameof(Booking).Underscore()); - } - - public IMongoCollection Booking { get; } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs b/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs deleted file mode 100644 index ff5cb93..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -using AutoBogus; - -namespace Integration.Test.Fakes; - -using System; -using global::Booking.Booking.Features.CreatingBook.V1; -using MassTransit; - -public sealed class FakeCreateBookingCommand : AutoFaker -{ - public FakeCreateBookingCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightId, _ => new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9")); - RuleFor(r => r.PassengerId, _ => new Guid("4c5c8888-97c6-fc34-2eb9-18db322230c1")); - } -} diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/xunit.runner.json b/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/xunit.runner.json deleted file mode 100644 index 9db029b..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator/VERSION b/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator/VERSION deleted file mode 100644 index ba8a874..0000000 --- a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.6.0-SNAPSHOT \ No newline at end of file diff --git a/3-microservices-architecture-style/src/Services/Flight/Dockerfile b/3-microservices-architecture-style/src/Services/Flight/Dockerfile deleted file mode 100644 index 8d09f90..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/Dockerfile +++ /dev/null @@ -1,48 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight/Flight.csproj ./3-microservices-architecture-style/src/Services/Flight/src/Flight/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/ - - -# Restore nuget packages -RUN dotnet restore ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight/ ./3-microservices-architecture-style/src/Services/Flight/src/Flight/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/ ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Flight/src/Flight.Api - -# Publish project to output folder -# and no build, as we did it already -RUN dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/out . - - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Flight.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Flight/dev.Dockerfile b/3-microservices-architecture-style/src/Services/Flight/dev.Dockerfile deleted file mode 100644 index f4df0b5..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/dev.Dockerfile +++ /dev/null @@ -1,51 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight/Flight.csproj ./3-microservices-architecture-style/src/Services/Flight/src/Flight/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/ - - -# Restore nuget packages -RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ - dotnet restore ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Flight/src/Flight/ ./3-microservices-architecture-style/src/Services/Flight/src/Flight/ -COPY .3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/ ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ - dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Flight/src/Flight.Api - -# Publish project to output folder -# and no build, as we did it already -RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ - dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/out . - - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Flight.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Dtos/AircraftDto.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Dtos/AircraftDto.cs deleted file mode 100644 index 89aeed8..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Dtos/AircraftDto.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Flight.Aircrafts.Dtos; - -public record AircraftDto(long Id, string Name, string Model, int ManufacturingYear); diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs deleted file mode 100644 index 2bd320e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Flight.Aircrafts.Exceptions; - -public class AircraftAlreadyExistException : AppException -{ - public AircraftAlreadyExistException() : base("Aircraft already exist!", HttpStatusCode.Conflict) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs deleted file mode 100644 index ba061ff..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Aircrafts.Exceptions; - -public class InvalidAircraftIdException : DomainException -{ - public InvalidAircraftIdException(Guid aircraftId) - : base($"AircraftId: '{aircraftId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs deleted file mode 100644 index 8313ca8..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Aircrafts.Exceptions; - -public class InvalidManufacturingYearException : DomainException -{ - public InvalidManufacturingYearException() : base("ManufacturingYear must be greater than 1900") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs deleted file mode 100644 index 96da762..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Aircrafts.Exceptions; - -public class InvalidModelException : DomainException -{ - public InvalidModelException() : base("Model cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs deleted file mode 100644 index 599dcb9..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Aircrafts.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs deleted file mode 100644 index 81be420..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Flight.Aircrafts.Models; -using Mapster; - -namespace Flight.Aircrafts.Features; - -using CreatingAircraft.V1; -using MassTransit; -using ValueObjects; - -public class AircraftMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AircraftId, s => AircraftId.Of(s.Id)); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AircraftId, s => AircraftId.Of(s.Id.Value)); - - config.NewConfig() - .ConstructUsing(x => new CreatingAircraft.V1.CreateAircraft(x.Name, x.Model, x.ManufacturingYear)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs deleted file mode 100644 index ff9b266..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs +++ /dev/null @@ -1,108 +0,0 @@ -namespace Flight.Aircrafts.Features.CreatingAircraft.V1; - -using System; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using Flight.Aircrafts.ValueObjects; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; -using Models; - -public record CreateAircraft(string Name, string Model, int ManufacturingYear) : ICommand, - IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateAircraftResult(AircraftId Id); - -public record AircraftCreatedDomainEvent - (Guid Id, string Name, string Model, int ManufacturingYear, bool IsDeleted) : IDomainEvent; - -public record CreateAircraftRequestDto(string Name, string Model, int ManufacturingYear); - -public record CreateAircraftResponseDto(Guid Id); - -public class CreateAircraftEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/aircraft", async (CreateAircraftRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateAircraft") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Aircraft") - .WithDescription("Create Aircraft") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateAircraftValidator : AbstractValidator -{ - public CreateAircraftValidator() - { - RuleFor(x => x.Model).NotEmpty().WithMessage("Model is required"); - RuleFor(x => x.Name).NotEmpty().WithMessage("Name is required"); - RuleFor(x => x.ManufacturingYear).NotEmpty().WithMessage("ManufacturingYear is required"); - } -} - -internal class CreateAircraftHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateAircraftHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateAircraft request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var aircraft = await _flightDbContext.Aircraft.SingleOrDefaultAsync( - a => a.Model.Value == request.Model, cancellationToken); - - if (aircraft is not null) - { - throw new AircraftAlreadyExistException(); - } - - var aircraftEntity = Aircraft.Create(AircraftId.Of(request.Id), Name.Of(request.Name), Model.Of(request.Model), ManufacturingYear.Of(request.ManufacturingYear)); - - var newAircraft = (await _flightDbContext.Aircraft.AddAsync(aircraftEntity, cancellationToken)).Entity; - - return new CreateAircraftResult(newAircraft.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs deleted file mode 100644 index e89ccb0..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Flight.Aircrafts.Features.CreatingAircraft.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using Exceptions; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; -using ValueObjects; - -public record CreateAircraftMongo(Guid Id, string Name, string Model, int ManufacturingYear, bool IsDeleted = false) : InternalCommand; - -internal class CreateAircraftMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateAircraftMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateAircraftMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var aircraftReadModel = _mapper.Map(request); - - var aircraft = await _flightReadDbContext.Aircraft.AsQueryable() - .FirstOrDefaultAsync(x => x.AircraftId == aircraftReadModel.AircraftId && - !x.IsDeleted, cancellationToken); - - if (aircraft is not null) - { - throw new AircraftAlreadyExistException(); - } - - await _flightReadDbContext.Aircraft.InsertOneAsync(aircraftReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs deleted file mode 100644 index ab71aeb..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs +++ /dev/null @@ -1,35 +0,0 @@ -using BuildingBlocks.Core.Model; - -namespace Flight.Aircrafts.Models; - -using Features.CreatingAircraft.V1; -using ValueObjects; - -public record Aircraft : Aggregate -{ - public Name Name { get; private set; } = default!; - public Model Model { get; private set; } = default!; - public ManufacturingYear ManufacturingYear { get; private set; } = default!; - - public static Aircraft Create(AircraftId id, Name name, Model model, ManufacturingYear manufacturingYear, bool isDeleted = false) - { - var aircraft = new Aircraft - { - Id = id, - Name = name, - Model = model, - ManufacturingYear = manufacturingYear - }; - - var @event = new AircraftCreatedDomainEvent( - aircraft.Id, - aircraft.Name, - aircraft.Model, - aircraft.ManufacturingYear, - isDeleted); - - aircraft.AddDomainEvent(@event); - - return aircraft; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs deleted file mode 100644 index d80052e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Flight.Aircrafts.Models; - -using System; - -public class AircraftReadModel -{ - public required Guid Id { get; init; } - public required Guid AircraftId { get; init; } - public required string Name { get; init; } - public required string Model { get; init; } - public required int ManufacturingYear { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/AircraftId.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/AircraftId.cs deleted file mode 100644 index cc7e241..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/AircraftId.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Flight.Aircrafts.ValueObjects; - -using System; -using Flight.Aircrafts.Exceptions; - -public record AircraftId -{ - public Guid Value { get; } - - private AircraftId(Guid value) - { - Value = value; - } - - public static AircraftId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidAircraftIdException(value); - } - - return new AircraftId(value); - } - - public static implicit operator Guid(AircraftId aircraftId) - { - return aircraftId.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs deleted file mode 100644 index 3ab80a5..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Aircrafts.ValueObjects; - -using Exceptions; - -public record ManufacturingYear -{ - public int Value { get; } - - private ManufacturingYear(int value) - { - Value = value; - } - - public static ManufacturingYear Of(int value) - { - if (value < 1900) - { - throw new InvalidManufacturingYearException(); - } - - return new ManufacturingYear(value); - } - - public static implicit operator int(ManufacturingYear manufacturingYear) - { - return manufacturingYear.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Model.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Model.cs deleted file mode 100644 index eae73f5..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Model.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Aircrafts.ValueObjects; - -using Exceptions; - -public record Model -{ - public string Value { get; } - - private Model(string value) - { - Value = value; - } - - public static Model Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidModelException(); - } - - return new Model(value); - } - - public static implicit operator string(Model model) - { - return model.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Name.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Name.cs deleted file mode 100644 index 63a0fa4..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Name.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Aircrafts.ValueObjects; - -using Exceptions; - -public record Name -{ - public string Value { get; } - - private Name(string value) - { - Value = value; - } - - public static Name Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidNameException(); - } - - return new Name(value); - } - - public static implicit operator string(Name name) - { - return name.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Dtos/AirportDto.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Dtos/AirportDto.cs deleted file mode 100644 index 6ff8797..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Dtos/AirportDto.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace Flight.Airports.Dtos; - -public record AirportDto(long Id, string Name, string Address, string Code); diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs deleted file mode 100644 index aef8bf8..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Flight.Airports.Exceptions; - -public class AirportAlreadyExistException : AppException -{ - public AirportAlreadyExistException(int? code = default) : base("Airport already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAddressException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAddressException.cs deleted file mode 100644 index 05d115c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAddressException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Airports.Exceptions; - -public class InvalidAddressException : DomainException -{ - public InvalidAddressException() : base("Address cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs deleted file mode 100644 index c40c6bc..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Airports.Exceptions; - -public class InvalidAirportIdException : DomainException -{ - public InvalidAirportIdException(Guid airportId) - : base($"airportId: '{airportId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidCodeException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidCodeException.cs deleted file mode 100644 index f78555b..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidCodeException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Airports.Exceptions; - -public class InvalidCodeException : DomainException -{ - public InvalidCodeException() : base("Code cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidNameException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidNameException.cs deleted file mode 100644 index a6b3355..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Airports.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs deleted file mode 100644 index 5c7b7cd..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Flight.Airports.Features; - -using CreatingAirport.V1; -using Mapster; -using MassTransit; -using Models; - -public class AirportMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AirportId, s => s.Id); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.AirportId, s => s.Id.Value); - - config.NewConfig() - .ConstructUsing(x => new CreateAirport(x.Name, x.Address, x.Code)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs deleted file mode 100644 index 580f9c7..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs +++ /dev/null @@ -1,105 +0,0 @@ -namespace Flight.Airports.Features.CreatingAirport.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; -using ValueObjects; - -public record CreateAirport(string Name, string Address, string Code) : ICommand, IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateAirportResult(Guid Id); - -public record AirportCreatedDomainEvent - (Guid Id, string Name, string Address, string Code, bool IsDeleted) : IDomainEvent; - -public record CreateAirportRequestDto(string Name, string Address, string Code); - -public record CreateAirportResponseDto(Guid Id); - -public class CreateAirportEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/airport", async (CreateAirportRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateAirport") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Airport") - .WithDescription("Create Airport") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateAirportValidator : AbstractValidator -{ - public CreateAirportValidator() - { - RuleFor(x => x.Code).NotEmpty().WithMessage("Code is required"); - RuleFor(x => x.Name).NotEmpty().WithMessage("Name is required"); - RuleFor(x => x.Address).NotEmpty().WithMessage("Address is required"); - } -} - -internal class CreateAirportHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateAirportHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateAirport request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var airport = - await _flightDbContext.Airports.SingleOrDefaultAsync(x => x.Code.Value == request.Code, cancellationToken); - - if (airport is not null) - { - throw new AirportAlreadyExistException(); - } - - var airportEntity = Models.Airport.Create(AirportId.Of(request.Id), Name.Of(request.Name), Address.Of(request.Address), Code.Of(request.Code)); - - var newAirport = (await _flightDbContext.Airports.AddAsync(airportEntity, cancellationToken)).Entity; - - return new CreateAirportResult(newAirport.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs deleted file mode 100644 index ad1df5c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace Flight.Airports.Features.CreatingAirport.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using Exceptions; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -public record CreateAirportMongo(Guid Id, string Name, string Address, string Code, bool IsDeleted = false) : InternalCommand; - -internal class CreateAirportMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateAirportMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateAirportMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var airportReadModel = _mapper.Map(request); - - var aircraft = await _flightReadDbContext.Airport.AsQueryable() - .FirstOrDefaultAsync(x => x.AirportId == airportReadModel.AirportId && - !x.IsDeleted, cancellationToken); - - if (aircraft is not null) - { - throw new AirportAlreadyExistException(); - } - - await _flightReadDbContext.Airport.InsertOneAsync(airportReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Models/Airport.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Models/Airport.cs deleted file mode 100644 index efe8120..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Models/Airport.cs +++ /dev/null @@ -1,35 +0,0 @@ -using BuildingBlocks.Core.Model; - -namespace Flight.Airports.Models; - -using Features.CreatingAirport.V1; -using ValueObjects; - -public record Airport : Aggregate -{ - public Name Name { get; private set; } = default!; - public Address Address { get; private set; } = default!; - public Code Code { get; private set; } = default!; - - public static Airport Create(AirportId id, Name name, Address address, Code code, bool isDeleted = false) - { - var airport = new Airport - { - Id = id, - Name = name, - Address = address, - Code = code - }; - - var @event = new AirportCreatedDomainEvent( - airport.Id, - airport.Name, - airport.Address, - airport.Code, - isDeleted); - - airport.AddDomainEvent(@event); - - return airport; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs deleted file mode 100644 index 14d5a32..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Flight.Airports.Models; - -using System; - -public class AirportReadModel -{ - public required Guid Id { get; init; } - public required Guid AirportId { get; init; } - public required string Name { get; init; } - public string Address { get; init; } - public required string Code { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Address.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Address.cs deleted file mode 100644 index 04bbc7c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Address.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Airports.ValueObjects; - -using Exceptions; - -public class Address -{ - public string Value { get; } - - private Address(string value) - { - Value = value; - } - - public static Address Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidAddressException(); - } - - return new Address(value); - } - - public static implicit operator string(Address address) - { - return address.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/AirportId.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/AirportId.cs deleted file mode 100644 index d1fd8ae..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/AirportId.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Flight.Airports.ValueObjects; - -using System; -using Flight.Airports.Exceptions; - -public record AirportId -{ - public Guid Value { get; } - - private AirportId(Guid value) - { - Value = value; - } - - public static AirportId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidAirportIdException(value); - } - - return new AirportId(value); - } - - public static implicit operator Guid(AirportId airportId) - { - return airportId.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Code.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Code.cs deleted file mode 100644 index f53c297..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Code.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Airports.ValueObjects; - -using Exceptions; - -public record Code -{ - public string Value { get; } - - private Code(string value) - { - Value = value; - } - - public static Code Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidCodeException(); - } - - return new Code(value); - } - - public static implicit operator string(Code code) - { - return code.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Name.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Name.cs deleted file mode 100644 index c66e500..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Airports/ValueObjects/Name.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Airports.ValueObjects; - -using Exceptions; - -public record Name -{ - public string Value { get; } - - private Name(string value) - { - Value = value; - } - - public static Name Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidNameException(); - } - - return new Name(value); - } - - public static implicit operator string(Name name) - { - return name.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/AssemblyInfo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/AssemblyInfo.cs deleted file mode 100644 index 60fedfd..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Unit.Test")] -[assembly: InternalsVisibleTo("Integration.Test")] -[assembly: InternalsVisibleTo("EndToEnd.Test")] - diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/AircraftConfiguration.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/AircraftConfiguration.cs deleted file mode 100644 index cb0adfa..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/AircraftConfiguration.cs +++ /dev/null @@ -1,56 +0,0 @@ -using Flight.Aircrafts.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Flight.Data.Configurations; - -using System; -using Aircrafts.ValueObjects; - -public class AircraftConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - - builder.ToTable(nameof(Aircraft)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(aircraftId => aircraftId.Value, dbId => AircraftId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - builder.OwnsOne( - x => x.Name, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Aircraft.Name)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Model, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Aircraft.Model)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.ManufacturingYear, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Aircraft.ManufacturingYear)) - .HasMaxLength(5) - .IsRequired(); - } - ); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/AirportConfiguration.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/AirportConfiguration.cs deleted file mode 100644 index 6570a2d..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/AirportConfiguration.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Flight.Airports.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Flight.Data.Configurations; - -using Airports.ValueObjects; - -public class AirportConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - - builder.ToTable(nameof(Airport)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(airportId => airportId.Value, dbId => AirportId.Of(dbId)); - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - - - builder.OwnsOne( - x => x.Name, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Airport.Name)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Address, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Airport.Address)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Code, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Airport.Code)) - .HasMaxLength(50) - .IsRequired(); - } - ); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs deleted file mode 100644 index 18e75fe..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs +++ /dev/null @@ -1,113 +0,0 @@ -using Flight.Aircrafts.Models; -using Flight.Airports.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Flight.Data.Configurations; - -using System; -using Flights.Models; -using Flights.ValueObjects; - -public class FlightConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(Flight)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(flight => flight.Value, dbId => FlightId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - - builder.OwnsOne( - x => x.FlightNumber, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flight.FlightNumber)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder - .HasOne() - .WithMany() - .HasForeignKey(p => p.AircraftId) - .IsRequired(); - - builder - .HasOne() - .WithMany() - .HasForeignKey(d => d.DepartureAirportId) - .IsRequired(); - - builder - .HasOne() - .WithMany() - .HasForeignKey(d => d.ArriveAirportId) - .IsRequired(); - - - builder.OwnsOne( - x => x.DurationMinutes, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flight.DurationMinutes)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.Property(x => x.Status) - .HasDefaultValue(Flights.Enums.FlightStatus.Unknown) - .HasConversion( - x => x.ToString(), - x => (Flights.Enums.FlightStatus)Enum.Parse(typeof(Flights.Enums.FlightStatus), x)); - - builder.OwnsOne( - x => x.Price, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flight.Price)) - .HasMaxLength(10) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.ArriveDate, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flight.ArriveDate)) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.DepartureDate, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flight.DepartureDate)) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.FlightDate, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Flight.FlightDate)) - .IsRequired(); - } - ); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/SeatConfiguration.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/SeatConfiguration.cs deleted file mode 100644 index ff8b995..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Configurations/SeatConfiguration.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Flight.Seats.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Flight.Data.Configurations; - -using System; -using Seats.ValueObjects; - -public class SeatConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(Seat)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(seatId => seatId.Value, dbId => SeatId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - builder.OwnsOne( - x => x.SeatNumber, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Seat.SeatNumber)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder - .HasOne() - .WithMany() - .HasForeignKey(p => p.FlightId); - - builder.Property(x => x.Class) - .HasDefaultValue(Seats.Enums.SeatClass.Unknown) - .HasConversion( - x => x.ToString(), - x => (Flight.Seats.Enums.SeatClass)Enum.Parse(typeof(Flight.Seats.Enums.SeatClass), x)); - - builder.Property(x => x.Type) - .HasDefaultValue(Seats.Enums.SeatType.Unknown) - .HasConversion( - x => x.ToString(), - x => (Flight.Seats.Enums.SeatType)Enum.Parse(typeof(Flight.Seats.Enums.SeatType), x)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/DesignTimeDbContextFactory.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/DesignTimeDbContextFactory.cs deleted file mode 100644 index b9a7a6c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/DesignTimeDbContextFactory.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace Flight.Data -{ - public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory - { - public FlightDbContext CreateDbContext(string[] args) - { - var builder = new DbContextOptionsBuilder(); - - builder.UseNpgsql("Server=localhost;Port=5432;Database=flight;User Id=postgres;Password=postgres;Include Error Detail=true") - .UseSnakeCaseNamingConvention(); - return new FlightDbContext(builder.Options); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/FlightReadDbContext.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/FlightReadDbContext.cs deleted file mode 100644 index 0c63e27..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/FlightReadDbContext.cs +++ /dev/null @@ -1,27 +0,0 @@ -using BuildingBlocks.Mongo; -using Humanizer; -using Microsoft.Extensions.Options; -using MongoDB.Driver; - -namespace Flight.Data; - -using Aircrafts.Models; -using Airports.Models; -using Flights.Models; -using Seats.Models; - -public class FlightReadDbContext : MongoDbContext -{ - public FlightReadDbContext(IOptions options) : base(options) - { - Flight = GetCollection(nameof(Flight).Underscore()); - Aircraft = GetCollection(nameof(Aircraft).Underscore()); - Airport = GetCollection(nameof(Airport).Underscore()); - Seat = GetCollection(nameof(Seat).Underscore()); - } - - public IMongoCollection Flight { get; } - public IMongoCollection Aircraft { get; } - public IMongoCollection Airport { get; } - public IMongoCollection Seat { get; } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.Designer.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.Designer.cs deleted file mode 100644 index 4010517..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.Designer.cs +++ /dev/null @@ -1,583 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - [Migration("20230611230948_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_aircraft"); - - b.ToTable("aircraft", (string)null); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_airport"); - - b.ToTable("airport", (string)null); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("aircraft_id"); - - b.Property("ArriveAirportId") - .HasColumnType("uuid") - .HasColumnName("arrive_airport_id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("DepartureAirportId") - .HasColumnType("uuid") - .HasColumnName("departure_airport_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("status"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_flight"); - - b.HasIndex("AircraftId") - .HasDatabaseName("ix_flight_aircraft_id"); - - b.HasIndex("ArriveAirportId") - .HasDatabaseName("ix_flight_arrive_airport_id"); - - b.HasIndex("DepartureAirportId") - .HasDatabaseName("ix_flight_departure_airport_id"); - - b.ToTable("flight", (string)null); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Class") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("class"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("flight_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Type") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_seat"); - - b.HasIndex("FlightId") - .HasDatabaseName("ix_seat_flight_id"); - - b.ToTable("seat", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.OwnsOne("Flight.Aircrafts.ValueObjects.ManufacturingYear", "ManufacturingYear", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(5) - .HasColumnType("integer") - .HasColumnName("manufacturing_year"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("Flight.Aircrafts.ValueObjects.Model", "Model", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("model"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("Flight.Aircrafts.ValueObjects.Name", "Name", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.Navigation("ManufacturingYear") - .IsRequired(); - - b.Navigation("Model") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.OwnsOne("Flight.Airports.ValueObjects.Address", "Address", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("address"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("Flight.Airports.ValueObjects.Code", "Code", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("code"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("Flight.Airports.ValueObjects.Name", "Name", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("Code") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_aircraft_aircraft_id"); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_arrive_airport_id"); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("DepartureAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_departure_airport_id"); - - b.OwnsOne("Flight.Flights.ValueObjects.ArriveDate", "ArriveDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("arrive_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.DepartureDate", "DepartureDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("departure_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.DurationMinutes", "DurationMinutes", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(50) - .HasColumnType("numeric") - .HasColumnName("duration_minutes"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.FlightDate", "FlightDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("flight_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.FlightNumber", "FlightNumber", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("flight_number"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.Price", "Price", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(10) - .HasColumnType("numeric") - .HasColumnName("price"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.Navigation("ArriveDate") - .IsRequired(); - - b.Navigation("DepartureDate") - .IsRequired(); - - b.Navigation("DurationMinutes") - .IsRequired(); - - b.Navigation("FlightDate") - .IsRequired(); - - b.Navigation("FlightNumber") - .IsRequired(); - - b.Navigation("Price") - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_seat_flight_flight_id"); - - b.OwnsOne("Flight.Seats.ValueObjects.SeatNumber", "SeatNumber", b1 => - { - b1.Property("SeatId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("seat_number"); - - b1.HasKey("SeatId") - .HasName("pk_seat"); - - b1.ToTable("seat"); - - b1.WithOwner() - .HasForeignKey("SeatId") - .HasConstraintName("fk_seat_seat_id"); - }); - - b.Navigation("SeatNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.cs deleted file mode 100644 index 630f49f..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Flight.Data.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "aircraft", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - model = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - manufacturingyear = table.Column(name: "manufacturing_year", type: "integer", maxLength: 5, nullable: false), - createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), - createdby = table.Column(name: "created_by", type: "bigint", nullable: true), - lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), - lastmodifiedby = table.Column(name: "last_modified_by", type: "bigint", nullable: true), - isdeleted = table.Column(name: "is_deleted", type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_aircraft", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "airport", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - address = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - code = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), - createdby = table.Column(name: "created_by", type: "bigint", nullable: true), - lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), - lastmodifiedby = table.Column(name: "last_modified_by", type: "bigint", nullable: true), - isdeleted = table.Column(name: "is_deleted", type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_airport", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "flight", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - flightnumber = table.Column(name: "flight_number", type: "character varying(50)", maxLength: 50, nullable: false), - aircraftid = table.Column(name: "aircraft_id", type: "uuid", nullable: false), - departureairportid = table.Column(name: "departure_airport_id", type: "uuid", nullable: false), - arriveairportid = table.Column(name: "arrive_airport_id", type: "uuid", nullable: false), - durationminutes = table.Column(name: "duration_minutes", type: "numeric", maxLength: 50, nullable: false), - status = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), - price = table.Column(type: "numeric", maxLength: 10, nullable: false), - arrivedate = table.Column(name: "arrive_date", type: "timestamp with time zone", nullable: false), - departuredate = table.Column(name: "departure_date", type: "timestamp with time zone", nullable: false), - flightdate = table.Column(name: "flight_date", type: "timestamp with time zone", nullable: false), - createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), - createdby = table.Column(name: "created_by", type: "bigint", nullable: true), - lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), - lastmodifiedby = table.Column(name: "last_modified_by", type: "bigint", nullable: true), - isdeleted = table.Column(name: "is_deleted", type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_flight", x => x.id); - table.ForeignKey( - name: "fk_flight_aircraft_aircraft_id", - column: x => x.aircraftid, - principalTable: "aircraft", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_flight_airport_arrive_airport_id", - column: x => x.arriveairportid, - principalTable: "airport", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_flight_airport_departure_airport_id", - column: x => x.departureairportid, - principalTable: "airport", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "seat", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - seatnumber = table.Column(name: "seat_number", type: "character varying(50)", maxLength: 50, nullable: false), - type = table.Column(type: "text", nullable: false, defaultValue: "Unknown"), - @class = table.Column(name: "class", type: "text", nullable: false, defaultValue: "Unknown"), - flightid = table.Column(name: "flight_id", type: "uuid", nullable: false), - createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), - createdby = table.Column(name: "created_by", type: "bigint", nullable: true), - lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), - lastmodifiedby = table.Column(name: "last_modified_by", type: "bigint", nullable: true), - isdeleted = table.Column(name: "is_deleted", type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_seat", x => x.id); - table.ForeignKey( - name: "fk_seat_flight_flight_id", - column: x => x.flightid, - principalTable: "flight", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_flight_aircraft_id", - table: "flight", - column: "aircraft_id"); - - migrationBuilder.CreateIndex( - name: "ix_flight_arrive_airport_id", - table: "flight", - column: "arrive_airport_id"); - - migrationBuilder.CreateIndex( - name: "ix_flight_departure_airport_id", - table: "flight", - column: "departure_airport_id"); - - migrationBuilder.CreateIndex( - name: "ix_seat_flight_id", - table: "seat", - column: "flight_id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "seat"); - - migrationBuilder.DropTable( - name: "flight"); - - migrationBuilder.DropTable( - name: "aircraft"); - - migrationBuilder.DropTable( - name: "airport"); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs deleted file mode 100644 index 930ce7a..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs +++ /dev/null @@ -1,580 +0,0 @@ -// -using System; -using Flight.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Flight.Data.Migrations -{ - [DbContext(typeof(FlightDbContext))] - partial class FlightDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_aircraft"); - - b.ToTable("aircraft", (string)null); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_airport"); - - b.ToTable("airport", (string)null); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("aircraft_id"); - - b.Property("ArriveAirportId") - .HasColumnType("uuid") - .HasColumnName("arrive_airport_id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("DepartureAirportId") - .HasColumnType("uuid") - .HasColumnName("departure_airport_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Status") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("status"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_flight"); - - b.HasIndex("AircraftId") - .HasDatabaseName("ix_flight_aircraft_id"); - - b.HasIndex("ArriveAirportId") - .HasDatabaseName("ix_flight_arrive_airport_id"); - - b.HasIndex("DepartureAirportId") - .HasDatabaseName("ix_flight_departure_airport_id"); - - b.ToTable("flight", (string)null); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("Class") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("class"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("flight_id"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("Type") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_seat"); - - b.HasIndex("FlightId") - .HasDatabaseName("ix_seat_flight_id"); - - b.ToTable("seat", (string)null); - }); - - modelBuilder.Entity("Flight.Aircrafts.Models.Aircraft", b => - { - b.OwnsOne("Flight.Aircrafts.ValueObjects.ManufacturingYear", "ManufacturingYear", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(5) - .HasColumnType("integer") - .HasColumnName("manufacturing_year"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("Flight.Aircrafts.ValueObjects.Model", "Model", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("model"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.OwnsOne("Flight.Aircrafts.ValueObjects.Name", "Name", b1 => - { - b1.Property("AircraftId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AircraftId") - .HasName("pk_aircraft"); - - b1.ToTable("aircraft"); - - b1.WithOwner() - .HasForeignKey("AircraftId") - .HasConstraintName("fk_aircraft_aircraft_id"); - }); - - b.Navigation("ManufacturingYear") - .IsRequired(); - - b.Navigation("Model") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Airports.Models.Airport", b => - { - b.OwnsOne("Flight.Airports.ValueObjects.Address", "Address", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("address"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("Flight.Airports.ValueObjects.Code", "Code", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("code"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.OwnsOne("Flight.Airports.ValueObjects.Name", "Name", b1 => - { - b1.Property("AirportId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("AirportId") - .HasName("pk_airport"); - - b1.ToTable("airport"); - - b1.WithOwner() - .HasForeignKey("AirportId") - .HasConstraintName("fk_airport_airport_id"); - }); - - b.Navigation("Address") - .IsRequired(); - - b.Navigation("Code") - .IsRequired(); - - b.Navigation("Name") - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Flights.Models.Flight", b => - { - b.HasOne("Flight.Aircrafts.Models.Aircraft", null) - .WithMany() - .HasForeignKey("AircraftId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_aircraft_aircraft_id"); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("ArriveAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_arrive_airport_id"); - - b.HasOne("Flight.Airports.Models.Airport", null) - .WithMany() - .HasForeignKey("DepartureAirportId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_flight_airport_departure_airport_id"); - - b.OwnsOne("Flight.Flights.ValueObjects.ArriveDate", "ArriveDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("arrive_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.DepartureDate", "DepartureDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("departure_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.DurationMinutes", "DurationMinutes", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(50) - .HasColumnType("numeric") - .HasColumnName("duration_minutes"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.FlightDate", "FlightDate", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasColumnType("timestamp with time zone") - .HasColumnName("flight_date"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.FlightNumber", "FlightNumber", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("flight_number"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.OwnsOne("Flight.Flights.ValueObjects.Price", "Price", b1 => - { - b1.Property("FlightId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(10) - .HasColumnType("numeric") - .HasColumnName("price"); - - b1.HasKey("FlightId") - .HasName("pk_flight"); - - b1.ToTable("flight"); - - b1.WithOwner() - .HasForeignKey("FlightId") - .HasConstraintName("fk_flight_flight_id"); - }); - - b.Navigation("ArriveDate") - .IsRequired(); - - b.Navigation("DepartureDate") - .IsRequired(); - - b.Navigation("DurationMinutes") - .IsRequired(); - - b.Navigation("FlightDate") - .IsRequired(); - - b.Navigation("FlightNumber") - .IsRequired(); - - b.Navigation("Price") - .IsRequired(); - }); - - modelBuilder.Entity("Flight.Seats.Models.Seat", b => - { - b.HasOne("Flight.Flights.Models.Flight", null) - .WithMany() - .HasForeignKey("FlightId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_seat_flight_flight_id"); - - b.OwnsOne("Flight.Seats.ValueObjects.SeatNumber", "SeatNumber", b1 => - { - b1.Property("SeatId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("seat_number"); - - b1.HasKey("SeatId") - .HasName("pk_seat"); - - b1.ToTable("seat"); - - b1.WithOwner() - .HasForeignKey("SeatId") - .HasConstraintName("fk_seat_seat_id"); - }); - - b.Navigation("SeatNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs deleted file mode 100644 index e2d8cd9..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs +++ /dev/null @@ -1,88 +0,0 @@ -using BuildingBlocks.EFCore; -using Flight.Aircrafts.Models; -using Flight.Airports.Models; -using Flight.Flights.Models; -using Flight.Seats.Models; -using MapsterMapper; -using Microsoft.EntityFrameworkCore; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace Flight.Data.Seed; - -public class FlightDataSeeder( - FlightDbContext flightDbContext, - FlightReadDbContext flightReadDbContext, - IMapper mapper -) : IDataSeeder -{ - public async Task SeedAllAsync() - { - var pendingMigrations = await flightDbContext.Database.GetPendingMigrationsAsync(); - - if (!pendingMigrations.Any()) - { - await SeedAirportAsync(); - await SeedAircraftAsync(); - await SeedFlightAsync(); - await SeedSeatAsync(); - } - } - - private async Task SeedAirportAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Airports)) - { - await flightDbContext.Airports.AddRangeAsync(InitialData.Airports); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Airport.AsQueryable())) - { - await flightReadDbContext.Airport.InsertManyAsync(mapper.Map>(InitialData.Airports)); - } - } - } - - private async Task SeedAircraftAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Aircraft)) - { - await flightDbContext.Aircraft.AddRangeAsync(InitialData.Aircrafts); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Aircraft.AsQueryable())) - { - await flightReadDbContext.Aircraft.InsertManyAsync(mapper.Map>(InitialData.Aircrafts)); - } - } - } - - - private async Task SeedSeatAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Seats)) - { - await flightDbContext.Seats.AddRangeAsync(InitialData.Seats); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Seat.AsQueryable())) - { - await flightReadDbContext.Seat.InsertManyAsync(mapper.Map>(InitialData.Seats)); - } - } - } - - private async Task SeedFlightAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Flights)) - { - await flightDbContext.Flights.AddRangeAsync(InitialData.Flights); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Flight.AsQueryable())) - { - await flightReadDbContext.Flight.InsertManyAsync(mapper.Map>(InitialData.Flights)); - } - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs deleted file mode 100644 index 695251e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Flight.Data.Seed; - -using System; -using System.Collections.Generic; -using System.Linq; -using Aircrafts.Models; -using Airports.Models; -using Airports.ValueObjects; -using Flight.Aircrafts.ValueObjects; -using Flights.Models; -using Flights.ValueObjects; -using MassTransit; -using Seats.Models; -using Seats.ValueObjects; -using AirportName = Airports.ValueObjects.Name; -using Name = Aircrafts.ValueObjects.Name; - -public static class InitialData -{ - public static List Airports { get; } - public static List Aircrafts { get; } - public static List Seats { get; } - public static List Flights { get; } - - - static InitialData() - { - Airports = new List - { - Airport.Create(AirportId.Of(new Guid("3c5c0000-97c6-fc34-a0cb-08db322230c8")), AirportName.Of("Lisbon International Airport"), Address.Of("LIS"), Code.Of("12988")), - Airport.Create(AirportId.Of(new Guid("3c5c0000-97c6-fc34-fc3c-08db322230c8")), AirportName.Of("Sao Paulo International Airport"), Address.Of("BRZ"), Code.Of("11200")) - }; - - Aircrafts = new List - { - Aircraft.Create(AircraftId.Of(new Guid("3c5c0000-97c6-fc34-fcd3-08db322230c8")), Name.Of("Boeing 737"), Model.Of("B737"), ManufacturingYear.Of(2005)), - Aircraft.Create(AircraftId.Of(new Guid("3c5c0000-97c6-fc34-2e04-08db322230c9")), Name.Of("Airbus 300"), Model.Of("A300"), ManufacturingYear.Of(2000)), - Aircraft.Create(AircraftId.Of(new Guid("3c5c0000-97c6-fc34-2e11-08db322230c9")), Name.Of("Airbus 320"), Model.Of("A320"), ManufacturingYear.Of(2003)) - }; - - - Flights = new List - { - Flight.Create(FlightId.Of(new Guid("3c5c0000-97c6-fc34-2eb9-08db322230c9")), FlightNumber.Of("BD467"), AircraftId.Of(Aircrafts.First().Id.Value), AirportId.Of( Airports.First().Id), DepartureDate.Of(new DateTime(2022, 1, 31, 12, 0, 0)), - ArriveDate.Of(new DateTime(2022, 1, 31, 14, 0, 0)), - AirportId.Of(Airports.Last().Id), DurationMinutes.Of(120m), - FlightDate.Of(new DateTime(2022, 1, 31, 13, 0, 0)), global::Flight.Flights.Enums.FlightStatus.Completed, - Price.Of(8000)) - }; - - Seats = new List - { - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of( "12A"), global::Flight.Seats.Enums.SeatType.Window, global::Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid)Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12B"), global::Flight.Seats.Enums.SeatType.Window, global::Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid)Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12C"), global::Flight.Seats.Enums.SeatType.Middle, global::Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12D"), global::Flight.Seats.Enums.SeatType.Middle, global::Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12E"), global::Flight.Seats.Enums.SeatType.Aisle, global::Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)), - Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12F"), global::Flight.Seats.Enums.SeatType.Aisle, global::Flight.Seats.Enums.SeatClass.Economy, FlightId.Of((Guid) Flights.First().Id)) - }; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/readme.md b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/readme.md deleted file mode 100644 index f47e679..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -dotnet ef migrations add initial --context FlightDbContext -o "Data\Migrations" -dotnet ef database update --context FlightDbContext diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/FlightEventMapper.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/FlightEventMapper.cs deleted file mode 100644 index 06249e0..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/FlightEventMapper.cs +++ /dev/null @@ -1,51 +0,0 @@ -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace Flight; - -using Aircrafts.Features.CreatingAircraft.V1; -using Aircrafts.ValueObjects; -using Airports.Features.CreatingAirport.V1; -using Flights.Features.CreatingFlight.V1; -using Flights.Features.DeletingFlight.V1; -using Flights.Features.UpdatingFlight.V1; -using Seats.Features.CreatingSeat.V1; -using Seats.Features.ReservingSeat.V1; - -// ref: https://www.ledjonbehluli.com/posts/domain_to_integration_event/ -public sealed class FlightEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - FlightCreatedDomainEvent e => new FlightCreated(e.Id), - FlightUpdatedDomainEvent e => new FlightUpdated(e.Id), - FlightDeletedDomainEvent e => new FlightDeleted(e.Id), - AirportCreatedDomainEvent e => new AirportCreated(e.Id), - AircraftCreatedDomainEvent e => new AircraftCreated(e.Id), - SeatCreatedDomainEvent e => new SeatCreated(e.Id), - SeatReservedDomainEvent e => new SeatReserved(e.Id), - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - FlightCreatedDomainEvent e => new CreateFlightMongo(e.Id, e.FlightNumber, e.AircraftId, e.DepartureDate, e.DepartureAirportId, - e.ArriveDate, e.ArriveAirportId, e.DurationMinutes, e.FlightDate, e.Status, e.Price, e.IsDeleted), - FlightUpdatedDomainEvent e => new UpdateFlightMongo(e.Id, e.FlightNumber, e.AircraftId, e.DepartureDate, e.DepartureAirportId, - e.ArriveDate, e.ArriveAirportId, e.DurationMinutes, e.FlightDate, e.Status, e.Price, e.IsDeleted), - FlightDeletedDomainEvent e => new DeleteFlightMongo(e.Id, e.FlightNumber, e.AircraftId, e.DepartureDate, e.DepartureAirportId, - e.ArriveDate, e.ArriveAirportId, e.DurationMinutes, e.FlightDate, e.Status, e.Price, e.IsDeleted), - AircraftCreatedDomainEvent e => new CreateAircraftMongo(e.Id, e.Name, e.Model, e.ManufacturingYear, e.IsDeleted), - AirportCreatedDomainEvent e => new CreateAirportMongo(e.Id, e.Name, e.Address, e.Code, e.IsDeleted), - SeatCreatedDomainEvent e => new CreateSeatMongo(e.Id, e.SeatNumber, e.Type, e.Class, e.FlightId, e.IsDeleted), - SeatReservedDomainEvent e => new ReserveSeatMongo(e.Id, e.SeatNumber, e.Type, e.Class, e.FlightId, e.IsDeleted), - _ => null - }; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/FlightRoot.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/FlightRoot.cs deleted file mode 100644 index 5fe2291..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/FlightRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Flight; - -public class FlightRoot -{ - -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs deleted file mode 100644 index 1da222e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System; - -namespace Flight.Flights.Dtos; -public record FlightDto(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price); diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Enums/FlightStatus.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Enums/FlightStatus.cs deleted file mode 100644 index 14de1d3..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Enums/FlightStatus.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Flight.Flights.Enums; - -public enum FlightStatus -{ - Unknown = 0, - Flying = 1, - Delay = 2, - Canceled = 3, - Completed = 4 -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs deleted file mode 100644 index 339a00d..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Flight.Flights.Exceptions; - -public class FlightAlreadyExistException : AppException -{ - public FlightAlreadyExistException(int? code = default) : base("Flight already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/FlightNotFountException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/FlightNotFountException.cs deleted file mode 100644 index 60a53e8..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/FlightNotFountException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Flight.Flights.Exceptions; - -public class FlightNotFountException : AppException -{ - public FlightNotFountException() : base("Flight not found!", HttpStatusCode.NotFound) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs deleted file mode 100644 index ae8163f..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidArriveDateException : DomainException -{ - public InvalidArriveDateException(DateTime arriveDate) - : base($"Arrive Date: '{arriveDate}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs deleted file mode 100644 index 913de9d..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidDepartureDateException : DomainException -{ - public InvalidDepartureDateException(DateTime departureDate) - : base($"Departure Date: '{departureDate}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDurationException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDurationException.cs deleted file mode 100644 index de172e0..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDurationException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidDurationException : DomainException -{ - public InvalidDurationException() - : base("Duration cannot be negative.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs deleted file mode 100644 index d40f476..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidFlightDateException : DomainException -{ - public InvalidFlightDateException(DateTime flightDate) - : base($"Flight Date: '{flightDate}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs deleted file mode 100644 index 7ef355d..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidFlightIdException : DomainException -{ - public InvalidFlightIdException(Guid flightId) - : base($"flightId: '{flightId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs deleted file mode 100644 index fdaf34c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidFlightNumberException : DomainException -{ - public InvalidFlightNumberException(string flightNumber) - : base($"Flight Number: '{flightNumber}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidPriceException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidPriceException.cs deleted file mode 100644 index 3a17496..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidPriceException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Flights.Exceptions; - -public class InvalidPriceException : DomainException -{ - public InvalidPriceException() - : base($"Price Cannot be negative.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs deleted file mode 100644 index e0a3d99..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs +++ /dev/null @@ -1,127 +0,0 @@ -namespace Flight.Flights.Features.CreatingFlight.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Aircrafts.ValueObjects; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using Flight.Airports.ValueObjects; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; -using ValueObjects; - -public record CreateFlight(string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, - decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, - decimal Price) : ICommand, IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateFlightResult(Guid Id); - -public record FlightCreatedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, - DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent; - -public record CreateFlightRequestDto(string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, - decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price); - -public record CreateFlightResponseDto(Guid Id); - -public class CreateFlightEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight", async (CreateFlightRequestDto request, - IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.CreatedAtRoute("GetFlightById", new { id = result.Id }, response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateFlight") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces(StatusCodes.Status201Created) - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Flight") - .WithDescription("Create Flight") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class CreateFlightValidator : AbstractValidator -{ - public CreateFlightValidator() - { - RuleFor(x => x.Price).GreaterThan(0).WithMessage("Price must be greater than 0"); - - RuleFor(x => x.Status).Must(p => (p.GetType().IsEnum && - p == Enums.FlightStatus.Flying) || - p == Enums.FlightStatus.Canceled || - p == Enums.FlightStatus.Delay || - p == Enums.FlightStatus.Completed) - .WithMessage("Status must be Flying, Delay, Canceled or Completed"); - - RuleFor(x => x.AircraftId).NotEmpty().WithMessage("AircraftId must be not empty"); - RuleFor(x => x.DepartureAirportId).NotEmpty().WithMessage("DepartureAirportId must be not empty"); - RuleFor(x => x.ArriveAirportId).NotEmpty().WithMessage("ArriveAirportId must be not empty"); - RuleFor(x => x.DurationMinutes).GreaterThan(0).WithMessage("DurationMinutes must be greater than 0"); - RuleFor(x => x.FlightDate).NotEmpty().WithMessage("FlightDate must be not empty"); - } -} - -internal class CreateFlightHandler : ICommandHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateFlightHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateFlight request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == request.Id, - cancellationToken); - - if (flight is not null) - { - throw new FlightAlreadyExistException(); - } - - var flightEntity = Models.Flight.Create(FlightId.Of(request.Id), FlightNumber.Of(request.FlightNumber), AircraftId.Of(request.AircraftId), - AirportId.Of(request.DepartureAirportId), DepartureDate.Of(request.DepartureDate), - ArriveDate.Of(request.ArriveDate), AirportId.Of(request.ArriveAirportId), DurationMinutes.Of(request.DurationMinutes), FlightDate.Of(request.FlightDate), request.Status, - Price.Of(request.Price)); - - var newFlight = (await _flightDbContext.Flights.AddAsync(flightEntity, cancellationToken)).Entity; - - return new CreateFlightResult(newFlight.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs deleted file mode 100644 index 8d283ab..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Flight.Flights.Features.CreatingFlight.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using Exceptions; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -public record CreateFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price, bool IsDeleted = false) : InternalCommand; - -internal class CreateFlightMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateFlightMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateFlightMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flightReadModel = _mapper.Map(request); - - var flight = await _flightReadDbContext.Flight.AsQueryable() - .FirstOrDefaultAsync(x => x.FlightId == flightReadModel.FlightId && !x.IsDeleted, cancellationToken); - - if (flight is not null) - { - throw new FlightAlreadyExistException(); - } - - await _flightReadDbContext.Flight.InsertOneAsync(flightReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs deleted file mode 100644 index 3f82d40..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs +++ /dev/null @@ -1,110 +0,0 @@ -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using Flight.Data; -using Flight.Flights.Exceptions; -using FluentValidation; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -namespace Flight.Flights.Features.DeletingFlight.V1; - -public record DeleteFlight(Guid Id) : ICommand, IInternalCommand; - -public record DeleteFlightResult(Guid Id); - -public record FlightDeletedDomainEvent( - Guid Id, - string FlightNumber, - Guid AircraftId, - DateTime DepartureDate, - Guid DepartureAirportId, - DateTime ArriveDate, - Guid ArriveAirportId, - decimal DurationMinutes, - DateTime FlightDate, - Enums.FlightStatus Status, - decimal Price, - bool IsDeleted -) : IDomainEvent; - -public class DeleteFlightEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapDelete( - $"{EndpointConfig.BaseApiPath}/flight/{{id}}", - async (Guid id, IMediator mediator, CancellationToken cancellationToken) => - { - await mediator.Send(new DeleteFlight(id), cancellationToken); - - return Results.NoContent(); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("DeleteFlight") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces(StatusCodes.Status204NoContent) - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Delete Flight") - .WithDescription("Delete Flight") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class DeleteFlightValidator : AbstractValidator -{ - public DeleteFlightValidator() - { - RuleFor(x => x.Id).NotEmpty(); - } -} - -internal class DeleteFlightHandler : ICommandHandler -{ - private readonly FlightDbContext _flightDbContext; - - public DeleteFlightHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle( - DeleteFlight request, - CancellationToken cancellationToken - ) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == request.Id, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - flight.Delete( - flight.Id, - flight.FlightNumber, - flight.AircraftId, - flight.DepartureAirportId, - flight.DepartureDate, - flight.ArriveDate, - flight.ArriveAirportId, - flight.DurationMinutes, - flight.FlightDate, - flight.Status, - flight.Price); - - var deleteFlight = _flightDbContext.Flights.Update(flight).Entity; - - return new DeleteFlightResult(deleteFlight.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs deleted file mode 100644 index caed0c0..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace Flight.Flights.Features.DeletingFlight.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using Exceptions; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -public record DeleteFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price, bool IsDeleted = false) : InternalCommand; - -internal class DeleteFlightMongoCommandHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public DeleteFlightMongoCommandHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(DeleteFlightMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flightReadModel = _mapper.Map(request); - - var flight = await _flightReadDbContext.Flight.AsQueryable() - .FirstOrDefaultAsync(x => x.FlightId == flightReadModel.FlightId && !x.IsDeleted, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - await _flightReadDbContext.Flight.UpdateOneAsync( - x => x.FlightId == flightReadModel.FlightId, - Builders.Update - .Set(x => x.IsDeleted, flightReadModel.IsDeleted), - cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs deleted file mode 100644 index 505dd7a..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Mapster; - -namespace Flight.Flights.Features; - -using CreatingFlight.V1; -using DeletingFlight.V1; -using MassTransit; -using Models; -using UpdatingFlight.V1; -using FlightDto = Dtos.FlightDto; - -public class FlightMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .ConstructUsing(x => new FlightDto(x.Id, x.FlightNumber, x.AircraftId, x.DepartureAirportId, - x.DepartureDate, - x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.Price)); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.FlightId, s => s.Id); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.FlightId, s => s.Id.Value); - - config.NewConfig() - .Map(d => d.Id, s => s.FlightId); - - config.NewConfig() - .Map(d => d.FlightId, s => s.Id); - - config.NewConfig() - .Map(d => d.FlightId, s => s.Id); - - config.NewConfig() - .ConstructUsing(x => new CreateFlight(x.FlightNumber, x.AircraftId, x.DepartureAirportId, - x.DepartureDate, x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.Price)); - - config.NewConfig() - .ConstructUsing(x => new UpdateFlight(x.Id, x.FlightNumber, x.AircraftId, x.DepartureAirportId, x.DepartureDate, - x.ArriveDate, x.ArriveAirportId, x.DurationMinutes, x.FlightDate, x.Status, x.IsDeleted, x.Price)); - - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs deleted file mode 100644 index 73d435e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs +++ /dev/null @@ -1,91 +0,0 @@ -using MongoDB.Driver.Linq; - -namespace Flight.Flights.Features.GettingAvailableFlights.V1; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Caching; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Data; -using Dtos; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; - -public record GetAvailableFlights : IQuery, ICacheRequest -{ - public string CacheKey => "GetAvailableFlights"; - public DateTime? AbsoluteExpirationRelativeToNow => DateTime.Now.AddHours(1); -} - -public record GetAvailableFlightsResult(IEnumerable FlightDtos); - -public record GetAvailableFlightsResponseDto(IEnumerable FlightDtos); - -public class GetAvailableFlightsEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/flight/get-available-flights", - async (IMediator mediator, CancellationToken cancellationToken) => - { - var result = await mediator.Send(new GetAvailableFlights(), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetAvailableFlights") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Available Flights") - .WithDescription("Get Available Flights") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -internal class GetAvailableFlightsHandler : IQueryHandler -{ - private readonly IMapper _mapper; - private readonly FlightReadDbContext _flightReadDbContext; - - public GetAvailableFlightsHandler(IMapper mapper, FlightReadDbContext flightReadDbContext) - { - _mapper = mapper; - _flightReadDbContext = flightReadDbContext; - } - - public async Task Handle(GetAvailableFlights request, - CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = (await _flightReadDbContext.Flight.AsQueryable().ToListAsync(cancellationToken)) - .Where(x => !x.IsDeleted); - - if (!flight.Any()) - { - throw new FlightNotFountException(); - } - - var flightDtos = _mapper.Map>(flight); - - return new GetAvailableFlightsResult(flightDtos); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs deleted file mode 100644 index 5f01b14..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace Flight.Flights.Features.GettingFlightById.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Data; -using Dtos; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -public record GetFlightById(Guid Id) : IQuery; - -public record GetFlightByIdResult(FlightDto FlightDto); - -public record GetFlightByIdResponseDto(FlightDto FlightDto); - -public class GetFlightByIdEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/flight/{{id}}", - async (Guid id, IMediator mediator, IMapper mapper, CancellationToken cancellationToken) => - { - var result = await mediator.Send(new GetFlightById(id), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetFlightById") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Flight By Id") - .WithDescription("Get Flight By Id") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class GetFlightByIdValidator : AbstractValidator -{ - public GetFlightByIdValidator() - { - RuleFor(x => x.Id).NotNull().WithMessage("Id is required!"); - } -} - -internal class GetFlightByIdHandler : IQueryHandler -{ - private readonly IMapper _mapper; - private readonly FlightReadDbContext _flightReadDbContext; - - public GetFlightByIdHandler(IMapper mapper, FlightReadDbContext flightReadDbContext) - { - _mapper = mapper; - _flightReadDbContext = flightReadDbContext; - } - - public async Task Handle(GetFlightById request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightReadDbContext.Flight.AsQueryable().SingleOrDefaultAsync( - x => x.FlightId == request.Id && - !x.IsDeleted, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - var flightDto = _mapper.Map(flight); - - return new GetFlightByIdResult(flightDto); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs deleted file mode 100644 index 242f951..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs +++ /dev/null @@ -1,125 +0,0 @@ -namespace Flight.Flights.Features.UpdatingFlight.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Aircrafts.ValueObjects; -using Ardalis.GuardClauses; -using BuildingBlocks.Caching; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using Flight.Airports.ValueObjects; -using Flight.Flights.Features.CreatingFlight.V1; -using FluentValidation; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; -using ValueObjects; - -public record UpdateFlight(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, bool IsDeleted, decimal Price) : ICommand, IInternalCommand, - IInvalidateCacheRequest -{ - public string CacheKey => "GetAvailableFlights"; -} - -public record UpdateFlightResult(Guid Id); - -public record FlightUpdatedDomainEvent(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, - DateTime FlightDate, Enums.FlightStatus Status, decimal Price, bool IsDeleted) : IDomainEvent; - -public record UpdateFlightRequestDto(Guid Id, string FlightNumber, Guid AircraftId, Guid DepartureAirportId, - DateTime DepartureDate, DateTime ArriveDate, - Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, Enums.FlightStatus Status, decimal Price, - bool IsDeleted); - -public class UpdateFlightEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPut($"{EndpointConfig.BaseApiPath}/flight", async (UpdateFlightRequestDto request, - IMediator mediator, - IMapper mapper, CancellationToken cancellationToken) => - { - var command = mapper.Map(request); - - await mediator.Send(command, cancellationToken); - - return Results.NoContent(); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("UpdateFlight") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces(StatusCodes.Status204NoContent) - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Update Flight") - .WithDescription("Update Flight") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class UpdateFlightValidator : AbstractValidator -{ - public UpdateFlightValidator() - { - RuleFor(x => x.Price).GreaterThan(0).WithMessage("Price must be greater than 0"); - - RuleFor(x => x.Status).Must(p => (p.GetType().IsEnum && - p == Enums.FlightStatus.Flying) || - p == Enums.FlightStatus.Canceled || - p == Enums.FlightStatus.Delay || - p == Enums.FlightStatus.Completed) - .WithMessage("Status must be Flying, Delay, Canceled or Completed"); - - RuleFor(x => x.AircraftId).NotEmpty().WithMessage("AircraftId must be not empty"); - RuleFor(x => x.DepartureAirportId).NotEmpty().WithMessage("DepartureAirportId must be not empty"); - RuleFor(x => x.ArriveAirportId).NotEmpty().WithMessage("ArriveAirportId must be not empty"); - RuleFor(x => x.DurationMinutes).GreaterThan(0).WithMessage("DurationMinutes must be greater than 0"); - RuleFor(x => x.FlightDate).NotEmpty().WithMessage("FlightDate must be not empty"); - } -} - -internal class UpdateFlightHandler : ICommandHandler -{ - private readonly FlightDbContext _flightDbContext; - - public UpdateFlightHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(UpdateFlight request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flight = await _flightDbContext.Flights.SingleOrDefaultAsync(x => x.Id == request.Id, - cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - - flight.Update(FlightId.Of(request.Id), FlightNumber.Of(request.FlightNumber), AircraftId.Of(request.AircraftId), AirportId.Of(request.DepartureAirportId), - DepartureDate.Of(request.DepartureDate), - ArriveDate.Of(request.ArriveDate), AirportId.Of(request.ArriveAirportId), DurationMinutes.Of(request.DurationMinutes), FlightDate.Of(request.FlightDate), request.Status, - Price.Of(request.Price), request.IsDeleted); - - var updateFlight = _flightDbContext.Flights.Update(flight).Entity; - - return new UpdateFlightResult(updateFlight.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs deleted file mode 100644 index 523bfe4..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs +++ /dev/null @@ -1,67 +0,0 @@ -namespace Flight.Flights.Features.UpdatingFlight.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using Exceptions; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -public record UpdateFlightMongo(Guid Id, string FlightNumber, Guid AircraftId, DateTime DepartureDate, - Guid DepartureAirportId, DateTime ArriveDate, Guid ArriveAirportId, decimal DurationMinutes, DateTime FlightDate, - Enums.FlightStatus Status, decimal Price, bool IsDeleted = false) : InternalCommand; - - -internal class UpdateFlightMongoCommandHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public UpdateFlightMongoCommandHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(UpdateFlightMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var flightReadModel = _mapper.Map(request); - - var flight = await _flightReadDbContext.Flight.AsQueryable() - .FirstOrDefaultAsync(x => x.FlightId == flightReadModel.FlightId && !x.IsDeleted, cancellationToken); - - if (flight is null) - { - throw new FlightNotFountException(); - } - - await _flightReadDbContext.Flight.UpdateOneAsync( - x => x.FlightId == flightReadModel.FlightId, - Builders.Update - .Set(x => x.Price, flightReadModel.Price) - .Set(x => x.ArriveDate, flightReadModel.ArriveDate) - .Set(x => x.AircraftId, flightReadModel.AircraftId) - .Set(x => x.DurationMinutes, flightReadModel.DurationMinutes) - .Set(x => x.DepartureDate, flightReadModel.DepartureDate) - .Set(x => x.FlightDate, flightReadModel.FlightDate) - .Set(x => x.FlightNumber, flightReadModel.FlightNumber) - .Set(x => x.IsDeleted, flightReadModel.IsDeleted) - .Set(x => x.Status, flightReadModel.Status) - .Set(x => x.ArriveAirportId, flightReadModel.ArriveAirportId) - .Set(x => x.DepartureAirportId, flightReadModel.DepartureAirportId), - cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Models/Flight.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Models/Flight.cs deleted file mode 100644 index 4b5b86c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Models/Flight.cs +++ /dev/null @@ -1,102 +0,0 @@ -using BuildingBlocks.Core.Model; - -namespace Flight.Flights.Models; - -using Aircrafts.ValueObjects; -using Airports.ValueObjects; -using Features.CreatingFlight.V1; -using Features.DeletingFlight.V1; -using Features.UpdatingFlight.V1; -using ValueObjects; - -public record Flight : Aggregate -{ - public FlightNumber FlightNumber { get; private set; } = default!; - public AircraftId AircraftId { get; private set; } = default!; - public AirportId DepartureAirportId { get; private set; } = default!; - public AirportId ArriveAirportId { get; private set; } = default!; - public DurationMinutes DurationMinutes { get; private set; } = default!; - public Enums.FlightStatus Status { get; private set; } - public Price Price { get; private set; } = default!; - public ArriveDate ArriveDate { get; private set; } = default!; - public DepartureDate DepartureDate { get; private set; } = default!; - public FlightDate FlightDate { get; private set; } = default!; - - public static Flight Create(FlightId id, FlightNumber flightNumber, AircraftId aircraftId, - AirportId departureAirportId, DepartureDate departureDate, ArriveDate arriveDate, - AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status, - Price price, bool isDeleted = false) - { - var flight = new Flight - { - Id = id, - FlightNumber = flightNumber, - AircraftId = aircraftId, - DepartureAirportId = departureAirportId, - DepartureDate = departureDate, - ArriveDate = arriveDate, - ArriveAirportId = arriveAirportId, - DurationMinutes = durationMinutes, - FlightDate = flightDate, - Status = status, - Price = price, - IsDeleted = isDeleted, - }; - - var @event = new FlightCreatedDomainEvent(flight.Id, flight.FlightNumber, flight.AircraftId, - flight.DepartureDate, flight.DepartureAirportId, - flight.ArriveDate, flight.ArriveAirportId, flight.DurationMinutes, flight.FlightDate, flight.Status, - flight.Price, flight.IsDeleted); - - flight.AddDomainEvent(@event); - - return flight; - } - - - public void Update(FlightId id, FlightNumber flightNumber, AircraftId aircraftId, - AirportId departureAirportId, DepartureDate departureDate, ArriveDate arriveDate, - AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status, - Price price, bool isDeleted = false) - { - this.FlightNumber = flightNumber; - this.AircraftId = aircraftId; - this.DepartureAirportId = departureAirportId; - this.DepartureDate = departureDate; - this.ArriveDate = arriveDate; - this.ArriveAirportId = arriveAirportId; - this.DurationMinutes = durationMinutes; - this.FlightDate = flightDate; - this.Status = status; - this.Price = price; - this.IsDeleted = isDeleted; - - var @event = new FlightUpdatedDomainEvent(id, flightNumber, aircraftId, departureDate, departureAirportId, - arriveDate, arriveAirportId, durationMinutes, flightDate, status, price, isDeleted); - - AddDomainEvent(@event); - } - - public void Delete(FlightId id, FlightNumber flightNumber, AircraftId aircraftId, - AirportId departureAirportId, DepartureDate departureDate, ArriveDate arriveDate, - AirportId arriveAirportId, DurationMinutes durationMinutes, FlightDate flightDate, Enums.FlightStatus status, - Price price, bool isDeleted = true) - { - FlightNumber = flightNumber; - AircraftId = aircraftId; - DepartureAirportId = departureAirportId; - DepartureDate = departureDate; - ArriveDate = arriveDate; - ArriveAirportId = arriveAirportId; - DurationMinutes = durationMinutes; - FlightDate = flightDate; - Status = status; - Price = price; - IsDeleted = isDeleted; - - var @event = new FlightDeletedDomainEvent(id, flightNumber, aircraftId, departureDate, departureAirportId, - arriveDate, arriveAirportId, durationMinutes, flightDate, status, price, isDeleted); - - AddDomainEvent(@event); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs deleted file mode 100644 index 74eec28..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Flight.Flights.Models; - -using System; - -public class FlightReadModel -{ - public required Guid Id { get; init; } - public required Guid FlightId { get; init; } - public required string FlightNumber { get; init; } - public required Guid AircraftId { get; init; } - public required DateTime DepartureDate { get; init; } - public required Guid DepartureAirportId { get; init; } - public required DateTime ArriveDate { get; init; } - public required Guid ArriveAirportId { get; init; } - public required decimal DurationMinutes { get; init; } - public required DateTime FlightDate { get; init; } - public required Enums.FlightStatus Status { get; init; } - public required decimal Price { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/ArriveDate.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/ArriveDate.cs deleted file mode 100644 index 72996c5..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/ArriveDate.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Flights.ValueObjects; -using System; -using Flight.Flights.Exceptions; - -public record ArriveDate -{ - public DateTime Value { get; } - - private ArriveDate(DateTime value) - { - Value = value; - } - - public static ArriveDate Of(DateTime value) - { - if (value == default) - { - throw new InvalidArriveDateException(value); - } - - return new ArriveDate(value); - } - - public static implicit operator DateTime(ArriveDate arriveDate) - { - return arriveDate.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/DepartureDate.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/DepartureDate.cs deleted file mode 100644 index a24e137..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/DepartureDate.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Flight.Flights.ValueObjects; -using System; -using Flight.Flights.Exceptions; - - -public record DepartureDate -{ - public DateTime Value { get; } - - private DepartureDate(DateTime value) - { - Value = value; - } - - public static DepartureDate Of(DateTime value) - { - if (value == default) - { - throw new InvalidDepartureDateException(value); - } - - return new DepartureDate(value); - } - - public static implicit operator DateTime(DepartureDate departureDate) - { - return departureDate.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/DurationMinutes.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/DurationMinutes.cs deleted file mode 100644 index 292b345..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/DurationMinutes.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Flight.Flights.ValueObjects; - -using Exceptions; - -public class DurationMinutes -{ - public decimal Value { get; } - - private DurationMinutes(decimal value) - { - Value = value; - } - - public static DurationMinutes Of(decimal value) - { - if (value < 0) - { - throw new InvalidDurationException(); - } - - return new DurationMinutes(value); - } - - public static implicit operator decimal(DurationMinutes duration) - { - return duration.Value; - } - - public static explicit operator DurationMinutes(decimal value) - { - return new DurationMinutes(value); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightDate.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightDate.cs deleted file mode 100644 index 0da2949..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightDate.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Flights.ValueObjects; -using System; -using Flight.Flights.Exceptions; - -public record FlightDate -{ - public DateTime Value { get; } - - private FlightDate(DateTime value) - { - Value = value; - } - - public static FlightDate Of(DateTime value) - { - if (value == default) - { - throw new InvalidFlightDateException(value); - } - - return new FlightDate(value); - } - - public static implicit operator DateTime(FlightDate flightDate) - { - return flightDate.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightId.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightId.cs deleted file mode 100644 index c3e5a46..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightId.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Flight.Flights.ValueObjects; - -using System; -using Exceptions; - -public record FlightId -{ - public Guid Value { get; } - - private FlightId(Guid value) - { - Value = value; - } - - public static FlightId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidFlightIdException(value); - } - - return new FlightId(value); - } - - public static implicit operator Guid(FlightId flightId) - { - return flightId.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightNumber.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightNumber.cs deleted file mode 100644 index b709d7d..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightNumber.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Flights.ValueObjects; - -using Exceptions; - -public record FlightNumber -{ - public string Value { get; } - - private FlightNumber(string value) - { - Value = value; - } - - public static FlightNumber Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidFlightNumberException(value); - } - - return new FlightNumber(value); - } - - public static implicit operator string(FlightNumber flightNumber) - { - return flightNumber.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/Price.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/Price.cs deleted file mode 100644 index d2fa93e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flights/ValueObjects/Price.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Flights.ValueObjects; - -using Flight.Flights.Exceptions; - -public class Price -{ - public decimal Value { get; } - - private Price(decimal value) - { - Value = value; - } - - public static Price Of(decimal value) - { - if (value < 0) - { - throw new InvalidPriceException(); - } - - return new Price(value); - } - - public static implicit operator decimal(Price price) - { - return price.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto b/3-microservices-architecture-style/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto deleted file mode 100644 index aba77c4..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto +++ /dev/null @@ -1,85 +0,0 @@ -syntax = "proto3"; - -package flight; -import "google/protobuf/timestamp.proto"; - -service FlightGrpcService { - - rpc GetById (GetByIdRequest) returns (GetFlightByIdResult); - rpc GetAvailableSeats (GetAvailableSeatsRequest) returns (GetAvailableSeatsResult); - rpc ReserveSeat (ReserveSeatRequest) returns (ReserveSeatResult); -} - -message GetByIdRequest { - string Id = 1; -} - -message GetFlightByIdResult{ - FlightResponse FlightDto = 1; -} - -message GetAvailableSeatsResult{ -repeated SeatDtoResponse SeatDtos = 1; -} - -message ReserveSeatResult{ - string Id = 1; -} - -message FlightResponse { - string Id = 1; - string FlightNumber = 2; - string AircraftId = 3; - string DepartureAirportId = 4; - google.protobuf.Timestamp DepartureDate = 5; - google.protobuf.Timestamp ArriveDate = 6; - string ArriveAirportId = 7; - double DurationMinutes = 8; - google.protobuf.Timestamp FlightDate = 9; - FlightStatus Status = 10; - double Price = 11; - string FlightId = 12; -} - -message GetAvailableSeatsRequest { - string FlightId = 1; -} - -message SeatDtoResponse { - string Id = 1; - string SeatNumber = 2; - SeatType Type = 3; - SeatClass Class = 4; - string FlightId = 5; -} - - -message ReserveSeatRequest { - string FlightId = 1; - string SeatNumber = 2; -} - - - enum FlightStatus { - FLIGHT_STATUS_UNKNOWN = 0; - FLIGHT_STATUS_FLYING = 1; - FLIGHT_STATUS_DELAY = 2; - FLIGHT_STATUS_CANCELED = 3; - FLIGHT_STATUS_COMPLETED = 4; - } - - - enum SeatType { - SEAT_TYPE_UNKNOWN = 0; - SEAT_TYPE_WINDOW = 1; - SEAT_TYPE_MIDDLE = 2; - SEAT_TYPE_AISLE = 3; - } - - - enum SeatClass { - SEAT_CLASS_UNKNOWN = 0; - SEAT_CLASS_FIRST_CLASS = 1; - SEAT_CLASS_BUSINESS = 2; - SEAT_CLASS_ECONOMY = 3; - } diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs deleted file mode 100644 index f55dc1e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Threading.Tasks; -using Grpc.Core; -using Mapster; -using MediatR; - -namespace Flight.GrpcServer.Services; - -using System; -using Flights.Features.GettingFlightById.V1; -using Seats.Features.GettingAvailableSeats.V1; -using Seats.Features.ReservingSeat.V1; -using GetAvailableSeatsResult = GetAvailableSeatsResult; -using GetFlightByIdResult = GetFlightByIdResult; -using ReserveSeatResult = ReserveSeatResult; - -public class FlightGrpcServices : FlightGrpcService.FlightGrpcServiceBase -{ - private readonly IMediator _mediator; - - public FlightGrpcServices(IMediator mediator) - { - _mediator = mediator; - } - - public override async Task GetById(GetByIdRequest request, ServerCallContext context) - { - var result = await _mediator.Send(new GetFlightById(new Guid(request.Id))); - return result.Adapt(); - } - - public override async Task GetAvailableSeats(GetAvailableSeatsRequest request, ServerCallContext context) - { - var result = new GetAvailableSeatsResult(); - - var availableSeats = await _mediator.Send(new GetAvailableSeats(new Guid(request.FlightId))); - - if (availableSeats?.SeatDtos == null) - { - return result; - } - - foreach (var availableSeat in availableSeats.SeatDtos) - { - result.SeatDtos.Add(availableSeat.Adapt()); - } - - return result; - } - - public override async Task ReserveSeat(ReserveSeatRequest request, ServerCallContext context) - { - var result = await _mediator.Send(new ReserveSeat(new Guid(request.FlightId), request.SeatNumber)); - return result.Adapt(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs deleted file mode 100644 index 0547616..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Flight.Seats.Dtos; - -using System; - -public record SeatDto(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId); diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Enums/SeatClass.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Enums/SeatClass.cs deleted file mode 100644 index ad49617..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Enums/SeatClass.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Flight.Seats.Enums; - -public enum SeatClass -{ - Unknown = 0, - FirstClass, - Business, - Economy -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Enums/SeatType.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Enums/SeatType.cs deleted file mode 100644 index 0bd0684..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Enums/SeatType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Flight.Seats.Enums; - -public enum SeatType -{ - Unknown = 0, - Window, - Middle, - Aisle -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/AllSeatsFullException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/AllSeatsFullException.cs deleted file mode 100644 index 0f1ad8f..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/AllSeatsFullException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using BuildingBlocks.Exception; - -namespace Flight.Seats.Exceptions; - -public class AllSeatsFullException : AppException -{ - public AllSeatsFullException() : base("All seats are full!") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs deleted file mode 100644 index 57c8dc8..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Seats.Exceptions; - -public class InvalidSeatIdException : DomainException -{ - public InvalidSeatIdException(Guid seatId) - : base($"seatId: '{seatId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs deleted file mode 100644 index 7252c8c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Flight.Seats.Exceptions; - -public class InvalidSeatNumberException : DomainException -{ - public InvalidSeatNumberException() : base("SeatNumber Cannot be null or negative") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs deleted file mode 100644 index 015044b..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Flight.Seats.Exceptions; - -public class SeatAlreadyExistException : AppException -{ - public SeatAlreadyExistException(int? code = default) : base("Seat already exist!", HttpStatusCode.Conflict, code) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs deleted file mode 100644 index 8c15ce6..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using BuildingBlocks.Exception; - -namespace Flight.Seats.Exceptions; - -public class SeatNumberIncorrectException : AppException -{ - public SeatNumberIncorrectException() : base("Seat number is incorrect!") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs deleted file mode 100644 index 1ab80ff..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs +++ /dev/null @@ -1,113 +0,0 @@ -namespace Flight.Seats.Features.CreatingSeat.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using Flights.ValueObjects; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MassTransit; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; -using Models; -using ValueObjects; - -public record CreateSeat - (string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId) : ICommand, - IInternalCommand -{ - public Guid Id { get; init; } = NewId.NextGuid(); -} - -public record CreateSeatResult(Guid Id); - -public record SeatCreatedDomainEvent(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, - Guid FlightId, bool IsDeleted) : IDomainEvent; - -public record CreateSeatRequestDto(string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, Guid FlightId); - -public record CreateSeatResponseDto(Guid Id); - -public class CreateSeatEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/seat", CreateSeat) - .RequireAuthorization(nameof(ApiScope)) - .WithName("CreateSeat") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Create Seat") - .WithDescription("Create Seat") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } - - private async Task CreateSeat(CreateSeatRequestDto request, IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - } -} - -public class CreateSeatValidator : AbstractValidator -{ - public CreateSeatValidator() - { - RuleFor(x => x.SeatNumber).NotEmpty().WithMessage("SeatNumber is required"); - RuleFor(x => x.FlightId).NotEmpty().WithMessage("FlightId is required"); - RuleFor(x => x.Class).Must(p => (p.GetType().IsEnum && - p == Enums.SeatClass.FirstClass) || - p == Enums.SeatClass.Business || - p == Enums.SeatClass.Economy) - .WithMessage("Status must be FirstClass, Business or Economy"); - } -} - -internal class CreateSeatCommandHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public CreateSeatCommandHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(CreateSeat command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var seat = await _flightDbContext.Seats.SingleOrDefaultAsync(x => x.Id == command.Id, cancellationToken); - - if (seat is not null) - { - throw new SeatAlreadyExistException(); - } - - var seatEntity = Seat.Create(SeatId.Of(command.Id), SeatNumber.Of(command.SeatNumber), command.Type, command.Class, FlightId.Of(command.FlightId)); - - var newSeat = (await _flightDbContext.Seats.AddAsync(seatEntity, cancellationToken)).Entity; - - return new CreateSeatResult(newSeat.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs deleted file mode 100644 index fedbbfc..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace Flight.Seats.Features.CreatingSeat.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using Exceptions; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -public record CreateSeatMongo(Guid Id, string SeatNumber, Enums.SeatType Type, - Enums.SeatClass Class, Guid FlightId, bool IsDeleted = false) : InternalCommand; - -internal class CreateSeatMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public CreateSeatMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CreateSeatMongo request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var seatReadModel = _mapper.Map(request); - - var seat = await _flightReadDbContext.Seat.AsQueryable() - .FirstOrDefaultAsync(x => x.SeatId == seatReadModel.SeatId && - !x.IsDeleted, cancellationToken); - - if (seat is not null) - { - throw new SeatAlreadyExistException(); - } - - await _flightReadDbContext.Seat.InsertOneAsync(seatReadModel, cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs deleted file mode 100644 index 2470176..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs +++ /dev/null @@ -1,96 +0,0 @@ -using MongoDB.Driver.Linq; - -namespace Flight.Seats.Features.GettingAvailableSeats.V1; - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Data; -using Dtos; -using Duende.IdentityServer.EntityFramework.Entities; -using Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; - -public record GetAvailableSeats(Guid FlightId) : IQuery; - -public record GetAvailableSeatsResult(IEnumerable SeatDtos); - -public record GetAvailableSeatsResponseDto(IEnumerable SeatDtos); - -public class GetAvailableSeatsEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/flight/get-available-seats/{{id}}", GetAvailableSeats) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetAvailableSeats") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Available Seats") - .WithDescription("Get Available Seats") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } - - private async Task GetAvailableSeats(Guid id, IMediator mediator, CancellationToken cancellationToken) - { - var result = await mediator.Send(new GetAvailableSeats(id), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - } -} - -public class GetAvailableSeatsValidator : AbstractValidator -{ - public GetAvailableSeatsValidator() - { - RuleFor(x => x.FlightId).NotNull().WithMessage("FlightId is required!"); - } -} - -internal class GetAvailableSeatsQueryHandler : IRequestHandler -{ - private readonly IMapper _mapper; - private readonly FlightReadDbContext _flightReadDbContext; - - public GetAvailableSeatsQueryHandler(IMapper mapper, FlightReadDbContext flightReadDbContext) - { - _mapper = mapper; - _flightReadDbContext = flightReadDbContext; - } - - - public async Task Handle(GetAvailableSeats query, CancellationToken cancellationToken) - { - Guard.Against.Null(query, nameof(query)); - - var seats = (await _flightReadDbContext.Seat.AsQueryable().ToListAsync(cancellationToken)) - .Where(x => x.FlightId == query.FlightId && !x.IsDeleted); - - if (!seats.Any()) - { - throw new AllSeatsFullException(); - } - - var seatDtos = _mapper.Map>(seats); - - return new GetAvailableSeatsResult(seatDtos); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs deleted file mode 100644 index 4123393..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs +++ /dev/null @@ -1,101 +0,0 @@ -namespace Flight.Seats.Features.ReservingSeat.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using Flight.Data; -using Flight.Seats.Exceptions; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using Microsoft.EntityFrameworkCore; - -public record ReserveSeat(Guid FlightId, string SeatNumber) : ICommand, IInternalCommand; - -public record ReserveSeatResult(Guid Id); - -public record SeatReservedDomainEvent(Guid Id, string SeatNumber, Enums.SeatType Type, Enums.SeatClass Class, - Guid FlightId, bool IsDeleted) : IDomainEvent; - -public record ReserveSeatRequestDto(Guid FlightId, string SeatNumber); - -public record ReserveSeatResponseDto(Guid Id); - -public class ReserveSeatEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapPost($"{EndpointConfig.BaseApiPath}/flight/reserve-seat", ReserveSeat) - .RequireAuthorization(nameof(ApiScope)) - .WithName("ReserveSeat") - .WithApiVersionSet(builder.NewApiVersionSet("Flight").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Reserve Seat") - .WithDescription("Reserve Seat") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } - - private async Task ReserveSeat(ReserveSeatRequestDto request, IMediator mediator, IMapper mapper, - CancellationToken cancellationToken) - { - var command = mapper.Map(request); - - var result = await mediator.Send(command, cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - } -} - -public class ReserveSeatValidator : AbstractValidator -{ - public ReserveSeatValidator() - { - RuleFor(x => x.FlightId).NotEmpty().WithMessage("FlightId must not be empty"); - RuleFor(x => x.SeatNumber).NotEmpty().WithMessage("SeatNumber must not be empty"); - } -} - -internal class ReserveSeatCommandHandler : IRequestHandler -{ - private readonly FlightDbContext _flightDbContext; - - public ReserveSeatCommandHandler(FlightDbContext flightDbContext) - { - _flightDbContext = flightDbContext; - } - - public async Task Handle(ReserveSeat command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var seat = await _flightDbContext.Seats.SingleOrDefaultAsync( - x => x.SeatNumber.Value == command.SeatNumber && - x.FlightId == command.FlightId, cancellationToken); - - if (seat is null) - { - throw new SeatNumberIncorrectException(); - } - - seat.ReserveSeat(); - - var updatedSeat = _flightDbContext.Seats.Update(seat).Entity; - - return new ReserveSeatResult(updatedSeat.Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs deleted file mode 100644 index a99e438..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace Flight.Seats.Features.ReservingSeat.V1; - -using System; -using System.Threading; -using System.Threading.Tasks; -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Flight.Data; -using Flight.Seats.Models; -using MapsterMapper; -using MediatR; -using MongoDB.Driver; - -public record ReserveSeatMongo(Guid Id, string SeatNumber, Enums.SeatType Type, - Enums.SeatClass Class, Guid FlightId, bool IsDeleted = false) : InternalCommand; - -internal class ReserveSeatMongoHandler : ICommandHandler -{ - private readonly FlightReadDbContext _flightReadDbContext; - private readonly IMapper _mapper; - - public ReserveSeatMongoHandler( - FlightReadDbContext flightReadDbContext, - IMapper mapper) - { - _flightReadDbContext = flightReadDbContext; - _mapper = mapper; - } - - public async Task Handle(ReserveSeatMongo command, CancellationToken cancellationToken) - { - Guard.Against.Null(command, nameof(command)); - - var seatReadModel = _mapper.Map(command); - - await _flightReadDbContext.Seat.UpdateOneAsync( - x => x.SeatId == seatReadModel.SeatId, - Builders.Update - .Set(x => x.IsDeleted, seatReadModel.IsDeleted), - cancellationToken: cancellationToken); - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs deleted file mode 100644 index 65f24fa..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Flight.Seats.Dtos; -using Flight.Seats.Models; -using Mapster; - -namespace Flight.Seats.Features; - -using CreatingSeat.V1; -using MassTransit; -using ReservingSeat.V1; - -public class SeatMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .ConstructUsing(x => new SeatDto(x.Id.Value, x.SeatNumber.Value, x.Type, x.Class, x.FlightId.Value)); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.SeatId, s => s.Id); - - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.SeatId, s => s.Id.Value); - - config.NewConfig() - .Map(d => d.SeatId, s => s.Id); - - config.NewConfig() - .ConstructUsing(x => new CreateSeat(x.SeatNumber, x.Type, x.Class, x.FlightId)); - - config.NewConfig() - .ConstructUsing(x => new ReserveSeat(x.FlightId, x.SeatNumber)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Models/Seat.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Models/Seat.cs deleted file mode 100644 index ee817d9..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Models/Seat.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using BuildingBlocks.Core.Model; - -namespace Flight.Seats.Models; - -using Features.CreatingSeat.V1; -using Features.ReservingSeat.V1; -using Flight.Flights.ValueObjects; -using ValueObjects; - -public record Seat : Aggregate -{ - public SeatNumber SeatNumber { get; private set; } = default!; - public Enums.SeatType Type { get; private set; } - public Enums.SeatClass Class { get; private set; } - public FlightId FlightId { get; private set; } = default!; - - public static Seat Create(SeatId id, SeatNumber seatNumber, Enums.SeatType type, Enums.SeatClass @class, - FlightId flightId, - bool isDeleted = false) - { - var seat = new Seat() - { - Id = id, - Class = @class, - Type = type, - SeatNumber = seatNumber, - FlightId = flightId, - IsDeleted = isDeleted - }; - - var @event = new SeatCreatedDomainEvent( - seat.Id, - seat.SeatNumber, - seat.Type, - seat.Class, - seat.FlightId, - isDeleted); - - seat.AddDomainEvent(@event); - - return seat; - } - - public void ReserveSeat() - { - this.IsDeleted = true; - this.LastModified = DateTime.Now; - - var @event = new SeatReservedDomainEvent( - this.Id, - this.SeatNumber, - this.Type, - this.Class, - this.FlightId, - this.IsDeleted); - - this.AddDomainEvent(@event); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Models/SeatReadModel.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Models/SeatReadModel.cs deleted file mode 100644 index 536b62f..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/Models/SeatReadModel.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Flight.Seats.Models; - -using System; - -public class SeatReadModel -{ - public required Guid Id { get; init; } - public required Guid SeatId { get; init; } - public required string SeatNumber { get; init; } - public required Enums.SeatType Type { get; init; } - public required Enums.SeatClass Class { get; init; } - public required Guid FlightId { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatId.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatId.cs deleted file mode 100644 index 4196b6e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatId.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Flight.Seats.ValueObjects; - -using System; -using Exceptions; - -public record SeatId -{ - public Guid Value { get; } - - private SeatId(Guid value) - { - Value = value; - } - - public static SeatId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidSeatIdException(value); - } - - return new SeatId(value); - } - - public static implicit operator Guid(SeatId seatId) - { - return seatId.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatNumber.cs b/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatNumber.cs deleted file mode 100644 index e6d4b2e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatNumber.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Flight.Seats.ValueObjects; - -using Exceptions; - -public record SeatNumber -{ - public string Value { get; } - - private SeatNumber(string value) - { - Value = value; - } - - public static SeatNumber Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidSeatNumberException(); - } - - return new SeatNumber(value); - } - - public static implicit operator string(SeatNumber seatNumber) - { - return seatNumber.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightCommand.cs deleted file mode 100644 index 83df003..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightCommand.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AutoBogus; -using Flight.Flights.Enums; - -namespace EndToEnd.Test.Fakes; - -using global::Flight.Data.Seed; -using global::Flight.Flights.Features.CreatingFlight.V1; -using MassTransit; - -public sealed class FakeCreateFlightCommand : AutoFaker -{ - public FakeCreateFlightCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightNumber, r => "12FF"); - RuleFor(r => r.DepartureAirportId, _ => InitialData.Airports.First().Id); - RuleFor(r => r.ArriveAirportId, _ => InitialData.Airports.Last().Id); - RuleFor(r => r.Status, _ => FlightStatus.Flying); - RuleFor(r => r.AircraftId, _ => InitialData.Aircrafts.First().Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightMongoCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightMongoCommand.cs deleted file mode 100644 index 603c455..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightMongoCommand.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace EndToEnd.Test.Fakes; - -using AutoBogus; -using global::Flight.Data.Seed; -using global::Flight.Flights.Enums; -using global::Flight.Flights.Features.CreatingFlight.V1; -using MassTransit; - -public sealed class FakeCreateFlightMongoCommand : AutoFaker -{ - public FakeCreateFlightMongoCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightNumber, r => "12FF"); - RuleFor(r => r.DepartureAirportId, _ => InitialData.Airports.First().Id); - RuleFor(r => r.ArriveAirportId, _ => InitialData.Airports.Last().Id); - RuleFor(r => r.Status, _ => FlightStatus.Flying); - RuleFor(r => r.AircraftId, _ => InitialData.Aircrafts.First().Id); - RuleFor(r => r.IsDeleted, _ => false); - } -} - diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/FlightTestDataSeeder.cs b/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/FlightTestDataSeeder.cs deleted file mode 100644 index 862356f..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/FlightTestDataSeeder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using BuildingBlocks.EFCore; -using Flight.Aircrafts.Models; -using Flight.Airports.Models; -using Flight.Data; -using Flight.Data.Seed; -using Flight.Flights.Models; -using Flight.Seats.Models; -using MapsterMapper; -using Microsoft.EntityFrameworkCore; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace EndToEnd.Test; - -public class FlightTestDataSeeder( - FlightDbContext flightDbContext, - FlightReadDbContext flightReadDbContext, - IMapper mapper -) : ITestDataSeeder -{ - public async Task SeedAllAsync() - { - await SeedAirportAsync(); - await SeedAircraftAsync(); - await SeedFlightAsync(); - await SeedSeatAsync(); - } - - private async Task SeedAirportAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Airports)) - { - await flightDbContext.Airports.AddRangeAsync(InitialData.Airports); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Airport.AsQueryable())) - { - await flightReadDbContext.Airport.InsertManyAsync(mapper.Map>(InitialData.Airports)); - } - } - } - - private async Task SeedAircraftAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Aircraft)) - { - await flightDbContext.Aircraft.AddRangeAsync(InitialData.Aircrafts); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Aircraft.AsQueryable())) - { - await flightReadDbContext.Aircraft.InsertManyAsync(mapper.Map>(InitialData.Aircrafts)); - } - } - } - - - private async Task SeedSeatAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Seats)) - { - await flightDbContext.Seats.AddRangeAsync(InitialData.Seats); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Seat.AsQueryable())) - { - await flightReadDbContext.Seat.InsertManyAsync(mapper.Map>(InitialData.Seats)); - } - } - } - - private async Task SeedFlightAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Flights)) - { - await flightDbContext.Flights.AddRangeAsync(InitialData.Flights); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Flight.AsQueryable())) - { - await flightReadDbContext.Flight.InsertManyAsync(mapper.Map>(InitialData.Flights)); - } - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Routes/ApiRoutes.cs b/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Routes/ApiRoutes.cs deleted file mode 100644 index 0517f29..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Routes/ApiRoutes.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace EndToEnd.Test.Routes; - -public static class ApiRoutes -{ - private const string BaseApiPath = "api/v1.0"; - - public static class Flight - { - public const string Id = "{id}"; - public const string GetFlightById = $"{BaseApiPath}/flight/{Id}"; - public const string CreateFlight = $"{BaseApiPath}/flight"; - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/xunit.runner.json b/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/xunit.runner.json deleted file mode 100644 index 9db029b..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAircraftCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAircraftCommand.cs deleted file mode 100644 index 646ced6..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAircraftCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AutoBogus; - -namespace Integration.Test.Fakes; - -using global::Flight.Aircrafts.Features.CreatingAircraft.V1; -using MassTransit; - -public class FakeCreateAircraftCommand : AutoFaker -{ - public FakeCreateAircraftCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.ManufacturingYear, _ => 2000); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAirportCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAirportCommand.cs deleted file mode 100644 index 2cc7ae2..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAirportCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -using AutoBogus; - -namespace Integration.Test.Fakes; - -using global::Flight.Airports.Features.CreatingAirport.V1; -using MassTransit; - -public class FakeCreateAirportCommand : AutoFaker -{ - public FakeCreateAirportCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightCommand.cs deleted file mode 100644 index 5e2793e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightCommand.cs +++ /dev/null @@ -1,22 +0,0 @@ -using AutoBogus; -using Flight.Flights.Enums; - -namespace Integration.Test.Fakes; - -using System.Linq; -using global::Flight.Data.Seed; -using global::Flight.Flights.Features.CreatingFlight.V1; -using MassTransit; - -public sealed class FakeCreateFlightCommand : AutoFaker -{ - public FakeCreateFlightCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightNumber, r => r.Random.Number(1000, 2000).ToString()); - RuleFor(r => r.DepartureAirportId, _ => InitialData.Airports.First().Id); - RuleFor(r => r.ArriveAirportId, _ => InitialData.Airports.Last().Id); - RuleFor(r => r.Status, _ => FlightStatus.Flying); - RuleFor(r => r.AircraftId, _ => InitialData.Aircrafts.First().Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightMongoCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightMongoCommand.cs deleted file mode 100644 index 921b810..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightMongoCommand.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Integration.Test.Fakes; - -using System.Linq; -using AutoBogus; -using global::Flight.Data.Seed; -using global::Flight.Flights.Enums; -using global::Flight.Flights.Features.CreatingFlight.V1; -using MassTransit; - -public sealed class FakeCreateFlightMongoCommand : AutoFaker -{ - public FakeCreateFlightMongoCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightNumber, r => "12FF"); - RuleFor(r => r.DepartureAirportId, _ => InitialData.Airports.First().Id); - RuleFor(r => r.ArriveAirportId, _ => InitialData.Airports.Last().Id); - RuleFor(r => r.Status, _ => FlightStatus.Flying); - RuleFor(r => r.AircraftId, _ => InitialData.Aircrafts.First().Id); - RuleFor(r => r.IsDeleted, _ => false); - } -} - diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatCommand.cs deleted file mode 100644 index 1f68428..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -using AutoBogus; -using Flight.Seats.Enums; - -namespace Integration.Test.Fakes; - -using System; -using global::Flight.Seats.Features.CreatingSeat.V1; -using MassTransit; - -public class FakeCreateSeatCommand : AutoFaker -{ - public FakeCreateSeatCommand(Guid flightId) - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightId, _ => flightId); - RuleFor(r => r.Class, _ => SeatClass.Economy); - RuleFor(r => r.Type, _ => SeatType.Middle); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatMongoCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatMongoCommand.cs deleted file mode 100644 index 441d090..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatMongoCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Integration.Test.Fakes; - -using System; -using AutoBogus; -using global::Flight.Seats.Enums; -using global::Flight.Seats.Features.CreatingSeat.V1; -using MassTransit; - -public class FakeCreateSeatMongoCommand : AutoFaker -{ - public FakeCreateSeatMongoCommand(Guid flightId) - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightId, _ => flightId); - RuleFor(r => r.Class, _ => SeatClass.Economy); - RuleFor(r => r.Type, _ => SeatType.Middle); - RuleFor(r => r.IsDeleted, _ => false); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeUpdateFlightCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeUpdateFlightCommand.cs deleted file mode 100644 index e6ca140..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Fakes/FakeUpdateFlightCommand.cs +++ /dev/null @@ -1,20 +0,0 @@ -using AutoBogus; - -namespace Integration.Test.Fakes; - -using global::Flight.Flights.Features.UpdatingFlight.V1; - -public class FakeUpdateFlightCommand : AutoFaker -{ - public FakeUpdateFlightCommand(global::Flight.Flights.Models.Flight flight) - { - RuleFor(r => r.Id, _ => flight.Id); - RuleFor(r => r.DepartureAirportId, _ => flight.DepartureAirportId); - RuleFor(r => r.ArriveAirportId, _ => flight.ArriveAirportId); - RuleFor(r => r.AircraftId, _ => flight.AircraftId); - RuleFor(r => r.FlightNumber, r => r.Random.Number(1000, 2000).ToString()); - RuleFor(r => r.Price, _ => 800); - RuleFor(r => r.Status, _ => flight.Status); - RuleFor(r => r.ArriveDate, _ => flight.ArriveDate); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/FlightTestDataSeeder.cs b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/FlightTestDataSeeder.cs deleted file mode 100644 index 3121315..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/FlightTestDataSeeder.cs +++ /dev/null @@ -1,85 +0,0 @@ -using BuildingBlocks.EFCore; -using Flight.Aircrafts.Models; -using Flight.Airports.Models; -using Flight.Data; -using Flight.Data.Seed; -using Flight.Flights.Models; -using Flight.Seats.Models; -using MapsterMapper; -using Microsoft.EntityFrameworkCore; -using MongoDB.Driver; -using MongoDB.Driver.Linq; - -namespace Integration.Test; - -public class FlightTestDataSeeder( - FlightDbContext flightDbContext, - FlightReadDbContext flightReadDbContext, - IMapper mapper -) : ITestDataSeeder -{ - public async Task SeedAllAsync() - { - await SeedAirportAsync(); - await SeedAircraftAsync(); - await SeedFlightAsync(); - await SeedSeatAsync(); - } - - private async Task SeedAirportAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Airports)) - { - await flightDbContext.Airports.AddRangeAsync(InitialData.Airports); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Airport.AsQueryable())) - { - await flightReadDbContext.Airport.InsertManyAsync(mapper.Map>(InitialData.Airports)); - } - } - } - - private async Task SeedAircraftAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Aircraft)) - { - await flightDbContext.Aircraft.AddRangeAsync(InitialData.Aircrafts); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Aircraft.AsQueryable())) - { - await flightReadDbContext.Aircraft.InsertManyAsync(mapper.Map>(InitialData.Aircrafts)); - } - } - } - - - private async Task SeedSeatAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Seats)) - { - await flightDbContext.Seats.AddRangeAsync(InitialData.Seats); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Seat.AsQueryable())) - { - await flightReadDbContext.Seat.InsertManyAsync(mapper.Map>(InitialData.Seats)); - } - } - } - - private async Task SeedFlightAsync() - { - if (!await EntityFrameworkQueryableExtensions.AnyAsync(flightDbContext.Flights)) - { - await flightDbContext.Flights.AddRangeAsync(InitialData.Flights); - await flightDbContext.SaveChangesAsync(); - - if (!await MongoQueryable.AnyAsync(flightReadDbContext.Flight.AsQueryable())) - { - await flightReadDbContext.Flight.InsertManyAsync(mapper.Map>(InitialData.Flights)); - } - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/xunit.runner.json b/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/xunit.runner.json deleted file mode 100644 index 9db029b..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator/VERSION b/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator/VERSION deleted file mode 100644 index ba8a874..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.6.0-SNAPSHOT \ No newline at end of file diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs deleted file mode 100644 index 10c9f3f..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs +++ /dev/null @@ -1,53 +0,0 @@ -using FluentAssertions; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -namespace Unit.Test.Aircraft.Features.CreateAircraftTests; - -using global::Flight.Aircrafts.Features.CreatingAircraft.V1; - -[Collection(nameof(UnitTestFixture))] -public class CreateAircraftCommandHandlerTests -{ - private readonly UnitTestFixture _fixture; - private readonly CreateAircraftHandler _handler; - - public Task Act(CreateAircraft command, CancellationToken cancellationToken) => - _handler.Handle(command, cancellationToken); - - public CreateAircraftCommandHandlerTests(UnitTestFixture fixture) - { - _fixture = fixture; - _handler = new CreateAircraftHandler(_fixture.DbContext); - } - - [Fact] - public async Task handler_with_valid_command_should_create_new_aircraft_and_return_currect_aircraft_dto() - { - // Arrange - var command = new FakeCreateAircraftCommand().Generate(); - - // Act - var response = await Act(command, CancellationToken.None); - - // Assert - var entity = await _fixture.DbContext.Aircraft.FindAsync(response?.Id); - - entity?.Should().NotBeNull(); - response?.Id.Should().Be(entity.Id); - } - - [Fact] - public async Task handler_with_null_command_should_throw_argument_exception() - { - // Arrange - CreateAircraft command = null; - - // Act - Func act = async () => { await Act(command, CancellationToken.None); }; - - // Assert - await act.Should().ThrowAsync(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs deleted file mode 100644 index c68142a..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -using FluentAssertions; -using FluentValidation.TestHelper; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -namespace Unit.Test.Aircraft.Features.CreateAircraftTests; - -using global::Flight.Aircrafts.Features.CreatingAircraft.V1; - -[Collection(nameof(UnitTestFixture))] -public class CreateAircraftCommandValidatorTests -{ - [Fact] - public void is_valid_should_be_false_when_have_invalid_parameter() - { - // Arrange - var command = new FakeValidateCreateAircraftCommand().Generate(); - var validator = new CreateAircraftValidator(); - - // Act - var result = validator.TestValidate(command); - - // Assert - result.IsValid.Should().BeFalse(); - result.ShouldHaveValidationErrorFor(x => x.Model); - result.ShouldHaveValidationErrorFor(x => x.ManufacturingYear); - result.ShouldHaveValidationErrorFor(x => x.Name); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs deleted file mode 100644 index d6a4137..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs +++ /dev/null @@ -1,55 +0,0 @@ -using FluentAssertions; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -namespace Unit.Test.Airport.Features.CreateAirportTests; - -using global::Flight.Airports.Features.CreatingAirport.V1; -using global::Flight.Airports.ValueObjects; - -[Collection(nameof(UnitTestFixture))] -public class CreateAirportCommandHandlerTests -{ - private readonly UnitTestFixture _fixture; - private readonly CreateAirportHandler _handler; - - - public CreateAirportCommandHandlerTests(UnitTestFixture fixture) - { - _fixture = fixture; - _handler = new CreateAirportHandler(_fixture.DbContext); - } - - public Task Act(CreateAirport command, CancellationToken cancellationToken) => - _handler.Handle(command, cancellationToken); - - [Fact] - public async Task handler_with_valid_command_should_create_new_airport_and_return_currect_airport_dto() - { - // Arrange - var command = new FakeCreateAirportCommand().Generate(); - - // Act - var response = await Act(command, CancellationToken.None); - - // Assert - var entity = await _fixture.DbContext.Airports.FindAsync(AirportId.Of(response.Id)); - - entity?.Should().NotBeNull(); - response?.Id.Should().Be(entity.Id); - } - - [Fact] - public async Task handler_with_null_command_should_throw_argument_exception() - { - // Arrange - CreateAirport command = null; - - // Act - var act = async () => { await Act(command, CancellationToken.None); }; - - // Assert - await act.Should().ThrowAsync(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs deleted file mode 100644 index 9fa877e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -using FluentAssertions; -using FluentValidation.TestHelper; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -namespace Unit.Test.Airport.Features.CreateAirportTests; - -using global::Flight.Airports.Features.CreatingAirport.V1; - -[Collection(nameof(UnitTestFixture))] -public class CreateAirportCommandValidatorTests -{ - [Fact] - public void is_valid_should_be_false_when_have_invalid_parameter() - { - // Arrange - var command = new FakeValidateCreateAirportCommand().Generate(); - var validator = new CreateAirportValidator(); - - // Act - var result = validator.TestValidate(command); - - // Assert - result.IsValid.Should().BeFalse(); - result.ShouldHaveValidationErrorFor(x => x.Code); - result.ShouldHaveValidationErrorFor(x => x.Address); - result.ShouldHaveValidationErrorFor(x => x.Name); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs deleted file mode 100644 index f11753a..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs +++ /dev/null @@ -1,96 +0,0 @@ -using Flight.Data; -using Flight.Flights.Enums; -using Flight.Seats.Enums; -using Microsoft.EntityFrameworkCore; - -namespace Unit.Test.Common; - -using global::Flight.Aircrafts.ValueObjects; -using global::Flight.Airports.ValueObjects; -using global::Flight.Flights.ValueObjects; -using global::Flight.Seats.ValueObjects; -using MassTransit; -using AirportName = global::Flight.Airports.ValueObjects.Name; -using Name = global::Flight.Aircrafts.ValueObjects.Name; - -public static class DbContextFactory -{ - private static readonly Guid _airportId1 = NewId.NextGuid(); - private static readonly Guid _airportId2 = NewId.NextGuid(); - private static readonly Guid _aircraft1 = NewId.NextGuid(); - private static readonly Guid _aircraft2 = NewId.NextGuid(); - private static readonly Guid _aircraft3 = NewId.NextGuid(); - private static readonly Guid _flightId1 = NewId.NextGuid(); - - public static FlightDbContext Create() - { - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; - - var context = new FlightDbContext(options, currentUserProvider: null, null); - - // Seed our data - FlightDataSeeder(context); - - return context; - } - - private static void FlightDataSeeder(FlightDbContext context) - { - var airports = new List - { - global::Flight.Airports.Models.Airport.Create(AirportId.Of(_airportId1), AirportName.Of("Lisbon International Airport"), Address.Of("LIS"), - Code.Of("12988")), - global::Flight.Airports.Models.Airport.Create(AirportId.Of(_airportId2), AirportName.Of("Sao Paulo International Airport"), Address.Of("BRZ"), - Code.Of("11200")) - }; - - context.Airports.AddRange(airports); - - var aircrafts = new List - { - global::Flight.Aircrafts.Models.Aircraft.Create(AircraftId.Of(_aircraft1), Name.Of("Boeing 737"), Model.Of("B737"), ManufacturingYear.Of(2005)), - global::Flight.Aircrafts.Models.Aircraft.Create(AircraftId.Of(_aircraft2), Name.Of("Airbus 300"), Model.Of("A300"), ManufacturingYear.Of(2000)), - global::Flight.Aircrafts.Models.Aircraft.Create(AircraftId.Of(_aircraft3), Name.Of("Airbus 320"), Model.Of("A320"), ManufacturingYear.Of(2003)) - }; - - context.Aircraft.AddRange(aircrafts); - - var flights = new List - { - global::Flight.Flights.Models.Flight.Create(FlightId.Of(_flightId1), FlightNumber.Of( "BD467"), AircraftId.Of(_aircraft1), AirportId.Of( _airportId1), - DepartureDate.Of( new DateTime(2022, 1, 31, 12, 0, 0)), - ArriveDate.Of( new DateTime(2022, 1, 31, 14, 0, 0)), - AirportId.Of( _airportId2), DurationMinutes.Of(120m), - FlightDate.Of( new DateTime(2022, 1, 31)), FlightStatus.Completed, - Price.Of(8000)) - }; - context.Flights.AddRange(flights); - - var seats = new List - { - global::Flight.Seats.Models.Seat.Create(SeatId.Of( NewId.NextGuid()), SeatNumber.Of("12A"), SeatType.Window, SeatClass.Economy, - FlightId.Of(_flightId1)), - global::Flight.Seats.Models.Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12B"), SeatType.Window, SeatClass.Economy, - FlightId.Of(_flightId1)), - global::Flight.Seats.Models.Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12C"), SeatType.Middle, SeatClass.Economy, - FlightId.Of(_flightId1)), - global::Flight.Seats.Models.Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12D"), SeatType.Middle, SeatClass.Economy, - FlightId.Of(_flightId1)), - global::Flight.Seats.Models.Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12E"), SeatType.Aisle, SeatClass.Economy, - FlightId.Of(_flightId1)), - global::Flight.Seats.Models.Seat.Create(SeatId.Of(NewId.NextGuid()), SeatNumber.Of("12F"), SeatType.Aisle, SeatClass.Economy, - FlightId.Of(_flightId1)) - }; - - context.Seats.AddRange(seats); - - context.SaveChanges(); - } - - public static void Destroy(FlightDbContext context) - { - context.Database.EnsureDeleted(); - context.Dispose(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/MapperFactory.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/MapperFactory.cs deleted file mode 100644 index b848805..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/MapperFactory.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Flight; -using Mapster; -using MapsterMapper; - -namespace Unit.Test.Common -{ - public static class MapperFactory - { - public static IMapper Create() - { - var typeAdapterConfig = TypeAdapterConfig.GlobalSettings; - typeAdapterConfig.Scan(typeof(FlightRoot).Assembly); - IMapper instance = new Mapper(typeAdapterConfig); - - return instance; - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/UnitTestFixture.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/UnitTestFixture.cs deleted file mode 100644 index 102d755..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Common/UnitTestFixture.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Flight.Data; -using MapsterMapper; -using Xunit; - -namespace Unit.Test.Common -{ - [CollectionDefinition(nameof(UnitTestFixture))] - public class FixtureCollection : ICollectionFixture { } - - public class UnitTestFixture : IDisposable - { - public UnitTestFixture() - { - Mapper = MapperFactory.Create(); - DbContext = DbContextFactory.Create(); - } - - public IMapper Mapper { get; } - public FlightDbContext DbContext { get; } - - public void Dispose() - { - DbContextFactory.Destroy(DbContext); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAircraftCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAircraftCommand.cs deleted file mode 100644 index cafba2c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAircraftCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AutoBogus; - -namespace Unit.Test.Fakes; - -using global::Flight.Aircrafts.Features.CreatingAircraft.V1; -using MassTransit; - -public class FakeCreateAircraftCommand : AutoFaker -{ - public FakeCreateAircraftCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.ManufacturingYear, _ => 2000); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAirportCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAirportCommand.cs deleted file mode 100644 index f1fd415..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAirportCommand.cs +++ /dev/null @@ -1,14 +0,0 @@ -using AutoBogus; - -namespace Unit.Test.Fakes; - -using global::Flight.Airports.Features.CreatingAirport.V1; -using MassTransit; - -public class FakeCreateAirportCommand : AutoFaker -{ - public FakeCreateAirportCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateFlightCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateFlightCommand.cs deleted file mode 100644 index 1362b10..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateFlightCommand.cs +++ /dev/null @@ -1,20 +0,0 @@ -using AutoBogus; - -namespace Unit.Test.Fakes; - -using System.Linq; -using global::Flight.Data.Seed; -using global::Flight.Flights.Features.CreatingFlight.V1; -using MassTransit; - -public sealed class FakeCreateFlightCommand : AutoFaker -{ - public FakeCreateFlightCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightNumber, r => r.Random.Number(1000, 2000).ToString()); - RuleFor(r => r.DepartureAirportId, _ => InitialData.Airports.First().Id); - RuleFor(r => r.ArriveAirportId, _ => InitialData.Airports.Last().Id); - RuleFor(r => r.AircraftId, _ => InitialData.Aircrafts.First().Id); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateSeatCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateSeatCommand.cs deleted file mode 100644 index 7810d1b..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateSeatCommand.cs +++ /dev/null @@ -1,21 +0,0 @@ -using AutoBogus; -using Flight.Seats.Enums; - -namespace Unit.Test.Fakes; - -using System.Linq; -using global::Flight.Data.Seed; -using global::Flight.Seats.Features.CreatingSeat.V1; -using MassTransit; - -public class FakeCreateSeatCommand : AutoFaker -{ - public FakeCreateSeatCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.FlightId, _ => InitialData.Flights.First().Id); - RuleFor(r => r.SeatNumber, _ => "F99"); - RuleFor(r => r.Type, _ => SeatType.Window); - RuleFor(r => r.Class, _ => SeatClass.Economy); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightCreate.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightCreate.cs deleted file mode 100644 index d9c5e70..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightCreate.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Unit.Test.Fakes; - -using global::Flight.Aircrafts.ValueObjects; -using global::Flight.Airports.ValueObjects; -using global::Flight.Flights.ValueObjects; - -public static class FakeFlightCreate -{ - public static global::Flight.Flights.Models.Flight Generate() - { - var command = new FakeCreateFlightCommand().Generate(); - - return global::Flight.Flights.Models.Flight.Create(FlightId.Of(command.Id), FlightNumber.Of(command.FlightNumber), - AircraftId.Of(command.AircraftId), AirportId.Of(command.DepartureAirportId), DepartureDate.Of(command.DepartureDate), - ArriveDate.Of(command.ArriveDate), AirportId.Of(command.ArriveAirportId), DurationMinutes.Of(command.DurationMinutes), - FlightDate.Of(command.FlightDate), command.Status, Price.Of(command.Price)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightUpdate.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightUpdate.cs deleted file mode 100644 index 0996583..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightUpdate.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Unit.Test.Fakes; - -using global::Flight.Flights.Models; -using global::Flight.Flights.ValueObjects; - -public static class FakeFlightUpdate -{ - public static void Generate(Flight flight) - { - flight.Update(flight.Id, flight.FlightNumber, flight.AircraftId, flight.DepartureAirportId, flight.DepartureDate, - flight.ArriveDate, flight.ArriveAirportId, flight.DurationMinutes, flight.FlightDate, flight.Status, Price.Of(1000), flight.IsDeleted); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAircraftCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAircraftCommand.cs deleted file mode 100644 index d233486..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAircraftCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AutoBogus; - -namespace Unit.Test.Fakes; - -using global::Flight.Aircrafts.Features.CreatingAircraft.V1; - -public class FakeValidateCreateAircraftCommand : AutoFaker -{ - public FakeValidateCreateAircraftCommand() - { - RuleFor(r => r.ManufacturingYear, _ => 0); - RuleFor(r => r.Name, _ => null); - RuleFor(r => r.Model, _ => null); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAirportCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAirportCommand.cs deleted file mode 100644 index 508e85c..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAirportCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -using AutoBogus; - -namespace Unit.Test.Fakes; - -using global::Flight.Airports.Features.CreatingAirport.V1; - -public class FakeValidateCreateAirportCommand : AutoFaker -{ - public FakeValidateCreateAirportCommand() - { - RuleFor(r => r.Code, _ => null); - RuleFor(r => r.Name, _ => null); - RuleFor(r => r.Address, _ => null); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateFlightCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateFlightCommand.cs deleted file mode 100644 index 007d7fd..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateFlightCommand.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using AutoBogus; -using Flight.Flights.Enums; - -namespace Unit.Test.Fakes; - -using global::Flight.Flights.Features.CreatingFlight.V1; - -public class FakeValidateCreateFlightCommand : AutoFaker -{ - public FakeValidateCreateFlightCommand() - { - RuleFor(r => r.Price, _ => -10); - RuleFor(r => r.Status, _ => (FlightStatus)10); - RuleFor(r => r.AircraftId, _ => Guid.Empty); - RuleFor(r => r.DepartureAirportId, _ => Guid.Empty); - RuleFor(r => r.ArriveAirportId, _ => Guid.Empty); - RuleFor(r => r.DurationMinutes, _ => 0); - RuleFor(r => r.FlightDate, _ => new DateTime()); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateSeatCommand.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateSeatCommand.cs deleted file mode 100644 index f7985a9..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateSeatCommand.cs +++ /dev/null @@ -1,17 +0,0 @@ -using AutoBogus; -using Flight.Seats.Enums; - -namespace Unit.Test.Fakes; - -using System; -using global::Flight.Seats.Features.CreatingSeat.V1; - -public class FakeValidateCreateSeatCommand : AutoFaker -{ - public FakeValidateCreateSeatCommand() - { - RuleFor(r => r.SeatNumber, _ => null); - RuleFor(r => r.FlightId, _ => Guid.Empty); - RuleFor(r => r.Class, _ => (SeatClass)10); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs deleted file mode 100644 index bd4b3f6..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Unit.Test.Flight.Features.Domains -{ - using System.Linq; - using FluentAssertions; - using global::Flight.Flights.Features.CreatingFlight.V1; - using Unit.Test.Common; - using Unit.Test.Fakes; - using Xunit; - - [Collection(nameof(UnitTestFixture))] - public class CreateFlightTests - { - [Fact] - public void can_create_valid_flight() - { - // Arrange + Act - var fakeFlight = FakeFlightCreate.Generate(); - - // Assert - fakeFlight.Should().NotBeNull(); - } - - [Fact] - public void queue_domain_event_on_create() - { - // Arrange + Act - var fakeFlight = FakeFlightCreate.Generate(); - - // Assert - fakeFlight.DomainEvents.Count.Should().Be(1); - fakeFlight.DomainEvents.FirstOrDefault().Should().BeOfType(typeof(FlightCreatedDomainEvent)); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs deleted file mode 100644 index d0aaadd..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace Unit.Test.Flight.Features.Domains; - -using System.Linq; -using FluentAssertions; -using global::Flight.Flights.Features.UpdatingFlight.V1; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -[Collection(nameof(UnitTestFixture))] -public class UpdateFlightTests -{ - [Fact] - public void can_update_valid_flight() - { - // Arrange - var fakeFlight = FakeFlightCreate.Generate(); - - // Act - FakeFlightUpdate.Generate(fakeFlight); - - // Assert - fakeFlight.Price.Value.Should().Be(1000); - } - - [Fact] - public void queue_domain_event_on_update() - { - // Arrange - var fakeFlight = FakeFlightCreate.Generate(); - fakeFlight.ClearDomainEvents(); - - // Act - FakeFlightUpdate.Generate(fakeFlight); - - // Assert - fakeFlight.DomainEvents.Count.Should().Be(1); - fakeFlight.DomainEvents.FirstOrDefault().Should().BeOfType(typeof(FlightUpdatedDomainEvent)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs deleted file mode 100644 index 6a37fb4..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs +++ /dev/null @@ -1,56 +0,0 @@ -namespace Unit.Test.Flight.Features.Handlers.CreateFlight; - -using System; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using global::Flight.Flights.Features.CreatingFlight.V1; -using global::Flight.Flights.ValueObjects; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -[Collection(nameof(UnitTestFixture))] -public class CreateFlightCommandHandlerTests -{ - private readonly UnitTestFixture _fixture; - private readonly CreateFlightHandler _handler; - - public Task Act(CreateFlight command, CancellationToken cancellationToken) => - _handler.Handle(command, cancellationToken); - - public CreateFlightCommandHandlerTests(UnitTestFixture fixture) - { - _fixture = fixture; - _handler = new CreateFlightHandler(fixture.DbContext); - } - - [Fact] - public async Task handler_with_valid_command_should_create_new_flight_and_return_currect_flight_dto() - { - // Arrange - var command = new FakeCreateFlightCommand().Generate(); - - // Act - var response = await Act(command, CancellationToken.None); - - // Assert - var entity = await _fixture.DbContext.Flights.FindAsync(FlightId.Of(response.Id)); - - entity?.Should().NotBeNull(); - response?.Id.Should().Be(entity.Id); - } - - [Fact] - public async Task handler_with_null_command_should_throw_argument_exception() - { - // Arrange - CreateFlight command = null; - - // Act - Func act = async () => { await Act(command, CancellationToken.None); }; - - // Assert - await act.Should().ThrowAsync(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs deleted file mode 100644 index c339532..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Unit.Test.Flight.Features.Handlers.CreateFlight; - -using FluentAssertions; -using FluentValidation.TestHelper; -using global::Flight.Flights.Features.CreatingFlight.V1; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -[Collection(nameof(UnitTestFixture))] -public class CreateFlightCommandValidatorTests -{ - [Fact] - public void is_valid_should_be_false_when_have_invalid_parameter() - { - // Arrange - var command = new FakeValidateCreateFlightCommand().Generate(); - var validator = new CreateFlightValidator(); - - // Act - var result = validator.TestValidate(command); - - // Assert - result.IsValid.Should().BeFalse(); - result.ShouldHaveValidationErrorFor(x => x.Price); - result.ShouldHaveValidationErrorFor(x => x.Status); - result.ShouldHaveValidationErrorFor(x => x.AircraftId); - result.ShouldHaveValidationErrorFor(x => x.DepartureAirportId); - result.ShouldHaveValidationErrorFor(x => x.ArriveAirportId); - result.ShouldHaveValidationErrorFor(x => x.DurationMinutes); - result.ShouldHaveValidationErrorFor(x => x.FlightDate); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/FlightMappingTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/FlightMappingTests.cs deleted file mode 100644 index 4c1e26e..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Flight/FlightMappingTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Flight.Flights.Dtos; -using MapsterMapper; -using Unit.Test.Common; -using Xunit; - -namespace Unit.Test.Flight; - -[Collection(nameof(UnitTestFixture))] -public class FlightMappingTests -{ - private readonly IMapper _mapper; - - public FlightMappingTests(UnitTestFixture fixture) - { - _mapper = fixture.Mapper; - } - - public static IEnumerable Data - { - get - { - yield return new object[] - { - // these types will instantiate with reflection in the future - typeof(global::Flight.Flights.Models.FlightReadModel), typeof(FlightDto) - }; - } - } - - [Theory] - [MemberData(nameof(Data))] - public void should_support_mapping_from_source_to_destination(Type source, Type destination, - params object[] parameters) - { - var instance = Activator.CreateInstance(source, parameters); - - _mapper.Map(instance, source, destination); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandHandlerTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandHandlerTests.cs deleted file mode 100644 index ad9d85a..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandHandlerTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using FluentAssertions; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -namespace Unit.Test.Seat.Features; - -using global::Flight.Seats.Features.CreatingSeat.V1; -using global::Flight.Seats.ValueObjects; - -[Collection(nameof(UnitTestFixture))] -public class CreateSeatCommandHandlerTests -{ - private readonly UnitTestFixture _fixture; - private readonly CreateSeatCommandHandler _handler; - - - public CreateSeatCommandHandlerTests(UnitTestFixture fixture) - { - _fixture = fixture; - _handler = new CreateSeatCommandHandler(_fixture.DbContext); - } - - public Task Act(CreateSeat command, CancellationToken cancellationToken) - { - return _handler.Handle(command, cancellationToken); - } - - [Fact] - public async Task handler_with_valid_command_should_create_new_seat_and_return_currect_seat_dto() - { - // Arrange - var command = new FakeCreateSeatCommand().Generate(); - - // Act - var response = await Act(command, CancellationToken.None); - - // Assert - var entity = await _fixture.DbContext.Seats.FindAsync(SeatId.Of(response.Id)); - - entity?.Should().NotBeNull(); - response?.Id.Should().Be(entity.Id); - } - - [Fact] - public async Task handler_with_null_command_should_throw_argument_exception() - { - // Arrange - CreateSeat command = null; - - // Act - var act = async () => { await Act(command, CancellationToken.None); }; - - // Assert - await act.Should().ThrowAsync(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandValidatorTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandValidatorTests.cs deleted file mode 100644 index 79bb087..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandValidatorTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -using FluentAssertions; -using FluentValidation.TestHelper; -using Unit.Test.Common; -using Unit.Test.Fakes; -using Xunit; - -namespace Unit.Test.Seat.Features; - -using global::Flight.Seats.Features.CreatingSeat.V1; - -[Collection(nameof(UnitTestFixture))] -public class CreateSeatCommandValidatorTests -{ - [Fact] - public void is_valid_should_be_false_when_have_invalid_parameter() - { - // Arrange - var command = new FakeValidateCreateSeatCommand().Generate(); - var validator = new CreateSeatValidator(); - - // Act - var result = validator.TestValidate(command); - - // Assert - result.IsValid.Should().BeFalse(); - result.ShouldHaveValidationErrorFor(x => x.SeatNumber); - result.ShouldHaveValidationErrorFor(x => x.FlightId); - result.ShouldHaveValidationErrorFor(x => x.Class); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/SeatMappingTests.cs b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/SeatMappingTests.cs deleted file mode 100644 index 4652665..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Seat/SeatMappingTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Flight.Seats.Dtos; -using MapsterMapper; -using Unit.Test.Common; -using Xunit; - -namespace Unit.Test.Seat; - -[Collection(nameof(UnitTestFixture))] -public class SeatMappingTests -{ - private readonly UnitTestFixture _fixture; - private readonly IMapper _mapper; - - public SeatMappingTests(UnitTestFixture fixture) - { - _mapper = fixture.Mapper; - } - - public static IEnumerable Data - { - get - { - yield return new object[] - { - // these types will instantiate with reflection in the future - typeof(global::Flight.Seats.Models.SeatReadModel), typeof(SeatDto) - }; - } - } - - - [Theory] - [MemberData(nameof(Data))] - public void should_support_mapping_from_source_to_destination(Type source, Type destination, params object[] parameters) - { - var instance = Activator.CreateInstance(source, parameters); - - _mapper.Map(instance, source, destination); - } -} diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/xunit.runner.json b/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/xunit.runner.json deleted file mode 100644 index 9db029b..0000000 --- a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} diff --git a/3-microservices-architecture-style/src/Services/Identity/Dockerfile b/3-microservices-architecture-style/src/Services/Identity/Dockerfile deleted file mode 100644 index 1a1e020..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder - -# Setup working directory for the project -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity.csproj ./3-microservices-architecture-style/src/Services/Identity/src/Identity/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/ - -# Restore nuget packages -RUN dotnet restore ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity/ ./3-microservices-architecture-style/src/Services/Identity/src/Identity/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/ ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Identity/src/Identity.Api - -# Publish project to output folder -# and no build, as we did it already -RUN dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/out . - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Identity.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Identity/dev.Dockerfile b/3-microservices-architecture-style/src/Services/Identity/dev.Dockerfile deleted file mode 100644 index 45ab8f3..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/dev.Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder - -# Setup working directory for the project -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity.csproj ./3-microservices-architecture-style/src/Services/Identity/src/Identity/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/ - -# Restore nuget packages -RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ - dotnet restore .3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity/ ./3-microservices-architecture-style/src/Services/Identity/src/Identity/ -COPY ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/ ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ - dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Identity/src/Identity.Api - -# Publish project to output folder -# and no build, as we did it already -RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ - dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/out . - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Identity.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-0AC3347A09AA5E44E947F3E30ED54871.json b/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-0AC3347A09AA5E44E947F3E30ED54871.json deleted file mode 100644 index 86e98ed..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-0AC3347A09AA5E44E947F3E30ED54871.json +++ /dev/null @@ -1 +0,0 @@ -{"Version":1,"Id":"0AC3347A09AA5E44E947F3E30ED54871","Created":"2023-02-22T21:06:15.7901014Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8Pno3caweVxDrMdMtoqjLU9W7bGGdPAEm8VDpWIg5fNfBATZdniIo9r5lhBSMZ3OFJya6SlNGIFe9JkbzJBa5fwNa-omLt15Kjlu3QNX4bAWI3V87P70NAfKDKe4xBVF12B3ooXFXKJ2U5QzFBY8U_1tBXkeUTQKfioQ1lTPxIbQtmSyD-uSc5anbDjtqIWhDq1OlujSJpVHRJV9EzRCms4yZdUc506aWg_KrkpVITZyywj1X1cz-SaUGUqy01wJSXgEj70OdVo2DoPIEYTDAlymi40-R2jQsnseFEG3W7XQlYX29joTygtkumnVED2WF9y9Boy80Kj5XN5XZvL1opV-qtxA8aekkp3XuwMJtBmnMeslHK8TyvBl5JjdZwULdYJFo-rGSDEuI4bswDzMWUgv6oAxgqE6e7SQiFlHuLgWHkmEis4-r-EphCl7B_lNOMQViifon6L8t0lUGdPFhFfN5Fo7cj_lZPx5uqymwVUwIEPrEisZtkwsPYZeKuVdSaRnl5xDlU6AgbQvcNeTtg9_kyB6Z43rEPTvtwMkoBjVe5iTQ5ZtubByEGKVIugxNMfHzPc1E9FNTT3uW928Uq6RQiNah17cNBQsVmYAq_iRggDJwAeFnUgqnh0hFuve2_9T4Nt6XFSV-0OQ7aM8C8VPpEzROYhs_MMrzYuJAnV7VuvgUm4Zk9A2OFx9nGQXjL8WZ1-CcNV-TGESRUc9tfFizHPnd417h_qBYb8rJ-znet07KYs0Hwo_S8nbc4fAeG7OEj8cgn0nwgnDMa0_ROzvfFhmeWkkY5LdwtF0pgbO-_xdQwrx3mD2u6Nq5kABizd8ixH1urwvlfY5Z-MGwohf4HDjebiP49PsT96PAaj9ZFxz1HPfz4lOSCob7CBapIEt2exK0-OIhxkkU6i5_7iRvI_oFshzTvg2mSmR0zDWYfhiLZFoWGIlPi_B-pJvMEYgsyXW294yiAdVIJHXxs1nJRzgGBblY_FXM7IOzzwzpBtXH0odO8OPK6m8VBumDs9Q6iGiArFHwO5jKfvTxWYCM-PnTqW3ZselPIjZHSXbpGEU3o-HYg4rAGSIP9P_GoEJvSrQXqpYvhvPPbLh70OTwTtc8qG9GNW7XMoLpi6c8wUsapvrrYUBStlUWQ11UgvYSX1Nu4uCqTNTy6O1QHerbOHxWxfIOHzZyYfYnqQaF3bZZcMVJK3pOorcJKiMRCUp-hu5ismZ6T5Q2zfq93uqI3DpG2Wuov53o2s0QFmC4c5K6CCQVgLYBcib69twXjrWkVmGeM2CswLukOf8flUpGp_923M1TA4E89xkHxVhYESPfLB8FAULwNHOAW60U0tUksX-bcaAG1NUo3UEmaku2YfVbDJ7t5PJv8gc4zcPC0iXdBEL00G4FtSE2-r1TUhqK64iASEaAv3UTwefOMUR3qzxZC3HB7wH4iiUESH70s1RXvNIQoKz_ZirEa9WoR0tgk0MFyr4VDow-q-embX06vesnwyHhCdZBr8el_KT_yGWwlkR_xx18fR6mHT5G_BYuW-cK8ADvJe-Y_vns2yQprfGGgeVUQ5t4IKacpqnNNB9J2lLMisQ9fjYJCRhMP41CB7vk7oUXu49PgvJ_LkqtM5LAngo5f5DVdrzgX1-9I_KtyamJ9ic8nLqVsI5Z9iof9u9cRyDKhwQ4KPpD3uovwGnK7if25F9UaHFLvAJk2iOQjkA1rQyjCIJzi8dqpdw3W_L3Gc2m9Gr7HS1D0ZtWIk8z-TMNtR2PQcmlWiTJ9ZhLyMs67LWnLZri0jchEw4TJ46EAAUHE1hGhbs8xsmtta1yiu9VaZwCjDb5OJwnnl_2tA1ZkCE5Mh9NGSAZSCYLJCSRaCE53KypCYZBtJhR7Jcl1cz0OY9nNNUpzpPrcmCEz1cLw4z2H1OtujncZHDiyKqh57zQOTs--q9Nx8ytyhg7hBYIcqJFP8Gb0xQPjSkN1oO5ScAPIyPNY54VdIR7sk-99995Y-U6pnLQ_1JdIJZRYYnaYa4c5cqQaRE1n_G-L4_g20aBCX65SKkck5bwsAMJL371t4CqCBfPjzFugoNxR37DWicLUd9sJGBUMjj_lhWsk709om6shSJAy4loiz1qViwPi1K5XcFI7oyH735wg8X05Qxe1tby83X9FSd1FlTpVPRe1btEHddVubt9oeaZ0kOiN5BagaEF4wjIiQttnnzBfjKqcpuyd0zMhDTL_CqlmrTE09HH01VSnZ6lVllzCXGYI2hZKJFeOL7quHV4cDSoEVHOBL7SbChhm62iWOVTe2ho8V1NGnGFMmMfeplVWKorv-k2-L0H-K8rtg9d2vUdt-s5bxKkesUjxJhScBVOlFVcX6GdDa0o2R1W6qszC7D-_UILhIEtkQwnEg9SR-dDMulOotrHp5_LrsMCJLCgqGfzrjVymq7vkHbkh-8XIUzopyXgS4yr__N1MT2lI-7sFBG8fTa-GbN","DataProtected":true} \ No newline at end of file diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-A57781A0405849BDE786A79636460E49.json b/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-A57781A0405849BDE786A79636460E49.json deleted file mode 100644 index 7d24288..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-A57781A0405849BDE786A79636460E49.json +++ /dev/null @@ -1 +0,0 @@ -{"Version":1,"Id":"A57781A0405849BDE786A79636460E49","Created":"2023-05-11T21:58:42.4707649Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8Hnjqxp4tLpCov-J-Y0BVs7wR0CVu4eqUuKwsY0rf0WJyME4aNzhKfD2Z2K08hK8_8svrjSptVpC1ttyCPtXtPVMsQQRukJef7SjEUNlC-US2KuwQGOLMYIDNHkTHrnXN7GYHoFtZ1SQWdL61GJ43LYCyFY7_L_Sn9SFepnDcT9H3aA9-M3ZjDJNU8_qknPTEUhSjV1i7AMkYnCHHow0ttlYhcQGwXoiuMMI9oqu26yr79i7sG6m_BAK1f1eg_1cBGozNe4yRPHsRk4qCLKgG-JRaNfV8sXHM-3SpEeFx7iUYHLHl7SiQwsqrODIujk7sz_vJaDbiFqwSVxUTDBEBLPpmPULLGKzjGoPrGtpmvgHkghEsHtvXY6aTzWwDLBmOT4ao8IjImv8D3_ub_KgNC5rg5pBzYA-gKAhtE_RznEKP_DVR836v5Xpw7zMVxbYVNwLrJ5-QtD503G5QhywFUHO9pRiL-dtDHJTpSmq5esy-OKBl2QJ12WxfeeMUQ7tIkTSsj0ALMyJS-a7uVUkITxOkXxrBI5rF6OIK8GZwnmsxJK5L3Urbn76EgiFKVoqgyhBRs0GvRl5-WJyc69m3ltuhp1z7hYOh0BYjlecDd9WOqNbFE68BCYUi7O--mSE0Bv94K4eUs81ccSb3lwC0AtPWPWjG31E9cg8Sd-A1gXhAcYuLmeWSoAP2Issoi5blxeafWUadjbjdCtGI_lA1trpg9LpClEDZZt5uJ5DQa5yUVzdz7l-RnlF7C8ReBtM8qBxJYnaCnc4WC7WE5cKMYG6mGJY55o_EAR4urjsxy2Bdjh34cFIIEQwfh-tnex3uBvYFUzoCPp8KJY-eRhUXEjtZzeds51OVeLKkeyFtSVEZsFTCnmc3tTsOAtkpa7sjsU0Xe0sgMG_E1XS8P_BqfIm9RR8rPblmA6JytNt_Gs2f00ND28PAnj_UuLeOaFpl2sipa228-1JimzFxKnVN7ZtU_ztZtUCGCSELoNbana8ZyLuFRGjFxQnkVZarwEFVyl7w_4scMujShb3ttaJDul51tsSJJTY43nC-Vlo1UBtYUjjNKuexpmOKGXaYRPygy_g4EXsqiN4FTc3mcG7jRoHmd5mUcvXfI66WbDmpXn4DB4x1VrWs2MVrLJw1ioON42IgjhoUCklrYJx4cxEWrIC3EURILE_jTy2ThAhGF24Z6jdTM8iVN9W7wwrnUxoFJCflr_-jiWwCToUWxPfolVu4mpQDhWJ1K9vuTVhQNrbMbc95TH7-Z_HFKiZkw23U0Xvjd4dqBJol2POIdQkDDg_L2omPtlMdNwo8eJ9rLEycbqQzcFzbyZBr__BU7J16wpu2lwZZVGgYfiofb6E01Iq_2_VQw8WH7d6onBJNCRq6QIDfZ3VdEMjdlm3kGrcY-_kzsfM9x9H_a-EpzT0_PwZO6gWUvfEfI84fNgPhM0Gq4vkv4l0NSpvIpivmgU9g3J2yQpO4QXVyQGOcXSUvUGKDIBRMKch1IOIEB6qYi34muu8Et0pbHsDsXECCnkfs5FAnKlG-zuf6W2cNRsF7QyaoUpDSpRD8u_R_mcQEVA2VJb4NWPSV1zgJ6-ne7HO_DL1mW7F-0jl2yHqOJ5z8GMTNdl7Nh4LfvHEB7xs0M2fgPByq3JImX1M-KUZDyIxfqxUM8L44zPyjiHvpMgXDvaA21aytu7G4r3vlgFyuMnSPKJ-fV8LBYDUKZ7TSOtTL2yCV2D5Z_VE3uZzBrpmJzzPG1_OXgmqV57KsPnDdwVefeu9UbCaDzG0R_xGReJveQcf5be8iJtTRDwqB2qlYm01VuIUSxabFTb_MypnKoIFaOxonW1faOgZ0zV8ocbgDfKO-8T21BBAJryw76yHxEVm59_X7Oa1VS_TM7i2sB67DWQadn4i4VMrF34LQyyhwPguKPSey1k7DcsHMxJ9zwUbC22HURwqVRn9zzxz9vHHiCUskytu3bItRkSpwDD2z_ngL9hVUF3C4QM3d4vgoL4sWS7X1One8z-vyZpZH_BDUg4nwEx95KClv2XieWXTHep8_3rdSIyTPrLLqErhCur6U69boZlvoCmoYtgbYN7dA1VkdTzdnzU-zSRLRkOY_hsa2gEElHqdtjHHTdt9g3kNhnvBMmgTQcEsAKZFjnwSbC-BogTSYNiZYCUu9eYOmenwlF4X4Yti-bVpMCEn6_6H8dWjumdBb7hgsvm47Sbuna5vAnlfnPKZBgji-38Y5lPE3NRF0ImhrsaURNUFktoNhp2gwFh8R0nLRzoLr3jWF2pBMMbvKGGzEBxOGN0_3nodoSyjFJFyAHgTwNcxB0AeYImM_-mxFtjiCDESqZoZGWtg6MvXmXPnat_uaI-jwl6TFBUChTjWujfil5doh32BtImNFO8VQakhrpTCaVm6yBKH77eF6aCX50iTuVVBuMec3IJZNPdnsc_65R4VGpqLwdscWiJqtmaRt_Umj-eJ","DataProtected":true} \ No newline at end of file diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-B3C31EEE2718D3C5004C6E85AD74F26C.json b/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-B3C31EEE2718D3C5004C6E85AD74F26C.json deleted file mode 100644 index 0616cdf..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/keys/is-signing-key-B3C31EEE2718D3C5004C6E85AD74F26C.json +++ /dev/null @@ -1 +0,0 @@ -{"Version":1,"Id":"B3C31EEE2718D3C5004C6E85AD74F26C","Created":"2025-04-08T16:45:11.9802139Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8KNpFTgHKl5Nl-o13RQ8rse7iqNX7fzIuFQawPXYLwTCbj1HOrmv2WHbV51cOwFkSjECACMh5ad32vYQMXHgU7-l9gMNU0QwhV5gdoDScJLFzFf-_gBCqNPsUWJxNebIFDHwSn12y9Kg56DzaRq9o4XO_wGEc3KsQjDjHuh0p-3n8qiliIxl_sBXTs8UCXhWMBqU5srioHUKwFu6nyAlhkDlsA9J6Syb9w6_WESzli6DpR9UphBKbjoV85ajrkuZzjd9GItRJ6C-OICEKUUoFXh5meVGuV-JmWhE1_nzASToml0vI6GZt8kxrJQkICt1MI7K2ZIQtHcoKhC09rWu7RpuOvKY8sLm0b8gbJQ1dVMNuZEnOczi-E3b6kKrYFwV_I3TFK4UZP7I90-cojBGpaWwX3IzkB8-Uwf-5qU2KXUZanO0tXEqw187ZVPDuvKkAUeAtphWFbV2ZNH12DGcXTvnvJfRxV5lRAuzH3N-Dhgz10F3VOQZtgoQyQ4wJE-B-04j3pqN_76NIh4Yx7GvArlWYMQTNBePMaLW33ycLlCrjov1nKK2BIhk4wykUeFT_rorXcf01PHJd3uqbtBDrP7ZoUqz8qWdY9-on3dvNi6cruyJ5rbmmE4hLAsWHLOqYLcceBF7LaZUthglcMtLlufU5C3wpXjoqpJZb1KiC7QR5sQE_KPfEiQsCO_hyXnFUvavOaGIiWWAhqADfGdD3wNma3qCAMwmV5T-_4_yW3wvYbrM8YFrHmQty6ks4W6qKJow1uwfAziDoobdV7bSLSxddWiO5zOuCeFNxIzsmMkk8PfxUyb-JySYFh_tA8D3Tn5kvTbFIRibfiBJXtB8Kk4ouvQxd6ydHCHOAHzuPgxs_nP6s3u0Xa12fmPpiCLaUjeNFHNP_wzh4l5Tn7GN4S07nOiFE1PyQUjT7xnYxcUuzySpiqLl2k9Bu98MMagGg6gqWnl5zV_Adxkq_aIvuvZF25JlE9SzAJkuJFBNqnXJ_ep-BCFogdHPgtjL_Y250A5DsiFnKrlJLuBIz88V_oLEj54iSi4hiJ66YT0H8lagPUIrL4h6cPCVWFeMiCf8yNeQVHCnRkIyXtID4CrSOr8KN5Qv_nKeAUxw_5BOgs5yEGxj4OGLLYViAobOCFOA1uCurA3OqyoI65CCyoPERAXm7dyKcIN8l0ChIHhCX2VBtwEoSG2QXlEjKLxmmMmHQrTuMMRNkd2_GlY6XNRw6MELf7W4SrxyZ-eWNY9nfye7z9Q-hv_dDkf5FGmd8qGpVUenIjH0GUz4JqWOQ6GmHb7b_9u5g5vNIqi5YHf59SuNGAUbE3PFpDGpIeh5YVrCV-msoaUEkYxXvsBcUsOIiC32kQy-u-fDPxYSg-aNCgBrKDnTK4IFFBNYjT1IIApIiz-Xq8mjTsJvgaYKOLsVfqPlWX_Fr63Fnnygt9zO1tNZjW6JSj34nZJ_6120mGZcNueXtUy66QJeF8DqVdt4DbXMWYk-rQcHvqk3lQ_r7u7r88hIwzXgE3YtFFlesUK_7DVcblSuTxNxDXO5M7U_2EO4KIJbDfQ6BYxovJrWwtPcSXb_Nq25St_X3wSMk3eSGO7GNHL89t_muN5tE97As0s89h8OM5cISROR72zLWyvki2aB4L5WFWpBg1xylymZBzWGF-VKbDpoIb09PsyuuWy502OONDxmsheeadUZCNZYlxiSkmGLXrjSgsAhQHmLr7BwZ2FmVJGHtWD-nUPMj32NljxYQ1Bzv0aYXmJhHT8lcmTcWxb8yQKhOk-S6oP7m3ftq-gzsmE4lATEAHFGtO9a_xJlNYivB0zMsOYfY7YJzRSYEgLCSxS4HiUysv3WYXYjAQaGJNoSJX1YMMvCDu1rt29oV17Td58wHWvnnsCFlckVah6y_DCfez9ucTpQPHsQMsW1Hwl-3xgndEyTuynTHZNgqCcxQWBFlo1Ay9HHl68ppFpxm7FvSScyTdjtMPD89qZ84P_V38Qlz9ye0J2LXWoH1np7jAnaRiEzc-_Dcra3Yv792ks_ZlLS3Tu9-m-iZiGILHxIaccR53BSbjjgKS7LXMPsWZ_kf4pBNspcIbnn1dm_L47sEKCeA_2J0BVQeG_x7ZXG38M100wreTadW_PE5WysYyFIbHy5_wvfVVIEPZ3cMFt66LjoFfAmn52kQUG2w65Nnr95bavMBNdKk9oo22QpRy3YJsrABp9DtUqh4CwCqZCu7KvD2yx5u6UKAOK-XWlU1UJ-dPxxcuoPsjeuG1ER8ySYexec7iXzg-tbKjeGGSnyj2z1fnTihIiQIw_CAiZwXuyD4e0zowAmjEF2RWRsWvacoU7n_TCFwx4dX5bEG41-J2KHGJVX1X9D2tBX7R963ICgP8xeoE5wxWEiQLrsED68PKsnMasLGW2oOtLR8DwERbydMYHRH2f63mexVE5gbdf_4UXpaYMC8bNUc3HWY3-Sb_Fbc46r","DataProtected":true} \ No newline at end of file diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/AssemblyInfo.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/AssemblyInfo.cs deleted file mode 100644 index 60fedfd..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Unit.Test")] -[assembly: InternalsVisibleTo("Integration.Test")] -[assembly: InternalsVisibleTo("EndToEnd.Test")] - diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/AuthOptions.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/AuthOptions.cs deleted file mode 100644 index c7b7605..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/AuthOptions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Identity.Configurations; - -public class AuthOptions -{ - public string IssuerUri { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/UserValidator.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/UserValidator.cs deleted file mode 100644 index ef6c263..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/UserValidator.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace Identity.Configurations; - -using System.Security.Claims; -using System.Threading.Tasks; -using Duende.IdentityServer.Models; -using Duende.IdentityServer.Validation; -using Identity.Models; -using Microsoft.AspNetCore.Identity; - -public class UserValidator : IResourceOwnerPasswordValidator -{ - private readonly SignInManager _signInManager; - private readonly UserManager _userManager; - - public UserValidator(SignInManager signInManager, - UserManager userManager) - { - _signInManager = signInManager; - _userManager = userManager; - } - - public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context) - { - var user = await _userManager.FindByNameAsync(context.UserName); - - var signIn = await _signInManager.PasswordSignInAsync( - user, - context.Password, - isPersistent: true, - lockoutOnFailure: true); - - if (signIn.Succeeded) - { - var userId = user!.Id.ToString(); - - // context set to success - context.Result = new GrantValidationResult( - subject: userId, - authenticationMethod: "custom", - claims: new Claim[] - { - new Claim(ClaimTypes.NameIdentifier, userId), - new Claim(ClaimTypes.Name, user.UserName) - } - ); - - return; - } - - // context set to Failure - context.Result = new GrantValidationResult( - TokenRequestErrors.UnauthorizedClient, "Invalid Credentials"); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/RoleClaimConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/RoleClaimConfiguration.cs deleted file mode 100644 index 58fabd9..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/RoleClaimConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class RoleClaimConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(RoleClaim)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/RoleConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/RoleConfiguration.cs deleted file mode 100644 index 991cdea..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/RoleConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class RoleConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(Role)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserClaimConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserClaimConfiguration.cs deleted file mode 100644 index 40f2d30..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserClaimConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class UserClaimConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserClaim)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserConfiguration.cs deleted file mode 100644 index 9a66611..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class UserConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(User)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserLoginConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserLoginConfiguration.cs deleted file mode 100644 index 4b556b0..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserLoginConfiguration.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class UserLoginConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserLogin)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} - diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserRoleConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserRoleConfiguration.cs deleted file mode 100644 index c0f4bf8..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserRoleConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class UserRoleConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserRole)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserTokenConfiguration.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserTokenConfiguration.cs deleted file mode 100644 index 380151e..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Configurations/UserTokenConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Identity.Data.Configurations; - -using Identity.Models; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -public class UserTokenConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(UserToken)); - - // // ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=fluent-api - builder.Property(r => r.Version).IsConcurrencyToken(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/DesignTimeDbContextFactory.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/DesignTimeDbContextFactory.cs deleted file mode 100644 index 40f5138..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/DesignTimeDbContextFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace Identity.Data; - -public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory -{ - public IdentityContext CreateDbContext(string[] args) - { - var builder = new DbContextOptionsBuilder(); - - builder.UseNpgsql("Server=localhost;Port=5432;Database=identity;User Id=postgres;Password=postgres;Include Error Detail=true") - .UseSnakeCaseNamingConvention(); - return new IdentityContext(builder.Options); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/IdentityContext.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/IdentityContext.cs deleted file mode 100644 index e0f3237..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/IdentityContext.cs +++ /dev/null @@ -1,171 +0,0 @@ -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Data; -using System.Linq; -using System.Reflection; -using System.Threading; -using System.Threading.Tasks; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Core.Model; -using BuildingBlocks.EFCore; -using Identity.Identity.Models; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; - -namespace Identity.Data; - -using System; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.Logging; - -public sealed class IdentityContext : IdentityDbContext, IDbContext -{ - private readonly ILogger? _logger; - private IDbContextTransaction _currentTransaction; - - public IdentityContext(DbContextOptions options, ILogger? logger = null) : base(options) - { - _logger = logger; - } - - protected override void OnModelCreating(ModelBuilder builder) - { - builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); - base.OnModelCreating(builder); - builder.FilterSoftDeletedProperties(); - builder.ToSnakeCaseTables(); - } - - public IExecutionStrategy CreateExecutionStrategy() => Database.CreateExecutionStrategy(); - - public async Task BeginTransactionAsync(CancellationToken cancellationToken = default) - { - if (_currentTransaction != null) - return; - - _currentTransaction = await Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken); - } - - public async Task CommitTransactionAsync(CancellationToken cancellationToken = default) - { - try - { - await SaveChangesAsync(cancellationToken); - await _currentTransaction?.CommitAsync(cancellationToken)!; - } - catch - { - await RollbackTransactionAsync(cancellationToken); - throw; - } - finally - { - _currentTransaction?.Dispose(); - _currentTransaction = null; - } - } - - public async Task RollbackTransactionAsync(CancellationToken cancellationToken = default) - { - try - { - await _currentTransaction?.RollbackAsync(cancellationToken)!; - } - finally - { - _currentTransaction?.Dispose(); - _currentTransaction = null; - } - } - - //ref: https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency#execution-strategies-and-transactions - public Task ExecuteTransactionalAsync(CancellationToken cancellationToken = default) - { - var strategy = CreateExecutionStrategy(); - return strategy.ExecuteAsync(async () => - { - await using var transaction = - await Database.BeginTransactionAsync(IsolationLevel.ReadCommitted, cancellationToken); - try - { - await SaveChangesAsync(cancellationToken); - await transaction.CommitAsync(cancellationToken); - } - catch - { - await transaction.RollbackAsync(cancellationToken); - throw; - } - }); - } - - public override async Task SaveChangesAsync(CancellationToken cancellationToken = default) - { - OnBeforeSaving(); - try - { - return await base.SaveChangesAsync(cancellationToken); - } - //ref: https://learn.microsoft.com/en-us/ef/core/saving/concurrency?tabs=data-annotations#resolving-concurrency-conflicts - catch (DbUpdateConcurrencyException ex) - { - foreach (var entry in ex.Entries) - { - var databaseValues = await entry.GetDatabaseValuesAsync(cancellationToken); - - if (databaseValues == null) - { - _logger.LogError("The record no longer exists in the database, The record has been deleted by another user."); - throw; - } - - // Refresh the original values to bypass next concurrency check - entry.OriginalValues.SetValues(databaseValues); - } - - return await base.SaveChangesAsync(cancellationToken); - } - } - - public IReadOnlyList GetDomainEvents() - { - var domainEntities = ChangeTracker - .Entries() - .Where(x => x.Entity.DomainEvents.Any()) - .Select(x => x.Entity) - .ToList(); - - var domainEvents = domainEntities - .SelectMany(x => x.DomainEvents) - .ToImmutableList(); - - domainEntities.ForEach(entity => entity.ClearDomainEvents()); - - return domainEvents.ToImmutableList(); - } - - private void OnBeforeSaving() - { - try - { - foreach (var entry in ChangeTracker.Entries()) - { - switch (entry.State) - { - case EntityState.Modified: - entry.Entity.Version++; - break; - - case EntityState.Deleted: - entry.Entity.Version++; - break; - } - } - } - catch (Exception ex) - { - throw new Exception("try for find IVersion", ex); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.Designer.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.Designer.cs deleted file mode 100644 index 40c2889..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.Designer.cs +++ /dev/null @@ -1,377 +0,0 @@ -// -using System; -using Identity.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Identity.Data.Migrations -{ - [DbContext(typeof(IdentityContext))] - [Migration("20230331193410_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Identity.Identity.Models.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("name"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_roles"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("asp_net_roles", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.RoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_role_claims"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_role_claims_role_id"); - - b.ToTable("asp_net_role_claims", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AccessFailedCount") - .HasColumnType("integer") - .HasColumnName("access_failed_count"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("email"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean") - .HasColumnName("email_confirmed"); - - b.Property("FirstName") - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property("LastName") - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean") - .HasColumnName("lockout_enabled"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone") - .HasColumnName("lockout_end"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_email"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_user_name"); - - b.Property("PassPortNumber") - .HasColumnType("text") - .HasColumnName("pass_port_number"); - - b.Property("PasswordHash") - .HasColumnType("text") - .HasColumnName("password_hash"); - - b.Property("PhoneNumber") - .HasColumnType("text") - .HasColumnName("phone_number"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean") - .HasColumnName("phone_number_confirmed"); - - b.Property("SecurityStamp") - .HasColumnType("text") - .HasColumnName("security_stamp"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean") - .HasColumnName("two_factor_enabled"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("user_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_users"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("asp_net_users", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_user_claims"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_claims_user_id"); - - b.ToTable("asp_net_user_claims", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("ProviderKey") - .HasColumnType("text") - .HasColumnName("provider_key"); - - b.Property("ProviderDisplayName") - .HasColumnType("text") - .HasColumnName("provider_display_name"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("LoginProvider", "ProviderKey") - .HasName("pk_asp_net_user_logins"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_logins_user_id"); - - b.ToTable("asp_net_user_logins", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserRole", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "RoleId") - .HasName("pk_asp_net_user_roles"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_user_roles_role_id"); - - b.ToTable("asp_net_user_roles", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserToken", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Value") - .HasColumnType("text") - .HasColumnName("value"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "LoginProvider", "Name") - .HasName("pk_asp_net_user_tokens"); - - b.ToTable("asp_net_user_tokens", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.RoleClaim", b => - { - b.HasOne("Identity.Identity.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_role_claims_asp_net_roles_role_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserClaim", b => - { - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_claims_asp_net_users_user_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserLogin", b => - { - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_logins_asp_net_users_user_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserRole", b => - { - b.HasOne("Identity.Identity.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_roles_role_id"); - - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_users_user_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserToken", b => - { - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_tokens_asp_net_users_user_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.cs deleted file mode 100644 index 02df8ed..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.cs +++ /dev/null @@ -1,233 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Identity.Data.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "asp_net_roles", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - version = table.Column(type: "bigint", nullable: false), - name = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - normalizedname = table.Column(name: "normalized_name", type: "character varying(256)", maxLength: 256, nullable: true), - concurrencystamp = table.Column(name: "concurrency_stamp", type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_roles", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "asp_net_users", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - firstname = table.Column(name: "first_name", type: "text", nullable: true), - lastname = table.Column(name: "last_name", type: "text", nullable: true), - passportnumber = table.Column(name: "pass_port_number", type: "text", nullable: true), - version = table.Column(type: "bigint", nullable: false), - username = table.Column(name: "user_name", type: "character varying(256)", maxLength: 256, nullable: true), - normalizedusername = table.Column(name: "normalized_user_name", type: "character varying(256)", maxLength: 256, nullable: true), - email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), - normalizedemail = table.Column(name: "normalized_email", type: "character varying(256)", maxLength: 256, nullable: true), - emailconfirmed = table.Column(name: "email_confirmed", type: "boolean", nullable: false), - passwordhash = table.Column(name: "password_hash", type: "text", nullable: true), - securitystamp = table.Column(name: "security_stamp", type: "text", nullable: true), - concurrencystamp = table.Column(name: "concurrency_stamp", type: "text", nullable: true), - phonenumber = table.Column(name: "phone_number", type: "text", nullable: true), - phonenumberconfirmed = table.Column(name: "phone_number_confirmed", type: "boolean", nullable: false), - twofactorenabled = table.Column(name: "two_factor_enabled", type: "boolean", nullable: false), - lockoutend = table.Column(name: "lockout_end", type: "timestamp with time zone", nullable: true), - lockoutenabled = table.Column(name: "lockout_enabled", type: "boolean", nullable: false), - accessfailedcount = table.Column(name: "access_failed_count", type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_users", x => x.id); - }); - - migrationBuilder.CreateTable( - name: "asp_net_role_claims", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - version = table.Column(type: "bigint", nullable: false), - roleid = table.Column(name: "role_id", type: "uuid", nullable: false), - claimtype = table.Column(name: "claim_type", type: "text", nullable: true), - claimvalue = table.Column(name: "claim_value", type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_role_claims", x => x.id); - table.ForeignKey( - name: "fk_asp_net_role_claims_asp_net_roles_role_id", - column: x => x.roleid, - principalTable: "asp_net_roles", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_claims", - columns: table => new - { - id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - version = table.Column(type: "bigint", nullable: false), - userid = table.Column(name: "user_id", type: "uuid", nullable: false), - claimtype = table.Column(name: "claim_type", type: "text", nullable: true), - claimvalue = table.Column(name: "claim_value", type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_claims", x => x.id); - table.ForeignKey( - name: "fk_asp_net_user_claims_asp_net_users_user_id", - column: x => x.userid, - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_logins", - columns: table => new - { - loginprovider = table.Column(name: "login_provider", type: "text", nullable: false), - providerkey = table.Column(name: "provider_key", type: "text", nullable: false), - version = table.Column(type: "bigint", nullable: false), - providerdisplayname = table.Column(name: "provider_display_name", type: "text", nullable: true), - userid = table.Column(name: "user_id", type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_logins", x => new { x.loginprovider, x.providerkey }); - table.ForeignKey( - name: "fk_asp_net_user_logins_asp_net_users_user_id", - column: x => x.userid, - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_roles", - columns: table => new - { - userid = table.Column(name: "user_id", type: "uuid", nullable: false), - roleid = table.Column(name: "role_id", type: "uuid", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_roles", x => new { x.userid, x.roleid }); - table.ForeignKey( - name: "fk_asp_net_user_roles_asp_net_roles_role_id", - column: x => x.roleid, - principalTable: "asp_net_roles", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "fk_asp_net_user_roles_asp_net_users_user_id", - column: x => x.userid, - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "asp_net_user_tokens", - columns: table => new - { - userid = table.Column(name: "user_id", type: "uuid", nullable: false), - loginprovider = table.Column(name: "login_provider", type: "text", nullable: false), - name = table.Column(type: "text", nullable: false), - version = table.Column(type: "bigint", nullable: false), - value = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("pk_asp_net_user_tokens", x => new { x.userid, x.loginprovider, x.name }); - table.ForeignKey( - name: "fk_asp_net_user_tokens_asp_net_users_user_id", - column: x => x.userid, - principalTable: "asp_net_users", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_role_claims_role_id", - table: "asp_net_role_claims", - column: "role_id"); - - migrationBuilder.CreateIndex( - name: "RoleNameIndex", - table: "asp_net_roles", - column: "normalized_name", - unique: true); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_user_claims_user_id", - table: "asp_net_user_claims", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_user_logins_user_id", - table: "asp_net_user_logins", - column: "user_id"); - - migrationBuilder.CreateIndex( - name: "ix_asp_net_user_roles_role_id", - table: "asp_net_user_roles", - column: "role_id"); - - migrationBuilder.CreateIndex( - name: "EmailIndex", - table: "asp_net_users", - column: "normalized_email"); - - migrationBuilder.CreateIndex( - name: "UserNameIndex", - table: "asp_net_users", - column: "normalized_user_name", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "asp_net_role_claims"); - - migrationBuilder.DropTable( - name: "asp_net_user_claims"); - - migrationBuilder.DropTable( - name: "asp_net_user_logins"); - - migrationBuilder.DropTable( - name: "asp_net_user_roles"); - - migrationBuilder.DropTable( - name: "asp_net_user_tokens"); - - migrationBuilder.DropTable( - name: "asp_net_roles"); - - migrationBuilder.DropTable( - name: "asp_net_users"); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs deleted file mode 100644 index ce8faa3..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs +++ /dev/null @@ -1,374 +0,0 @@ -// -using System; -using Identity.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Identity.Data.Migrations -{ - [DbContext(typeof(IdentityContext))] - partial class IdentityContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Identity.Identity.Models.Role", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("name"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_roles"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("asp_net_roles", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.RoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_role_claims"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_role_claims_role_id"); - - b.ToTable("asp_net_role_claims", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("AccessFailedCount") - .HasColumnType("integer") - .HasColumnName("access_failed_count"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text") - .HasColumnName("concurrency_stamp"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("email"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean") - .HasColumnName("email_confirmed"); - - b.Property("FirstName") - .HasColumnType("text") - .HasColumnName("first_name"); - - b.Property("LastName") - .HasColumnType("text") - .HasColumnName("last_name"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean") - .HasColumnName("lockout_enabled"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone") - .HasColumnName("lockout_end"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_email"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("normalized_user_name"); - - b.Property("PassPortNumber") - .HasColumnType("text") - .HasColumnName("pass_port_number"); - - b.Property("PasswordHash") - .HasColumnType("text") - .HasColumnName("password_hash"); - - b.Property("PhoneNumber") - .HasColumnType("text") - .HasColumnName("phone_number"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean") - .HasColumnName("phone_number_confirmed"); - - b.Property("SecurityStamp") - .HasColumnType("text") - .HasColumnName("security_stamp"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean") - .HasColumnName("two_factor_enabled"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)") - .HasColumnName("user_name"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_users"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("asp_net_users", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text") - .HasColumnName("claim_type"); - - b.Property("ClaimValue") - .HasColumnType("text") - .HasColumnName("claim_value"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_asp_net_user_claims"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_claims_user_id"); - - b.ToTable("asp_net_user_claims", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("ProviderKey") - .HasColumnType("text") - .HasColumnName("provider_key"); - - b.Property("ProviderDisplayName") - .HasColumnType("text") - .HasColumnName("provider_display_name"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("LoginProvider", "ProviderKey") - .HasName("pk_asp_net_user_logins"); - - b.HasIndex("UserId") - .HasDatabaseName("ix_asp_net_user_logins_user_id"); - - b.ToTable("asp_net_user_logins", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserRole", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("RoleId") - .HasColumnType("uuid") - .HasColumnName("role_id"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "RoleId") - .HasName("pk_asp_net_user_roles"); - - b.HasIndex("RoleId") - .HasDatabaseName("ix_asp_net_user_roles_role_id"); - - b.ToTable("asp_net_user_roles", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserToken", b => - { - b.Property("UserId") - .HasColumnType("uuid") - .HasColumnName("user_id"); - - b.Property("LoginProvider") - .HasColumnType("text") - .HasColumnName("login_provider"); - - b.Property("Name") - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("Value") - .HasColumnType("text") - .HasColumnName("value"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("UserId", "LoginProvider", "Name") - .HasName("pk_asp_net_user_tokens"); - - b.ToTable("asp_net_user_tokens", (string)null); - }); - - modelBuilder.Entity("Identity.Identity.Models.RoleClaim", b => - { - b.HasOne("Identity.Identity.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_role_claims_asp_net_roles_role_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserClaim", b => - { - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_claims_asp_net_users_user_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserLogin", b => - { - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_logins_asp_net_users_user_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserRole", b => - { - b.HasOne("Identity.Identity.Models.Role", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_roles_role_id"); - - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_roles_asp_net_users_user_id"); - }); - - modelBuilder.Entity("Identity.Identity.Models.UserToken", b => - { - b.HasOne("Identity.Identity.Models.User", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("fk_asp_net_user_tokens_asp_net_users_user_id"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Seed/InitialData.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Seed/InitialData.cs deleted file mode 100644 index 1ab362b..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Seed/InitialData.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace Identity.Data.Seed; - -using System; -using System.Collections.Generic; -using Identity.Models; -using MassTransit; - -public static class InitialData -{ - public static List Users { get; } - - static InitialData() - { - Users = new List - { - new User - { - Id = NewId.NextGuid(), - FirstName = "Sam", - LastName = "H", - UserName = "samh", - PassPortNumber = "12345678", - Email = "sam@test.com", - SecurityStamp = Guid.NewGuid().ToString() - }, - new User - { - Id = NewId.NextGuid(), - FirstName = "Sam2", - LastName = "H2", - UserName = "samh2", - PassPortNumber = "87654321", - Email = "sam2@test.com", - SecurityStamp = Guid.NewGuid().ToString() - } - }; - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/readme.md b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/readme.md deleted file mode 100644 index 69eb2cb..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -dotnet ef migrations add initial --context IdentityContext -o "Data\Migrations" -dotnet ef database update --context IdentityContext diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs deleted file mode 100644 index 4487cbf..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs +++ /dev/null @@ -1,65 +0,0 @@ -using BuildingBlocks.Web; -using Identity.Data; -using Identity.Identity.Models; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.DependencyInjection; - -namespace Identity.Extensions.Infrastructure; - -using Configurations; - -public static class IdentityServerExtensions -{ - public static WebApplicationBuilder AddCustomIdentityServer(this WebApplicationBuilder builder) - { - builder.Services.AddValidateOptions(); - var authOptions = builder.Services.GetOptions(nameof(AuthOptions)); - - builder.Services.AddIdentity(config => - { - config.Password.RequiredLength = 6; - config.Password.RequireDigit = false; - config.Password.RequireNonAlphanumeric = false; - config.Password.RequireUppercase = false; - }) - .AddEntityFrameworkStores() - .AddDefaultTokenProviders(); - - var identityServerBuilder = builder.Services.AddIdentityServer(options => - { - options.Events.RaiseErrorEvents = true; - options.Events.RaiseInformationEvents = true; - options.Events.RaiseFailureEvents = true; - options.Events.RaiseSuccessEvents = true; - options.IssuerUri = authOptions.IssuerUri; - }) - .AddInMemoryIdentityResources(Config.IdentityResources) - .AddInMemoryApiResources(Config.ApiResources) - .AddInMemoryApiScopes(Config.ApiScopes) - .AddInMemoryClients(Config.Clients) - .AddAspNetIdentity() - .AddResourceOwnerValidator(); - - //ref: https://documentation.openiddict.com/configuration/encryption-and-signing-credentials.html - identityServerBuilder.AddDeveloperSigningCredential(); - - builder.Services.ConfigureApplicationCookie(options => - { - options.Events.OnRedirectToLogin = context => - { - context.Response.StatusCode = StatusCodes.Status401Unauthorized; - return Task.CompletedTask; - }; - - options.Events.OnRedirectToAccessDenied = context => - { - context.Response.StatusCode = StatusCodes.Status403Forbidden; - return Task.CompletedTask; - }; - }); - - return builder; - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity.csproj b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity.csproj deleted file mode 100644 index 2662e88..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Exceptions/RegisterIdentityUserException.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Exceptions/RegisterIdentityUserException.cs deleted file mode 100644 index d6aca87..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Exceptions/RegisterIdentityUserException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using BuildingBlocks.Exception; - -namespace Identity.Identity.Exceptions; - -public class RegisterIdentityUserException : AppException -{ - public RegisterIdentityUserException(string message) : base(message) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Features/IdentityMappings.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Features/IdentityMappings.cs deleted file mode 100644 index 906485a..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Features/IdentityMappings.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Mapster; - -namespace Identity.Identity.Features; - -using RegisteringNewUser.V1; - -public class IdentityMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .ConstructUsing(x => new RegisterNewUser(x.FirstName, x.LastName, x.Username, x.Email, - x.Password, x.ConfirmPassword, x.PassportNumber)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/Role.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/Role.cs deleted file mode 100644 index 3e14e3d..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/Role.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -public class Role : IdentityRole, IVersion -{ - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/RoleClaim.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/RoleClaim.cs deleted file mode 100644 index cc59e12..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/RoleClaim.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -public class RoleClaim : IdentityRoleClaim, IVersion -{ - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/User.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/User.cs deleted file mode 100644 index 2c1bdb0..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/User.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Microsoft.AspNetCore.Identity; - -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; - -public class User : IdentityUser, IVersion -{ - public required string FirstName { get; init; } - public required string LastName { get; init; } - public required string PassPortNumber { get; init; } - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserClaim.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserClaim.cs deleted file mode 100644 index c77e433..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserClaim.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -public class UserClaim : IdentityUserClaim, IVersion -{ - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserLogin.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserLogin.cs deleted file mode 100644 index 4d9fc22..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserLogin.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -public class UserLogin : IdentityUserLogin, IVersion -{ - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserRole.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserRole.cs deleted file mode 100644 index 3f0adf3..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserRole.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -public class UserRole : IdentityUserRole, IVersion -{ - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserToken.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserToken.cs deleted file mode 100644 index ce88cbf..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Models/UserToken.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Identity.Identity.Models; - -using System; -using BuildingBlocks.Core.Model; -using Microsoft.AspNetCore.Identity; - -public class UserToken : IdentityUserToken, IVersion -{ - public long Version { get; set; } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/IdentityEventMapper.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/IdentityEventMapper.cs deleted file mode 100644 index 887210d..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/IdentityEventMapper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace Identity; - -public sealed class IdentityEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - _ => null - }; - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/IdentityRoot.cs b/3-microservices-architecture-style/src/Services/Identity/src/Identity/IdentityRoot.cs deleted file mode 100644 index 05b7694..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity/IdentityRoot.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Identity; - -public class IdentityRoot -{ -} diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Fakes/FakeRegisterNewUserCommand.cs b/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Fakes/FakeRegisterNewUserCommand.cs deleted file mode 100644 index f351009..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Fakes/FakeRegisterNewUserCommand.cs +++ /dev/null @@ -1,16 +0,0 @@ -using AutoBogus; - -namespace Integration.Test.Fakes; - -using global::Identity.Identity.Features.RegisteringNewUser.V1; - -public class FakeRegisterNewUserCommand : AutoFaker -{ - public FakeRegisterNewUserCommand() - { - RuleFor(r => r.Username, x => "TestMyUser"); - RuleFor(r => r.Password, _ => "Password@123"); - RuleFor(r => r.ConfirmPassword, _ => "Password@123"); - RuleFor(r => r.Email, _ => "test@test.com"); - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/IdentityTestDataSeeder.cs b/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/IdentityTestDataSeeder.cs deleted file mode 100644 index 7bb371e..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/IdentityTestDataSeeder.cs +++ /dev/null @@ -1,64 +0,0 @@ -using BuildingBlocks.Constants; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.EFCore; -using Identity.Data.Seed; -using Identity.Identity.Constants; -using Identity.Identity.Models; -using Microsoft.AspNetCore.Identity; - -namespace Integration.Test; - -public class IdentityTestDataSeeder( - UserManager userManager, - RoleManager roleManager, - IEventDispatcher eventDispatcher -) - : ITestDataSeeder -{ - public async Task SeedAllAsync() - { - await SeedRoles(); - await SeedUsers(); - } - - private async Task SeedRoles() - { - if (await roleManager.RoleExistsAsync(IdentityConstant.Role.Admin) == false) - { - await roleManager.CreateAsync(new Role { Name = IdentityConstant.Role.Admin }); - } - - if (await roleManager.RoleExistsAsync(IdentityConstant.Role.User) == false) - { - await roleManager.CreateAsync(new Role { Name = IdentityConstant.Role.User }); - } - } - - private async Task SeedUsers() - { - if (await userManager.FindByNameAsync("samh") == null) - { - var result = await userManager.CreateAsync(InitialData.Users.First(), "Admin@123456"); - - if (result.Succeeded) - { - await userManager.AddToRoleAsync(InitialData.Users.First(), IdentityConstant.Role.Admin); - - await eventDispatcher.SendAsync(new UserCreated(InitialData.Users.First().Id, InitialData.Users.First().FirstName + " " + InitialData.Users.First().LastName, InitialData.Users.First().PassPortNumber)); - } - } - - if (await userManager.FindByNameAsync("meysamh2") == null) - { - var result = await userManager.CreateAsync(InitialData.Users.Last(), "User@123456"); - - if (result.Succeeded) - { - await userManager.AddToRoleAsync(InitialData.Users.Last(), IdentityConstant.Role.User); - - await eventDispatcher.SendAsync(new UserCreated(InitialData.Users.Last().Id, InitialData.Users.Last().FirstName + " " + InitialData.Users.Last().LastName, InitialData.Users.Last().PassPortNumber)); - } - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/xunit.runner.json b/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/xunit.runner.json deleted file mode 100644 index 9db029b..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator/VERSION b/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator/VERSION deleted file mode 100644 index ba8a874..0000000 --- a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.6.0-SNAPSHOT \ No newline at end of file diff --git a/3-microservices-architecture-style/src/Services/Passenger/Dockerfile b/3-microservices-architecture-style/src/Services/Passenger/Dockerfile deleted file mode 100644 index ea5d736..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passenger.csproj ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/ - - -# Restore nuget packages -RUN dotnet restore ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/ ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/ ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api - -# Publish project to output folder -# and no build, as we did it already -RUN dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/out . - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Passenger.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Passenger/dev.Dockerfile b/3-microservices-architecture-style/src/Services/Passenger/dev.Dockerfile deleted file mode 100644 index 79effda..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/dev.Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder -WORKDIR / - -COPY ./.editorconfig ./ -COPY ./global.json ./ -COPY ./Directory.Build.props ./ - -# Setup working directory for the project -COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passenger.csproj ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/ - - -# Restore nuget packages -RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ - dotnet restore ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj - -# Copy project files -COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/ ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger/ -COPY ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/ ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/ - -# Build project with Release configuration -# and no restore, as we did it already - -RUN ls -RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ - dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj - -WORKDIR /3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api - -# Publish project to output folder -# and no build, as we did it already -RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ - dotnet publish -c Release --no-build -o out - -FROM mcr.microsoft.com/dotnet/aspnet:9.0 - -# Setup working directory for the project -WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/out . - -ENV ASPNETCORE_URLS https://*:443, http://*:80 -ENV ASPNETCORE_ENVIRONMENT docker - -EXPOSE 80 -EXPOSE 443 - -ENTRYPOINT ["dotnet", "Passenger.Api.dll"] - diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/AssemblyInfo.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/AssemblyInfo.cs deleted file mode 100644 index 60fedfd..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Unit.Test")] -[assembly: InternalsVisibleTo("Integration.Test")] -[assembly: InternalsVisibleTo("EndToEnd.Test")] - diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Configurations/PassengerConfiguration.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Configurations/PassengerConfiguration.cs deleted file mode 100644 index 5871d21..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Configurations/PassengerConfiguration.cs +++ /dev/null @@ -1,60 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace Passenger.Data.Configurations; - -using Passengers.ValueObjects; - -public class PassengerConfiguration : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable(nameof(Passengers.Models.Passenger)); - - builder.HasKey(r => r.Id); - builder.Property(r => r.Id).ValueGeneratedNever() - .HasConversion(passengerId => passengerId.Value, dbId => PassengerId.Of(dbId)); - - builder.Property(r => r.Version).IsConcurrencyToken(); - - builder.OwnsOne( - x => x.Name, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Passengers.Models.Passenger.Name)) - .HasMaxLength(50) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.PassportNumber, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Passengers.Models.Passenger.PassportNumber)) - .HasMaxLength(10) - .IsRequired(); - } - ); - - builder.OwnsOne( - x => x.Age, - a => - { - a.Property(p => p.Value) - .HasColumnName(nameof(Passengers.Models.Passenger.Age)) - .HasMaxLength(3) - .IsRequired(); - } - ); - - builder.Property(x => x.PassengerType) - .IsRequired() - .HasDefaultValue(Passengers.Enums.PassengerType.Unknown) - .HasConversion( - x => x.ToString(), - x => (Passengers.Enums.PassengerType)Enum.Parse(typeof(Passengers.Enums.PassengerType), x)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/DesignTimeDbContextFactory.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/DesignTimeDbContextFactory.cs deleted file mode 100644 index 4ee9534..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/DesignTimeDbContextFactory.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -namespace Passenger.Data; - -public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory -{ - public PassengerDbContext CreateDbContext(string[] args) - { - var builder = new DbContextOptionsBuilder(); - - builder.UseNpgsql("Server=localhost;Port=5432;Database=passenger;User Id=postgres;Password=postgres;Include Error Detail=true") - .UseSnakeCaseNamingConvention(); - return new PassengerDbContext(builder.Options); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs deleted file mode 100644 index d471cb8..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs +++ /dev/null @@ -1,150 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Passenger.Data; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - [DbContext(typeof(PassengerDbContext))] - [Migration("20230611213031_initial")] - partial class initial - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("PassengerType") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("passenger_type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_passenger"); - - b.ToTable("passenger", (string)null); - }); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.OwnsOne("Passenger.Passengers.ValueObjects.Age", "Age", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(3) - .HasColumnType("integer") - .HasColumnName("age"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("Passenger.Passengers.ValueObjects.Name", "Name", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("Passenger.Passengers.ValueObjects.PassportNumber", "PassportNumber", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("passport_number"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.Navigation("Age"); - - b.Navigation("Name") - .IsRequired(); - - b.Navigation("PassportNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs deleted file mode 100644 index 57c1647..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - /// - public partial class initial : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "passenger", - columns: table => new - { - id = table.Column(type: "uuid", nullable: false), - passportnumber = table.Column(name: "passport_number", type: "character varying(10)", maxLength: 10, nullable: false), - name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), - passengertype = table.Column(name: "passenger_type", type: "text", nullable: false, defaultValue: "Unknown"), - age = table.Column(type: "integer", maxLength: 3, nullable: true), - createdat = table.Column(name: "created_at", type: "timestamp with time zone", nullable: true), - createdby = table.Column(name: "created_by", type: "bigint", nullable: true), - lastmodified = table.Column(name: "last_modified", type: "timestamp with time zone", nullable: true), - lastmodifiedby = table.Column(name: "last_modified_by", type: "bigint", nullable: true), - isdeleted = table.Column(name: "is_deleted", type: "boolean", nullable: false), - version = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("pk_passenger", x => x.id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "passenger"); - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs deleted file mode 100644 index 122b184..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs +++ /dev/null @@ -1,147 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Passenger.Data; - -#nullable disable - -namespace Passenger.Data.Migrations -{ - [DbContext(typeof(PassengerDbContext))] - partial class PassengerDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.Property("Id") - .HasColumnType("uuid") - .HasColumnName("id"); - - b.Property("CreatedAt") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_at"); - - b.Property("CreatedBy") - .HasColumnType("bigint") - .HasColumnName("created_by"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("LastModified") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_modified"); - - b.Property("LastModifiedBy") - .HasColumnType("bigint") - .HasColumnName("last_modified_by"); - - b.Property("PassengerType") - .IsRequired() - .ValueGeneratedOnAdd() - .HasColumnType("text") - .HasDefaultValue("Unknown") - .HasColumnName("passenger_type"); - - b.Property("Version") - .IsConcurrencyToken() - .HasColumnType("bigint") - .HasColumnName("version"); - - b.HasKey("Id") - .HasName("pk_passenger"); - - b.ToTable("passenger", (string)null); - }); - - modelBuilder.Entity("Passenger.Passengers.Models.Passenger", b => - { - b.OwnsOne("Passenger.Passengers.ValueObjects.Age", "Age", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .HasMaxLength(3) - .HasColumnType("integer") - .HasColumnName("age"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("Passenger.Passengers.ValueObjects.Name", "Name", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("character varying(50)") - .HasColumnName("name"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.OwnsOne("Passenger.Passengers.ValueObjects.PassportNumber", "PassportNumber", b1 => - { - b1.Property("PassengerId") - .HasColumnType("uuid") - .HasColumnName("id"); - - b1.Property("Value") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("character varying(10)") - .HasColumnName("passport_number"); - - b1.HasKey("PassengerId") - .HasName("pk_passenger"); - - b1.ToTable("passenger"); - - b1.WithOwner() - .HasForeignKey("PassengerId") - .HasConstraintName("fk_passenger_passenger_id"); - }); - - b.Navigation("Age"); - - b.Navigation("Name") - .IsRequired(); - - b.Navigation("PassportNumber") - .IsRequired(); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/PassengerDbContext.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/PassengerDbContext.cs deleted file mode 100644 index 2aa1227..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/PassengerDbContext.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using BuildingBlocks.EFCore; -using BuildingBlocks.Web; -using Microsoft.EntityFrameworkCore; - -namespace Passenger.Data; - -using Microsoft.Extensions.Logging; - -public sealed class PassengerDbContext : AppDbContextBase -{ - public PassengerDbContext(DbContextOptions options, - ICurrentUserProvider? currentUserProvider = null, ILogger? logger = null) : - base(options, currentUserProvider, logger) - { - } - - public DbSet Passengers => Set(); - - protected override void OnModelCreating(ModelBuilder builder) - { - builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly()); - base.OnModelCreating(builder); - builder.FilterSoftDeletedProperties(); - builder.ToSnakeCaseTables(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/PassengerReadDbContext.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/PassengerReadDbContext.cs deleted file mode 100644 index e4dcf14..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/PassengerReadDbContext.cs +++ /dev/null @@ -1,18 +0,0 @@ -using BuildingBlocks.Mongo; -using Humanizer; -using Microsoft.Extensions.Options; -using MongoDB.Driver; - -namespace Passenger.Data; - -using Passengers.Models; - -public class PassengerReadDbContext : MongoDbContext -{ - public PassengerReadDbContext(IOptions options) : base(options) - { - Passenger = GetCollection(nameof(Passenger).Underscore()); - } - - public IMongoCollection Passenger { get; } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/readme.md b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/readme.md deleted file mode 100644 index 97deb62..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Data/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -dotnet ef migrations add initial --context PassengerDbContext -o "Data\Migrations" -dotnet ef database update --context PassengerDbContext diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidAgeException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidAgeException.cs deleted file mode 100644 index 0e59ba9..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidAgeException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Passenger.Exceptions; - -public class InvalidAgeException : DomainException -{ - public InvalidAgeException() : base("Age Cannot be null or negative") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidNameException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidNameException.cs deleted file mode 100644 index 2665776..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Passenger.Exceptions; - -public class InvalidNameException : DomainException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassengerIdException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassengerIdException.cs deleted file mode 100644 index dd342d5..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassengerIdException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Passenger.Exceptions; -using System; - -public class InvalidPassengerIdException : DomainException -{ - public InvalidPassengerIdException(Guid passengerId) - : base($"PassengerId: '{passengerId}' is invalid.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassportNumberException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassportNumberException.cs deleted file mode 100644 index 491398d..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassportNumberException.cs +++ /dev/null @@ -1,10 +0,0 @@ -using SmartCharging.Infrastructure.Exceptions; - -namespace Passenger.Exceptions; - -public class InvalidPassportNumberException : DomainException -{ - public InvalidPassportNumberException() : base("Passport number cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/PassengerAlreadyExist.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/PassengerAlreadyExist.cs deleted file mode 100644 index 8f65d3c..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/PassengerAlreadyExist.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Passenger.Exceptions; - -public class PassengerNotExist : AppException -{ - public PassengerNotExist() : base("Please register before!", HttpStatusCode.NotFound) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/PassengerNotFoundException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/PassengerNotFoundException.cs deleted file mode 100644 index c387900..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Exceptions/PassengerNotFoundException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Net; -using BuildingBlocks.Exception; - -namespace Passenger.Exceptions; - -public class PassengerNotFoundException : AppException -{ - public PassengerNotFoundException() : base("Passenger not found!", HttpStatusCode.NotFound) - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/GrpcServer/Protos/passenger.proto b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/GrpcServer/Protos/passenger.proto deleted file mode 100644 index bb98c29..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/GrpcServer/Protos/passenger.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; - -package passenger; - -service PassengerGrpcService { - - rpc GetById (GetByIdRequest) returns (GetPassengerByIdResult); -} - -message GetByIdRequest { - string Id = 1; -} - -message GetPassengerByIdResult { - PassengerResponse PassengerDto = 1; -} - -message PassengerResponse { - string Id = 1; - string Name = 2; - string PassportNumber = 3; - PassengerType PassengerType = 4; - int32 Age = 5; - string Email = 6; -} - - - enum PassengerType { - PASSENGER_TYPE_UNKNOWN = 0; - PASSENGER_TYPE_MALE = 1; - PASSENGER_TYPE_FEMALE = 2; - PASSENGER_TYPE_BABY = 3; - } - diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/GrpcServer/Services/PassengerGrpcServices.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/GrpcServer/Services/PassengerGrpcServices.cs deleted file mode 100644 index d66cca5..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/GrpcServer/Services/PassengerGrpcServices.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Grpc.Core; -using MediatR; - -namespace Passenger.GrpcServer.Services; - -using Mapster; -using Passengers.Features.GettingPassengerById.V1; -using GetPassengerByIdResult = Passenger.GetPassengerByIdResult; - -public class PassengerGrpcServices : PassengerGrpcService.PassengerGrpcServiceBase -{ - private readonly IMediator _mediator; - - public PassengerGrpcServices(IMediator mediator) - { - _mediator = mediator; - } - - public override async Task GetById(GetByIdRequest request, ServerCallContext context) - { - var result = await _mediator.Send(new GetPassengerById(new Guid(request.Id))); - return result?.Adapt(); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs deleted file mode 100644 index 1e96c2d..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Passenger.Identity.Consumers.RegisteringNewUser.V1; - -using BuildingBlocks.Core.Event; - -public record PassengerCreatedDomainEvent(Guid Id, string Name, string PassportNumber, bool IsDeleted = false) : IDomainEvent; diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs deleted file mode 100644 index a674210..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace Passenger.Identity.Consumers.RegisteringNewUser.V1; - -using Ardalis.GuardClauses; -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; -using BuildingBlocks.Web; -using Data; -using Humanizer; -using MassTransit; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Passengers.ValueObjects; - -public class RegisterNewUserHandler : IConsumer -{ - private readonly PassengerDbContext _passengerDbContext; - private readonly IEventDispatcher _eventDispatcher; - private readonly ILogger _logger; - private readonly AppOptions _options; - - public RegisterNewUserHandler(PassengerDbContext passengerDbContext, - IEventDispatcher eventDispatcher, - ILogger logger, - IOptions options) - { - _passengerDbContext = passengerDbContext; - _eventDispatcher = eventDispatcher; - _logger = logger; - _options = options.Value; - } - - public async Task Consume(ConsumeContext context) - { - Guard.Against.Null(context.Message, nameof(UserCreated)); - - _logger.LogInformation($"consumer for {nameof(UserCreated).Underscore()} in {_options.Name}"); - - var passengerExist = - await _passengerDbContext.Passengers.AnyAsync(x => x.PassportNumber.Value == context.Message.PassportNumber); - - if (passengerExist) - { - return; - } - - var passenger = Passengers.Models.Passenger.Create(PassengerId.Of(NewId.NextGuid()), Name.Of(context.Message.Name), - PassportNumber.Of(context.Message.PassportNumber)); - - await _passengerDbContext.AddAsync(passenger); - - await _passengerDbContext.SaveChangesAsync(); - - await _eventDispatcher.SendAsync( - new PassengerCreatedDomainEvent(passenger.Id, passenger.Name, passenger.PassportNumber), - typeof(IInternalCommand)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passenger.csproj b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passenger.csproj deleted file mode 100644 index 8e453b0..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passenger.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - - - - - - - - diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/PassengerEventMapper.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/PassengerEventMapper.cs deleted file mode 100644 index 1deafb7..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/PassengerEventMapper.cs +++ /dev/null @@ -1,33 +0,0 @@ -using BuildingBlocks.Contracts.EventBus.Messages; -using BuildingBlocks.Core; -using BuildingBlocks.Core.Event; - -namespace Passenger; - -using Identity.Consumers.RegisteringNewUser.V1; -using Passengers.Features.CompletingRegisterPassenger.V1; - -public sealed class PassengerEventMapper : IEventMapper -{ - public IIntegrationEvent? MapToIntegrationEvent(IDomainEvent @event) - { - return @event switch - { - PassengerRegistrationCompletedDomainEvent e => new PassengerRegistrationCompleted(e.Id), - PassengerCreatedDomainEvent e => new PassengerCreated(e.Id), - _ => null - }; - } - - public IInternalCommand? MapToInternalCommand(IDomainEvent @event) - { - return @event switch - { - PassengerRegistrationCompletedDomainEvent e => new CompleteRegisterPassengerMongoCommand(e.Id, e.PassportNumber, e.Name, e.PassengerType, - e.Age, e.IsDeleted), - PassengerCreatedDomainEvent e => new CompleteRegisterPassengerMongoCommand(e.Id, e.PassportNumber, e.Name, Passengers.Enums.PassengerType.Unknown, - 0, e.IsDeleted), - _ => null - }; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/PassengerRoot.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/PassengerRoot.cs deleted file mode 100644 index faf4fe5..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/PassengerRoot.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Passenger; - -public class PassengerRoot -{ - -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Dtos/PassengerDto.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Dtos/PassengerDto.cs deleted file mode 100644 index 17fad5c..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Dtos/PassengerDto.cs +++ /dev/null @@ -1,2 +0,0 @@ -namespace Passenger.Passengers.Dtos; -public record PassengerDto(Guid Id, string Name, string PassportNumber, Enums.PassengerType PassengerType, int Age); diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Enums/PassengerType.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Enums/PassengerType.cs deleted file mode 100644 index 4767301..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Enums/PassengerType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Passenger.Passengers.Enums; - -public enum PassengerType -{ - Unknown = 0, - Male, - Female, - Baby -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs deleted file mode 100644 index df9a826..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Passenger.Passengers.Exceptions; -using BuildingBlocks.Exception; - -public class InvalidAgeException : BadRequestException -{ - public InvalidAgeException() : base("Age Cannot be null or negative") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidNameException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidNameException.cs deleted file mode 100644 index 0a44de6..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidNameException.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Passenger.Passengers.Exceptions; -using BuildingBlocks.Exception; - - -public class InvalidNameException : BadRequestException -{ - public InvalidNameException() : base("Name cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs deleted file mode 100644 index bb6429b..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Passenger.Passengers.Exceptions; -using BuildingBlocks.Exception; - - -public class InvalidPassportNumberException : BadRequestException -{ - public InvalidPassportNumberException() : base("Passport number cannot be empty or whitespace.") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs deleted file mode 100644 index 62a46a2..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Passenger.Passengers.Exceptions; - -using BuildingBlocks.Exception; - -public class PassengerNotExist : BadRequestException -{ - public PassengerNotExist(string code = default) : base("Please register before!") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs deleted file mode 100644 index 771089e..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Passenger.Passengers.Exceptions; - -using BuildingBlocks.Exception; - -public class PassengerNotFoundException : NotFoundException -{ - public PassengerNotFoundException(string code = default) : base("Passenger not found!") - { - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs deleted file mode 100644 index dcb20e0..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace Passenger.Passengers.Features.CompletingRegisterPassenger.V1; - -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Core.Event; -using Data; -using MapsterMapper; -using MediatR; -using Models; -using MongoDB.Driver; -using MongoDB.Driver.Linq; -using ValueObjects; - -public record CompleteRegisterPassengerMongoCommand(Guid Id, string PassportNumber, string Name, - Enums.PassengerType PassengerType, int Age, bool IsDeleted = false) : InternalCommand; - - -internal class CompleteRegisterPassengerMongoHandler : ICommandHandler -{ - private readonly PassengerReadDbContext _passengerReadDbContext; - private readonly IMapper _mapper; - - public CompleteRegisterPassengerMongoHandler( - PassengerReadDbContext passengerReadDbContext, - IMapper mapper) - { - _passengerReadDbContext = passengerReadDbContext; - _mapper = mapper; - } - - public async Task Handle(CompleteRegisterPassengerMongoCommand request, CancellationToken cancellationToken) - { - Guard.Against.Null(request, nameof(request)); - - var passengerReadModel = _mapper.Map(request); - - var passenger = await _passengerReadDbContext.Passenger.AsQueryable() - .FirstOrDefaultAsync(x => x.PassengerId == passengerReadModel.PassengerId && !x.IsDeleted, cancellationToken); - - if (passenger is not null) - { - await _passengerReadDbContext.Passenger.UpdateOneAsync( - x => x.PassengerId == PassengerId.Of(passengerReadModel.PassengerId), - Builders.Update - .Set(x => x.PassengerId, PassengerId.Of(passengerReadModel.PassengerId)) - .Set(x => x.Age, passengerReadModel.Age) - .Set(x => x.Name, passengerReadModel.Name) - .Set(x => x.IsDeleted, passengerReadModel.IsDeleted) - .Set(x => x.PassengerType, passengerReadModel.PassengerType) - .Set(x => x.PassportNumber, passengerReadModel.PassportNumber), - cancellationToken: cancellationToken); - } - else - { - await _passengerReadDbContext.Passenger.InsertOneAsync(passengerReadModel, - cancellationToken: cancellationToken); - } - - return Unit.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs deleted file mode 100644 index 2b36d5f..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs +++ /dev/null @@ -1,89 +0,0 @@ -namespace Passenger.Passengers.Features.GettingPassengerById.V1; - -using Ardalis.GuardClauses; -using BuildingBlocks.Core.CQRS; -using BuildingBlocks.Web; -using Duende.IdentityServer.EntityFramework.Entities; -using FluentValidation; -using Mapster; -using MapsterMapper; -using MediatR; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; -using MongoDB.Driver; -using MongoDB.Driver.Linq; -using Passenger.Data; -using Passenger.Passengers.Dtos; -using Passenger.Passengers.Exceptions; - -public record GetPassengerById(Guid Id) : IQuery; - -public record GetPassengerByIdResult(PassengerDto PassengerDto); - -public record GetPassengerByIdResponseDto(PassengerDto PassengerDto); - -public class GetPassengerByIdEndpoint : IMinimalEndpoint -{ - public IEndpointRouteBuilder MapEndpoint(IEndpointRouteBuilder builder) - { - builder.MapGet($"{EndpointConfig.BaseApiPath}/passenger/{{id}}", - async (Guid id, IMediator mediator, CancellationToken cancellationToken) => - { - var result = await mediator.Send(new GetPassengerById(id), cancellationToken); - - var response = result.Adapt(); - - return Results.Ok(response); - }) - .RequireAuthorization(nameof(ApiScope)) - .WithName("GetPassengerById") - .WithApiVersionSet(builder.NewApiVersionSet("Passenger").Build()) - .Produces() - .ProducesProblem(StatusCodes.Status400BadRequest) - .WithSummary("Get Passenger By Id") - .WithDescription("Get Passenger By Id") - .WithOpenApi() - .HasApiVersion(1.0); - - return builder; - } -} - -public class GetPassengerByIdValidator : AbstractValidator -{ - public GetPassengerByIdValidator() - { - RuleFor(x => x.Id).NotNull().WithMessage("Id is required!"); - } -} - -internal class GetPassengerByIdHandler : IQueryHandler -{ - private readonly IMapper _mapper; - private readonly PassengerReadDbContext _passengerReadDbContext; - - public GetPassengerByIdHandler(IMapper mapper, PassengerReadDbContext passengerReadDbContext) - { - _mapper = mapper; - _passengerReadDbContext = passengerReadDbContext; - } - - public async Task Handle(GetPassengerById query, CancellationToken cancellationToken) - { - Guard.Against.Null(query, nameof(query)); - - var passenger = - await _passengerReadDbContext.Passenger.AsQueryable() - .SingleOrDefaultAsync(x => x.PassengerId == query.Id && x.IsDeleted == false, cancellationToken); - - if (passenger is null) - { - throw new PassengerNotFoundException(); - } - - var passengerDto = _mapper.Map(passenger); - - return new GetPassengerByIdResult(passengerDto); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/PassengerMappings.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/PassengerMappings.cs deleted file mode 100644 index f3ac499..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/PassengerMappings.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Mapster; - -namespace Passenger.Passengers.Features; - -using CompletingRegisterPassenger.V1; -using Dtos; -using MassTransit; -using Models; -using ValueObjects; - -public class PassengerMappings : IRegister -{ - public void Register(TypeAdapterConfig config) - { - config.NewConfig() - .Map(d => d.Id, s => NewId.NextGuid()) - .Map(d => d.PassengerId, s => PassengerId.Of(s.Id)); - - config.NewConfig() - .ConstructUsing(x => new CompleteRegisterPassenger(x.PassportNumber, x.PassengerType, x.Age)); - - config.NewConfig() - .ConstructUsing(x => new PassengerDto(x.PassengerId, x.Name, x.PassportNumber, x.PassengerType, x.Age)); - - config.NewConfig() - .ConstructUsing(x => new PassengerDto(x.Id.Value, x.Name.Value, x.PassportNumber.Value, x.PassengerType, x.Age.Value)); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Models/Passenger.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Models/Passenger.cs deleted file mode 100644 index 1b287b9..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Models/Passenger.cs +++ /dev/null @@ -1,45 +0,0 @@ -using BuildingBlocks.Core.Model; - -namespace Passenger.Passengers.Models; - -using Features.CompletingRegisterPassenger.V1; -using Identity.Consumers.RegisteringNewUser.V1; -using ValueObjects; - -public record Passenger : Aggregate -{ - public PassportNumber PassportNumber { get; private set; } = default!; - public Name Name { get; private set; } = default!; - public Enums.PassengerType PassengerType { get; private set; } - public Age? Age { get; private set; } - - public void CompleteRegistrationPassenger(PassengerId id, Name name, PassportNumber passportNumber, - Enums.PassengerType passengerType, Age age, bool isDeleted = false) - { - this.Id = id; - this.Name = name; - this.PassportNumber = passportNumber; - this.PassengerType = passengerType; - this.Age = age; - this.IsDeleted = isDeleted; - - var @event = new PassengerRegistrationCompletedDomainEvent(this.Id, this.Name, - this.PassportNumber, - this.PassengerType, this.Age, this.IsDeleted); - - this.AddDomainEvent(@event); - } - - - public static Passenger Create(PassengerId id, Name name, PassportNumber passportNumber, bool isDeleted = false) - { - var passenger = new Passenger { Id = id, Name = name, PassportNumber = passportNumber, IsDeleted = isDeleted }; - - var @event = new PassengerCreatedDomainEvent(passenger.Id, passenger.Name, passenger.PassportNumber, - passenger.IsDeleted); - - passenger.AddDomainEvent(@event); - - return passenger; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Models/PassengerReadModel.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Models/PassengerReadModel.cs deleted file mode 100644 index faa64a3..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Models/PassengerReadModel.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Passenger.Passengers.Models; -public class PassengerReadModel -{ - public required Guid Id { get; init; } - public required Guid PassengerId { get; init; } - public required string PassportNumber { get; init; } - public required string Name { get; init; } - public required Enums.PassengerType PassengerType { get; init; } - public int Age { get; init; } - public required bool IsDeleted { get; init; } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Age.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Age.cs deleted file mode 100644 index 73524cf..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Age.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Passenger.Passengers.ValueObjects; - -using Exceptions; - -public record Age -{ - public int Value { get; } - - private Age(int value) - { - Value = value; - } - - public static Age Of(int value) - { - if (value <= 0) - { - throw new InvalidAgeException(); - } - - return new Age(value); - } - - public static implicit operator int(Age age) - { - return age.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Name.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Name.cs deleted file mode 100644 index 41c134f..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Name.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace Passenger.Passengers.ValueObjects; - -using Passenger.Passengers.Exceptions; - -public record Name -{ - public string Value { get; } - - private Name(string value) - { - Value = value; - } - - public static Name Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidNameException(); - } - - return new Name(value); - } - - public static implicit operator string(Name name) - { - return name.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassengerId.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassengerId.cs deleted file mode 100644 index 548e6ad..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassengerId.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace Passenger.Passengers.ValueObjects; - -using System; -using Passenger.Exceptions; - -public record PassengerId -{ - public Guid Value { get; } - - private PassengerId(Guid value) - { - Value = value; - } - - public static PassengerId Of(Guid value) - { - if (value == Guid.Empty) - { - throw new InvalidPassengerIdException(value); - } - - return new PassengerId(value); - } - - public static implicit operator Guid(PassengerId passengerId) - { - return passengerId.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassportNumber.cs b/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassportNumber.cs deleted file mode 100644 index 9e4f922..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassportNumber.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Passenger.Passengers.ValueObjects; - -using Passenger.Passengers.Exceptions; - -public record PassportNumber -{ - public string Value { get; } - - public override string ToString() - { - return Value; - } - - private PassportNumber(string value) - { - Value = value; - } - - public static PassportNumber Of(string value) - { - if (string.IsNullOrWhiteSpace(value)) - { - throw new InvalidPassportNumberException(); - } - - return new PassportNumber(value); - } - - public static implicit operator string(PassportNumber passportNumber) - { - return passportNumber.Value; - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerCommand.cs b/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerCommand.cs deleted file mode 100644 index d470686..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -using AutoBogus; -using Passenger.Passengers.Enums; - -namespace Integration.Test.Fakes; - -using global::Passenger.Passengers.Features.CompletingRegisterPassenger.V1; -using MassTransit; - -public sealed class FakeCompleteRegisterPassengerCommand : AutoFaker -{ - public FakeCompleteRegisterPassengerCommand(string passportNumber) - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.PassportNumber, _ => passportNumber); - RuleFor(r => r.PassengerType, _ => PassengerType.Male); - RuleFor(r => r.Age, _ => 30); - } -} - diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs b/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs deleted file mode 100644 index f4c3f05..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Integration.Test.Fakes; - -using AutoBogus; -using global::Passenger.Passengers.Enums; -using global::Passenger.Passengers.Features.CompletingRegisterPassenger.V1; -using MassTransit; - -public class FakeCompleteRegisterPassengerMongoCommand : AutoFaker -{ - public FakeCompleteRegisterPassengerMongoCommand() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.Name, _ => "Sam"); - RuleFor(r => r.PassportNumber, _ => "123456789"); - RuleFor(r => r.Age, _ => 30); - RuleFor(r => r.IsDeleted, _ => false); - RuleFor(r => r.PassengerType, _ => PassengerType.Male); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeUserCreated.cs b/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeUserCreated.cs deleted file mode 100644 index de9e78e..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeUserCreated.cs +++ /dev/null @@ -1,16 +0,0 @@ -using AutoBogus; -using BuildingBlocks.Contracts.EventBus.Messages; - -namespace Integration.Test.Fakes; - -using MassTransit; - -public class FakeUserCreated : AutoFaker -{ - public FakeUserCreated() - { - RuleFor(r => r.Id, _ => NewId.NextGuid()); - RuleFor(r => r.Name, _ => "Sam"); - RuleFor(r => r.PassportNumber, _ => "123456789"); - } -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/xunit.runner.json b/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/xunit.runner.json deleted file mode 100644 index 9db029b..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/xunit.runner.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "parallelizeAssembly": false, - "parallelizeTestCollections": false -} diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/VERSION b/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/VERSION deleted file mode 100644 index ba8a874..0000000 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -6.6.0-SNAPSHOT \ No newline at end of file diff --git a/README.md b/README.md index 77570b8..36fcfb5 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,48 @@ -# 🪁 Monolith To Cloud Architecture -
-
- ci-status - build-status + booking-microservices +
+ ci-status + build-status
-> **A practical architecture styles for migrating from monolith to modern cloud native application with the latest technologies and architectures like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, and Masstransit in .Net 9.** +> 🚀 **A practical and imaginary microservices for implementing an infrastructure for up and running distributed system with the latest technology and architecture like Vertical Slice Architecture, Event Sourcing, CQRS, DDD, gRpc, MongoDB, RabbitMq, Masstransit in .Net 9.** + +> 💡 **This project is not business-oriented and most of my focus was in the thechnical part for implement a distributed system with a sample project. In this project I implemented some concept in microservices like Messaging, Tracing, Event Driven Architecture, Vertical Slice Architecture, Event Sourcing, CQRS, DDD and gRpc.** +
- Open in Gitpod + Open in Gitpod
- Open in GitHub Codespaces + Open in GitHub Codespaces
# Table of Contents - [The Goals of This Project](#the-goals-of-this-project) - [Technologies - Libraries](#technologies---libraries) -- [Architectural Styles and How to Choose the Right One](#architectural-styles-and-how-to-choose-the-right-one) - - [1. Monolithic Architecture](#1-monolithic-architecture-style) - - [2. Modular Monolith Architecture](#2-modular-monolith-architecture-style) - - [3. Microservices Architecture](#3-microservices-architecture-style) +- [Key Features](#key-features) +- [When to Use](#when-to-use) +- [Challenges](#challenges) - [The Domain and Bounded Context - Service Boundary](#the-domain-and-bounded-context---service-boundary) - [Structure of Project](#structure-of-project) +- [Development Setup](#development-setup) + - [Dotnet Tools Packages](#dotnet-tools-packages) + - [Husky](#husky) + - [Upgrade Nuget Packages](#upgrade-nuget-packages) +- [How to Run](#how-to-run) + - [Config Certificate](#config-certificate) + - [Docker Compose](#docker-compose) + - [Kubernetes](#kubernetes) + - [Build](#build) + - [Run](#run) + - [Test](#test) +- [Documentation Apis](#documentation-apis) - [Support](#support) - [Contribution](#contribution) + ## The Goals of This Project - :sparkle: Using `Vertical Slice Architecture` for `architecture` level. @@ -88,75 +102,26 @@ - ✔️ **[`Testcontainers`](https://github.com/testcontainers/testcontainers-dotnet)** - Testcontainers for .NET is a library to support tests with throwaway instances of Docker containers. - ✔️ **[`K6`](https://github.com/grafana/k6)** - Modern load testing for developers and testers in the DevOps era. -## Architectural Styles and How to Choose the Right One -The repository is organized into `three folders`, each representing a different `architectural style`. Below is an overview of each style, along with guidance on when to choose it based on your `project requirements`, `team size`, `scalability needs`, and `long-term maintenance` goals. +## Key Features +1. **Independent Services**: Each service is a separate project with its own database and deployment pipeline, enabling independent development and deployment. +2. **Decentralized Communication**: Services communicate via APIs (REST, gRPC) or message brokers (RabbitMQ, Kafka), ensuring loose coupling and resilience. +3. **Scalability**: Services can be scaled independently based on demand, allowing efficient resource utilization. +4. **Fault Tolerance**: Failures are isolated, preventing cascading failures and ensuring high availability. +5. **Technology Agnostic**: Services can use different technologies, frameworks, or databases, providing flexibility. -### 1. Monolithic Architecture Style -> A traditional **[monolithic architecture](https://github.com/meysamhadeli/monolith-to-cloud-architecture/tree/main/1-monolith-architecture-style)** where all components of the application are tightly coupled and deployed as a single unit. -
- -
+## When to Use +1. **Large and Complex Projects**: Ideal for applications with complex business logic that can be broken into smaller, manageable services. +2. **High Scalability Needs**: Suitable for applications requiring independent scaling of components. +3. **Fault Tolerance and High Availability**: Perfect for systems where failure isolation and uptime are critical. +4. **Distributed Teams**: Enables teams to work independently on different services. +5. **Frequent Updates**: Supports continuous deployment and A/B testing for individual services. +6. **Technology Diversity**: Allows the use of different technologies for different services. -- **When to Choose**: - - Your project is small or medium-sized. - - You have a small development team. - - You need to develop and deploy the application quickly. - - The application has relatively simple functionality. - - You don’t anticipate significant scaling needs in the near future. -- **Pros**: - - Simple to develop, test, and deploy. - - Easier to manage for small teams. - - Lower operational overhead. -- **Cons**: - - Tight coupling makes it harder to maintain as the codebase grows. - - Scaling is limited to scaling the entire application. - - Difficult to adopt new technologies or frameworks incrementally. -### 2. Modular Monolith Architecture Style -> A **[modular monolith architecture](https://github.com/meysamhadeli/monolith-to-cloud-architecture/tree/main/2-modular-monolith-architecture-style)** where the application is divided into modules, but still deployed as a single unit. This approach promotes better separation of concerns and maintainability. - -
- -
- -- **When to Choose**: - - Your project is medium to large-sized. - - You want better separation of concerns and maintainability than a traditional monolith. - - You plan to scale the application in the future but want to avoid the complexity of microservices. - - Your team is growing, and you need a more organized codebase. -- **Pros**: - - Better separation of concerns compared to a traditional monolith. - - Easier to maintain and extend as the application grows. - - Can be a stepping stone toward a microservices architecture. - - Simpler deployment than microservices. -- **Cons**: - - Still a single deployment unit, so scaling is limited. - - Requires careful design to avoid tight coupling between modules. - -### 3. Microservices Architecture Style -> A **[microservices architecture](https://github.com/meysamhadeli/monolith-to-cloud-architecture/tree/main/3-microservices-architecture-style)** where the application is broken down into small, independent services that can be developed, deployed, and scaled independently. - -
- -
- -- **When to Choose**: - - Your project is large and complex. - - You need to scale different parts of the application independently. - - Your team is large and can handle the complexity of distributed systems. - - You need to adopt different technologies or frameworks for different parts of the application. - - You require high availability and fault tolerance. -- **Pros**: - - Independent development, deployment, and scaling of services. - - Better fault isolation. - - Flexibility to use different technologies for different services. - - Easier to maintain and update individual services. -- **Cons**: - - Higher complexity in development, testing, and deployment. - - Requires robust DevOps practices and infrastructure. - - Increased operational overhead (e.g., monitoring, logging, service discovery). +## Challenges +- Increased complexity in management, DevOps overhead, data consistency, latency, and higher costs. ## The Domain And Bounded Context - Service Boundary @@ -169,6 +134,8 @@ The repository is organized into `three folders`, each representing a different - `Booking Service`: The Booking Service is a bounded context for managing all operation related to booking ticket. +![](./assets/booking-microservices.png) + ## Structure of Project @@ -196,6 +163,100 @@ I used CQRS to decompose my features into small parts that makes our application Using the CQRS pattern, we cut each business functionality into vertical slices, for each of these slices we group classes (see [technical folders structure](http://www.kamilgrzybek.com/design/feature-folders)) specific to that feature together (command, handlers, infrastructure, repository, controllers, etc). In our CQRS pattern each command/query handler is a separate slice. This is where you can reduce coupling between layers. Each handler can be a separated code unit, even copy/pasted. Thanks to that, we can tune down the specific method to not follow general conventions (e.g. use custom SQL query or even different storage). In a traditional layered architecture, when we change the core generic mechanism in one layer, it can impact all methods. +## Development Setup + +### Dotnet Tools Packages +For installing our requirement packages with .NET cli tools, we need to install `dotnet tool manifest`. +```bash +dotnet new tool-manifest +``` +And after that we can restore our dotnet tools packages with .NET cli tools from `.config` folder and `dotnet-tools.json` file. +``` +dotnet tool restore +``` + +### Husky +Here we use `husky` to handel some pre commit rules and we used `conventional commits` rules and `formatting` as pre commit rules, here in [package.json](.././package.json). of course, we can add more rules for pre commit in future. (find more about husky in the [documentation](https://typicode.github.io/husky/get-started.html)) +We need to install `husky` package for `manage` `pre commits hooks` and also I add two packages `@commitlint/cli` and `@commitlint/config-conventional` for handling conventional commits rules in [package.json](.././package.json). +Run the command bellow in the root of project to install all npm dependencies related to husky: + +```bash +npm install +``` + +> Note: In the root of project we have `.husky` folder and it has `commit-msg` file for handling conventional commits rules with provide user friendly message and `pre-commit` file that we can run our `scripts` as a `pre-commit` hooks. that here we call `format` script from [package.json](./package.json) for formatting purpose. + +### Upgrade Nuget Packages +For upgrading our nuget packages to last version, we use the great package [dotnet-outdated](https://github.com/dotnet-outdated/dotnet-outdated). +Run the command below in the root of project to upgrade all of packages to last version: +```bash +dotnet outdated -u +``` + +## How to Run + +> ### Config Certificate +Run the following commands to [Config SSL](https://docs.microsoft.com/en-us/aspnet/core/security/docker-compose-https?view=aspnetcore-6.0) in your system: + +#### Windows using Linux containers +```bash +dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p password +dotnet dev-certs https --trust +``` +***Note:** for running this command in `powershell` use `$env:USERPROFILE` instead of `%USERPROFILE%`* + +#### macOS or Linux +```bash +dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p $CREDENTIAL_PLACEHOLDER$ +dotnet dev-certs https --trust +``` +> ### Docker Compose + + +To run this app in `Docker`, use the [docker-compose.yaml](./deployments/docker-compose/docker-compose.yaml) and execute the below command at the `root` of the application: + +```bash +docker-compose -f ./deployments/docker-compose/docker-compose.yaml up -d +``` + +> ### Kubernetes +To `configure TLS` in the `Kubernetes cluster`, we need to install `cert-manager` based on the [docs](https://cert-manager.io/docs/installation) and run the following commands to apply TLS in our application. Here, we use [Let's Encrypt](https://letsencrypt.org/) to encrypt our certificate. + +```bash +kubectl apply -f ./deployments/kubernetes/booking-cert-manager.yml +``` + +To apply all necessary `deployments`, `pods`, `services`, `ingress`, and `config maps`, please run the following command: + +```bash +kubectl apply -f ./deployments/kubernetes/booking-microservices.yml +``` + +> ### Build +To `build` all microservices, run this command in the `root` of the project: +```bash +dotnet build +``` + +> ### Run +To `run` each microservice, run this command in the root of the `Api` folder of each microservice where the `csproj` file is located: +```bash +dotnet run +``` + +> ### Test + +To `test` all microservices, run this command in the `root` of the project: +```bash +dotnet test +``` + +> ### Documentation Apis + +Each microservice provides `API documentation` and navigate to `/swagger` for `Swagger OpenAPI` or `/scalar/v1` for `Scalar OpenAPI` to visit list of endpoints. + +As part of API testing, I created the [booking.rest](./booking.rest) file which can be run with the [REST Client](https://github.com/Huachao/vscode-restclient) `VSCode plugin`. + # Support If you like my work, feel free to: @@ -206,7 +267,7 @@ Thanks a bunch for supporting me! ## Contribution -Thanks to all [contributors](https://github.com/meysamhadeli/monolith-to-cloud-architecture/graphs/contributors), you're awesome and this wouldn't be possible without you! The goal is to build a categorized, community-driven collection of very well-known resources. +Thanks to all [contributors](https://github.com/meysamhadeli/booking-microservices/graphs/contributors), you're awesome and this wouldn't be possible without you! The goal is to build a categorized, community-driven collection of very well-known resources. Please follow this [contribution guideline](./CONTRIBUTION.md) to submit a pull request or create the issue. @@ -219,4 +280,4 @@ Please follow this [contribution guideline](./CONTRIBUTION.md) to submit a pull - [https://github.com/pdevito3/MessageBusTestingInMemHarness](https://github.com/pdevito3/MessageBusTestingInMemHarness) ## License -This project is made available under the MIT license. See [LICENSE](https://github.com/meysamhadeli/monolith-to-cloud-architecture/blob/main/LICENSE) for details. +This project is made available under the MIT license. See [LICENSE](https://github.com/meysamhadeli/booking-microservices/blob/main/LICENSE) for details. diff --git a/assets/architecture.excalidraw b/assets/architecture.excalidraw deleted file mode 100644 index 9d0d81f..0000000 --- a/assets/architecture.excalidraw +++ /dev/null @@ -1,1143 +0,0 @@ -{ - "type": "excalidraw", - "version": 2, - "source": "https://excalidraw.com", - "elements": [ - { - "id": "BjVz5ngIi7npa_eAXqrpR", - "type": "rectangle", - "x": -7838.260221734026, - "y": -4726.2057629740475, - "width": 2140.000000000001, - "height": 1316.6666666666665, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "transparent", - "fillStyle": "solid", - "strokeWidth": 1, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b4S", - "roundness": null, - "seed": 801675962, - "version": 290, - "versionNonce": 392644154, - "isDeleted": false, - "boundElements": null, - "updated": 1742925403897, - "link": null, - "locked": false - }, - { - "id": "9pFbSSMe11yEAKiecLccL", - "type": "rectangle", - "x": -7299.926888400693, - "y": -1231.2057629740477, - "width": 993.3333333333329, - "height": 553.3333333333335, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 40, - "groupIds": [], - "frameId": null, - "index": "b4T", - "roundness": { - "type": 3 - }, - "seed": 1685718394, - "version": 558, - "versionNonce": 367517434, - "isDeleted": false, - "boundElements": [], - "updated": 1742925297976, - "link": null, - "locked": false - }, - { - "id": "L4K_40SSf1ZLotdQtm4cE", - "type": "rectangle", - "x": -7327.426888400694, - "y": -2400.3724296407145, - "width": 481.66666666666583, - "height": 255.0000000000001, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 40, - "groupIds": [], - "frameId": null, - "index": "b4U", - "roundness": { - "type": 3 - }, - "seed": 951972922, - "version": 713, - "versionNonce": 1703622330, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "NNj258fVpf8-LbeSyTa1u", - "type": "rectangle", - "x": -6807.426888400694, - "y": -2400.3724296407145, - "width": 481.66666666666583, - "height": 255.0000000000001, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 40, - "groupIds": [], - "frameId": null, - "index": "b4V", - "roundness": { - "type": 3 - }, - "seed": 2124156922, - "version": 777, - "versionNonce": 589844346, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "XpoPMyRPHXLds2QJq8z_q", - "type": "rectangle", - "x": -6805.760221734026, - "y": -2678.705762974048, - "width": 481.66666666666583, - "height": 255.0000000000001, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 40, - "groupIds": [], - "frameId": null, - "index": "b4W", - "roundness": { - "type": 3 - }, - "seed": 1960878822, - "version": 810, - "versionNonce": 119820346, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "OINDAhouzkHtcEsDqaZEm", - "type": "rectangle", - "x": -7329.926888400694, - "y": -2677.8724296407136, - "width": 481.66666666666583, - "height": 255.0000000000001, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 40, - "groupIds": [], - "frameId": null, - "index": "b4Y", - "roundness": { - "type": 3 - }, - "seed": 1045028538, - "version": 648, - "versionNonce": 895629562, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "CLZexEL-md7xi8hZOX8Ia", - "type": "rectangle", - "x": -7323.2602217340245, - "y": -4374.539096307381, - "width": 993.3333333333329, - "height": 553.3333333333335, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 40, - "groupIds": [], - "frameId": null, - "index": "b4Z", - "roundness": { - "type": 3 - }, - "seed": 525106426, - "version": 468, - "versionNonce": 1842769658, - "isDeleted": false, - "boundElements": null, - "updated": 1742925403897, - "link": null, - "locked": false - }, - { - "id": "IfnkV8aZMan50dYvBJJHI", - "type": "rectangle", - "x": -7262.867364591168, - "y": -4320.753382021666, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#a5d8ff", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b63", - "roundness": { - "type": 3 - }, - "seed": 395286714, - "version": 613, - "versionNonce": 635600826, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "ECStBOfMLN19P2_hw03Mw" - } - ], - "updated": 1742925403897, - "link": null, - "locked": false - }, - { - "id": "ECStBOfMLN19P2_hw03Mw", - "type": "text", - "x": -7103.357339566754, - "y": -4240.396239164523, - "width": 100.97994995117188, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b634", - "roundness": null, - "seed": 1307168934, - "version": 376, - "versionNonce": 1269725306, - "isDeleted": false, - "boundElements": null, - "updated": 1742925403897, - "link": null, - "locked": false, - "text": "Flight", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "IfnkV8aZMan50dYvBJJHI", - "originalText": "Flight", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "NStqHkMNfUW-MS2BgMSIx", - "type": "rectangle", - "x": -6813.2602217340245, - "y": -4082.3962391645236, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6A", - "roundness": { - "type": 3 - }, - "seed": 1051568442, - "version": 758, - "versionNonce": 1862097210, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "6cqpGCSNzMWAIKzfP1na3" - } - ], - "updated": 1742925403897, - "link": null, - "locked": false - }, - { - "id": "6cqpGCSNzMWAIKzfP1na3", - "type": "text", - "x": -6672.002195610978, - "y": -4002.0390963073805, - "width": 137.48394775390625, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6B", - "roundness": null, - "seed": 1146647034, - "version": 527, - "versionNonce": 791814650, - "isDeleted": false, - "boundElements": [], - "updated": 1742925403897, - "link": null, - "locked": false, - "text": "Booking", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "NStqHkMNfUW-MS2BgMSIx", - "originalText": "Booking", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "MK8GOKBicmAzkIE-iL3OI", - "type": "rectangle", - "x": -6814.926888400692, - "y": -4312.396239164523, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#b2f2bb", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6C", - "roundness": { - "type": 3 - }, - "seed": 1585593446, - "version": 658, - "versionNonce": 1196413626, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "-Mzyz1udMrrOxIdCW6GH2" - } - ], - "updated": 1742925403897, - "link": null, - "locked": false - }, - { - "id": "-Mzyz1udMrrOxIdCW6GH2", - "type": "text", - "x": -6692.8928536716885, - "y": -4232.03909630738, - "width": 175.9319305419922, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6D", - "roundness": null, - "seed": 554287014, - "version": 433, - "versionNonce": 435776378, - "isDeleted": false, - "boundElements": [], - "updated": 1742925403897, - "link": null, - "locked": false, - "text": "Passenger", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "MK8GOKBicmAzkIE-iL3OI", - "originalText": "Passenger", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "DsN5ktl1-vlrURStwnmoX", - "type": "rectangle", - "x": -7258.260221734025, - "y": -4089.06290583119, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffc9c9", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6E", - "roundness": { - "type": 3 - }, - "seed": 162224122, - "version": 693, - "versionNonce": 1030876218, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "VD20ck-JmOwrcQ31Vy1WD" - } - ], - "updated": 1742925403897, - "link": null, - "locked": false - }, - { - "id": "VD20ck-JmOwrcQ31Vy1WD", - "type": "text", - "x": -7121.9341948175215, - "y": -4008.705762974047, - "width": 147.3479461669922, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6F", - "roundness": null, - "seed": 691161274, - "version": 463, - "versionNonce": 127685882, - "isDeleted": false, - "boundElements": [], - "updated": 1742925403897, - "link": null, - "locked": false, - "text": "Identity", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "DsN5ktl1-vlrURStwnmoX", - "originalText": "Identity", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "TM-FY5o9GjzrttRghFLop", - "type": "rectangle", - "x": -7302.8673645911695, - "y": -2650.7533820216654, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#a5d8ff", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6H", - "roundness": { - "type": 3 - }, - "seed": 1037170554, - "version": 785, - "versionNonce": 1566902714, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "93pUS5NQ3kDY6uOwXiNyX" - } - ], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "93pUS5NQ3kDY6uOwXiNyX", - "type": "text", - "x": -7143.357339566755, - "y": -2570.3962391645223, - "width": 100.97994995117188, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6I", - "roundness": null, - "seed": 1851324474, - "version": 548, - "versionNonce": 1179632250, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false, - "text": "Flight", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "TM-FY5o9GjzrttRghFLop", - "originalText": "Flight", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "l2fp_wrlLNmyrYOGF8br4", - "type": "rectangle", - "x": -6774.926888400693, - "y": -2367.396239164523, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6J", - "roundness": { - "type": 3 - }, - "seed": 532799738, - "version": 1109, - "versionNonce": 1524982586, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "Ynv9vqbYS6b30PBQTcrTM" - } - ], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "Ynv9vqbYS6b30PBQTcrTM", - "type": "text", - "x": -6633.668862277646, - "y": -2287.03909630738, - "width": 137.48394775390625, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6K", - "roundness": null, - "seed": 764391866, - "version": 878, - "versionNonce": 898165754, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false, - "text": "Booking", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "l2fp_wrlLNmyrYOGF8br4", - "originalText": "Booking", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "Jk8Ug5gwpkv7_RT3O5k-d", - "type": "rectangle", - "x": -6774.926888400694, - "y": -2649.0629058311897, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#b2f2bb", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6L", - "roundness": { - "type": 3 - }, - "seed": 182807162, - "version": 892, - "versionNonce": 742218938, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "HCx9M-NUP5b7-mMGj46xP" - } - ], - "updated": 1742925314176, - "link": null, - "locked": false - }, - { - "id": "HCx9M-NUP5b7-mMGj46xP", - "type": "text", - "x": -6652.89285367169, - "y": -2568.7057629740466, - "width": 175.9319305419922, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6M", - "roundness": null, - "seed": 1317407546, - "version": 667, - "versionNonce": 1554363770, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314176, - "link": null, - "locked": false, - "text": "Passenger", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "Jk8Ug5gwpkv7_RT3O5k-d", - "originalText": "Passenger", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "gw48OKF0XnkiZE12oKoHM", - "type": "rectangle", - "x": -7298.260221734026, - "y": -2374.062905831189, - "width": 420, - "height": 205.71428571428595, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffc9c9", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6N", - "roundness": { - "type": 3 - }, - "seed": 1054118906, - "version": 879, - "versionNonce": 939849274, - "isDeleted": false, - "boundElements": [ - { - "type": "text", - "id": "dgewanKwtA8RKD5E85LwS" - } - ], - "updated": 1742925314177, - "link": null, - "locked": false - }, - { - "id": "dgewanKwtA8RKD5E85LwS", - "type": "text", - "x": -7161.934194817522, - "y": -2293.7057629740457, - "width": 147.3479461669922, - "height": 45, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#ffec99", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 80, - "groupIds": [], - "frameId": null, - "index": "b6O", - "roundness": null, - "seed": 1574175930, - "version": 649, - "versionNonce": 255729402, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314177, - "link": null, - "locked": false, - "text": "Identity", - "fontSize": 36, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "middle", - "containerId": "gw48OKF0XnkiZE12oKoHM", - "originalText": "Identity", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "8T0DNQgx-jytzaKFLBw8s", - "type": "rectangle", - "x": -7246.593555067359, - "y": -1182.3962391645243, - "width": 885.0000000000002, - "height": 459.0476190476194, - "angle": 0, - "strokeColor": "#343a40", - "backgroundColor": "#a5d8ff", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 70, - "groupIds": [], - "frameId": null, - "index": "b6PV", - "roundness": { - "type": 3 - }, - "seed": 1658045990, - "version": 1025, - "versionNonce": 709226426, - "isDeleted": false, - "boundElements": [], - "updated": 1742925297976, - "link": null, - "locked": false - }, - { - "id": "NhJAyh624gLmQwfML7Cah", - "type": "text", - "x": -7047.083530042945, - "y": -1082.8724296407147, - "width": 122.64661661783774, - "height": 54.65538208794339, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6S", - "roundness": null, - "seed": 820680358, - "version": 322, - "versionNonce": 1378084986, - "isDeleted": false, - "boundElements": null, - "updated": 1742925297976, - "link": null, - "locked": false, - "text": "Flight", - "fontSize": 43.72430567035471, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Flight", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "XRVV2g4gKj5FefvG9VI-H", - "type": "text", - "x": -6745.090017571429, - "y": -1080.200120684686, - "width": 213.6595916748047, - "height": 54.65538208794339, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6T", - "roundness": null, - "seed": 519632998, - "version": 316, - "versionNonce": 1699006778, - "isDeleted": false, - "boundElements": [], - "updated": 1742925297976, - "link": null, - "locked": false, - "text": "Passenger", - "fontSize": 43.72430567035471, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Passenger", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "XEG0OOnugE271gZsgKcHz", - "type": "text", - "x": -7057.733183159808, - "y": -921.866787351353, - "width": 178.9459228515625, - "height": 54.65538208794339, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6U", - "roundness": null, - "seed": 289999930, - "version": 346, - "versionNonce": 1259049466, - "isDeleted": false, - "boundElements": [], - "updated": 1742925297976, - "link": null, - "locked": false, - "text": "Identity", - "fontSize": 43.72430567035471, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Identity", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "cD3ryk_G-nthYIOEz4Ye6", - "type": "text", - "x": -6733.410210544246, - "y": -913.5334540180197, - "width": 166.96664428710938, - "height": 54.65538208794339, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6V", - "roundness": null, - "seed": 1607810746, - "version": 346, - "versionNonce": 108741306, - "isDeleted": false, - "boundElements": [], - "updated": 1742925297976, - "link": null, - "locked": false, - "text": "Booking", - "fontSize": 43.72430567035471, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Booking", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "LDgZVMr41ywbYfl2sOnMA", - "type": "text", - "x": -7161.094145073869, - "y": -3804.53909630738, - "width": 609.0011800130218, - "height": 92.68864845583057, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6W", - "roundness": null, - "seed": 1880786150, - "version": 312, - "versionNonce": 435922362, - "isDeleted": false, - "boundElements": null, - "updated": 1742925403897, - "link": null, - "locked": false, - "text": "Modular Monolith", - "fontSize": 74.15091876466454, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Modular Monolith", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "odgzC_xFXbSmfZwnzP5tO", - "type": "text", - "x": -7086.131661349911, - "y": -2125.883420535296, - "width": 472.4095458984375, - "height": 92.68864845583067, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6X", - "roundness": null, - "seed": 804136166, - "version": 384, - "versionNonce": 517222330, - "isDeleted": false, - "boundElements": [], - "updated": 1742925314177, - "link": null, - "locked": false, - "text": "Microservices", - "fontSize": 74.15091876466454, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Microservices", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "lcN28N-yGNH4OqazL407m", - "type": "text", - "x": -6992.896594618142, - "y": -660.8834205352973, - "width": 302.6060791015625, - "height": 92.68864845583067, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "#ced4da", - "fillStyle": "solid", - "strokeWidth": 4, - "strokeStyle": "dashed", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6Y", - "roundness": null, - "seed": 1851264294, - "version": 508, - "versionNonce": 1110891386, - "isDeleted": false, - "boundElements": [], - "updated": 1742925297976, - "link": null, - "locked": false, - "text": "Monolith", - "fontSize": 74.15091876466454, - "fontFamily": 5, - "textAlign": "center", - "verticalAlign": "top", - "containerId": null, - "originalText": "Monolith", - "autoResize": true, - "lineHeight": 1.25 - }, - { - "id": "8OYgjGgSjDT-VzmAB02Mh", - "type": "rectangle", - "x": -7844.926888400693, - "y": -3066.2057629740466, - "width": 2156.6666666666674, - "height": 1328.3333333333335, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "transparent", - "fillStyle": "solid", - "strokeWidth": 1, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6a", - "roundness": null, - "seed": 64822522, - "version": 229, - "versionNonce": 375869670, - "isDeleted": false, - "boundElements": null, - "updated": 1742925309521, - "link": null, - "locked": false - }, - { - "id": "eLpon2lFFCxV1tsYq7QF0", - "type": "rectangle", - "x": -7824.926888400693, - "y": -1589.5390963073814, - "width": 2141.666666666666, - "height": 1358.3333333333335, - "angle": 0, - "strokeColor": "#1e1e1e", - "backgroundColor": "transparent", - "fillStyle": "solid", - "strokeWidth": 1, - "strokeStyle": "solid", - "roughness": 2, - "opacity": 100, - "groupIds": [], - "frameId": null, - "index": "b6b", - "roundness": null, - "seed": 1259896166, - "version": 240, - "versionNonce": 503135866, - "isDeleted": false, - "boundElements": null, - "updated": 1742925287383, - "link": null, - "locked": false - } - ], - "appState": { - "gridSize": 20, - "gridStep": 5, - "gridModeEnabled": false, - "viewBackgroundColor": "#ffffff" - }, - "files": {} -} diff --git a/3-microservices-architecture-style/assets/booking-microservices.drawio b/assets/booking-microservices.drawio similarity index 100% rename from 3-microservices-architecture-style/assets/booking-microservices.drawio rename to assets/booking-microservices.drawio diff --git a/3-microservices-architecture-style/assets/booking-microservices.png b/assets/booking-microservices.png similarity index 100% rename from 3-microservices-architecture-style/assets/booking-microservices.png rename to assets/booking-microservices.png diff --git a/assets/booking.png b/assets/booking.png new file mode 100644 index 0000000..7d0eb89 Binary files /dev/null and b/assets/booking.png differ diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000..bb808f5 Binary files /dev/null and b/assets/logo.png differ diff --git a/assets/microservices.png b/assets/microservices.png deleted file mode 100644 index 0869cda..0000000 Binary files a/assets/microservices.png and /dev/null differ diff --git a/assets/modular-monolith.png b/assets/modular-monolith.png deleted file mode 100644 index 60818f3..0000000 Binary files a/assets/modular-monolith.png and /dev/null differ diff --git a/assets/monolith.png b/assets/monolith.png deleted file mode 100644 index 22f7797..0000000 Binary files a/assets/monolith.png and /dev/null differ diff --git a/booking-microservices.sln b/booking-microservices.sln new file mode 100644 index 0000000..f189a38 --- /dev/null +++ b/booking-microservices.sln @@ -0,0 +1,312 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CD4A4407-C3B0-422D-BB8C-2A810CED9938}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGateway", "ApiGateway", "{CDFA86FA-BBBA-4A5B-A833-3BE219E373E5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{B19FD14B-4DFE-26B6-646B-3D5D94CC4D36}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BuildingBlocks", "BuildingBlocks", "{C734CEF7-A2AC-3076-84D8-694B7490AA9D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Flight", "Flight", "{A3579DE0-F7C5-67E8-3CF8-3AC89B64E059}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Booking", "Booking", "{C6034A5C-F49A-5FA4-86A6-65B2CB19613F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Passenger", "Passenger", "{9D4F3958-FE6E-C048-E6F9-6F53D8AF03CA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{B465D535-05D9-3A0A-08BF-35A1C18CEC46}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A2834164-BF04-BF13-ADC5-A97145852861}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{1B4FBE3A-43F5-1B1E-2877-3036AC5431EF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DDEDC5E0-5D13-A45C-2393-A774DD4A1A07}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{51D8F471-B8EB-AD1C-0E89-AA84C5D0C759}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{773BFBD8-04CD-79F8-8301-C81308C3ED45}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{4B043475-1AFA-C467-FE09-A46D09CD6936}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5CED3889-AECF-A6CD-55DC-F680D3C18861}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{54BCCDE8-25E6-6FCB-4A9E-D5D2AF76D352}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking.Api", "src\Services\Booking\src\Booking.Api\Booking.Api.csproj", "{D3BF565A-C413-4185-9528-BE1B4F46993C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "src\Services\Booking\src\Booking\Booking.csproj", "{3EA375C7-2900-4927-B1E5-C9D31E67F4A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flight", "src\Services\Flight\src\Flight\Flight.csproj", "{BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flight.Api", "src\Services\Flight\src\Flight.Api\Flight.Api.csproj", "{836D1466-3C20-4D74-B54A-FA09C0EE0FA2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity", "src\Services\Identity\src\Identity\Identity.csproj", "{BCDEAB10-6373-46E7-B408-846A3B0B508B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity.Api", "src\Services\Identity\src\Identity.Api\Identity.Api.csproj", "{B0EC74C5-9B2D-492C-ABAE-3E868397B122}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Passenger", "src\Services\Passenger\src\Passenger\Passenger.csproj", "{9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Passenger.Api", "src\Services\Passenger\src\Passenger.Api\Passenger.Api.csproj", "{101FFD12-17A4-4615-9438-F347BBF4CC85}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildingBlocks", "src\BuildingBlocks\BuildingBlocks.csproj", "{AEDB3219-5E1D-4716-8DE2-F5F9391913A2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{427BE8BE-DA7B-FC74-412B-547671E05463}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiGateway", "src\ApiGateway\src\ApiGateway.csproj", "{C015BF35-6977-407B-8948-636A9C81C5BE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "src\Services\Booking\tests\IntegrationTest\Integration.Test.csproj", "{19A89F36-FD3A-448D-90D1-04A1B67BB255}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndToEnd.Test", "src\Services\Flight\tests\EndToEndTest\EndToEnd.Test.csproj", "{B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "src\Services\Flight\tests\IntegrationTest\Integration.Test.csproj", "{BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit.Test", "src\Services\Flight\tests\UnitTest\Unit.Test.csproj", "{B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "src\Services\Identity\tests\IntegrationTest\Integration.Test.csproj", "{0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "src\Services\Passenger\tests\IntegrationTest\Integration.Test.csproj", "{A85AE27D-81ED-485A-BA4B-161B25BEB8A5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Debug|x64.ActiveCfg = Debug|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Debug|x64.Build.0 = Debug|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Debug|x86.ActiveCfg = Debug|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Debug|x86.Build.0 = Debug|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Release|Any CPU.Build.0 = Release|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Release|x64.ActiveCfg = Release|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Release|x64.Build.0 = Release|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Release|x86.ActiveCfg = Release|Any CPU + {D3BF565A-C413-4185-9528-BE1B4F46993C}.Release|x86.Build.0 = Release|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Debug|x64.ActiveCfg = Debug|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Debug|x64.Build.0 = Debug|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Debug|x86.ActiveCfg = Debug|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Debug|x86.Build.0 = Debug|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Release|Any CPU.Build.0 = Release|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Release|x64.ActiveCfg = Release|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Release|x64.Build.0 = Release|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Release|x86.ActiveCfg = Release|Any CPU + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8}.Release|x86.Build.0 = Release|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Debug|x64.ActiveCfg = Debug|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Debug|x64.Build.0 = Debug|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Debug|x86.ActiveCfg = Debug|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Debug|x86.Build.0 = Debug|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Release|Any CPU.Build.0 = Release|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Release|x64.ActiveCfg = Release|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Release|x64.Build.0 = Release|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Release|x86.ActiveCfg = Release|Any CPU + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279}.Release|x86.Build.0 = Release|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Debug|x64.ActiveCfg = Debug|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Debug|x64.Build.0 = Debug|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Debug|x86.ActiveCfg = Debug|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Debug|x86.Build.0 = Debug|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Release|Any CPU.Build.0 = Release|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Release|x64.ActiveCfg = Release|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Release|x64.Build.0 = Release|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Release|x86.ActiveCfg = Release|Any CPU + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2}.Release|x86.Build.0 = Release|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Debug|x64.ActiveCfg = Debug|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Debug|x64.Build.0 = Debug|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Debug|x86.ActiveCfg = Debug|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Debug|x86.Build.0 = Debug|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Release|Any CPU.Build.0 = Release|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Release|x64.ActiveCfg = Release|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Release|x64.Build.0 = Release|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Release|x86.ActiveCfg = Release|Any CPU + {BCDEAB10-6373-46E7-B408-846A3B0B508B}.Release|x86.Build.0 = Release|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Debug|x64.ActiveCfg = Debug|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Debug|x64.Build.0 = Debug|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Debug|x86.ActiveCfg = Debug|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Debug|x86.Build.0 = Debug|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Release|Any CPU.Build.0 = Release|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Release|x64.ActiveCfg = Release|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Release|x64.Build.0 = Release|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Release|x86.ActiveCfg = Release|Any CPU + {B0EC74C5-9B2D-492C-ABAE-3E868397B122}.Release|x86.Build.0 = Release|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Debug|x64.ActiveCfg = Debug|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Debug|x64.Build.0 = Debug|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Debug|x86.ActiveCfg = Debug|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Debug|x86.Build.0 = Debug|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Release|Any CPU.Build.0 = Release|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Release|x64.ActiveCfg = Release|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Release|x64.Build.0 = Release|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Release|x86.ActiveCfg = Release|Any CPU + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538}.Release|x86.Build.0 = Release|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Debug|x64.ActiveCfg = Debug|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Debug|x64.Build.0 = Debug|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Debug|x86.ActiveCfg = Debug|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Debug|x86.Build.0 = Debug|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Release|Any CPU.Build.0 = Release|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Release|x64.ActiveCfg = Release|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Release|x64.Build.0 = Release|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Release|x86.ActiveCfg = Release|Any CPU + {101FFD12-17A4-4615-9438-F347BBF4CC85}.Release|x86.Build.0 = Release|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Debug|x64.ActiveCfg = Debug|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Debug|x64.Build.0 = Debug|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Debug|x86.ActiveCfg = Debug|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Debug|x86.Build.0 = Debug|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Release|Any CPU.Build.0 = Release|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Release|x64.ActiveCfg = Release|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Release|x64.Build.0 = Release|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Release|x86.ActiveCfg = Release|Any CPU + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2}.Release|x86.Build.0 = Release|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Debug|x64.ActiveCfg = Debug|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Debug|x64.Build.0 = Debug|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Debug|x86.ActiveCfg = Debug|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Debug|x86.Build.0 = Debug|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Release|Any CPU.Build.0 = Release|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Release|x64.ActiveCfg = Release|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Release|x64.Build.0 = Release|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Release|x86.ActiveCfg = Release|Any CPU + {C015BF35-6977-407B-8948-636A9C81C5BE}.Release|x86.Build.0 = Release|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Debug|x64.ActiveCfg = Debug|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Debug|x64.Build.0 = Debug|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Debug|x86.ActiveCfg = Debug|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Debug|x86.Build.0 = Debug|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Release|Any CPU.Build.0 = Release|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Release|x64.ActiveCfg = Release|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Release|x64.Build.0 = Release|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Release|x86.ActiveCfg = Release|Any CPU + {19A89F36-FD3A-448D-90D1-04A1B67BB255}.Release|x86.Build.0 = Release|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Debug|x64.ActiveCfg = Debug|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Debug|x64.Build.0 = Debug|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Debug|x86.ActiveCfg = Debug|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Debug|x86.Build.0 = Debug|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Release|Any CPU.Build.0 = Release|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Release|x64.ActiveCfg = Release|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Release|x64.Build.0 = Release|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Release|x86.ActiveCfg = Release|Any CPU + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4}.Release|x86.Build.0 = Release|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Debug|x64.ActiveCfg = Debug|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Debug|x64.Build.0 = Debug|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Debug|x86.ActiveCfg = Debug|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Debug|x86.Build.0 = Debug|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Release|Any CPU.Build.0 = Release|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Release|x64.ActiveCfg = Release|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Release|x64.Build.0 = Release|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Release|x86.ActiveCfg = Release|Any CPU + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B}.Release|x86.Build.0 = Release|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Debug|x64.ActiveCfg = Debug|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Debug|x64.Build.0 = Debug|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Debug|x86.ActiveCfg = Debug|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Debug|x86.Build.0 = Debug|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Release|Any CPU.Build.0 = Release|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Release|x64.ActiveCfg = Release|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Release|x64.Build.0 = Release|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Release|x86.ActiveCfg = Release|Any CPU + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB}.Release|x86.Build.0 = Release|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Debug|x64.ActiveCfg = Debug|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Debug|x64.Build.0 = Debug|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Debug|x86.ActiveCfg = Debug|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Debug|x86.Build.0 = Debug|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Release|Any CPU.Build.0 = Release|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Release|x64.ActiveCfg = Release|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Release|x64.Build.0 = Release|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Release|x86.ActiveCfg = Release|Any CPU + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01}.Release|x86.Build.0 = Release|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Debug|x64.ActiveCfg = Debug|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Debug|x64.Build.0 = Debug|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Debug|x86.ActiveCfg = Debug|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Debug|x86.Build.0 = Debug|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Release|Any CPU.Build.0 = Release|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Release|x64.ActiveCfg = Release|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Release|x64.Build.0 = Release|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Release|x86.ActiveCfg = Release|Any CPU + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {CDFA86FA-BBBA-4A5B-A833-3BE219E373E5} = {CD4A4407-C3B0-422D-BB8C-2A810CED9938} + {B19FD14B-4DFE-26B6-646B-3D5D94CC4D36} = {CD4A4407-C3B0-422D-BB8C-2A810CED9938} + {C734CEF7-A2AC-3076-84D8-694B7490AA9D} = {CD4A4407-C3B0-422D-BB8C-2A810CED9938} + {A3579DE0-F7C5-67E8-3CF8-3AC89B64E059} = {B19FD14B-4DFE-26B6-646B-3D5D94CC4D36} + {C6034A5C-F49A-5FA4-86A6-65B2CB19613F} = {B19FD14B-4DFE-26B6-646B-3D5D94CC4D36} + {9D4F3958-FE6E-C048-E6F9-6F53D8AF03CA} = {B19FD14B-4DFE-26B6-646B-3D5D94CC4D36} + {B465D535-05D9-3A0A-08BF-35A1C18CEC46} = {B19FD14B-4DFE-26B6-646B-3D5D94CC4D36} + {A2834164-BF04-BF13-ADC5-A97145852861} = {C6034A5C-F49A-5FA4-86A6-65B2CB19613F} + {1B4FBE3A-43F5-1B1E-2877-3036AC5431EF} = {C6034A5C-F49A-5FA4-86A6-65B2CB19613F} + {DDEDC5E0-5D13-A45C-2393-A774DD4A1A07} = {A3579DE0-F7C5-67E8-3CF8-3AC89B64E059} + {51D8F471-B8EB-AD1C-0E89-AA84C5D0C759} = {A3579DE0-F7C5-67E8-3CF8-3AC89B64E059} + {773BFBD8-04CD-79F8-8301-C81308C3ED45} = {B465D535-05D9-3A0A-08BF-35A1C18CEC46} + {4B043475-1AFA-C467-FE09-A46D09CD6936} = {B465D535-05D9-3A0A-08BF-35A1C18CEC46} + {5CED3889-AECF-A6CD-55DC-F680D3C18861} = {9D4F3958-FE6E-C048-E6F9-6F53D8AF03CA} + {54BCCDE8-25E6-6FCB-4A9E-D5D2AF76D352} = {9D4F3958-FE6E-C048-E6F9-6F53D8AF03CA} + {D3BF565A-C413-4185-9528-BE1B4F46993C} = {A2834164-BF04-BF13-ADC5-A97145852861} + {3EA375C7-2900-4927-B1E5-C9D31E67F4A8} = {A2834164-BF04-BF13-ADC5-A97145852861} + {BCC8A8A6-C2ED-42D2-86BB-A05C790D7279} = {DDEDC5E0-5D13-A45C-2393-A774DD4A1A07} + {836D1466-3C20-4D74-B54A-FA09C0EE0FA2} = {DDEDC5E0-5D13-A45C-2393-A774DD4A1A07} + {BCDEAB10-6373-46E7-B408-846A3B0B508B} = {773BFBD8-04CD-79F8-8301-C81308C3ED45} + {B0EC74C5-9B2D-492C-ABAE-3E868397B122} = {773BFBD8-04CD-79F8-8301-C81308C3ED45} + {9B4BDD42-56F3-4DB9-B3E5-74ABB7C19538} = {5CED3889-AECF-A6CD-55DC-F680D3C18861} + {101FFD12-17A4-4615-9438-F347BBF4CC85} = {5CED3889-AECF-A6CD-55DC-F680D3C18861} + {AEDB3219-5E1D-4716-8DE2-F5F9391913A2} = {C734CEF7-A2AC-3076-84D8-694B7490AA9D} + {427BE8BE-DA7B-FC74-412B-547671E05463} = {CDFA86FA-BBBA-4A5B-A833-3BE219E373E5} + {C015BF35-6977-407B-8948-636A9C81C5BE} = {427BE8BE-DA7B-FC74-412B-547671E05463} + {19A89F36-FD3A-448D-90D1-04A1B67BB255} = {1B4FBE3A-43F5-1B1E-2877-3036AC5431EF} + {B27759CD-5A7D-43A4-A55C-FE1154DC4CC4} = {51D8F471-B8EB-AD1C-0E89-AA84C5D0C759} + {BD23EEF8-9196-4E0F-BF33-E14E99D34C1B} = {51D8F471-B8EB-AD1C-0E89-AA84C5D0C759} + {B52D6341-AAD9-43CB-82AF-2DBE39CBF1DB} = {51D8F471-B8EB-AD1C-0E89-AA84C5D0C759} + {0DAACE48-4EA6-4DB7-8A5C-99B86BCB1E01} = {4B043475-1AFA-C467-FE09-A46D09CD6936} + {A85AE27D-81ED-485A-BA4B-161B25BEB8A5} = {54BCCDE8-25E6-6FCB-4A9E-D5D2AF76D352} + EndGlobalSection +EndGlobal diff --git a/3-microservices-architecture-style/booking.rest b/booking.rest similarity index 98% rename from 3-microservices-architecture-style/booking.rest rename to booking.rest index d06c99a..efc99b6 100644 --- a/3-microservices-architecture-style/booking.rest +++ b/booking.rest @@ -1,7 +1,7 @@ ## uncommnet this line for use kubernetes ingress controller instead of Yarp -//@api-gateway=https://booking-microservices.com -@api-gateway=https://localhost:5000 +//@api-gateway=https://booking-microservices.com +@api-gateway=https://localhost:5000 @identity-api=http://localhost:6005 @flight-api=http://localhost:5004 @passenger-api=http://localhost:6012 diff --git a/1-monolith-architecture-style/deployments/configs/dashboards.md b/deployments/configs/dashboards.md similarity index 96% rename from 1-monolith-architecture-style/deployments/configs/dashboards.md rename to deployments/configs/dashboards.md index 999b1d8..e2e5747 100644 --- a/1-monolith-architecture-style/deployments/configs/dashboards.md +++ b/deployments/configs/dashboards.md @@ -5,4 +5,4 @@ - [ASP.NET Core Endpoint](https://grafana.com/grafana/dashboards/19925-asp-net-core-endpoint/) - [Node Exporter Quickstart and Dashboard](https://grafana.com/grafana/dashboards/13978-node-exporter-quickstart-and-dashboard/) - [PostgreSQL Exporter Quickstart and Dashboard](https://grafana.com/grafana/dashboards/14114-postgres-overview/) -- [RabbitMQ-Overview](https://grafana.com/grafana/dashboards/10991-rabbitmq-overview/) \ No newline at end of file +- [RabbitMQ-Overview](https://grafana.com/grafana/dashboards/10991-rabbitmq-overview/) diff --git a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json b/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json similarity index 99% rename from 1-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json rename to deployments/configs/grafana/dashboards/dotnet-core-endpoint.json index 9859cc9..c40f34d 100644 --- a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json +++ b/deployments/configs/grafana/dashboards/dotnet-core-endpoint.json @@ -905,4 +905,4 @@ "uid": "NagEsjE4z", "version": 10, "weekStart": "" -} \ No newline at end of file +} diff --git a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json b/deployments/configs/grafana/dashboards/dotnet-core.json similarity index 99% rename from 3-microservices-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json rename to deployments/configs/grafana/dashboards/dotnet-core.json index b435130..943a44d 100644 --- a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/dotnet-core.json +++ b/deployments/configs/grafana/dashboards/dotnet-core.json @@ -1304,4 +1304,4 @@ "uid": "KdDACDp4z", "version": 5, "weekStart": "" -} \ No newline at end of file +} diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json b/deployments/configs/grafana/dashboards/node-exporter.json similarity index 99% rename from 2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json rename to deployments/configs/grafana/dashboards/node-exporter.json index 4839d46..d8d70a0 100644 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/dashboards/node-exporter.json +++ b/deployments/configs/grafana/dashboards/node-exporter.json @@ -889,4 +889,4 @@ "title": "Node Exporter Quickstart and Dashboard", "version": 0, "description": "A quickstart to setup Prometheus Node Exporter with preconfigured dashboards, alerting rules, and recording rules." -} \ No newline at end of file +} diff --git a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/postgresql.json b/deployments/configs/grafana/dashboards/postgresql.json similarity index 99% rename from 3-microservices-architecture-style/deployments/configs/grafana/dashboards/postgresql.json rename to deployments/configs/grafana/dashboards/postgresql.json index d1d696f..bf51922 100644 --- a/3-microservices-architecture-style/deployments/configs/grafana/dashboards/postgresql.json +++ b/deployments/configs/grafana/dashboards/postgresql.json @@ -1456,4 +1456,4 @@ "title": "PostgreSQL Exporter Quickstart and Dashboard", "uid": "wGgaPlciz", "version": 5 -} \ No newline at end of file +} diff --git a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json b/deployments/configs/grafana/dashboards/rabbitmq.json similarity index 99% rename from 1-monolith-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json rename to deployments/configs/grafana/dashboards/rabbitmq.json index b199b4b..bcb38fe 100644 --- a/1-monolith-architecture-style/deployments/configs/grafana/dashboards/rabbitmq.json +++ b/deployments/configs/grafana/dashboards/rabbitmq.json @@ -8206,4 +8206,4 @@ "version": 20220805, "weekStart": "", "gnetId": 10991 -} \ No newline at end of file +} diff --git a/2-modular-monolith-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml b/deployments/configs/grafana/provisioning/dashboards/dashboard.yml similarity index 98% rename from 2-modular-monolith-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml rename to deployments/configs/grafana/provisioning/dashboards/dashboard.yml index f1fb0bb..fd8e503 100644 --- a/2-modular-monolith-architecture-style/deployments/configs/grafana/provisioning/dashboards/dashboard.yml +++ b/deployments/configs/grafana/provisioning/dashboards/dashboard.yml @@ -11,4 +11,4 @@ providers: allowUiUpdates: true updateIntervalSeconds: 5 # how often Grafana will scan for changed dashboards options: - path: /var/lib/grafana/dashboards # path to dashboards on disk \ No newline at end of file + path: /var/lib/grafana/dashboards # path to dashboards on disk diff --git a/3-microservices-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml b/deployments/configs/grafana/provisioning/datasources/datasource.yml similarity index 94% rename from 3-microservices-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml rename to deployments/configs/grafana/provisioning/datasources/datasource.yml index 5b04359..7236f23 100644 --- a/3-microservices-architecture-style/deployments/configs/grafana/provisioning/datasources/datasource.yml +++ b/deployments/configs/grafana/provisioning/datasources/datasource.yml @@ -28,8 +28,8 @@ datasources: access: proxy url: http://jaeger-all-in-one:16686 editable: false - uid: jaeger-uid - + uid: jaeger-uid + - name: Zipkin type: zipkin access: proxy @@ -55,8 +55,8 @@ datasources: datasourceUid: prometheus-uid streamingEnabled: search: true - - #https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml + + #https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - name: Loki type: loki access: proxy @@ -71,8 +71,8 @@ datasources: matcherRegex: "^.*?traceI[d|D]=(\\w+).*$" name: traceId url: '$${__value.raw}' - - - name: Kibana + + - name: Kibana type: elasticsearch url: http://elasticsearch:9200 access: proxy @@ -85,4 +85,4 @@ datasources: interval: Daily logMessageField: "message" # Optional: Field for log messages logLevelField: "level" # Optional: Field for log levels - editable: true \ No newline at end of file + editable: true diff --git a/1-monolith-architecture-style/deployments/configs/loki-config.yaml b/deployments/configs/loki-config.yaml similarity index 100% rename from 1-monolith-architecture-style/deployments/configs/loki-config.yaml rename to deployments/configs/loki-config.yaml diff --git a/2-modular-monolith-architecture-style/deployments/configs/otel-collector-config.yaml b/deployments/configs/otel-collector-config.yaml similarity index 95% rename from 2-modular-monolith-architecture-style/deployments/configs/otel-collector-config.yaml rename to deployments/configs/otel-collector-config.yaml index ea6ef40..8537c72 100644 --- a/2-modular-monolith-architecture-style/deployments/configs/otel-collector-config.yaml +++ b/deployments/configs/otel-collector-config.yaml @@ -4,10 +4,10 @@ # https://betterstack.com/community/guides/observability/opentelemetry-collector/ # https://signoz.io/blog/opentelemetry-collector-complete-guide/ -# This configuration sets up an OpenTelemetry Collector that receives trace data via the OTLP protocol over HTTP on port 4318, applies batch processing, and then exports the processed traces +# This configuration sets up an OpenTelemetry Collector that receives trace data via the OTLP protocol over HTTP on port 4318, applies batch processing, and then exports the processed traces # to exporter components like `Jaeger` endpoint located at `jaeger-all-in-one:4317`. It also includes a health_check extension for monitoring the collector's status. -# Receivers in the OpenTelemetry Collector are components that collect telemetry data (traces, metrics, and logs) from various sources, such as instrumented applications or agents. +# Receivers in the OpenTelemetry Collector are components that collect telemetry data (traces, metrics, and logs) from various sources, such as instrumented applications or agents. # They act as entry points, converting incoming data into OpenTelemetry's internal format for processing and export. # https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components # https://opentelemetry.io/docs/collector/architecture/#receivers @@ -29,7 +29,7 @@ receivers: # - job_name: 'node-exporter' # scrape_interval: 10s # static_configs: -# - targets: [ 'node-exporter:9100' ] +# - targets: [ 'node-exporter:9100' ] # Processors in the OpenTelemetry Collector modify and enhance telemetry data by filtering, transforming, enriching, or batching it to prepare it for export. @@ -41,13 +41,13 @@ processors: # - The `key` follows the `type/name` format, where `type` specifies the exporter `type` (e.g., otlp, kafka, prometheus), and `name` (optional) can be appended to provide a unique name for multiple instance of the same type # https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components # https://opentelemetry.io/docs/collector/architecture/#exporters -# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter +# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter # https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter # https://opentelemetry.io/docs/collector/configuration/#exporters exporters: - + # valid values: [prometheusremotewrite zipkin otlphttp file kafka prometheus debug nop otlp opencensus] - + # Prometheus exporter metrics prometheus: endpoint: "0.0.0.0:8889" @@ -61,20 +61,20 @@ exporters: endpoint: "http://loki:3100/otlp" tls: insecure: true - + # # we can also use `loki component` from `opentelemetry-collector-contrib` if we don't want to use builtin `otlphttp` exporter type and `http://loki:3100/otlp` loki endpoint # loki: # endpoint: "http://loki:3100/loki/api/v1/push" # tls: # insecure: true - + debug: # https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/elasticsearchexporter # using `elasticsearch` from `opentelemetry-collector-contrib` components because it doesn't exist in `opentelemetry-collector` elasticsearch: endpoint: "http://elasticsearch:9200" - + zipkin: endpoint: "http://zipkin-all-in-one:9411/api/v2/spans" format: proto @@ -89,7 +89,7 @@ exporters: endpoint: "http://tempo:4317" tls: insecure: true - + # seq-otlp: # endpoint: "http://seq:5341/ingest/otlp" @@ -103,7 +103,7 @@ extensions: health_check: endpoint: 0.0.0.0:13133 -# - The service section is used to configure what components are enabled in the Collector based on the configuration found in the receivers, processors, exporters, and extensions sections. +# - The service section is used to configure what components are enabled in the Collector based on the configuration found in the receivers, processors, exporters, and extensions sections. # - If a component is configured, but not defined within the service section, then it’s not enabled. # https://betterstack.com/community/guides/observability/opentelemetry-collector/#exploring-the-opentelemetry-collector-components # https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/README.md @@ -112,7 +112,7 @@ extensions: service: # The `service.extensions` subsection determines which of the configured extensions will be enabled extensions: [pprof, zpages, health_check] - # The `service.pipeline` Each pipeline starts with one or more receivers collecting data, which is then processed sequentially by processors (applying transformations, filtering, or sampling). + # The `service.pipeline` Each pipeline starts with one or more receivers collecting data, which is then processed sequentially by processors (applying transformations, filtering, or sampling). # The processed data is finally sent to all configured exporters, ensuring each receives a copy. Components must be pre-configured in their respective sections before being used in a pipeline. # pipeline activate predefined components, defined components are disabled by default pipelines: @@ -128,4 +128,4 @@ service: logs: receivers: [otlp] processors: [batch] - exporters: [otlphttp/loki, elasticsearch] \ No newline at end of file + exporters: [otlphttp/loki, elasticsearch] diff --git a/3-microservices-architecture-style/deployments/configs/prometheus.yaml b/deployments/configs/prometheus.yaml similarity index 96% rename from 3-microservices-architecture-style/deployments/configs/prometheus.yaml rename to deployments/configs/prometheus.yaml index 1928aaf..bc30ab6 100644 --- a/3-microservices-architecture-style/deployments/configs/prometheus.yaml +++ b/deployments/configs/prometheus.yaml @@ -4,7 +4,7 @@ global: scrape_interval: 5s - + scrape_configs: # when we use otel-collector we should comment other jobs in prometheus config, and we read configs from `otel-collector-config` - job_name: "otel-collector" @@ -13,7 +13,7 @@ scrape_configs: # otel-collector Prometheus exporter metrics - targets: [ 'otel-collector:8889' ] - targets: [ 'otel-collector:8888' ] - + - job_name: "prometheus" static_configs: - targets: ["prometheus:9090"] @@ -32,10 +32,10 @@ scrape_configs: # metrics_path: /metrics # static_configs: # - targets: ['host.docker.internal:4000'] -# +# # # if we don't use otel collector we should uncomment this # # scrap application health metrics -# # http://localhost:4000/health/metrics by AddPrometheusExporter() +# # http://localhost:4000/health/metrics by AddPrometheusExporter() # - job_name: vertical-slice-template-api-healthchecks # scrape_interval: 10s # metrics_path: /health/metrics @@ -45,4 +45,4 @@ scrape_configs: ## https://github.com/grafana/tempo/blob/main/example/docker-compose/shared/prometheus.yaml # - job_name: 'tempo' # static_configs: -# - targets: [ 'tempo:3200' ] \ No newline at end of file +# - targets: [ 'tempo:3200' ] diff --git a/3-microservices-architecture-style/deployments/configs/tempo.yaml b/deployments/configs/tempo.yaml similarity index 97% rename from 3-microservices-architecture-style/deployments/configs/tempo.yaml rename to deployments/configs/tempo.yaml index fcb2ed3..903f7fb 100644 --- a/3-microservices-architecture-style/deployments/configs/tempo.yaml +++ b/deployments/configs/tempo.yaml @@ -46,4 +46,4 @@ overrides: defaults: metrics_generator: processors: [service-graphs, span-metrics, local-blocks] # enables metrics generator - generate_native_histograms: both \ No newline at end of file + generate_native_histograms: both diff --git a/3-microservices-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml b/deployments/docker-compose/docker-compose.infrastructure.yaml similarity index 94% rename from 3-microservices-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml rename to deployments/docker-compose/docker-compose.infrastructure.yaml index 22cc6b9..0c5f610 100644 --- a/3-microservices-architecture-style/deployments/docker-compose/docker-compose.infrastructure.yaml +++ b/deployments/docker-compose/docker-compose.infrastructure.yaml @@ -64,7 +64,7 @@ services: ports: - "2113:2113" networks: - - infrastructure + - infrastructure # ####################################################### @@ -91,16 +91,16 @@ services: container_name: redis restart: unless-stopped ports: - - 6379:6379 + - 6379:6379 networks: - - infrastructure + - infrastructure # ####################################################### - # # jaeger + # # jaeger # # https://www.jaegertracing.io/docs/1.64/deployment/ # # https://www.jaegertracing.io/docs/1.6/deployment/ - # ####################################################### + # ####################################################### jaeger-all-in-one: image: jaegertracing/all-in-one:latest container_name: jaeger-all-in-one @@ -108,7 +108,7 @@ services: ports: - "6831:6831/udp" # UDP port for Jaeger agent - "16686:16686" # endpoints and Jaeger UI - - "14268:14268" # HTTP port for accept trace spans directly from clients + - "14268:14268" # HTTP port for accept trace spans directly from clients - "14317:4317" # OTLP gRPC receiver for jaeger - "14318:4318" # OTLP http receiver for jaeger # - "9411" # Accepts Zipkin spans - /api/v2/spans @@ -117,9 +117,9 @@ services: # ####################################################### - # # zipkin + # # zipkin # # https://zipkin.io/pages/quickstart - # ####################################################### + # ####################################################### zipkin-all-in-one: image: openzipkin/zipkin:latest container_name: zipkin-all-in-one @@ -131,13 +131,13 @@ services: # ####################################################### - # # otel-collector + # # otel-collector # # https://opentelemetry.io/docs/collector/installation/ # # https://github.com/open-telemetry/opentelemetry-collector # # https://github.com/open-telemetry/opentelemetry-collector-contrib # # we can use none contrib docker `otel/opentelemetry-collector` version from `https://github.com/open-telemetry/opentelemetry-collector` repository but, - # # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. - # ####################################################### + # # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. + # ####################################################### otel-collector: image: otel/opentelemetry-collector-contrib:latest container_name: otel-collector @@ -162,7 +162,7 @@ services: # # https://prometheus.io/docs/introduction/first_steps/ # # https://prometheus.io/docs/prometheus/3.1/installation/ # # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - # ####################################################### + # ####################################################### prometheus: image: prom/prometheus:latest restart: unless-stopped @@ -187,7 +187,7 @@ services: # # node-exporter # # https://prometheus.io/docs/guides/node-exporter/ # # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - # ####################################################### + # ####################################################### node-exporter: image: prom/node-exporter:latest container_name: node-exporter @@ -212,7 +212,7 @@ services: # # https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ # # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ # # https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - # ####################################################### + # ####################################################### grafana: image: grafana/grafana:latest container_name: grafana @@ -244,7 +244,7 @@ services: # # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared # # https://github.com/grafana/tempo/blob/main/example/docker-compose/local # # https://github.com/grafana/tempo/tree/main/example/docker-compose - # ####################################################### + # ####################################################### tempo: image: grafana/tempo:latest container_name: tempo @@ -277,7 +277,7 @@ services: - ./../configs/loki-config.yaml:/etc/loki/local-config.yaml networks: - infrastructure - + # ####################################################### # # elasticsearch @@ -329,8 +329,8 @@ services: - elasticsearch networks: - infrastructure - - + + # ####################################################### # # cadvisor # ####################################################### @@ -356,6 +356,6 @@ networks: infrastructure: name: infrastructure driver: bridge - + volumes: - postgres-data: \ No newline at end of file + postgres-data: diff --git a/3-microservices-architecture-style/deployments/docker-compose/docker-compose.yaml b/deployments/docker-compose/docker-compose.yaml similarity index 96% rename from 3-microservices-architecture-style/deployments/docker-compose/docker-compose.yaml rename to deployments/docker-compose/docker-compose.yaml index 4c288dd..1e35c38 100644 --- a/3-microservices-architecture-style/deployments/docker-compose/docker-compose.yaml +++ b/deployments/docker-compose/docker-compose.yaml @@ -58,7 +58,7 @@ services: ports: - "2113:2113" networks: - - booking + - booking ####################################################### @@ -85,16 +85,16 @@ services: container_name: redis restart: unless-stopped ports: - - 6379:6379 + - 6379:6379 networks: - - booking + - booking ####################################################### - # jaeger + # jaeger # https://www.jaegertracing.io/docs/1.64/deployment/ # https://www.jaegertracing.io/docs/1.6/deployment/ - ####################################################### + ####################################################### jaeger-all-in-one: image: jaegertracing/all-in-one:latest container_name: jaeger-all-in-one @@ -102,7 +102,7 @@ services: ports: - "6831:6831/udp" # UDP port for Jaeger agent - "16686:16686" # endpoints and Jaeger UI - - "14268:14268" # HTTP port for accept trace spans directly from clients + - "14268:14268" # HTTP port for accept trace spans directly from clients - "14317:4317" # OTLP gRPC receiver for jaeger - "14318:4318" # OTLP http receiver for jaeger # - "9411" # Accepts Zipkin spans - /api/v2/spans @@ -111,9 +111,9 @@ services: ####################################################### - # zipkin + # zipkin # https://zipkin.io/pages/quickstart - ####################################################### + ####################################################### zipkin-all-in-one: image: openzipkin/zipkin:latest container_name: zipkin-all-in-one @@ -125,13 +125,13 @@ services: ####################################################### - # otel-collector + # otel-collector # https://opentelemetry.io/docs/collector/installation/ # https://github.com/open-telemetry/opentelemetry-collector # https://github.com/open-telemetry/opentelemetry-collector-contrib # we can use none contrib docker `otel/opentelemetry-collector` version from `https://github.com/open-telemetry/opentelemetry-collector` repository but, - # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. - ####################################################### + # if we need more components like `elasticsearch` we should use `otel/opentelemetry-collector-contrib` image of `https://github.com/open-telemetry/opentelemetry-collector-contrib` repository. + ####################################################### otel-collector: image: otel/opentelemetry-collector-contrib:latest container_name: otel-collector @@ -156,7 +156,7 @@ services: # https://prometheus.io/docs/introduction/first_steps/ # https://prometheus.io/docs/prometheus/3.1/installation/ # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - ####################################################### + ####################################################### prometheus: image: prom/prometheus:latest restart: unless-stopped @@ -181,7 +181,7 @@ services: # node-exporter # https://prometheus.io/docs/guides/node-exporter/ # https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/prometheus-config-examples/docker-compose-linux/ - ####################################################### + ####################################################### node-exporter: image: prom/node-exporter:latest container_name: node-exporter @@ -206,7 +206,7 @@ services: # https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ # https://grafana.com/docs/grafana/latest/setup-grafana/configure-docker/ # https://github.com/grafana/intro-to-mltp/blob/main/grafana/provisioning/datasources/datasources.yaml - ####################################################### + ####################################################### grafana: image: grafana/grafana:latest container_name: grafana @@ -238,7 +238,7 @@ services: # https://github.com/grafana/tempo/blob/main/example/docker-compose/shared # https://github.com/grafana/tempo/blob/main/example/docker-compose/local # https://github.com/grafana/tempo/tree/main/example/docker-compose - ####################################################### + ####################################################### tempo: image: grafana/tempo:latest container_name: tempo @@ -271,7 +271,7 @@ services: - ./../configs/loki-config.yaml:/etc/loki/local-config.yaml networks: - booking - + ####################################################### # elasticsearch @@ -323,8 +323,8 @@ services: - elasticsearch networks: - booking - - + + ####################################################### # cadvisor ####################################################### @@ -484,7 +484,7 @@ networks: booking: name: booking driver: bridge - + volumes: elastic-data: postgres-data: diff --git a/3-microservices-architecture-style/deployments/kubernetes/booking-cert-manager.yml b/deployments/kubernetes/booking-cert-manager.yml similarity index 94% rename from 3-microservices-architecture-style/deployments/kubernetes/booking-cert-manager.yml rename to deployments/kubernetes/booking-cert-manager.yml index 78ce466..94e6c63 100644 --- a/3-microservices-architecture-style/deployments/kubernetes/booking-cert-manager.yml +++ b/deployments/kubernetes/booking-cert-manager.yml @@ -13,4 +13,4 @@ spec: solvers: - http01: ingress: - class: nginx \ No newline at end of file + class: nginx diff --git a/3-microservices-architecture-style/deployments/kubernetes/booking-microservices.yml b/deployments/kubernetes/booking-microservices.yml similarity index 98% rename from 3-microservices-architecture-style/deployments/kubernetes/booking-microservices.yml rename to deployments/kubernetes/booking-microservices.yml index 68aa5b2..d3186f5 100644 --- a/3-microservices-architecture-style/deployments/kubernetes/booking-microservices.yml +++ b/deployments/kubernetes/booking-microservices.yml @@ -158,7 +158,7 @@ spec: - port: 5601 targetPort: 5601 type: ClusterIP ---- +--- ####################################################### # Tempo ####################################################### @@ -947,7 +947,7 @@ data: { .Files.Get "settings/appsettings.docker.json" } -#ref: https://www.mrjamiebowman.com/software-development/dotnet/kubernetes-configmaps-with-net-core/ +#ref: https://www.mrjamiebowman.com/software-development/dotnet/kubernetes-configmaps-with-net-core/ --- ####################################################### # Flight @@ -1079,7 +1079,7 @@ spec: - name: ASPNETCORE_ENVIRONMENT value: docker - name: ASPNETCORE_URLS - value: http://+ + value: http://+ volumeMounts: - name: appsettings-volume mountPath: /app/Settings @@ -1100,7 +1100,7 @@ spec: protocol: TCP port: 80 targetPort: 80 - type: ClusterIP + type: ClusterIP --- ####################################################### # Passenger @@ -1130,7 +1130,7 @@ spec: - name: ASPNETCORE_ENVIRONMENT value: docker - name: ASPNETCORE_URLS - value: http://+ + value: http://+ volumeMounts: - name: appsettings-volume mountPath: /app/Settings @@ -1154,7 +1154,7 @@ spec: protocol: TCP port: 80 targetPort: 80 - type: ClusterIP + type: ClusterIP --- apiVersion: networking.k8s.io/v1 kind: Ingress @@ -1170,14 +1170,14 @@ metadata: nginx.ingress.kubernetes.io/client-header-buffer-size: "64k" nginx.ingress.kubernetes.io/http2-max-field-size: "16k" nginx.ingress.kubernetes.io/http2-max-header-size: "128k" - nginx.ingress.kubernetes.io/large-client-header-buffers: "8 64k" + nginx.ingress.kubernetes.io/large-client-header-buffers: "8 64k" spec: ingressClassName: nginx tls: - hosts: - booking-microservices.com - secretName: letsencrypt-staging - rules: + secretName: letsencrypt-staging + rules: - host: booking-microservices.com http: paths: @@ -1219,7 +1219,7 @@ spec: service: name: passenger port: - number: 80 + number: 80 - path: /passenger/(.*) pathType: Prefix backend: @@ -1235,11 +1235,11 @@ spec: service: name: booking port: - number: 80 + number: 80 - path: /booking/(.*) pathType: Prefix backend: service: name: booking port: - number: 80 \ No newline at end of file + number: 80 diff --git a/monolith-to-cloud-architecture.sln b/monolith-to-cloud-architecture.sln deleted file mode 100644 index abf159a..0000000 --- a/monolith-to-cloud-architecture.sln +++ /dev/null @@ -1,313 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31903.59 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "building-blocks", "building-blocks", "{B85B39B5-B341-4117-8626-C5DD4F375569}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "monolith", "monolith", "{96913068-5EFE-4D13-8B00-924AFED16439}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modular-monolith", "modular-monolith", "{F1BEC66C-B321-45D8-95C1-8DCD4743275D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "microservices", "microservices", "{33F5E6F6-FACB-4D34-8E48-B80E0497D239}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{57366225-A26A-4715-A690-DA641B0C0450}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{39BAB0A0-3C16-49B1-B817-9EC5C600BF5E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{570274DD-E84A-4F22-9079-D60B59EC9ED2}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AD2FB7C1-8641-47E9-B62D-B3A2D74147D8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DBAE70CC-011A-4997-9612-58AFAFF73291}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FB529C7A-F884-42D1-BE41-2A6B7CC4101B}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Flight", "Flight", "{5A2A9F1C-245A-4978-93A0-E00120FEE765}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Booking", "Booking", "{D0A6E1E7-DFB6-4940-A254-F2E24897C4AC}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Passenger", "Passenger", "{F77CA77C-49CE-49B5-BE5A-FCCF6C63D65A}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{A1786514-35EB-4AFA-87E1-2FB89D748C02}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ApiGateway", "ApiGateway", "{A5E49049-0DFF-4D87-9188-2B0ACBC0D59B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiGateway", "3-microservices-architecture-style\src\ApiGateway\src\ApiGateway.csproj", "{6538BDF3-A741-46E9-8988-C859ABB2FBB2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking.Api", "3-microservices-architecture-style\src\Services\Booking\src\Booking.Api\Booking.Api.csproj", "{B851799B-A328-4E40-9095-C56C11A6235E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "3-microservices-architecture-style\src\Services\Booking\src\Booking\Booking.csproj", "{674C0974-11C4-4BF7-B2DF-8ED753919224}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flight.Api", "3-microservices-architecture-style\src\Services\Flight\src\Flight.Api\Flight.Api.csproj", "{FB8AA20B-0D31-4241-A126-07992BCF7E2A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flight", "3-microservices-architecture-style\src\Services\Flight\src\Flight\Flight.csproj", "{0EB6B262-197D-450C-A56E-634D2D428FCB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity.Api", "3-microservices-architecture-style\src\Services\Identity\src\Identity.Api\Identity.Api.csproj", "{694E763C-E076-4F36-A3CE-3A55D794C871}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity", "3-microservices-architecture-style\src\Services\Identity\src\Identity\Identity.csproj", "{E18BC5D2-5A32-469A-9E0B-5ACFE3B6639B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Passenger.Api", "3-microservices-architecture-style\src\Services\Passenger\src\Passenger.Api\Passenger.Api.csproj", "{1F2CE508-42D0-437B-83AB-0D5FEBE324F8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Passenger", "3-microservices-architecture-style\src\Services\Passenger\src\Passenger\Passenger.csproj", "{77410EA7-739C-475B-B460-CCEF5CEE1AD1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Flight", "Flight", "{7D81CAA6-6DEF-43C1-AE1B-D0F0B7B09CE7}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Passenger", "Passenger", "{D2F19D7F-A9DA-47D2-A445-F9ED8D4479C1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Booking", "Booking", "{51EE0C7A-6D1A-4538-957A-34B6906FC932}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{3FD37B50-3C7D-49E9-9456-A3E82675227D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "3-microservices-architecture-style\src\Services\Booking\tests\IntegrationTest\Integration.Test.csproj", "{5D3D2499-0732-4545-87F5-C26AF1FE827B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndToEnd.Test", "3-microservices-architecture-style\src\Services\Flight\tests\EndToEndTest\EndToEnd.Test.csproj", "{EE5ECF6A-0D4F-4737-BAD3-AE66D1B53D83}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "3-microservices-architecture-style\src\Services\Flight\tests\IntegrationTest\Integration.Test.csproj", "{0A74D3F2-7814-4FB4-890D-4899749B67A2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit.Test", "3-microservices-architecture-style\src\Services\Flight\tests\UnitTest\Unit.Test.csproj", "{FDA41108-8194-49B2-8F78-9F8AECABB7BC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "3-microservices-architecture-style\src\Services\Identity\tests\IntegrationTest\Integration.Test.csproj", "{B6D11E8B-CAAE-4452-B3AE-A49DA7E68FE0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "3-microservices-architecture-style\src\Services\Passenger\tests\IntegrationTest\Integration.Test.csproj", "{6D17EFCC-63DB-4E51-8073-25D5E59B2170}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuildingBlocks", "building-blocks\BuildingBlocks.csproj", "{5ED78466-4114-48ED-9A6E-02143984E7A1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{D1907049-C23E-47CB-9DF1-0D9EDB7CE117}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{5F943131-E273-474E-891E-6386C4B10D00}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Flight", "Flight", "{183FF15D-1B24-4FA4-A5E4-505825919113}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Booking", "Booking", "{3CB44FE8-8DC1-49BD-864A-72FB6A8229C5}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Passenger", "Passenger", "{254C235E-7E2D-4FEE-9EB4-50E48BDB1295}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{6C250353-B112-42F5-BBE9-FA2A725870FD}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flight", "2-modular-monolith-architecture-style\src\Modules\Flight\src\Flight.csproj", "{99914C87-B2FC-4DB2-9BFC-AA2D63B3024F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "2-modular-monolith-architecture-style\src\Api\src\Api.csproj", "{18FAA2C9-5B3B-41D4-83F4-F91B0F2355A0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Booking", "2-modular-monolith-architecture-style\src\Modules\Booking\src\Booking.csproj", "{301AB091-1BBB-4D95-9A54-AA7A8EE928EF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Identity", "2-modular-monolith-architecture-style\src\Modules\Identity\src\Identity.csproj", "{3020E2CD-C6E5-4489-914E-96083705AF0E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Passenger", "2-modular-monolith-architecture-style\src\Modules\Passenger\src\Passenger.csproj", "{1CD81080-9F44-49AA-94F9-EFEBFD8073E4}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BookingMonolith", "BookingMonolith", "{DB31E41A-D441-4BB8-B96C-F70395FBFB95}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BookingMonolith", "1-monolith-architecture-style\src\BookingMonolith\src\BookingMonolith.csproj", "{ECBE72AF-7F47-4086-A3F8-AF011085E253}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Api", "Api", "{EAAC4A89-D71D-426F-ABB0-127C3E777E54}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Api", "1-monolith-architecture-style\src\Api\src\Api.csproj", "{E7BA185C-B26D-4ACB-A24A-70AB730DD2A0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Flight", "Flight", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit.Test", "2-modular-monolith-architecture-style\src\Modules\Flight\tests\Unit.Test\Unit.Test.csproj", "{E7B7E65D-DB14-494C-A748-EF90666FB0B1}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "2-modular-monolith-architecture-style\src\Modules\Flight\tests\Integration.Test\Integration.Test.csproj", "{AE7E4AE8-4A5C-44AE-B1FC-2A04824EE29B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EndToEnd.Test", "2-modular-monolith-architecture-style\src\Modules\Flight\tests\EndToEnd.Test\EndToEnd.Test.csproj", "{7CBA4E35-64EA-BFB3-0507-B7DE1E60CD54}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Booking", "Booking", "{5DE68C42-13B1-44D0-B966-7EE083B9B2B5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "2-modular-monolith-architecture-style\src\Modules\Booking\tests\Integration.Test\Integration.Test.csproj", "{A23A47DB-7C4B-411C-9078-AE567407FEB1}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{F59A33C1-6197-4F76-82BF-D7F2CC9D6438}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "2-modular-monolith-architecture-style\src\Modules\Identity\tests\Integration.Test\Integration.Test.csproj", "{39DE2739-1426-2288-DF5D-B58D339E5CDE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Passenger", "Passenger", "{687C40B6-F05C-4794-981D-5DA28C07E3D2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Integration.Test", "2-modular-monolith-architecture-style\src\Modules\Passenger\tests\Integration.Test\Integration.Test.csproj", "{87AE85AA-A092-2130-C912-97B9B252845A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6538BDF3-A741-46E9-8988-C859ABB2FBB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6538BDF3-A741-46E9-8988-C859ABB2FBB2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6538BDF3-A741-46E9-8988-C859ABB2FBB2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6538BDF3-A741-46E9-8988-C859ABB2FBB2}.Release|Any CPU.Build.0 = Release|Any CPU - {B851799B-A328-4E40-9095-C56C11A6235E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B851799B-A328-4E40-9095-C56C11A6235E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B851799B-A328-4E40-9095-C56C11A6235E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B851799B-A328-4E40-9095-C56C11A6235E}.Release|Any CPU.Build.0 = Release|Any CPU - {674C0974-11C4-4BF7-B2DF-8ED753919224}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {674C0974-11C4-4BF7-B2DF-8ED753919224}.Debug|Any CPU.Build.0 = Debug|Any CPU - {674C0974-11C4-4BF7-B2DF-8ED753919224}.Release|Any CPU.ActiveCfg = Release|Any CPU - {674C0974-11C4-4BF7-B2DF-8ED753919224}.Release|Any CPU.Build.0 = Release|Any CPU - {FB8AA20B-0D31-4241-A126-07992BCF7E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FB8AA20B-0D31-4241-A126-07992BCF7E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FB8AA20B-0D31-4241-A126-07992BCF7E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FB8AA20B-0D31-4241-A126-07992BCF7E2A}.Release|Any CPU.Build.0 = Release|Any CPU - {0EB6B262-197D-450C-A56E-634D2D428FCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0EB6B262-197D-450C-A56E-634D2D428FCB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0EB6B262-197D-450C-A56E-634D2D428FCB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0EB6B262-197D-450C-A56E-634D2D428FCB}.Release|Any CPU.Build.0 = Release|Any CPU - {694E763C-E076-4F36-A3CE-3A55D794C871}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {694E763C-E076-4F36-A3CE-3A55D794C871}.Debug|Any CPU.Build.0 = Debug|Any CPU - {694E763C-E076-4F36-A3CE-3A55D794C871}.Release|Any CPU.ActiveCfg = Release|Any CPU - {694E763C-E076-4F36-A3CE-3A55D794C871}.Release|Any CPU.Build.0 = Release|Any CPU - {E18BC5D2-5A32-469A-9E0B-5ACFE3B6639B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E18BC5D2-5A32-469A-9E0B-5ACFE3B6639B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E18BC5D2-5A32-469A-9E0B-5ACFE3B6639B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E18BC5D2-5A32-469A-9E0B-5ACFE3B6639B}.Release|Any CPU.Build.0 = Release|Any CPU - {1F2CE508-42D0-437B-83AB-0D5FEBE324F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1F2CE508-42D0-437B-83AB-0D5FEBE324F8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1F2CE508-42D0-437B-83AB-0D5FEBE324F8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1F2CE508-42D0-437B-83AB-0D5FEBE324F8}.Release|Any CPU.Build.0 = Release|Any CPU - {77410EA7-739C-475B-B460-CCEF5CEE1AD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {77410EA7-739C-475B-B460-CCEF5CEE1AD1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {77410EA7-739C-475B-B460-CCEF5CEE1AD1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {77410EA7-739C-475B-B460-CCEF5CEE1AD1}.Release|Any CPU.Build.0 = Release|Any CPU - {5D3D2499-0732-4545-87F5-C26AF1FE827B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5D3D2499-0732-4545-87F5-C26AF1FE827B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5D3D2499-0732-4545-87F5-C26AF1FE827B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5D3D2499-0732-4545-87F5-C26AF1FE827B}.Release|Any CPU.Build.0 = Release|Any CPU - {EE5ECF6A-0D4F-4737-BAD3-AE66D1B53D83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EE5ECF6A-0D4F-4737-BAD3-AE66D1B53D83}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EE5ECF6A-0D4F-4737-BAD3-AE66D1B53D83}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EE5ECF6A-0D4F-4737-BAD3-AE66D1B53D83}.Release|Any CPU.Build.0 = Release|Any CPU - {0A74D3F2-7814-4FB4-890D-4899749B67A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0A74D3F2-7814-4FB4-890D-4899749B67A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0A74D3F2-7814-4FB4-890D-4899749B67A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0A74D3F2-7814-4FB4-890D-4899749B67A2}.Release|Any CPU.Build.0 = Release|Any CPU - {FDA41108-8194-49B2-8F78-9F8AECABB7BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FDA41108-8194-49B2-8F78-9F8AECABB7BC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FDA41108-8194-49B2-8F78-9F8AECABB7BC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FDA41108-8194-49B2-8F78-9F8AECABB7BC}.Release|Any CPU.Build.0 = Release|Any CPU - {B6D11E8B-CAAE-4452-B3AE-A49DA7E68FE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B6D11E8B-CAAE-4452-B3AE-A49DA7E68FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B6D11E8B-CAAE-4452-B3AE-A49DA7E68FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B6D11E8B-CAAE-4452-B3AE-A49DA7E68FE0}.Release|Any CPU.Build.0 = Release|Any CPU - {6D17EFCC-63DB-4E51-8073-25D5E59B2170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D17EFCC-63DB-4E51-8073-25D5E59B2170}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6D17EFCC-63DB-4E51-8073-25D5E59B2170}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6D17EFCC-63DB-4E51-8073-25D5E59B2170}.Release|Any CPU.Build.0 = Release|Any CPU - {5ED78466-4114-48ED-9A6E-02143984E7A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5ED78466-4114-48ED-9A6E-02143984E7A1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5ED78466-4114-48ED-9A6E-02143984E7A1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5ED78466-4114-48ED-9A6E-02143984E7A1}.Release|Any CPU.Build.0 = Release|Any CPU - {99914C87-B2FC-4DB2-9BFC-AA2D63B3024F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {99914C87-B2FC-4DB2-9BFC-AA2D63B3024F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {99914C87-B2FC-4DB2-9BFC-AA2D63B3024F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {99914C87-B2FC-4DB2-9BFC-AA2D63B3024F}.Release|Any CPU.Build.0 = Release|Any CPU - {18FAA2C9-5B3B-41D4-83F4-F91B0F2355A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {18FAA2C9-5B3B-41D4-83F4-F91B0F2355A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {18FAA2C9-5B3B-41D4-83F4-F91B0F2355A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {18FAA2C9-5B3B-41D4-83F4-F91B0F2355A0}.Release|Any CPU.Build.0 = Release|Any CPU - {301AB091-1BBB-4D95-9A54-AA7A8EE928EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {301AB091-1BBB-4D95-9A54-AA7A8EE928EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {301AB091-1BBB-4D95-9A54-AA7A8EE928EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {301AB091-1BBB-4D95-9A54-AA7A8EE928EF}.Release|Any CPU.Build.0 = Release|Any CPU - {3020E2CD-C6E5-4489-914E-96083705AF0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3020E2CD-C6E5-4489-914E-96083705AF0E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3020E2CD-C6E5-4489-914E-96083705AF0E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3020E2CD-C6E5-4489-914E-96083705AF0E}.Release|Any CPU.Build.0 = Release|Any CPU - {1CD81080-9F44-49AA-94F9-EFEBFD8073E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1CD81080-9F44-49AA-94F9-EFEBFD8073E4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1CD81080-9F44-49AA-94F9-EFEBFD8073E4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1CD81080-9F44-49AA-94F9-EFEBFD8073E4}.Release|Any CPU.Build.0 = Release|Any CPU - {ECBE72AF-7F47-4086-A3F8-AF011085E253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ECBE72AF-7F47-4086-A3F8-AF011085E253}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ECBE72AF-7F47-4086-A3F8-AF011085E253}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ECBE72AF-7F47-4086-A3F8-AF011085E253}.Release|Any CPU.Build.0 = Release|Any CPU - {E7BA185C-B26D-4ACB-A24A-70AB730DD2A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7BA185C-B26D-4ACB-A24A-70AB730DD2A0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7BA185C-B26D-4ACB-A24A-70AB730DD2A0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7BA185C-B26D-4ACB-A24A-70AB730DD2A0}.Release|Any CPU.Build.0 = Release|Any CPU - {E7B7E65D-DB14-494C-A748-EF90666FB0B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7B7E65D-DB14-494C-A748-EF90666FB0B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7B7E65D-DB14-494C-A748-EF90666FB0B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7B7E65D-DB14-494C-A748-EF90666FB0B1}.Release|Any CPU.Build.0 = Release|Any CPU - {AE7E4AE8-4A5C-44AE-B1FC-2A04824EE29B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE7E4AE8-4A5C-44AE-B1FC-2A04824EE29B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE7E4AE8-4A5C-44AE-B1FC-2A04824EE29B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE7E4AE8-4A5C-44AE-B1FC-2A04824EE29B}.Release|Any CPU.Build.0 = Release|Any CPU - {7CBA4E35-64EA-BFB3-0507-B7DE1E60CD54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CBA4E35-64EA-BFB3-0507-B7DE1E60CD54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7CBA4E35-64EA-BFB3-0507-B7DE1E60CD54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7CBA4E35-64EA-BFB3-0507-B7DE1E60CD54}.Release|Any CPU.Build.0 = Release|Any CPU - {A23A47DB-7C4B-411C-9078-AE567407FEB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A23A47DB-7C4B-411C-9078-AE567407FEB1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A23A47DB-7C4B-411C-9078-AE567407FEB1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A23A47DB-7C4B-411C-9078-AE567407FEB1}.Release|Any CPU.Build.0 = Release|Any CPU - {39DE2739-1426-2288-DF5D-B58D339E5CDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {39DE2739-1426-2288-DF5D-B58D339E5CDE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {39DE2739-1426-2288-DF5D-B58D339E5CDE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {39DE2739-1426-2288-DF5D-B58D339E5CDE}.Release|Any CPU.Build.0 = Release|Any CPU - {87AE85AA-A092-2130-C912-97B9B252845A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {87AE85AA-A092-2130-C912-97B9B252845A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {87AE85AA-A092-2130-C912-97B9B252845A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {87AE85AA-A092-2130-C912-97B9B252845A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {57366225-A26A-4715-A690-DA641B0C0450} = {33F5E6F6-FACB-4D34-8E48-B80E0497D239} - {39BAB0A0-3C16-49B1-B817-9EC5C600BF5E} = {33F5E6F6-FACB-4D34-8E48-B80E0497D239} - {570274DD-E84A-4F22-9079-D60B59EC9ED2} = {F1BEC66C-B321-45D8-95C1-8DCD4743275D} - {AD2FB7C1-8641-47E9-B62D-B3A2D74147D8} = {F1BEC66C-B321-45D8-95C1-8DCD4743275D} - {DBAE70CC-011A-4997-9612-58AFAFF73291} = {96913068-5EFE-4D13-8B00-924AFED16439} - {FB529C7A-F884-42D1-BE41-2A6B7CC4101B} = {96913068-5EFE-4D13-8B00-924AFED16439} - {5A2A9F1C-245A-4978-93A0-E00120FEE765} = {57366225-A26A-4715-A690-DA641B0C0450} - {D0A6E1E7-DFB6-4940-A254-F2E24897C4AC} = {57366225-A26A-4715-A690-DA641B0C0450} - {F77CA77C-49CE-49B5-BE5A-FCCF6C63D65A} = {57366225-A26A-4715-A690-DA641B0C0450} - {A1786514-35EB-4AFA-87E1-2FB89D748C02} = {57366225-A26A-4715-A690-DA641B0C0450} - {A5E49049-0DFF-4D87-9188-2B0ACBC0D59B} = {57366225-A26A-4715-A690-DA641B0C0450} - {6538BDF3-A741-46E9-8988-C859ABB2FBB2} = {A5E49049-0DFF-4D87-9188-2B0ACBC0D59B} - {B851799B-A328-4E40-9095-C56C11A6235E} = {D0A6E1E7-DFB6-4940-A254-F2E24897C4AC} - {674C0974-11C4-4BF7-B2DF-8ED753919224} = {D0A6E1E7-DFB6-4940-A254-F2E24897C4AC} - {FB8AA20B-0D31-4241-A126-07992BCF7E2A} = {5A2A9F1C-245A-4978-93A0-E00120FEE765} - {0EB6B262-197D-450C-A56E-634D2D428FCB} = {5A2A9F1C-245A-4978-93A0-E00120FEE765} - {694E763C-E076-4F36-A3CE-3A55D794C871} = {A1786514-35EB-4AFA-87E1-2FB89D748C02} - {E18BC5D2-5A32-469A-9E0B-5ACFE3B6639B} = {A1786514-35EB-4AFA-87E1-2FB89D748C02} - {1F2CE508-42D0-437B-83AB-0D5FEBE324F8} = {F77CA77C-49CE-49B5-BE5A-FCCF6C63D65A} - {77410EA7-739C-475B-B460-CCEF5CEE1AD1} = {F77CA77C-49CE-49B5-BE5A-FCCF6C63D65A} - {7D81CAA6-6DEF-43C1-AE1B-D0F0B7B09CE7} = {39BAB0A0-3C16-49B1-B817-9EC5C600BF5E} - {D2F19D7F-A9DA-47D2-A445-F9ED8D4479C1} = {39BAB0A0-3C16-49B1-B817-9EC5C600BF5E} - {51EE0C7A-6D1A-4538-957A-34B6906FC932} = {39BAB0A0-3C16-49B1-B817-9EC5C600BF5E} - {3FD37B50-3C7D-49E9-9456-A3E82675227D} = {39BAB0A0-3C16-49B1-B817-9EC5C600BF5E} - {5D3D2499-0732-4545-87F5-C26AF1FE827B} = {51EE0C7A-6D1A-4538-957A-34B6906FC932} - {EE5ECF6A-0D4F-4737-BAD3-AE66D1B53D83} = {7D81CAA6-6DEF-43C1-AE1B-D0F0B7B09CE7} - {0A74D3F2-7814-4FB4-890D-4899749B67A2} = {7D81CAA6-6DEF-43C1-AE1B-D0F0B7B09CE7} - {FDA41108-8194-49B2-8F78-9F8AECABB7BC} = {7D81CAA6-6DEF-43C1-AE1B-D0F0B7B09CE7} - {B6D11E8B-CAAE-4452-B3AE-A49DA7E68FE0} = {3FD37B50-3C7D-49E9-9456-A3E82675227D} - {6D17EFCC-63DB-4E51-8073-25D5E59B2170} = {D2F19D7F-A9DA-47D2-A445-F9ED8D4479C1} - {5ED78466-4114-48ED-9A6E-02143984E7A1} = {B85B39B5-B341-4117-8626-C5DD4F375569} - {D1907049-C23E-47CB-9DF1-0D9EDB7CE117} = {570274DD-E84A-4F22-9079-D60B59EC9ED2} - {5F943131-E273-474E-891E-6386C4B10D00} = {570274DD-E84A-4F22-9079-D60B59EC9ED2} - {183FF15D-1B24-4FA4-A5E4-505825919113} = {5F943131-E273-474E-891E-6386C4B10D00} - {3CB44FE8-8DC1-49BD-864A-72FB6A8229C5} = {5F943131-E273-474E-891E-6386C4B10D00} - {254C235E-7E2D-4FEE-9EB4-50E48BDB1295} = {5F943131-E273-474E-891E-6386C4B10D00} - {6C250353-B112-42F5-BBE9-FA2A725870FD} = {5F943131-E273-474E-891E-6386C4B10D00} - {99914C87-B2FC-4DB2-9BFC-AA2D63B3024F} = {183FF15D-1B24-4FA4-A5E4-505825919113} - {18FAA2C9-5B3B-41D4-83F4-F91B0F2355A0} = {D1907049-C23E-47CB-9DF1-0D9EDB7CE117} - {301AB091-1BBB-4D95-9A54-AA7A8EE928EF} = {3CB44FE8-8DC1-49BD-864A-72FB6A8229C5} - {3020E2CD-C6E5-4489-914E-96083705AF0E} = {6C250353-B112-42F5-BBE9-FA2A725870FD} - {1CD81080-9F44-49AA-94F9-EFEBFD8073E4} = {254C235E-7E2D-4FEE-9EB4-50E48BDB1295} - {DB31E41A-D441-4BB8-B96C-F70395FBFB95} = {DBAE70CC-011A-4997-9612-58AFAFF73291} - {ECBE72AF-7F47-4086-A3F8-AF011085E253} = {DB31E41A-D441-4BB8-B96C-F70395FBFB95} - {EAAC4A89-D71D-426F-ABB0-127C3E777E54} = {DBAE70CC-011A-4997-9612-58AFAFF73291} - {E7BA185C-B26D-4ACB-A24A-70AB730DD2A0} = {EAAC4A89-D71D-426F-ABB0-127C3E777E54} - {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {AD2FB7C1-8641-47E9-B62D-B3A2D74147D8} - {E7B7E65D-DB14-494C-A748-EF90666FB0B1} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {AE7E4AE8-4A5C-44AE-B1FC-2A04824EE29B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {7CBA4E35-64EA-BFB3-0507-B7DE1E60CD54} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} - {5DE68C42-13B1-44D0-B966-7EE083B9B2B5} = {AD2FB7C1-8641-47E9-B62D-B3A2D74147D8} - {A23A47DB-7C4B-411C-9078-AE567407FEB1} = {5DE68C42-13B1-44D0-B966-7EE083B9B2B5} - {F59A33C1-6197-4F76-82BF-D7F2CC9D6438} = {AD2FB7C1-8641-47E9-B62D-B3A2D74147D8} - {39DE2739-1426-2288-DF5D-B58D339E5CDE} = {F59A33C1-6197-4F76-82BF-D7F2CC9D6438} - {687C40B6-F05C-4794-981D-5DA28C07E3D2} = {AD2FB7C1-8641-47E9-B62D-B3A2D74147D8} - {87AE85AA-A092-2130-C912-97B9B252845A} = {687C40B6-F05C-4794-981D-5DA28C07E3D2} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF29DFD4-25EC-44C4-9DA6-E3AC4B292257} - EndGlobalSection -EndGlobal diff --git a/package.json b/package.json index ed1da4f..e703f5a 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "monolith-to-cloud-architecture", + "name": "booking-microservices", "version": "1.0.0", - "description": "monolith-to-cloud-architecture", + "description": "booking-microservices", "author": "Meysam Hadeli", "license": "MIT", "main": "index.js", "scripts": { "prepare": "husky && dotnet tool restore", - "format": "dotnet format monolith-to-cloud-architecture.sln --severity error --verbosity detailed", - "ci-format": "dotnet format monolith-to-cloud-architecture.sln --verify-no-changes --severity error --verbosity detailed", + "format": "dotnet format booking-microservices.sln --severity error --verbosity detailed", + "ci-format": "dotnet format booking-microservices.sln --verify-no-changes --severity error --verbosity detailed", "upgrade-packages": "dotnet outdated --upgrade" }, "devDependencies": { diff --git a/3-microservices-architecture-style/src/ApiGateway/Dockerfile b/src/ApiGateway/Dockerfile similarity index 56% rename from 3-microservices-architecture-style/src/ApiGateway/Dockerfile rename to src/ApiGateway/Dockerfile index 11dac27..27a73e2 100644 --- a/3-microservices-architecture-style/src/ApiGateway/Dockerfile +++ b/src/ApiGateway/Dockerfile @@ -7,23 +7,23 @@ COPY ./Directory.Build.props ./ # Setup working directory for the project COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj ./3-microservices-architecture-style/src/ApiGateway/src/ +COPY ./src/ApiGateway/src/ApiGateway.csproj ./src/ApiGateway/src/ # Restore nuget packages -RUN dotnet restore ./3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj +RUN dotnet restore ./src/ApiGateway/src/ApiGateway.csproj # Copy project files COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/ApiGateway/src ./3-microservices-architecture-style/src/ApiGateway/src/ +COPY ./src/ApiGateway/src ./src/ApiGateway/src/ # Build project with Release configuration # and no restore, as we did it already RUN ls -RUN dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj +RUN dotnet build -c Release --no-restore ./src/ApiGateway/src/ApiGateway.csproj -WORKDIR /3-microservices-architecture-style/src/ApiGateway/src +WORKDIR /src/ApiGateway/src # Publish project to output folder # and no build, as we did it already @@ -33,7 +33,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:9.0 # Setup working directory for the project WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/ApiGateway/src/out . +COPY --from=builder /src/ApiGateway/src/out . ENV ASPNETCORE_URLS https://*:443, http://*:80 ENV ASPNETCORE_ENVIRONMENT docker diff --git a/3-microservices-architecture-style/src/ApiGateway/dev.Dockerfile b/src/ApiGateway/dev.Dockerfile similarity index 62% rename from 3-microservices-architecture-style/src/ApiGateway/dev.Dockerfile rename to src/ApiGateway/dev.Dockerfile index b3a54f7..9425bd6 100644 --- a/3-microservices-architecture-style/src/ApiGateway/dev.Dockerfile +++ b/src/ApiGateway/dev.Dockerfile @@ -7,25 +7,25 @@ COPY ./Directory.Build.props ./ # Setup working directory for the project COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj ./3-microservices-architecture-style/src/ApiGateway/src/ +COPY ./src/ApiGateway/src/ApiGateway.csproj ./src/ApiGateway/src/ # Restore nuget packages RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \ - dotnet restore ./3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj + dotnet restore ./src/ApiGateway/src/ApiGateway.csproj # Copy project files COPY ./building-blocks ./building-blocks/ -COPY ./3-microservices-architecture-style/src/ApiGateway/src ./3-microservices-architecture-style/src/ApiGateway/src/ +COPY ./src/ApiGateway/src ./src/ApiGateway/src/ # Build project with Release configuration # and no restore, as we did it already RUN ls RUN --mount=type=cache,id=gateway_nuget,target=/root/.nuget/packages \ - dotnet build -c Release --no-restore ./3-microservices-architecture-style/src/ApiGateway/src/ApiGateway.csproj + dotnet build -c Release --no-restore ./src/ApiGateway/src/ApiGateway.csproj -WORKDIR /3-microservices-architecture-style/src/ApiGateway/src +WORKDIR /src/ApiGateway/src # Publish project to output folder # and no build, as we did it already @@ -36,7 +36,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:9.0 # Setup working directory for the project WORKDIR / -COPY --from=builder /3-microservices-architecture-style/src/ApiGateway/src/out . +COPY --from=builder /src/ApiGateway/src/out . ENV ASPNETCORE_URLS https://*:443, http://*:80 ENV ASPNETCORE_ENVIRONMENT docker diff --git a/src/ApiGateway/src/ApiGateway.csproj b/src/ApiGateway/src/ApiGateway.csproj new file mode 100644 index 0000000..594f73e --- /dev/null +++ b/src/ApiGateway/src/ApiGateway.csproj @@ -0,0 +1,5 @@ + + + + + diff --git a/3-microservices-architecture-style/src/ApiGateway/src/Program.cs b/src/ApiGateway/src/Program.cs similarity index 100% rename from 3-microservices-architecture-style/src/ApiGateway/src/Program.cs rename to src/ApiGateway/src/Program.cs diff --git a/3-microservices-architecture-style/src/ApiGateway/src/Properties/launchSettings.json b/src/ApiGateway/src/Properties/launchSettings.json similarity index 98% rename from 3-microservices-architecture-style/src/ApiGateway/src/Properties/launchSettings.json rename to src/ApiGateway/src/Properties/launchSettings.json index 9ac3bd0..9ed193c 100644 --- a/3-microservices-architecture-style/src/ApiGateway/src/Properties/launchSettings.json +++ b/src/ApiGateway/src/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "ApiGateway": { diff --git a/1-monolith-architecture-style/src/Api/src/appsettings.Development.json b/src/ApiGateway/src/appsettings.Development.json similarity index 100% rename from 1-monolith-architecture-style/src/Api/src/appsettings.Development.json rename to src/ApiGateway/src/appsettings.Development.json diff --git a/3-microservices-architecture-style/src/ApiGateway/src/appsettings.docker.json b/src/ApiGateway/src/appsettings.docker.json similarity index 100% rename from 3-microservices-architecture-style/src/ApiGateway/src/appsettings.docker.json rename to src/ApiGateway/src/appsettings.docker.json diff --git a/3-microservices-architecture-style/src/ApiGateway/src/appsettings.json b/src/ApiGateway/src/appsettings.json similarity index 94% rename from 3-microservices-architecture-style/src/ApiGateway/src/appsettings.json rename to src/ApiGateway/src/appsettings.json index 205372b..f952a1d 100644 --- a/3-microservices-architecture-style/src/ApiGateway/src/appsettings.json +++ b/src/ApiGateway/src/appsettings.json @@ -17,7 +17,7 @@ "match": { "path": "identity/{**catch-all}" }, - "Transforms": [ + "Transforms": [ { "PathRemovePrefix": "identity" } @@ -28,7 +28,7 @@ "match": { "path": "flight/{**catch-all}" }, - "Transforms": [ + "Transforms": [ { "PathRemovePrefix": "flight" } @@ -39,7 +39,7 @@ "match": { "path": "passenger/{**catch-all}" }, - "Transforms": [ + "Transforms": [ { "PathRemovePrefix": "passenger" } @@ -50,7 +50,7 @@ "match": { "path": "booking/{**catch-all}" }, - "Transforms": [ + "Transforms": [ { "PathRemovePrefix": "booking" } diff --git a/building-blocks/BuildingBlocks.csproj b/src/BuildingBlocks/BuildingBlocks.csproj similarity index 100% rename from building-blocks/BuildingBlocks.csproj rename to src/BuildingBlocks/BuildingBlocks.csproj diff --git a/building-blocks/Caching/CachingBehavior.cs b/src/BuildingBlocks/Caching/CachingBehavior.cs similarity index 100% rename from building-blocks/Caching/CachingBehavior.cs rename to src/BuildingBlocks/Caching/CachingBehavior.cs diff --git a/building-blocks/Caching/ICacheRequest.cs b/src/BuildingBlocks/Caching/ICacheRequest.cs similarity index 100% rename from building-blocks/Caching/ICacheRequest.cs rename to src/BuildingBlocks/Caching/ICacheRequest.cs diff --git a/building-blocks/Caching/IInvalidateCacheRequest.cs b/src/BuildingBlocks/Caching/IInvalidateCacheRequest.cs similarity index 100% rename from building-blocks/Caching/IInvalidateCacheRequest.cs rename to src/BuildingBlocks/Caching/IInvalidateCacheRequest.cs diff --git a/building-blocks/Caching/InvalidateCachingBehavior.cs b/src/BuildingBlocks/Caching/InvalidateCachingBehavior.cs similarity index 100% rename from building-blocks/Caching/InvalidateCachingBehavior.cs rename to src/BuildingBlocks/Caching/InvalidateCachingBehavior.cs diff --git a/building-blocks/Constants/IdentityConstant.cs b/src/BuildingBlocks/Constants/IdentityConstant.cs similarity index 100% rename from building-blocks/Constants/IdentityConstant.cs rename to src/BuildingBlocks/Constants/IdentityConstant.cs diff --git a/building-blocks/Contracts/EventBus.Messages/FlighContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/FlighContracts.cs similarity index 100% rename from building-blocks/Contracts/EventBus.Messages/FlighContracts.cs rename to src/BuildingBlocks/Contracts/EventBus.Messages/FlighContracts.cs diff --git a/building-blocks/Contracts/EventBus.Messages/IdentityContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/IdentityContracts.cs similarity index 100% rename from building-blocks/Contracts/EventBus.Messages/IdentityContracts.cs rename to src/BuildingBlocks/Contracts/EventBus.Messages/IdentityContracts.cs diff --git a/building-blocks/Contracts/EventBus.Messages/PassengerContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/PassengerContracts.cs similarity index 100% rename from building-blocks/Contracts/EventBus.Messages/PassengerContracts.cs rename to src/BuildingBlocks/Contracts/EventBus.Messages/PassengerContracts.cs diff --git a/building-blocks/Contracts/EventBus.Messages/ReservationContracts.cs b/src/BuildingBlocks/Contracts/EventBus.Messages/ReservationContracts.cs similarity index 100% rename from building-blocks/Contracts/EventBus.Messages/ReservationContracts.cs rename to src/BuildingBlocks/Contracts/EventBus.Messages/ReservationContracts.cs diff --git a/building-blocks/Core/CQRS/ICommand.cs b/src/BuildingBlocks/Core/CQRS/ICommand.cs similarity index 100% rename from building-blocks/Core/CQRS/ICommand.cs rename to src/BuildingBlocks/Core/CQRS/ICommand.cs diff --git a/building-blocks/Core/CQRS/ICommandHandler.cs b/src/BuildingBlocks/Core/CQRS/ICommandHandler.cs similarity index 100% rename from building-blocks/Core/CQRS/ICommandHandler.cs rename to src/BuildingBlocks/Core/CQRS/ICommandHandler.cs diff --git a/building-blocks/Core/CQRS/IQuery.cs b/src/BuildingBlocks/Core/CQRS/IQuery.cs similarity index 100% rename from building-blocks/Core/CQRS/IQuery.cs rename to src/BuildingBlocks/Core/CQRS/IQuery.cs diff --git a/building-blocks/Core/CQRS/IQueryHandler.cs b/src/BuildingBlocks/Core/CQRS/IQueryHandler.cs similarity index 100% rename from building-blocks/Core/CQRS/IQueryHandler.cs rename to src/BuildingBlocks/Core/CQRS/IQueryHandler.cs diff --git a/building-blocks/Core/CompositeEventMapper.cs b/src/BuildingBlocks/Core/CompositeEventMapper.cs similarity index 100% rename from building-blocks/Core/CompositeEventMapper.cs rename to src/BuildingBlocks/Core/CompositeEventMapper.cs diff --git a/building-blocks/Core/Event/EventType.cs b/src/BuildingBlocks/Core/Event/EventType.cs similarity index 100% rename from building-blocks/Core/Event/EventType.cs rename to src/BuildingBlocks/Core/Event/EventType.cs diff --git a/building-blocks/Core/Event/IDomainEvent.cs b/src/BuildingBlocks/Core/Event/IDomainEvent.cs similarity index 100% rename from building-blocks/Core/Event/IDomainEvent.cs rename to src/BuildingBlocks/Core/Event/IDomainEvent.cs diff --git a/building-blocks/Core/Event/IEvent.cs b/src/BuildingBlocks/Core/Event/IEvent.cs similarity index 100% rename from building-blocks/Core/Event/IEvent.cs rename to src/BuildingBlocks/Core/Event/IEvent.cs diff --git a/building-blocks/Core/Event/IHaveIntegrationEvent.cs b/src/BuildingBlocks/Core/Event/IHaveIntegrationEvent.cs similarity index 100% rename from building-blocks/Core/Event/IHaveIntegrationEvent.cs rename to src/BuildingBlocks/Core/Event/IHaveIntegrationEvent.cs diff --git a/building-blocks/Core/Event/IIntegrationEvent.cs b/src/BuildingBlocks/Core/Event/IIntegrationEvent.cs similarity index 100% rename from building-blocks/Core/Event/IIntegrationEvent.cs rename to src/BuildingBlocks/Core/Event/IIntegrationEvent.cs diff --git a/building-blocks/Core/Event/IInternalCommand.cs b/src/BuildingBlocks/Core/Event/IInternalCommand.cs similarity index 100% rename from building-blocks/Core/Event/IInternalCommand.cs rename to src/BuildingBlocks/Core/Event/IInternalCommand.cs diff --git a/building-blocks/Core/Event/InternalCommand.cs b/src/BuildingBlocks/Core/Event/InternalCommand.cs similarity index 100% rename from building-blocks/Core/Event/InternalCommand.cs rename to src/BuildingBlocks/Core/Event/InternalCommand.cs diff --git a/building-blocks/Core/Event/MessageEnvelope.cs b/src/BuildingBlocks/Core/Event/MessageEnvelope.cs similarity index 100% rename from building-blocks/Core/Event/MessageEnvelope.cs rename to src/BuildingBlocks/Core/Event/MessageEnvelope.cs diff --git a/building-blocks/Core/EventDispatcher.cs b/src/BuildingBlocks/Core/EventDispatcher.cs similarity index 100% rename from building-blocks/Core/EventDispatcher.cs rename to src/BuildingBlocks/Core/EventDispatcher.cs diff --git a/building-blocks/Core/IEventDispatcher.cs b/src/BuildingBlocks/Core/IEventDispatcher.cs similarity index 100% rename from building-blocks/Core/IEventDispatcher.cs rename to src/BuildingBlocks/Core/IEventDispatcher.cs diff --git a/building-blocks/Core/IEventMapper.cs b/src/BuildingBlocks/Core/IEventMapper.cs similarity index 100% rename from building-blocks/Core/IEventMapper.cs rename to src/BuildingBlocks/Core/IEventMapper.cs diff --git a/building-blocks/Core/IntegrationEventWrapper.cs b/src/BuildingBlocks/Core/IntegrationEventWrapper.cs similarity index 100% rename from building-blocks/Core/IntegrationEventWrapper.cs rename to src/BuildingBlocks/Core/IntegrationEventWrapper.cs diff --git a/building-blocks/Core/Model/Aggregate.cs b/src/BuildingBlocks/Core/Model/Aggregate.cs similarity index 100% rename from building-blocks/Core/Model/Aggregate.cs rename to src/BuildingBlocks/Core/Model/Aggregate.cs diff --git a/building-blocks/Core/Model/Entity.cs b/src/BuildingBlocks/Core/Model/Entity.cs similarity index 100% rename from building-blocks/Core/Model/Entity.cs rename to src/BuildingBlocks/Core/Model/Entity.cs diff --git a/building-blocks/Core/Model/IAggregate.cs b/src/BuildingBlocks/Core/Model/IAggregate.cs similarity index 100% rename from building-blocks/Core/Model/IAggregate.cs rename to src/BuildingBlocks/Core/Model/IAggregate.cs diff --git a/building-blocks/Core/Model/IEntity.cs b/src/BuildingBlocks/Core/Model/IEntity.cs similarity index 100% rename from building-blocks/Core/Model/IEntity.cs rename to src/BuildingBlocks/Core/Model/IEntity.cs diff --git a/building-blocks/Core/Model/IVersion.cs b/src/BuildingBlocks/Core/Model/IVersion.cs similarity index 100% rename from building-blocks/Core/Model/IVersion.cs rename to src/BuildingBlocks/Core/Model/IVersion.cs diff --git a/building-blocks/Core/Pagination/Extensions.cs b/src/BuildingBlocks/Core/Pagination/Extensions.cs similarity index 100% rename from building-blocks/Core/Pagination/Extensions.cs rename to src/BuildingBlocks/Core/Pagination/Extensions.cs diff --git a/building-blocks/Core/Pagination/IPageList.cs b/src/BuildingBlocks/Core/Pagination/IPageList.cs similarity index 100% rename from building-blocks/Core/Pagination/IPageList.cs rename to src/BuildingBlocks/Core/Pagination/IPageList.cs diff --git a/building-blocks/Core/Pagination/IPageQuery.cs b/src/BuildingBlocks/Core/Pagination/IPageQuery.cs similarity index 100% rename from building-blocks/Core/Pagination/IPageQuery.cs rename to src/BuildingBlocks/Core/Pagination/IPageQuery.cs diff --git a/building-blocks/Core/Pagination/IPageRequest.cs b/src/BuildingBlocks/Core/Pagination/IPageRequest.cs similarity index 100% rename from building-blocks/Core/Pagination/IPageRequest.cs rename to src/BuildingBlocks/Core/Pagination/IPageRequest.cs diff --git a/building-blocks/Core/Pagination/PageList.cs b/src/BuildingBlocks/Core/Pagination/PageList.cs similarity index 100% rename from building-blocks/Core/Pagination/PageList.cs rename to src/BuildingBlocks/Core/Pagination/PageList.cs diff --git a/building-blocks/EFCore/AppDbContextBase.cs b/src/BuildingBlocks/EFCore/AppDbContextBase.cs similarity index 100% rename from building-blocks/EFCore/AppDbContextBase.cs rename to src/BuildingBlocks/EFCore/AppDbContextBase.cs diff --git a/building-blocks/EFCore/DesignTimeDbContextFactoryBase.cs b/src/BuildingBlocks/EFCore/DesignTimeDbContextFactoryBase.cs similarity index 100% rename from building-blocks/EFCore/DesignTimeDbContextFactoryBase.cs rename to src/BuildingBlocks/EFCore/DesignTimeDbContextFactoryBase.cs diff --git a/building-blocks/EFCore/EfTxBehavior.cs b/src/BuildingBlocks/EFCore/EfTxBehavior.cs similarity index 100% rename from building-blocks/EFCore/EfTxBehavior.cs rename to src/BuildingBlocks/EFCore/EfTxBehavior.cs diff --git a/building-blocks/EFCore/Extensions.cs b/src/BuildingBlocks/EFCore/Extensions.cs similarity index 100% rename from building-blocks/EFCore/Extensions.cs rename to src/BuildingBlocks/EFCore/Extensions.cs diff --git a/building-blocks/EFCore/IDataSeeder.cs b/src/BuildingBlocks/EFCore/IDataSeeder.cs similarity index 100% rename from building-blocks/EFCore/IDataSeeder.cs rename to src/BuildingBlocks/EFCore/IDataSeeder.cs diff --git a/building-blocks/EFCore/IDbContext.cs b/src/BuildingBlocks/EFCore/IDbContext.cs similarity index 100% rename from building-blocks/EFCore/IDbContext.cs rename to src/BuildingBlocks/EFCore/IDbContext.cs diff --git a/building-blocks/EFCore/ISeedManager.cs b/src/BuildingBlocks/EFCore/ISeedManager.cs similarity index 100% rename from building-blocks/EFCore/ISeedManager.cs rename to src/BuildingBlocks/EFCore/ISeedManager.cs diff --git a/building-blocks/EFCore/PostgresOptions.cs b/src/BuildingBlocks/EFCore/PostgresOptions.cs similarity index 100% rename from building-blocks/EFCore/PostgresOptions.cs rename to src/BuildingBlocks/EFCore/PostgresOptions.cs diff --git a/building-blocks/EFCore/SeedManagers.cs b/src/BuildingBlocks/EFCore/SeedManagers.cs similarity index 100% rename from building-blocks/EFCore/SeedManagers.cs rename to src/BuildingBlocks/EFCore/SeedManagers.cs diff --git a/building-blocks/EventStoreDB/BackgroundWorkers/BackgroundWorker.cs b/src/BuildingBlocks/EventStoreDB/BackgroundWorkers/BackgroundWorker.cs similarity index 100% rename from building-blocks/EventStoreDB/BackgroundWorkers/BackgroundWorker.cs rename to src/BuildingBlocks/EventStoreDB/BackgroundWorkers/BackgroundWorker.cs diff --git a/building-blocks/EventStoreDB/Config.cs b/src/BuildingBlocks/EventStoreDB/Config.cs similarity index 100% rename from building-blocks/EventStoreDB/Config.cs rename to src/BuildingBlocks/EventStoreDB/Config.cs diff --git a/building-blocks/EventStoreDB/Events/AggregateEventSourcing.cs b/src/BuildingBlocks/EventStoreDB/Events/AggregateEventSourcing.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/AggregateEventSourcing.cs rename to src/BuildingBlocks/EventStoreDB/Events/AggregateEventSourcing.cs diff --git a/building-blocks/EventStoreDB/Events/AggregateStreamExtensions.cs b/src/BuildingBlocks/EventStoreDB/Events/AggregateStreamExtensions.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/AggregateStreamExtensions.cs rename to src/BuildingBlocks/EventStoreDB/Events/AggregateStreamExtensions.cs diff --git a/building-blocks/EventStoreDB/Events/EventTypeMapper.cs b/src/BuildingBlocks/EventStoreDB/Events/EventTypeMapper.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/EventTypeMapper.cs rename to src/BuildingBlocks/EventStoreDB/Events/EventTypeMapper.cs diff --git a/building-blocks/EventStoreDB/Events/IAggregateEventSourcing.cs b/src/BuildingBlocks/EventStoreDB/Events/IAggregateEventSourcing.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/IAggregateEventSourcing.cs rename to src/BuildingBlocks/EventStoreDB/Events/IAggregateEventSourcing.cs diff --git a/building-blocks/EventStoreDB/Events/IEventHandler.cs b/src/BuildingBlocks/EventStoreDB/Events/IEventHandler.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/IEventHandler.cs rename to src/BuildingBlocks/EventStoreDB/Events/IEventHandler.cs diff --git a/building-blocks/EventStoreDB/Events/IExternalEvent.cs b/src/BuildingBlocks/EventStoreDB/Events/IExternalEvent.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/IExternalEvent.cs rename to src/BuildingBlocks/EventStoreDB/Events/IExternalEvent.cs diff --git a/building-blocks/EventStoreDB/Events/IProjection.cs b/src/BuildingBlocks/EventStoreDB/Events/IProjection.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/IProjection.cs rename to src/BuildingBlocks/EventStoreDB/Events/IProjection.cs diff --git a/building-blocks/EventStoreDB/Events/StreamEvent.cs b/src/BuildingBlocks/EventStoreDB/Events/StreamEvent.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/StreamEvent.cs rename to src/BuildingBlocks/EventStoreDB/Events/StreamEvent.cs diff --git a/building-blocks/EventStoreDB/Events/StreamEventExtensions.cs b/src/BuildingBlocks/EventStoreDB/Events/StreamEventExtensions.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/StreamEventExtensions.cs rename to src/BuildingBlocks/EventStoreDB/Events/StreamEventExtensions.cs diff --git a/building-blocks/EventStoreDB/Events/StreamNameMapper.cs b/src/BuildingBlocks/EventStoreDB/Events/StreamNameMapper.cs similarity index 100% rename from building-blocks/EventStoreDB/Events/StreamNameMapper.cs rename to src/BuildingBlocks/EventStoreDB/Events/StreamNameMapper.cs diff --git a/building-blocks/EventStoreDB/Extensions.cs b/src/BuildingBlocks/EventStoreDB/Extensions.cs similarity index 100% rename from building-blocks/EventStoreDB/Extensions.cs rename to src/BuildingBlocks/EventStoreDB/Extensions.cs diff --git a/building-blocks/EventStoreDB/Projections/IProjectionProcessor.cs b/src/BuildingBlocks/EventStoreDB/Projections/IProjectionProcessor.cs similarity index 100% rename from building-blocks/EventStoreDB/Projections/IProjectionProcessor.cs rename to src/BuildingBlocks/EventStoreDB/Projections/IProjectionProcessor.cs diff --git a/building-blocks/EventStoreDB/Projections/IProjectionPublisher.cs b/src/BuildingBlocks/EventStoreDB/Projections/IProjectionPublisher.cs similarity index 100% rename from building-blocks/EventStoreDB/Projections/IProjectionPublisher.cs rename to src/BuildingBlocks/EventStoreDB/Projections/IProjectionPublisher.cs diff --git a/building-blocks/EventStoreDB/Projections/ProjectionPublisher.cs b/src/BuildingBlocks/EventStoreDB/Projections/ProjectionPublisher.cs similarity index 100% rename from building-blocks/EventStoreDB/Projections/ProjectionPublisher.cs rename to src/BuildingBlocks/EventStoreDB/Projections/ProjectionPublisher.cs diff --git a/building-blocks/EventStoreDB/Repository/EventStoreDBRepository.cs b/src/BuildingBlocks/EventStoreDB/Repository/EventStoreDBRepository.cs similarity index 100% rename from building-blocks/EventStoreDB/Repository/EventStoreDBRepository.cs rename to src/BuildingBlocks/EventStoreDB/Repository/EventStoreDBRepository.cs diff --git a/building-blocks/EventStoreDB/Repository/RepositoryExtensions.cs b/src/BuildingBlocks/EventStoreDB/Repository/RepositoryExtensions.cs similarity index 100% rename from building-blocks/EventStoreDB/Repository/RepositoryExtensions.cs rename to src/BuildingBlocks/EventStoreDB/Repository/RepositoryExtensions.cs diff --git a/building-blocks/EventStoreDB/Serialization/EventStoreDBSerializer.cs b/src/BuildingBlocks/EventStoreDB/Serialization/EventStoreDBSerializer.cs similarity index 100% rename from building-blocks/EventStoreDB/Serialization/EventStoreDBSerializer.cs rename to src/BuildingBlocks/EventStoreDB/Serialization/EventStoreDBSerializer.cs diff --git a/building-blocks/EventStoreDB/Serialization/JsonObjectContractProvider.cs b/src/BuildingBlocks/EventStoreDB/Serialization/JsonObjectContractProvider.cs similarity index 100% rename from building-blocks/EventStoreDB/Serialization/JsonObjectContractProvider.cs rename to src/BuildingBlocks/EventStoreDB/Serialization/JsonObjectContractProvider.cs diff --git a/building-blocks/EventStoreDB/Serialization/NonDefaultConstructorContractResolver.cs b/src/BuildingBlocks/EventStoreDB/Serialization/NonDefaultConstructorContractResolver.cs similarity index 100% rename from building-blocks/EventStoreDB/Serialization/NonDefaultConstructorContractResolver.cs rename to src/BuildingBlocks/EventStoreDB/Serialization/NonDefaultConstructorContractResolver.cs diff --git a/building-blocks/EventStoreDB/Serialization/SerializationExtensions.cs b/src/BuildingBlocks/EventStoreDB/Serialization/SerializationExtensions.cs similarity index 100% rename from building-blocks/EventStoreDB/Serialization/SerializationExtensions.cs rename to src/BuildingBlocks/EventStoreDB/Serialization/SerializationExtensions.cs diff --git a/building-blocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionCheckpointRepository.cs b/src/BuildingBlocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionCheckpointRepository.cs similarity index 100% rename from building-blocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionCheckpointRepository.cs rename to src/BuildingBlocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionCheckpointRepository.cs diff --git a/building-blocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionToAll.cs b/src/BuildingBlocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionToAll.cs similarity index 100% rename from building-blocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionToAll.cs rename to src/BuildingBlocks/EventStoreDB/Subscriptions/EventStoreDBSubscriptionToAll.cs diff --git a/building-blocks/EventStoreDB/Subscriptions/ISubscriptionCheckpointRepository.cs b/src/BuildingBlocks/EventStoreDB/Subscriptions/ISubscriptionCheckpointRepository.cs similarity index 100% rename from building-blocks/EventStoreDB/Subscriptions/ISubscriptionCheckpointRepository.cs rename to src/BuildingBlocks/EventStoreDB/Subscriptions/ISubscriptionCheckpointRepository.cs diff --git a/building-blocks/EventStoreDB/Subscriptions/InMemorySubscriptionCheckpointRepository.cs b/src/BuildingBlocks/EventStoreDB/Subscriptions/InMemorySubscriptionCheckpointRepository.cs similarity index 100% rename from building-blocks/EventStoreDB/Subscriptions/InMemorySubscriptionCheckpointRepository.cs rename to src/BuildingBlocks/EventStoreDB/Subscriptions/InMemorySubscriptionCheckpointRepository.cs diff --git a/building-blocks/Exception/AggregateNotFoundException.cs b/src/BuildingBlocks/Exception/AggregateNotFoundException.cs similarity index 100% rename from building-blocks/Exception/AggregateNotFoundException.cs rename to src/BuildingBlocks/Exception/AggregateNotFoundException.cs diff --git a/src/BuildingBlocks/Exception/AppException.cs b/src/BuildingBlocks/Exception/AppException.cs new file mode 100644 index 0000000..f567498 --- /dev/null +++ b/src/BuildingBlocks/Exception/AppException.cs @@ -0,0 +1,14 @@ +using System.Net; + +namespace BuildingBlocks.Exception; + +public class AppException : CustomException +{ + public AppException(string message, HttpStatusCode statusCode = HttpStatusCode.BadRequest, int? code = null) : base(message, statusCode, code: code) + { + } + + public AppException(string message, System.Exception innerException, HttpStatusCode statusCode = HttpStatusCode.BadRequest, int? code = null) : base(message, innerException, statusCode, code) + { + } +} diff --git a/src/BuildingBlocks/Exception/BadRequestException.cs b/src/BuildingBlocks/Exception/BadRequestException.cs new file mode 100644 index 0000000..6056488 --- /dev/null +++ b/src/BuildingBlocks/Exception/BadRequestException.cs @@ -0,0 +1,13 @@ +using System; +using System.Net; + +namespace BuildingBlocks.Exception +{ + public class BadRequestException : CustomException + { + public BadRequestException(string message, int? code = null) : base(message, HttpStatusCode.BadRequest, code: code) + { + + } + } +} diff --git a/src/BuildingBlocks/Exception/ConflictException.cs b/src/BuildingBlocks/Exception/ConflictException.cs new file mode 100644 index 0000000..4d45372 --- /dev/null +++ b/src/BuildingBlocks/Exception/ConflictException.cs @@ -0,0 +1,11 @@ +using System.Net; + +namespace BuildingBlocks.Exception +{ + public class ConflictException : CustomException + { + public ConflictException(string message, int? code = null) : base(message, HttpStatusCode.Conflict, code: code) + { + } + } +} diff --git a/src/BuildingBlocks/Exception/CustomException.cs b/src/BuildingBlocks/Exception/CustomException.cs new file mode 100644 index 0000000..586dcd8 --- /dev/null +++ b/src/BuildingBlocks/Exception/CustomException.cs @@ -0,0 +1,37 @@ +using System.Net; + +namespace BuildingBlocks.Exception; + +public class CustomException : System.Exception +{ + public CustomException( + string message, + HttpStatusCode statusCode = HttpStatusCode.InternalServerError, + int? code = null) : base(message) + { + StatusCode = statusCode; + Code = code; + } + + public CustomException( + string message, + System.Exception innerException, + HttpStatusCode statusCode = HttpStatusCode.InternalServerError, + int? code = null) : base(message, innerException) + { + StatusCode = statusCode; + Code = code; + } + + public CustomException( + HttpStatusCode statusCode = HttpStatusCode.InternalServerError, + int? code = null) : base() + { + StatusCode = statusCode; + Code = code; + } + + public HttpStatusCode StatusCode { get; } + + public int? Code { get; } +} diff --git a/src/BuildingBlocks/Exception/DomainException.cs b/src/BuildingBlocks/Exception/DomainException.cs new file mode 100644 index 0000000..b8f661f --- /dev/null +++ b/src/BuildingBlocks/Exception/DomainException.cs @@ -0,0 +1,16 @@ +using System.Net; +using BuildingBlocks.Exception; + +namespace SmartCharging.Infrastructure.Exceptions +{ + public class DomainException : CustomException + { + public DomainException(string message, HttpStatusCode statusCode = HttpStatusCode.BadRequest) : base(message, statusCode) + { + } + + public DomainException(string message, Exception innerException, HttpStatusCode statusCode = HttpStatusCode.BadRequest, int? code = null) : base(message, innerException, statusCode, code) + { + } + } +} diff --git a/building-blocks/Exception/GrpcExceptionInterceptor.cs b/src/BuildingBlocks/Exception/GrpcExceptionInterceptor.cs similarity index 100% rename from building-blocks/Exception/GrpcExceptionInterceptor.cs rename to src/BuildingBlocks/Exception/GrpcExceptionInterceptor.cs diff --git a/src/BuildingBlocks/Exception/InternalServerException.cs b/src/BuildingBlocks/Exception/InternalServerException.cs new file mode 100644 index 0000000..e276cc2 --- /dev/null +++ b/src/BuildingBlocks/Exception/InternalServerException.cs @@ -0,0 +1,17 @@ +using System.Globalization; +using System.Net; + +namespace BuildingBlocks.Exception +{ + public class InternalServerException : CustomException + { + public InternalServerException() : base() { } + + public InternalServerException(string message, int? code) : base(message, code: code) { } + + public InternalServerException(string message, int? code = null, params object[] args) + : base(message: String.Format(CultureInfo.CurrentCulture, message, args, HttpStatusCode.InternalServerError, code)) + { + } + } +} diff --git a/src/BuildingBlocks/Exception/NotFoundException.cs b/src/BuildingBlocks/Exception/NotFoundException.cs new file mode 100644 index 0000000..4367ca0 --- /dev/null +++ b/src/BuildingBlocks/Exception/NotFoundException.cs @@ -0,0 +1,11 @@ +using System.Net; + +namespace BuildingBlocks.Exception +{ + public class NotFoundException : CustomException + { + public NotFoundException(string message, int? code = null) : base(message, HttpStatusCode.NotFound, code: code) + { + } + } +} diff --git a/building-blocks/Exception/ProblemDetailsWithCode.cs b/src/BuildingBlocks/Exception/ProblemDetailsWithCode.cs similarity index 100% rename from building-blocks/Exception/ProblemDetailsWithCode.cs rename to src/BuildingBlocks/Exception/ProblemDetailsWithCode.cs diff --git a/src/BuildingBlocks/Exception/ValidationException.cs b/src/BuildingBlocks/Exception/ValidationException.cs new file mode 100644 index 0000000..f3c812b --- /dev/null +++ b/src/BuildingBlocks/Exception/ValidationException.cs @@ -0,0 +1,11 @@ +using System.Net; + +namespace BuildingBlocks.Exception +{ + public class ValidationException : CustomException + { + public ValidationException(string message, int? code = null) : base(message, HttpStatusCode.BadRequest, code: code) + { + } + } +} diff --git a/building-blocks/HealthCheck/Extensions.cs b/src/BuildingBlocks/HealthCheck/Extensions.cs similarity index 100% rename from building-blocks/HealthCheck/Extensions.cs rename to src/BuildingBlocks/HealthCheck/Extensions.cs diff --git a/building-blocks/HealthCheck/HealthOptions.cs b/src/BuildingBlocks/HealthCheck/HealthOptions.cs similarity index 100% rename from building-blocks/HealthCheck/HealthOptions.cs rename to src/BuildingBlocks/HealthCheck/HealthOptions.cs diff --git a/building-blocks/Jwt/AuthHeaderHandler.cs b/src/BuildingBlocks/Jwt/AuthHeaderHandler.cs similarity index 100% rename from building-blocks/Jwt/AuthHeaderHandler.cs rename to src/BuildingBlocks/Jwt/AuthHeaderHandler.cs diff --git a/building-blocks/Jwt/JwtExtensions.cs b/src/BuildingBlocks/Jwt/JwtExtensions.cs similarity index 100% rename from building-blocks/Jwt/JwtExtensions.cs rename to src/BuildingBlocks/Jwt/JwtExtensions.cs diff --git a/building-blocks/Logging/Extensions.cs b/src/BuildingBlocks/Logging/Extensions.cs similarity index 100% rename from building-blocks/Logging/Extensions.cs rename to src/BuildingBlocks/Logging/Extensions.cs diff --git a/building-blocks/Logging/FileOptions.cs b/src/BuildingBlocks/Logging/FileOptions.cs similarity index 100% rename from building-blocks/Logging/FileOptions.cs rename to src/BuildingBlocks/Logging/FileOptions.cs diff --git a/building-blocks/Logging/LogEnrichHelper.cs b/src/BuildingBlocks/Logging/LogEnrichHelper.cs similarity index 100% rename from building-blocks/Logging/LogEnrichHelper.cs rename to src/BuildingBlocks/Logging/LogEnrichHelper.cs diff --git a/building-blocks/Logging/LogOptions.cs b/src/BuildingBlocks/Logging/LogOptions.cs similarity index 100% rename from building-blocks/Logging/LogOptions.cs rename to src/BuildingBlocks/Logging/LogOptions.cs diff --git a/building-blocks/Logging/LoggingBehavior.cs b/src/BuildingBlocks/Logging/LoggingBehavior.cs similarity index 100% rename from building-blocks/Logging/LoggingBehavior.cs rename to src/BuildingBlocks/Logging/LoggingBehavior.cs diff --git a/building-blocks/Mapster/Extensions.cs b/src/BuildingBlocks/Mapster/Extensions.cs similarity index 100% rename from building-blocks/Mapster/Extensions.cs rename to src/BuildingBlocks/Mapster/Extensions.cs diff --git a/building-blocks/MassTransit/ConsumeFilter.cs b/src/BuildingBlocks/MassTransit/ConsumeFilter.cs similarity index 100% rename from building-blocks/MassTransit/ConsumeFilter.cs rename to src/BuildingBlocks/MassTransit/ConsumeFilter.cs diff --git a/building-blocks/MassTransit/Extensions.cs b/src/BuildingBlocks/MassTransit/Extensions.cs similarity index 100% rename from building-blocks/MassTransit/Extensions.cs rename to src/BuildingBlocks/MassTransit/Extensions.cs diff --git a/building-blocks/MassTransit/RabbitMqOptions.cs b/src/BuildingBlocks/MassTransit/RabbitMqOptions.cs similarity index 100% rename from building-blocks/MassTransit/RabbitMqOptions.cs rename to src/BuildingBlocks/MassTransit/RabbitMqOptions.cs diff --git a/building-blocks/MassTransit/TransportType.cs b/src/BuildingBlocks/MassTransit/TransportType.cs similarity index 100% rename from building-blocks/MassTransit/TransportType.cs rename to src/BuildingBlocks/MassTransit/TransportType.cs diff --git a/building-blocks/Mongo/Extensions.cs b/src/BuildingBlocks/Mongo/Extensions.cs similarity index 100% rename from building-blocks/Mongo/Extensions.cs rename to src/BuildingBlocks/Mongo/Extensions.cs diff --git a/building-blocks/Mongo/IMongoDbContext.cs b/src/BuildingBlocks/Mongo/IMongoDbContext.cs similarity index 100% rename from building-blocks/Mongo/IMongoDbContext.cs rename to src/BuildingBlocks/Mongo/IMongoDbContext.cs diff --git a/building-blocks/Mongo/IMongoRepository.cs b/src/BuildingBlocks/Mongo/IMongoRepository.cs similarity index 100% rename from building-blocks/Mongo/IMongoRepository.cs rename to src/BuildingBlocks/Mongo/IMongoRepository.cs diff --git a/building-blocks/Mongo/IMongoUnitOfWork.cs b/src/BuildingBlocks/Mongo/IMongoUnitOfWork.cs similarity index 100% rename from building-blocks/Mongo/IMongoUnitOfWork.cs rename to src/BuildingBlocks/Mongo/IMongoUnitOfWork.cs diff --git a/building-blocks/Mongo/IRepository.cs b/src/BuildingBlocks/Mongo/IRepository.cs similarity index 100% rename from building-blocks/Mongo/IRepository.cs rename to src/BuildingBlocks/Mongo/IRepository.cs diff --git a/building-blocks/Mongo/ITransactionAble.cs b/src/BuildingBlocks/Mongo/ITransactionAble.cs similarity index 100% rename from building-blocks/Mongo/ITransactionAble.cs rename to src/BuildingBlocks/Mongo/ITransactionAble.cs diff --git a/building-blocks/Mongo/IUnitOfWork.cs b/src/BuildingBlocks/Mongo/IUnitOfWork.cs similarity index 100% rename from building-blocks/Mongo/IUnitOfWork.cs rename to src/BuildingBlocks/Mongo/IUnitOfWork.cs diff --git a/building-blocks/Mongo/ImmutablePocoConvention.cs b/src/BuildingBlocks/Mongo/ImmutablePocoConvention.cs similarity index 100% rename from building-blocks/Mongo/ImmutablePocoConvention.cs rename to src/BuildingBlocks/Mongo/ImmutablePocoConvention.cs diff --git a/building-blocks/Mongo/MicroBootstrap.Persistence.Mongo.csproj b/src/BuildingBlocks/Mongo/MicroBootstrap.Persistence.Mongo.csproj similarity index 100% rename from building-blocks/Mongo/MicroBootstrap.Persistence.Mongo.csproj rename to src/BuildingBlocks/Mongo/MicroBootstrap.Persistence.Mongo.csproj diff --git a/building-blocks/Mongo/MongoDbContext.cs b/src/BuildingBlocks/Mongo/MongoDbContext.cs similarity index 100% rename from building-blocks/Mongo/MongoDbContext.cs rename to src/BuildingBlocks/Mongo/MongoDbContext.cs diff --git a/building-blocks/Mongo/MongoOptions.cs b/src/BuildingBlocks/Mongo/MongoOptions.cs similarity index 100% rename from building-blocks/Mongo/MongoOptions.cs rename to src/BuildingBlocks/Mongo/MongoOptions.cs diff --git a/building-blocks/Mongo/MongoRepository.cs b/src/BuildingBlocks/Mongo/MongoRepository.cs similarity index 100% rename from building-blocks/Mongo/MongoRepository.cs rename to src/BuildingBlocks/Mongo/MongoRepository.cs diff --git a/building-blocks/Mongo/MongoUnitOfWork.cs b/src/BuildingBlocks/Mongo/MongoUnitOfWork.cs similarity index 100% rename from building-blocks/Mongo/MongoUnitOfWork.cs rename to src/BuildingBlocks/Mongo/MongoUnitOfWork.cs diff --git a/building-blocks/OpenApi/Extensions.cs b/src/BuildingBlocks/OpenApi/Extensions.cs similarity index 100% rename from building-blocks/OpenApi/Extensions.cs rename to src/BuildingBlocks/OpenApi/Extensions.cs diff --git a/building-blocks/OpenApi/SecuritySchemeDocumentTransformer.cs b/src/BuildingBlocks/OpenApi/SecuritySchemeDocumentTransformer.cs similarity index 100% rename from building-blocks/OpenApi/SecuritySchemeDocumentTransformer.cs rename to src/BuildingBlocks/OpenApi/SecuritySchemeDocumentTransformer.cs diff --git a/building-blocks/OpenTelemetryCollector/ActivityExtensions.cs b/src/BuildingBlocks/OpenTelemetryCollector/ActivityExtensions.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/ActivityExtensions.cs rename to src/BuildingBlocks/OpenTelemetryCollector/ActivityExtensions.cs diff --git a/building-blocks/OpenTelemetryCollector/ActivityInfo.cs b/src/BuildingBlocks/OpenTelemetryCollector/ActivityInfo.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/ActivityInfo.cs rename to src/BuildingBlocks/OpenTelemetryCollector/ActivityInfo.cs diff --git a/building-blocks/OpenTelemetryCollector/Behaviors/ObservabilityPipelineBehavior.cs b/src/BuildingBlocks/OpenTelemetryCollector/Behaviors/ObservabilityPipelineBehavior.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/Behaviors/ObservabilityPipelineBehavior.cs rename to src/BuildingBlocks/OpenTelemetryCollector/Behaviors/ObservabilityPipelineBehavior.cs diff --git a/building-blocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerActivity.cs b/src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerActivity.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerActivity.cs rename to src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerActivity.cs diff --git a/building-blocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerMetrics.cs b/src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerMetrics.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerMetrics.cs rename to src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Commands/CommandHandlerMetrics.cs diff --git a/building-blocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerActivity.cs b/src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerActivity.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerActivity.cs rename to src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerActivity.cs diff --git a/building-blocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerMetrics.cs b/src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerMetrics.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerMetrics.cs rename to src/BuildingBlocks/OpenTelemetryCollector/CoreDiagnostics/Query/QueryHandlerMetrics.cs diff --git a/building-blocks/OpenTelemetryCollector/CreateActivityInfo.cs b/src/BuildingBlocks/OpenTelemetryCollector/CreateActivityInfo.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/CreateActivityInfo.cs rename to src/BuildingBlocks/OpenTelemetryCollector/CreateActivityInfo.cs diff --git a/building-blocks/OpenTelemetryCollector/DiagnosticsProvider/CustomeDiagnosticsProvider.cs b/src/BuildingBlocks/OpenTelemetryCollector/DiagnosticsProvider/CustomeDiagnosticsProvider.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/DiagnosticsProvider/CustomeDiagnosticsProvider.cs rename to src/BuildingBlocks/OpenTelemetryCollector/DiagnosticsProvider/CustomeDiagnosticsProvider.cs diff --git a/building-blocks/OpenTelemetryCollector/DiagnosticsProvider/IDiagnosticsProvider.cs b/src/BuildingBlocks/OpenTelemetryCollector/DiagnosticsProvider/IDiagnosticsProvider.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/DiagnosticsProvider/IDiagnosticsProvider.cs rename to src/BuildingBlocks/OpenTelemetryCollector/DiagnosticsProvider/IDiagnosticsProvider.cs diff --git a/building-blocks/OpenTelemetryCollector/Extensions.cs b/src/BuildingBlocks/OpenTelemetryCollector/Extensions.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/Extensions.cs rename to src/BuildingBlocks/OpenTelemetryCollector/Extensions.cs diff --git a/building-blocks/OpenTelemetryCollector/ObservabilityConstant.cs b/src/BuildingBlocks/OpenTelemetryCollector/ObservabilityConstant.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/ObservabilityConstant.cs rename to src/BuildingBlocks/OpenTelemetryCollector/ObservabilityConstant.cs diff --git a/building-blocks/OpenTelemetryCollector/ObservabilityOptions.cs b/src/BuildingBlocks/OpenTelemetryCollector/ObservabilityOptions.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/ObservabilityOptions.cs rename to src/BuildingBlocks/OpenTelemetryCollector/ObservabilityOptions.cs diff --git a/building-blocks/OpenTelemetryCollector/TelemetryTags.cs b/src/BuildingBlocks/OpenTelemetryCollector/TelemetryTags.cs similarity index 100% rename from building-blocks/OpenTelemetryCollector/TelemetryTags.cs rename to src/BuildingBlocks/OpenTelemetryCollector/TelemetryTags.cs diff --git a/building-blocks/PersistMessageProcessor/Extensions.cs b/src/BuildingBlocks/PersistMessageProcessor/Extensions.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/Extensions.cs rename to src/BuildingBlocks/PersistMessageProcessor/Extensions.cs diff --git a/building-blocks/PersistMessageProcessor/IPersistMessageDbContext.cs b/src/BuildingBlocks/PersistMessageProcessor/IPersistMessageDbContext.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/IPersistMessageDbContext.cs rename to src/BuildingBlocks/PersistMessageProcessor/IPersistMessageDbContext.cs diff --git a/building-blocks/PersistMessageProcessor/IPersistMessageProcessor.cs b/src/BuildingBlocks/PersistMessageProcessor/IPersistMessageProcessor.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/IPersistMessageProcessor.cs rename to src/BuildingBlocks/PersistMessageProcessor/IPersistMessageProcessor.cs diff --git a/building-blocks/PersistMessageProcessor/MessageDeliveryType.cs b/src/BuildingBlocks/PersistMessageProcessor/MessageDeliveryType.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/MessageDeliveryType.cs rename to src/BuildingBlocks/PersistMessageProcessor/MessageDeliveryType.cs diff --git a/building-blocks/PersistMessageProcessor/MessageStatus.cs b/src/BuildingBlocks/PersistMessageProcessor/MessageStatus.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/MessageStatus.cs rename to src/BuildingBlocks/PersistMessageProcessor/MessageStatus.cs diff --git a/building-blocks/PersistMessageProcessor/PersistMessage.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessage.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/PersistMessage.cs rename to src/BuildingBlocks/PersistMessageProcessor/PersistMessage.cs diff --git a/building-blocks/PersistMessageProcessor/PersistMessageBackgroundService.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessageBackgroundService.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/PersistMessageBackgroundService.cs rename to src/BuildingBlocks/PersistMessageProcessor/PersistMessageBackgroundService.cs diff --git a/building-blocks/PersistMessageProcessor/PersistMessageDbContext.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessageDbContext.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/PersistMessageDbContext.cs rename to src/BuildingBlocks/PersistMessageProcessor/PersistMessageDbContext.cs diff --git a/building-blocks/PersistMessageProcessor/PersistMessageOptions.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessageOptions.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/PersistMessageOptions.cs rename to src/BuildingBlocks/PersistMessageProcessor/PersistMessageOptions.cs diff --git a/building-blocks/PersistMessageProcessor/PersistMessageProcessor.cs b/src/BuildingBlocks/PersistMessageProcessor/PersistMessageProcessor.cs similarity index 100% rename from building-blocks/PersistMessageProcessor/PersistMessageProcessor.cs rename to src/BuildingBlocks/PersistMessageProcessor/PersistMessageProcessor.cs diff --git a/building-blocks/Polly/CircuitBreakerOptions.cs b/src/BuildingBlocks/Polly/CircuitBreakerOptions.cs similarity index 100% rename from building-blocks/Polly/CircuitBreakerOptions.cs rename to src/BuildingBlocks/Polly/CircuitBreakerOptions.cs diff --git a/building-blocks/Polly/Extensions.cs b/src/BuildingBlocks/Polly/Extensions.cs similarity index 100% rename from building-blocks/Polly/Extensions.cs rename to src/BuildingBlocks/Polly/Extensions.cs diff --git a/building-blocks/Polly/GrpcCircuitBreaker.cs b/src/BuildingBlocks/Polly/GrpcCircuitBreaker.cs similarity index 100% rename from building-blocks/Polly/GrpcCircuitBreaker.cs rename to src/BuildingBlocks/Polly/GrpcCircuitBreaker.cs diff --git a/building-blocks/Polly/GrpcRetry.cs b/src/BuildingBlocks/Polly/GrpcRetry.cs similarity index 100% rename from building-blocks/Polly/GrpcRetry.cs rename to src/BuildingBlocks/Polly/GrpcRetry.cs diff --git a/building-blocks/Polly/HttpClientCircuitBreaker.cs b/src/BuildingBlocks/Polly/HttpClientCircuitBreaker.cs similarity index 100% rename from building-blocks/Polly/HttpClientCircuitBreaker.cs rename to src/BuildingBlocks/Polly/HttpClientCircuitBreaker.cs diff --git a/building-blocks/Polly/HttpClientRetry.cs b/src/BuildingBlocks/Polly/HttpClientRetry.cs similarity index 100% rename from building-blocks/Polly/HttpClientRetry.cs rename to src/BuildingBlocks/Polly/HttpClientRetry.cs diff --git a/building-blocks/Polly/PolicyOptions.cs b/src/BuildingBlocks/Polly/PolicyOptions.cs similarity index 100% rename from building-blocks/Polly/PolicyOptions.cs rename to src/BuildingBlocks/Polly/PolicyOptions.cs diff --git a/building-blocks/Polly/RetryOptions.cs b/src/BuildingBlocks/Polly/RetryOptions.cs similarity index 100% rename from building-blocks/Polly/RetryOptions.cs rename to src/BuildingBlocks/Polly/RetryOptions.cs diff --git a/building-blocks/ProblemDetails/Extensions.cs b/src/BuildingBlocks/ProblemDetails/Extensions.cs similarity index 100% rename from building-blocks/ProblemDetails/Extensions.cs rename to src/BuildingBlocks/ProblemDetails/Extensions.cs diff --git a/building-blocks/TestBase/TestBase.cs b/src/BuildingBlocks/TestBase/TestBase.cs similarity index 100% rename from building-blocks/TestBase/TestBase.cs rename to src/BuildingBlocks/TestBase/TestBase.cs diff --git a/building-blocks/TestBase/TestContainers.cs b/src/BuildingBlocks/TestBase/TestContainers.cs similarity index 100% rename from building-blocks/TestBase/TestContainers.cs rename to src/BuildingBlocks/TestBase/TestContainers.cs diff --git a/building-blocks/Utils/NoSynchronizationContextScope.cs b/src/BuildingBlocks/Utils/NoSynchronizationContextScope.cs similarity index 100% rename from building-blocks/Utils/NoSynchronizationContextScope.cs rename to src/BuildingBlocks/Utils/NoSynchronizationContextScope.cs diff --git a/building-blocks/Utils/ServiceLocator.cs b/src/BuildingBlocks/Utils/ServiceLocator.cs similarity index 100% rename from building-blocks/Utils/ServiceLocator.cs rename to src/BuildingBlocks/Utils/ServiceLocator.cs diff --git a/building-blocks/Utils/TypeProvider.cs b/src/BuildingBlocks/Utils/TypeProvider.cs similarity index 100% rename from building-blocks/Utils/TypeProvider.cs rename to src/BuildingBlocks/Utils/TypeProvider.cs diff --git a/building-blocks/Validation/Extensions.cs b/src/BuildingBlocks/Validation/Extensions.cs similarity index 100% rename from building-blocks/Validation/Extensions.cs rename to src/BuildingBlocks/Validation/Extensions.cs diff --git a/building-blocks/Validation/ValidationBehavior.cs b/src/BuildingBlocks/Validation/ValidationBehavior.cs similarity index 100% rename from building-blocks/Validation/ValidationBehavior.cs rename to src/BuildingBlocks/Validation/ValidationBehavior.cs diff --git a/building-blocks/Validation/ValidationError.cs b/src/BuildingBlocks/Validation/ValidationError.cs similarity index 100% rename from building-blocks/Validation/ValidationError.cs rename to src/BuildingBlocks/Validation/ValidationError.cs diff --git a/building-blocks/Validation/ValidationResultModel.cs b/src/BuildingBlocks/Validation/ValidationResultModel.cs similarity index 100% rename from building-blocks/Validation/ValidationResultModel.cs rename to src/BuildingBlocks/Validation/ValidationResultModel.cs diff --git a/building-blocks/Web/ApiVersioningExtensions.cs b/src/BuildingBlocks/Web/ApiVersioningExtensions.cs similarity index 100% rename from building-blocks/Web/ApiVersioningExtensions.cs rename to src/BuildingBlocks/Web/ApiVersioningExtensions.cs diff --git a/building-blocks/Web/AppOptions.cs b/src/BuildingBlocks/Web/AppOptions.cs similarity index 100% rename from building-blocks/Web/AppOptions.cs rename to src/BuildingBlocks/Web/AppOptions.cs diff --git a/building-blocks/Web/BaseController.cs b/src/BuildingBlocks/Web/BaseController.cs similarity index 100% rename from building-blocks/Web/BaseController.cs rename to src/BuildingBlocks/Web/BaseController.cs diff --git a/building-blocks/Web/ConfigurationExtensions.cs b/src/BuildingBlocks/Web/ConfigurationExtensions.cs similarity index 100% rename from building-blocks/Web/ConfigurationExtensions.cs rename to src/BuildingBlocks/Web/ConfigurationExtensions.cs diff --git a/building-blocks/Web/ConfigurationHelper.cs b/src/BuildingBlocks/Web/ConfigurationHelper.cs similarity index 100% rename from building-blocks/Web/ConfigurationHelper.cs rename to src/BuildingBlocks/Web/ConfigurationHelper.cs diff --git a/building-blocks/Web/CorrelationExtensions.cs b/src/BuildingBlocks/Web/CorrelationExtensions.cs similarity index 100% rename from building-blocks/Web/CorrelationExtensions.cs rename to src/BuildingBlocks/Web/CorrelationExtensions.cs diff --git a/building-blocks/Web/CurrentUserProvider.cs b/src/BuildingBlocks/Web/CurrentUserProvider.cs similarity index 100% rename from building-blocks/Web/CurrentUserProvider.cs rename to src/BuildingBlocks/Web/CurrentUserProvider.cs diff --git a/building-blocks/Web/EndpointConfig.cs b/src/BuildingBlocks/Web/EndpointConfig.cs similarity index 100% rename from building-blocks/Web/EndpointConfig.cs rename to src/BuildingBlocks/Web/EndpointConfig.cs diff --git a/building-blocks/Web/IMinimalEndpoint.cs b/src/BuildingBlocks/Web/IMinimalEndpoint.cs similarity index 100% rename from building-blocks/Web/IMinimalEndpoint.cs rename to src/BuildingBlocks/Web/IMinimalEndpoint.cs diff --git a/building-blocks/Web/MinimalApiExtensions.cs b/src/BuildingBlocks/Web/MinimalApiExtensions.cs similarity index 100% rename from building-blocks/Web/MinimalApiExtensions.cs rename to src/BuildingBlocks/Web/MinimalApiExtensions.cs diff --git a/building-blocks/Web/ServiceCollectionExtensions.cs b/src/BuildingBlocks/Web/ServiceCollectionExtensions.cs similarity index 100% rename from building-blocks/Web/ServiceCollectionExtensions.cs rename to src/BuildingBlocks/Web/ServiceCollectionExtensions.cs diff --git a/building-blocks/Web/ServiceProviderExtensions.cs b/src/BuildingBlocks/Web/ServiceProviderExtensions.cs similarity index 100% rename from building-blocks/Web/ServiceProviderExtensions.cs rename to src/BuildingBlocks/Web/ServiceProviderExtensions.cs diff --git a/building-blocks/Web/SlugifyParameterTransformer.cs b/src/BuildingBlocks/Web/SlugifyParameterTransformer.cs similarity index 100% rename from building-blocks/Web/SlugifyParameterTransformer.cs rename to src/BuildingBlocks/Web/SlugifyParameterTransformer.cs diff --git a/src/Services/Booking/Dockerfile b/src/Services/Booking/Dockerfile new file mode 100644 index 0000000..4bafe29 --- /dev/null +++ b/src/Services/Booking/Dockerfile @@ -0,0 +1,47 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +# Setup working directory for the project +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Booking/src/Booking/Booking.csproj ./src/Services/Booking/src/Booking/ +COPY ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./src/Services/Booking/src/Booking.Api/ + + +# Restore nuget packages +RUN dotnet restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Booking/src/Booking/ ./src/Services/Booking/src/Booking/ +COPY ./src/Services/Booking/src/Booking.Api/ ./src/Services/Booking/src/Booking.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN dotnet build -c Release --no-restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj + +WORKDIR /src/Services/Booking/src/Booking.Api + +# Publish project to output folder +# and no build, as we did it already +RUN dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Booking/src/Booking.Api/out . + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Booking.Api.dll"] + diff --git a/1-monolith-architecture-style/src/BookingMonolith/dev.Dockerfile b/src/Services/Booking/dev.Dockerfile similarity index 50% rename from 1-monolith-architecture-style/src/BookingMonolith/dev.Dockerfile rename to src/Services/Booking/dev.Dockerfile index a60ba82..6165b7d 100644 --- a/1-monolith-architecture-style/src/BookingMonolith/dev.Dockerfile +++ b/src/Services/Booking/dev.Dockerfile @@ -7,25 +7,27 @@ COPY ./Directory.Build.props ./ # Setup working directory for the project COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ -COPY ./1-monolith-architecture-style/src/BookingMonolith/src/BookingMonolith.csproj ./1-monolith-architecture-style/src/BookingMonolith/src/ -COPY ./1-monolith-architecture-style/src/Api/src/Api.csproj ./1-monolith-architecture-style/src/Api/src/ +COPY ./src/Services/Booking/src/Booking/Booking.csproj ./src/Services/Booking/src/Booking/ +COPY ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj ./src/Services/Booking/src/Booking.Api/ + # Restore nuget packages RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages \ - dotnet restore ./1-monolith-architecture-style/src/Api/src/Api.csproj + dotnet restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj # Copy project files COPY ./building-blocks ./building-blocks/ -COPY ./1-monolith-architecture-style/src/BookingMonolith/src/ ./1-monolith-architecture-style/src/BookingMonolith/src/ -COPY ./1-monolith-architecture-style/src/Api/src/ ./1-monolith-architecture-style/src/Api/src/ +COPY ./src/Services/Booking/src/Booking/ ./src/Services/Booking/src/Booking/ +COPY ./src/Services/Booking/src/Booking.Api/ ./src/Services/Booking/src/Booking.Api/ # Build project with Release configuration # and no restore, as we did it already + RUN ls RUN --mount=type=cache,id=booking_nuget,target=/root/.nuget/packages\ - dotnet build -c Release --no-restore ./1-monolith-architecture-style/src/Api/src/Api.csproj + dotnet build -c Release --no-restore ./src/Services/Booking/src/Booking.Api/Booking.Api.csproj -WORKDIR /1-monolith-architecture-style/src/Api/src +WORKDIR /src/Services/Booking/src/Booking.Api # Publish project to output folder # and no build, as we did it already @@ -36,13 +38,13 @@ FROM mcr.microsoft.com/dotnet/aspnet:9.0 # Setup working directory for the project WORKDIR / -COPY --from=builder /1-monolith-architecture-style/src/Api/src/out . +COPY --from=builder /src/Services/Booking/src/Booking.Api/out . -ENV ASPNETCORE_URLS="https://*:443, http://*:80" -ENV ASPNETCORE_ENVIRONMENT=docker +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker EXPOSE 80 EXPOSE 443 -ENTRYPOINT ["dotnet", "Api.dll"] +ENTRYPOINT ["dotnet", "Booking.Api.dll"] diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj b/src/Services/Booking/src/Booking.Api/Booking.Api.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Booking.Api.csproj rename to src/Services/Booking/src/Booking.Api/Booking.Api.csproj diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Program.cs b/src/Services/Booking/src/Booking.Api/Program.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Program.cs rename to src/Services/Booking/src/Booking.Api/Program.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json b/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json similarity index 98% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json rename to src/Services/Booking/src/Booking.Api/Properties/launchSettings.json index 78f3fac..0fb0fa2 100644 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json +++ b/src/Services/Booking/src/Booking.Api/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "Booking.Api": { diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.Development.json b/src/Services/Booking/src/Booking.Api/appsettings.Development.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.Development.json rename to src/Services/Booking/src/Booking.Api/appsettings.Development.json diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.docker.json b/src/Services/Booking/src/Booking.Api/appsettings.docker.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.docker.json rename to src/Services/Booking/src/Booking.Api/appsettings.docker.json diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.json b/src/Services/Booking/src/Booking.Api/appsettings.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.json rename to src/Services/Booking/src/Booking.Api/appsettings.json diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.test.json b/src/Services/Booking/src/Booking.Api/appsettings.test.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking.Api/appsettings.test.json rename to src/Services/Booking/src/Booking.Api/appsettings.test.json diff --git a/1-monolith-architecture-style/src/BookingMonolith/src/AssemblyInfo.cs b/src/Services/Booking/src/Booking/AssemblyInfo.cs similarity index 100% rename from 1-monolith-architecture-style/src/BookingMonolith/src/AssemblyInfo.cs rename to src/Services/Booking/src/Booking/AssemblyInfo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking.csproj b/src/Services/Booking/src/Booking/Booking.csproj similarity index 86% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking.csproj rename to src/Services/Booking/src/Booking/Booking.csproj index f9c7082..e4418df 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking.csproj +++ b/src/Services/Booking/src/Booking/Booking.csproj @@ -14,7 +14,7 @@ - + diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Dtos/CreateReservation.cs b/src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Dtos/CreateReservation.cs rename to src/Services/Booking/src/Booking/Booking/Dtos/CreateReservation.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/BookingAlreadyExistException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/BookingAlreadyExistException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/BookingAlreadyExistException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/BookingAlreadyExistException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/FlightNotFoundException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/FlightNotFoundException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/FlightNotFoundException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/FlightNotFoundException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidAircraftIdException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidAircraftIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidAircraftIdException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidAircraftIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidArriveAirportIdException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidArriveAirportIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidArriveAirportIdException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidArriveAirportIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidDepartureAirportIdException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidDepartureAirportIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidDepartureAirportIdException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidDepartureAirportIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidFlightDateException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightDateException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidFlightDateException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightDateException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidFlightNumberException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightNumberException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidFlightNumberException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidFlightNumberException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidPassengerNameException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPassengerNameException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidPassengerNameException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPassengerNameException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidPriceException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPriceException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/InvalidPriceException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/InvalidPriceException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/SeatNumberException.cs b/src/Services/Booking/src/Booking/Booking/Exceptions/SeatNumberException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Exceptions/SeatNumberException.cs rename to src/Services/Booking/src/Booking/Booking/Exceptions/SeatNumberException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Features/BookingMappings.cs b/src/Services/Booking/src/Booking/Booking/Features/BookingMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Features/BookingMappings.cs rename to src/Services/Booking/src/Booking/Booking/Features/BookingMappings.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/V1/CreateBooking.cs b/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/V1/CreateBooking.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking/Booking/Features/CreatingBook/V1/CreateBooking.cs rename to src/Services/Booking/src/Booking/Booking/Features/CreatingBook/V1/CreateBooking.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Models/Booking.cs b/src/Services/Booking/src/Booking/Booking/Models/Booking.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Models/Booking.cs rename to src/Services/Booking/src/Booking/Booking/Models/Booking.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Models/BookingReadModel.cs b/src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/Models/BookingReadModel.cs rename to src/Services/Booking/src/Booking/Booking/Models/BookingReadModel.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/ValueObjects/PassengerInfo.cs b/src/Services/Booking/src/Booking/Booking/ValueObjects/PassengerInfo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/ValueObjects/PassengerInfo.cs rename to src/Services/Booking/src/Booking/Booking/ValueObjects/PassengerInfo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/ValueObjects/Trip.cs b/src/Services/Booking/src/Booking/Booking/ValueObjects/Trip.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Booking/ValueObjects/Trip.cs rename to src/Services/Booking/src/Booking/Booking/ValueObjects/Trip.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/BookingEventMapper.cs b/src/Services/Booking/src/Booking/BookingEventMapper.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/BookingEventMapper.cs rename to src/Services/Booking/src/Booking/BookingEventMapper.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/BookingProjection.cs b/src/Services/Booking/src/Booking/BookingProjection.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/BookingProjection.cs rename to src/Services/Booking/src/Booking/BookingProjection.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/BookingRoot.cs b/src/Services/Booking/src/Booking/BookingRoot.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/BookingRoot.cs rename to src/Services/Booking/src/Booking/BookingRoot.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Configuration/GrpcOptions.cs b/src/Services/Booking/src/Booking/Configuration/GrpcOptions.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Configuration/GrpcOptions.cs rename to src/Services/Booking/src/Booking/Configuration/GrpcOptions.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/Data/BookingReadDbContext.cs b/src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/Data/BookingReadDbContext.cs rename to src/Services/Booking/src/Booking/Data/BookingReadDbContext.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Extensions/Infrastructure/GrpcClientExtensions.cs b/src/Services/Booking/src/Booking/Extensions/Infrastructure/GrpcClientExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking/Extensions/Infrastructure/GrpcClientExtensions.cs rename to src/Services/Booking/src/Booking/Extensions/Infrastructure/GrpcClientExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs b/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs rename to src/Services/Booking/src/Booking/Extensions/Infrastructure/InfrastructureExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/Extensions/Infrastructure/MediatRExtensions.cs b/src/Services/Booking/src/Booking/Extensions/Infrastructure/MediatRExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking/Extensions/Infrastructure/MediatRExtensions.cs rename to src/Services/Booking/src/Booking/Extensions/Infrastructure/MediatRExtensions.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/GrpcServer/Protos/flight.proto b/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/GrpcServer/Protos/flight.proto rename to src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/GrpcServer/Protos/passenger.proto b/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto similarity index 96% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/GrpcServer/Protos/passenger.proto rename to src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto index bb98c29..bc133d3 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/GrpcServer/Protos/passenger.proto +++ b/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto @@ -1,4 +1,4 @@ -syntax = "proto3"; +syntax = "proto3"; package passenger; diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs b/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs rename to src/Services/Booking/tests/IntegrationTest/Booking/Features/CreateBookingTests.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/BookingIntegrationTestBase.cs b/src/Services/Booking/tests/IntegrationTest/BookingIntegrationTestBase.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/BookingIntegrationTestBase.cs rename to src/Services/Booking/tests/IntegrationTest/BookingIntegrationTestBase.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeCreateBookingCommand.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/Fakes/FakeCreateBookingCommand.cs rename to src/Services/Booking/tests/IntegrationTest/Fakes/FakeCreateBookingCommand.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs rename to src/Services/Booking/tests/IntegrationTest/Fakes/FakeFlightResponse.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs rename to src/Services/Booking/tests/IntegrationTest/Fakes/FakeGetAvailableSeatsResponse.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs rename to src/Services/Booking/tests/IntegrationTest/Fakes/FakePassengerResponse.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs b/src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs rename to src/Services/Booking/tests/IntegrationTest/Fakes/FakeReserveSeatResponse.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Integration.Test.csproj b/src/Services/Booking/tests/IntegrationTest/Integration.Test.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/IntegrationTest/Integration.Test.csproj rename to src/Services/Booking/tests/IntegrationTest/Integration.Test.csproj diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/xunit.runner.json b/src/Services/Booking/tests/IntegrationTest/xunit.runner.json similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/tests/Integration.Test/xunit.runner.json rename to src/Services/Booking/tests/IntegrationTest/xunit.runner.json diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator-ignore b/src/Services/Booking/tests/PerformanceTest/.openapi-generator-ignore similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator-ignore rename to src/Services/Booking/tests/PerformanceTest/.openapi-generator-ignore diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator/FILES b/src/Services/Booking/tests/PerformanceTest/.openapi-generator/FILES similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/.openapi-generator/FILES rename to src/Services/Booking/tests/PerformanceTest/.openapi-generator/FILES diff --git a/src/Services/Booking/tests/PerformanceTest/.openapi-generator/VERSION b/src/Services/Booking/tests/PerformanceTest/.openapi-generator/VERSION new file mode 100644 index 0000000..6fc4f62 --- /dev/null +++ b/src/Services/Booking/tests/PerformanceTest/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0-SNAPSHOT diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/README.md b/src/Services/Booking/tests/PerformanceTest/README.md similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/README.md rename to src/Services/Booking/tests/PerformanceTest/README.md diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/script.js b/src/Services/Booking/tests/PerformanceTest/script.js similarity index 98% rename from 3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/script.js rename to src/Services/Booking/tests/PerformanceTest/script.js index d07f84a..ad88da1 100644 --- a/3-microservices-architecture-style/src/Services/Booking/tests/PerformanceTest/script.js +++ b/src/Services/Booking/tests/PerformanceTest/script.js @@ -3,7 +3,7 @@ * An example application with OpenAPI, Swashbuckle, and API versioning. * * OpenAPI spec version: 1.0 - * Contact: + * Contact: * * NOTE: This class is auto generated by OpenAPI Generator. * https://github.com/OpenAPITools/openapi-generator diff --git a/3-microservices-architecture-style/src/Services/Booking/tests/tests.sln b/src/Services/Booking/tests/tests.sln similarity index 99% rename from 3-microservices-architecture-style/src/Services/Booking/tests/tests.sln rename to src/Services/Booking/tests/tests.sln index 2e7c3aa..f280925 100644 --- a/3-microservices-architecture-style/src/Services/Booking/tests/tests.sln +++ b/src/Services/Booking/tests/tests.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 diff --git a/src/Services/Flight/Dockerfile b/src/Services/Flight/Dockerfile new file mode 100644 index 0000000..dcd807e --- /dev/null +++ b/src/Services/Flight/Dockerfile @@ -0,0 +1,48 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +# Setup working directory for the project +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Flight/src/Flight/Flight.csproj ./src/Services/Flight/src/Flight/ +COPY ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./src/Services/Flight/src/Flight.Api/ + + +# Restore nuget packages +RUN dotnet restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Flight/src/Flight/ ./src/Services/Flight/src/Flight/ +COPY ./src/Services/Flight/src/Flight.Api/ ./src/Services/Flight/src/Flight.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN dotnet build -c Release --no-restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj + +WORKDIR /src/Services/Flight/src/Flight.Api + +# Publish project to output folder +# and no build, as we did it already +RUN dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Flight/src/Flight.Api/out . + + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Flight.Api.dll"] + diff --git a/src/Services/Flight/dev.Dockerfile b/src/Services/Flight/dev.Dockerfile new file mode 100644 index 0000000..2a66679 --- /dev/null +++ b/src/Services/Flight/dev.Dockerfile @@ -0,0 +1,51 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +# Setup working directory for the project +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Flight/src/Flight/Flight.csproj ./src/Services/Flight/src/Flight/ +COPY ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj ./src/Services/Flight/src/Flight.Api/ + + +# Restore nuget packages +RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ + dotnet restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Flight/src/Flight/ ./src/Services/Flight/src/Flight/ +COPY ./src/Services/Flight/src/Flight.Api/ ./src/Services/Flight/src/Flight.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ + dotnet build -c Release --no-restore ./src/Services/Flight/src/Flight.Api/Flight.Api.csproj + +WORKDIR /src/Services/Flight/src/Flight.Api + +# Publish project to output folder +# and no build, as we did it already +RUN --mount=type=cache,id=flight_nuget,target=/root/.nuget/packages \ + dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Flight/src/Flight.Api/out . + + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Flight.Api.dll"] + diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj b/src/Services/Flight/src/Flight.Api/Flight.Api.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Flight.Api.csproj rename to src/Services/Flight/src/Flight.Api/Flight.Api.csproj diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Program.cs b/src/Services/Flight/src/Flight.Api/Program.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Program.cs rename to src/Services/Flight/src/Flight.Api/Program.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json b/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json similarity index 98% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json rename to src/Services/Flight/src/Flight.Api/Properties/launchSettings.json index d227a8b..079cccb 100644 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json +++ b/src/Services/Flight/src/Flight.Api/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "Flight.Api": { diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.Development.json b/src/Services/Flight/src/Flight.Api/appsettings.Development.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.Development.json rename to src/Services/Flight/src/Flight.Api/appsettings.Development.json diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.docker.json b/src/Services/Flight/src/Flight.Api/appsettings.docker.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.docker.json rename to src/Services/Flight/src/Flight.Api/appsettings.docker.json diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.json b/src/Services/Flight/src/Flight.Api/appsettings.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.json rename to src/Services/Flight/src/Flight.Api/appsettings.json diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.test.json b/src/Services/Flight/src/Flight.Api/appsettings.test.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight.Api/appsettings.test.json rename to src/Services/Flight/src/Flight.Api/appsettings.test.json diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Dtos/AircraftDto.cs b/src/Services/Flight/src/Flight/Aircrafts/Dtos/AircraftDto.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Dtos/AircraftDto.cs rename to src/Services/Flight/src/Flight/Aircrafts/Dtos/AircraftDto.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/AircraftAlreadyExistException.cs b/src/Services/Flight/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/AircraftAlreadyExistException.cs rename to src/Services/Flight/src/Flight/Aircrafts/Exceptions/AircraftAlreadyExistException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidAircraftIdException.cs b/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidAircraftIdException.cs rename to src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidAircraftIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidManufacturingYearException.cs b/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidManufacturingYearException.cs rename to src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidManufacturingYearException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidModelException.cs b/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidModelException.cs rename to src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidModelException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidNameException.cs b/src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Exceptions/InvalidNameException.cs rename to src/Services/Flight/src/Flight/Aircrafts/Exceptions/InvalidNameException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Features/AircraftMappings.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Features/AircraftMappings.cs rename to src/Services/Flight/src/Flight/Aircrafts/Features/AircraftMappings.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs rename to src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraft.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs b/src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs rename to src/Services/Flight/src/Flight/Aircrafts/Features/CreatingAircraft/V1/CreateAircraftMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Models/Aircraft.cs b/src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Models/Aircraft.cs rename to src/Services/Flight/src/Flight/Aircrafts/Models/Aircraft.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Models/AircraftReadModel.cs b/src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/Models/AircraftReadModel.cs rename to src/Services/Flight/src/Flight/Aircrafts/Models/AircraftReadModel.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/AircraftId.cs b/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/AircraftId.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/AircraftId.cs rename to src/Services/Flight/src/Flight/Aircrafts/ValueObjects/AircraftId.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/ManufacturingYear.cs b/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/ManufacturingYear.cs rename to src/Services/Flight/src/Flight/Aircrafts/ValueObjects/ManufacturingYear.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/Model.cs b/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Model.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/Model.cs rename to src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Model.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/Name.cs b/src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Name.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Aircrafts/ValueObjects/Name.cs rename to src/Services/Flight/src/Flight/Aircrafts/ValueObjects/Name.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Dtos/AirportDto.cs b/src/Services/Flight/src/Flight/Airports/Dtos/AirportDto.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Dtos/AirportDto.cs rename to src/Services/Flight/src/Flight/Airports/Dtos/AirportDto.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/AirportAlreadyExistException.cs b/src/Services/Flight/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/AirportAlreadyExistException.cs rename to src/Services/Flight/src/Flight/Airports/Exceptions/AirportAlreadyExistException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidAddressException.cs b/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAddressException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidAddressException.cs rename to src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAddressException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidAirportIdException.cs b/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidAirportIdException.cs rename to src/Services/Flight/src/Flight/Airports/Exceptions/InvalidAirportIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidCodeException.cs b/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidCodeException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidCodeException.cs rename to src/Services/Flight/src/Flight/Airports/Exceptions/InvalidCodeException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidNameException.cs b/src/Services/Flight/src/Flight/Airports/Exceptions/InvalidNameException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Exceptions/InvalidNameException.cs rename to src/Services/Flight/src/Flight/Airports/Exceptions/InvalidNameException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Features/AirportMappings.cs b/src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Features/AirportMappings.cs rename to src/Services/Flight/src/Flight/Airports/Features/AirportMappings.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Features/CreatingAirport/V1/CreateAirport.cs b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Features/CreatingAirport/V1/CreateAirport.cs rename to src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirport.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs b/src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs rename to src/Services/Flight/src/Flight/Airports/Features/CreatingAirport/V1/CreateAirportMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Models/Airport.cs b/src/Services/Flight/src/Flight/Airports/Models/Airport.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Models/Airport.cs rename to src/Services/Flight/src/Flight/Airports/Models/Airport.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Models/AirportReadModel.cs b/src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/Models/AirportReadModel.cs rename to src/Services/Flight/src/Flight/Airports/Models/AirportReadModel.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/Address.cs b/src/Services/Flight/src/Flight/Airports/ValueObjects/Address.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/Address.cs rename to src/Services/Flight/src/Flight/Airports/ValueObjects/Address.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/AirportId.cs b/src/Services/Flight/src/Flight/Airports/ValueObjects/AirportId.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/AirportId.cs rename to src/Services/Flight/src/Flight/Airports/ValueObjects/AirportId.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/Code.cs b/src/Services/Flight/src/Flight/Airports/ValueObjects/Code.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/Code.cs rename to src/Services/Flight/src/Flight/Airports/ValueObjects/Code.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/Name.cs b/src/Services/Flight/src/Flight/Airports/ValueObjects/Name.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Airports/ValueObjects/Name.cs rename to src/Services/Flight/src/Flight/Airports/ValueObjects/Name.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Booking/src/AssemblyInfo.cs b/src/Services/Flight/src/Flight/AssemblyInfo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Booking/src/AssemblyInfo.cs rename to src/Services/Flight/src/Flight/AssemblyInfo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/AircraftConfiguration.cs b/src/Services/Flight/src/Flight/Data/Configurations/AircraftConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/AircraftConfiguration.cs rename to src/Services/Flight/src/Flight/Data/Configurations/AircraftConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/AirportConfiguration.cs b/src/Services/Flight/src/Flight/Data/Configurations/AirportConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/AirportConfiguration.cs rename to src/Services/Flight/src/Flight/Data/Configurations/AirportConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/FlightConfiguration.cs b/src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/FlightConfiguration.cs rename to src/Services/Flight/src/Flight/Data/Configurations/FlightConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/SeatConfiguration.cs b/src/Services/Flight/src/Flight/Data/Configurations/SeatConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Configurations/SeatConfiguration.cs rename to src/Services/Flight/src/Flight/Data/Configurations/SeatConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/DesignTimeDbContextFactory.cs b/src/Services/Flight/src/Flight/Data/DesignTimeDbContextFactory.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/DesignTimeDbContextFactory.cs rename to src/Services/Flight/src/Flight/Data/DesignTimeDbContextFactory.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/FlightDbContext.cs b/src/Services/Flight/src/Flight/Data/FlightDbContext.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight/Data/FlightDbContext.cs rename to src/Services/Flight/src/Flight/Data/FlightDbContext.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/FlightReadDbContext.cs b/src/Services/Flight/src/Flight/Data/FlightReadDbContext.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/FlightReadDbContext.cs rename to src/Services/Flight/src/Flight/Data/FlightReadDbContext.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/20230611230948_initial.Designer.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.Designer.cs similarity index 99% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/20230611230948_initial.Designer.cs rename to src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.Designer.cs index 4010517..9a83d32 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/20230611230948_initial.Designer.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using Flight.Data; using Microsoft.EntityFrameworkCore; diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/20230611230948_initial.cs b/src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/20230611230948_initial.cs rename to src/Services/Flight/src/Flight/Data/Migrations/20230611230948_initial.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/FlightDbContextModelSnapshot.cs b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs similarity index 99% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/FlightDbContextModelSnapshot.cs rename to src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs index 930ce7a..433d049 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Migrations/FlightDbContextModelSnapshot.cs +++ b/src/Services/Flight/src/Flight/Data/Migrations/FlightDbContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using Flight.Data; using Microsoft.EntityFrameworkCore; diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Seed/FlightDataSeeder.cs b/src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Seed/FlightDataSeeder.cs rename to src/Services/Flight/src/Flight/Data/Seed/FlightDataSeeder.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Seed/InitialData.cs b/src/Services/Flight/src/Flight/Data/Seed/InitialData.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/Seed/InitialData.cs rename to src/Services/Flight/src/Flight/Data/Seed/InitialData.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/readme.md b/src/Services/Flight/src/Flight/Data/readme.md similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Data/readme.md rename to src/Services/Flight/src/Flight/Data/readme.md diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs b/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs rename to src/Services/Flight/src/Flight/Extensions/Infrastructure/InfrastructureExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Extensions/Infrastructure/MediatRExtensions.cs b/src/Services/Flight/src/Flight/Extensions/Infrastructure/MediatRExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight/Extensions/Infrastructure/MediatRExtensions.cs rename to src/Services/Flight/src/Flight/Extensions/Infrastructure/MediatRExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flight.csproj b/src/Services/Flight/src/Flight/Flight.csproj similarity index 90% rename from 3-microservices-architecture-style/src/Services/Flight/src/Flight/Flight.csproj rename to src/Services/Flight/src/Flight/Flight.csproj index 7471005..7a524e0 100644 --- a/3-microservices-architecture-style/src/Services/Flight/src/Flight/Flight.csproj +++ b/src/Services/Flight/src/Flight/Flight.csproj @@ -22,7 +22,7 @@ - + diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/FlightEventMapper.cs b/src/Services/Flight/src/Flight/FlightEventMapper.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/FlightEventMapper.cs rename to src/Services/Flight/src/Flight/FlightEventMapper.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/FlightRoot.cs b/src/Services/Flight/src/Flight/FlightRoot.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/FlightRoot.cs rename to src/Services/Flight/src/Flight/FlightRoot.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Dtos/FlightDto.cs b/src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Dtos/FlightDto.cs rename to src/Services/Flight/src/Flight/Flights/Dtos/FlightDto.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Enums/FlightStatus.cs b/src/Services/Flight/src/Flight/Flights/Enums/FlightStatus.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Enums/FlightStatus.cs rename to src/Services/Flight/src/Flight/Flights/Enums/FlightStatus.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/FlightAlreadyExistException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/FlightAlreadyExistException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/FlightAlreadyExistException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/FlightNotFountException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/FlightNotFountException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/FlightNotFountException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/FlightNotFountException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidArriveDateException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidArriveDateException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidArriveDateException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidDepartureDateException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidDepartureDateException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDepartureDateException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidDurationException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDurationException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidDurationException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidDurationException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidFlightDateException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidFlightDateException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightDateException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidFlightIdException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidFlightIdException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidFlightNumberException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidFlightNumberException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidFlightNumberException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidPriceException.cs b/src/Services/Flight/src/Flight/Flights/Exceptions/InvalidPriceException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Exceptions/InvalidPriceException.cs rename to src/Services/Flight/src/Flight/Flights/Exceptions/InvalidPriceException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/CreatingFlight/V1/CreateFlight.cs b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/CreatingFlight/V1/CreateFlight.cs rename to src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlight.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs b/src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs rename to src/Services/Flight/src/Flight/Flights/Features/CreatingFlight/V1/CreateFlightMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/DeletingFlight/V1/DeleteFlight.cs b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/DeletingFlight/V1/DeleteFlight.cs rename to src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlight.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs b/src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs rename to src/Services/Flight/src/Flight/Flights/Features/DeletingFlight/V1/DeleteFlightMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/FlightMappings.cs b/src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/FlightMappings.cs rename to src/Services/Flight/src/Flight/Flights/Features/FlightMappings.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs b/src/Services/Flight/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs rename to src/Services/Flight/src/Flight/Flights/Features/GettingAvailableFlights/V1/GetAvailableFlights.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/GettingFlightById/V1/GetFlightById.cs b/src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/GettingFlightById/V1/GetFlightById.cs rename to src/Services/Flight/src/Flight/Flights/Features/GettingFlightById/V1/GetFlightById.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs rename to src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlight.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs b/src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs rename to src/Services/Flight/src/Flight/Flights/Features/UpdatingFlight/V1/UpdateFlightMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Models/Flight.cs b/src/Services/Flight/src/Flight/Flights/Models/Flight.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Models/Flight.cs rename to src/Services/Flight/src/Flight/Flights/Models/Flight.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Models/FlightReadModel.cs b/src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/Models/FlightReadModel.cs rename to src/Services/Flight/src/Flight/Flights/Models/FlightReadModel.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/ArriveDate.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/ArriveDate.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/ArriveDate.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/ArriveDate.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/DepartureDate.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/DepartureDate.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/DepartureDate.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/DepartureDate.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/DurationMinutes.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/DurationMinutes.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/DurationMinutes.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/DurationMinutes.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/FlightDate.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightDate.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/FlightDate.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/FlightDate.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/FlightId.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightId.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/FlightId.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/FlightId.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/FlightNumber.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/FlightNumber.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/FlightNumber.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/FlightNumber.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/Price.cs b/src/Services/Flight/src/Flight/Flights/ValueObjects/Price.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Flights/ValueObjects/Price.cs rename to src/Services/Flight/src/Flight/Flights/ValueObjects/Price.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto b/src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto similarity index 100% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking/GrpcClient/Protos/flight.proto rename to src/Services/Flight/src/Flight/GrpcServer/Protos/flight.proto diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/GrpcServer/Services/FlightGrpcServices.cs b/src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/GrpcServer/Services/FlightGrpcServices.cs rename to src/Services/Flight/src/Flight/GrpcServer/Services/FlightGrpcServices.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Dtos/SeatDto.cs b/src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Dtos/SeatDto.cs rename to src/Services/Flight/src/Flight/Seats/Dtos/SeatDto.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Enums/SeatClass.cs b/src/Services/Flight/src/Flight/Seats/Enums/SeatClass.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Enums/SeatClass.cs rename to src/Services/Flight/src/Flight/Seats/Enums/SeatClass.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Enums/SeatType.cs b/src/Services/Flight/src/Flight/Seats/Enums/SeatType.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Enums/SeatType.cs rename to src/Services/Flight/src/Flight/Seats/Enums/SeatType.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/AllSeatsFullException.cs b/src/Services/Flight/src/Flight/Seats/Exceptions/AllSeatsFullException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/AllSeatsFullException.cs rename to src/Services/Flight/src/Flight/Seats/Exceptions/AllSeatsFullException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/InvalidSeatIdException.cs b/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/InvalidSeatIdException.cs rename to src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/InvalidSeatNumberException.cs b/src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/InvalidSeatNumberException.cs rename to src/Services/Flight/src/Flight/Seats/Exceptions/InvalidSeatNumberException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/SeatAlreadyExistException.cs b/src/Services/Flight/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/SeatAlreadyExistException.cs rename to src/Services/Flight/src/Flight/Seats/Exceptions/SeatAlreadyExistException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/SeatNumberIncorrectException.cs b/src/Services/Flight/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Exceptions/SeatNumberIncorrectException.cs rename to src/Services/Flight/src/Flight/Seats/Exceptions/SeatNumberIncorrectException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/CreatingSeat/V1/CreateSeat.cs b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/CreatingSeat/V1/CreateSeat.cs rename to src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeat.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs b/src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs rename to src/Services/Flight/src/Flight/Seats/Features/CreatingSeat/V1/CreateSeatMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs b/src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs rename to src/Services/Flight/src/Flight/Seats/Features/GettingAvailableSeats/V1/GetAvailableSeats.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/ReservingSeat/V1/ReserveSeat.cs b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/ReservingSeat/V1/ReserveSeat.cs rename to src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeat.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs b/src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs rename to src/Services/Flight/src/Flight/Seats/Features/ReservingSeat/V1/ReserveSeatMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/SeatMappings.cs b/src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Features/SeatMappings.cs rename to src/Services/Flight/src/Flight/Seats/Features/SeatMappings.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Models/Seat.cs b/src/Services/Flight/src/Flight/Seats/Models/Seat.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Models/Seat.cs rename to src/Services/Flight/src/Flight/Seats/Models/Seat.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Models/SeatReadModel.cs b/src/Services/Flight/src/Flight/Seats/Models/SeatReadModel.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/Models/SeatReadModel.cs rename to src/Services/Flight/src/Flight/Seats/Models/SeatReadModel.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/ValueObjects/SeatId.cs b/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatId.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/ValueObjects/SeatId.cs rename to src/Services/Flight/src/Flight/Seats/ValueObjects/SeatId.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/ValueObjects/SeatNumber.cs b/src/Services/Flight/src/Flight/Seats/ValueObjects/SeatNumber.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/Seats/ValueObjects/SeatNumber.cs rename to src/Services/Flight/src/Flight/Seats/ValueObjects/SeatNumber.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/EndToEnd.Test.csproj b/src/Services/Flight/tests/EndToEndTest/EndToEnd.Test.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/EndToEnd.Test.csproj rename to src/Services/Flight/tests/EndToEndTest/EndToEnd.Test.csproj diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Fakes/FakeCreateFlightCommand.cs b/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Fakes/FakeCreateFlightCommand.cs rename to src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Fakes/FakeCreateFlightMongoCommand.cs b/src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightMongoCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Fakes/FakeCreateFlightMongoCommand.cs rename to src/Services/Flight/tests/EndToEndTest/Fakes/FakeCreateFlightMongoCommand.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Flight/Features/CreateFlightTests.cs b/src/Services/Flight/tests/EndToEndTest/Flight/Features/CreateFlightTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Flight/Features/CreateFlightTests.cs rename to src/Services/Flight/tests/EndToEndTest/Flight/Features/CreateFlightTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Flight/Features/GetFlightByIdTests.cs b/src/Services/Flight/tests/EndToEndTest/Flight/Features/GetFlightByIdTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/Flight/Features/GetFlightByIdTests.cs rename to src/Services/Flight/tests/EndToEndTest/Flight/Features/GetFlightByIdTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/FlightEndToEndTestBase.cs b/src/Services/Flight/tests/EndToEndTest/FlightEndToEndTestBase.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/EndToEndTest/FlightEndToEndTestBase.cs rename to src/Services/Flight/tests/EndToEndTest/FlightEndToEndTestBase.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/FlightTestDataSeeder.cs b/src/Services/Flight/tests/EndToEndTest/FlightTestDataSeeder.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/FlightTestDataSeeder.cs rename to src/Services/Flight/tests/EndToEndTest/FlightTestDataSeeder.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Routes/ApiRoutes.cs b/src/Services/Flight/tests/EndToEndTest/Routes/ApiRoutes.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/Routes/ApiRoutes.cs rename to src/Services/Flight/tests/EndToEndTest/Routes/ApiRoutes.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/xunit.runner.json b/src/Services/Flight/tests/EndToEndTest/xunit.runner.json similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/EndToEnd.Test/xunit.runner.json rename to src/Services/Flight/tests/EndToEndTest/xunit.runner.json diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Aircraft/Features/CreateAircraftTests.cs b/src/Services/Flight/tests/IntegrationTest/Aircraft/Features/CreateAircraftTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Aircraft/Features/CreateAircraftTests.cs rename to src/Services/Flight/tests/IntegrationTest/Aircraft/Features/CreateAircraftTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Airport/Features/CreateAirportTests.cs b/src/Services/Flight/tests/IntegrationTest/Airport/Features/CreateAirportTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Airport/Features/CreateAirportTests.cs rename to src/Services/Flight/tests/IntegrationTest/Airport/Features/CreateAirportTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateAircraftCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAircraftCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateAircraftCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAircraftCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateAirportCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAirportCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateAirportCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateAirportCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateFlightCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateFlightCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateFlightMongoCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightMongoCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateFlightMongoCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateFlightMongoCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateSeatCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateSeatCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateSeatMongoCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatMongoCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeCreateSeatMongoCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeCreateSeatMongoCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeUpdateFlightCommand.cs b/src/Services/Flight/tests/IntegrationTest/Fakes/FakeUpdateFlightCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/Fakes/FakeUpdateFlightCommand.cs rename to src/Services/Flight/tests/IntegrationTest/Fakes/FakeUpdateFlightCommand.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/CreateFlightTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/CreateFlightTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/CreateFlightTests.cs rename to src/Services/Flight/tests/IntegrationTest/Flight/Features/CreateFlightTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs rename to src/Services/Flight/tests/IntegrationTest/Flight/Features/DeleteFlightTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/GetAvailableFlightsTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/GetAvailableFlightsTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/GetAvailableFlightsTests.cs rename to src/Services/Flight/tests/IntegrationTest/Flight/Features/GetAvailableFlightsTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/GetFlightByIdTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/GetFlightByIdTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/GetFlightByIdTests.cs rename to src/Services/Flight/tests/IntegrationTest/Flight/Features/GetFlightByIdTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs b/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs rename to src/Services/Flight/tests/IntegrationTest/Flight/Features/UpdateFlightTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/FlightIntegrationTestBase.cs b/src/Services/Flight/tests/IntegrationTest/FlightIntegrationTestBase.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/FlightIntegrationTestBase.cs rename to src/Services/Flight/tests/IntegrationTest/FlightIntegrationTestBase.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/FlightTestDataSeeder.cs b/src/Services/Flight/tests/IntegrationTest/FlightTestDataSeeder.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/FlightTestDataSeeder.cs rename to src/Services/Flight/tests/IntegrationTest/FlightTestDataSeeder.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Integration.Test.csproj b/src/Services/Flight/tests/IntegrationTest/Integration.Test.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Integration.Test.csproj rename to src/Services/Flight/tests/IntegrationTest/Integration.Test.csproj diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Seat/Features/GetAvailableSeatsTests.cs b/src/Services/Flight/tests/IntegrationTest/Seat/Features/GetAvailableSeatsTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Seat/Features/GetAvailableSeatsTests.cs rename to src/Services/Flight/tests/IntegrationTest/Seat/Features/GetAvailableSeatsTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Seat/Features/ReserveSeatTests.cs b/src/Services/Flight/tests/IntegrationTest/Seat/Features/ReserveSeatTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/IntegrationTest/Seat/Features/ReserveSeatTests.cs rename to src/Services/Flight/tests/IntegrationTest/Seat/Features/ReserveSeatTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/xunit.runner.json b/src/Services/Flight/tests/IntegrationTest/xunit.runner.json similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Integration.Test/xunit.runner.json rename to src/Services/Flight/tests/IntegrationTest/xunit.runner.json diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator-ignore b/src/Services/Flight/tests/PerformanceTest/.openapi-generator-ignore similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator-ignore rename to src/Services/Flight/tests/PerformanceTest/.openapi-generator-ignore diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator/FILES b/src/Services/Flight/tests/PerformanceTest/.openapi-generator/FILES similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/.openapi-generator/FILES rename to src/Services/Flight/tests/PerformanceTest/.openapi-generator/FILES diff --git a/src/Services/Flight/tests/PerformanceTest/.openapi-generator/VERSION b/src/Services/Flight/tests/PerformanceTest/.openapi-generator/VERSION new file mode 100644 index 0000000..6fc4f62 --- /dev/null +++ b/src/Services/Flight/tests/PerformanceTest/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0-SNAPSHOT diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/README.md b/src/Services/Flight/tests/PerformanceTest/README.md similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/README.md rename to src/Services/Flight/tests/PerformanceTest/README.md diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/script.js b/src/Services/Flight/tests/PerformanceTest/script.js similarity index 99% rename from 3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/script.js rename to src/Services/Flight/tests/PerformanceTest/script.js index 48348e1..086ee27 100644 --- a/3-microservices-architecture-style/src/Services/Flight/tests/PerformanceTest/script.js +++ b/src/Services/Flight/tests/PerformanceTest/script.js @@ -3,7 +3,7 @@ * An example application with OpenAPI, Swashbuckle, and API versioning. * * OpenAPI spec version: 1.0 - * Contact: + * Contact: * * NOTE: This class is auto generated by OpenAPI Generator. * https://github.com/OpenAPITools/openapi-generator diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs b/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs rename to src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandHandlerTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs b/src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs rename to src/Services/Flight/tests/UnitTest/Aircraft/Features/CreateAircraftTests/CreateAircraftCommandValidatorTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs b/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs rename to src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandHandlerTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs b/src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs rename to src/Services/Flight/tests/UnitTest/Airport/Features/CreateAirportTests/CreateAirportCommandValidatorTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Common/DbContextFactory.cs b/src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Common/DbContextFactory.cs rename to src/Services/Flight/tests/UnitTest/Common/DbContextFactory.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Common/MapperFactory.cs b/src/Services/Flight/tests/UnitTest/Common/MapperFactory.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Common/MapperFactory.cs rename to src/Services/Flight/tests/UnitTest/Common/MapperFactory.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Common/UnitTestFixture.cs b/src/Services/Flight/tests/UnitTest/Common/UnitTestFixture.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Common/UnitTestFixture.cs rename to src/Services/Flight/tests/UnitTest/Common/UnitTestFixture.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateAircraftCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAircraftCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateAircraftCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAircraftCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateAirportCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAirportCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateAirportCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeCreateAirportCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateFlightCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateFlightCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateFlightCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeCreateFlightCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateSeatCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeCreateSeatCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeCreateSeatCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeCreateSeatCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeFlightCreate.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightCreate.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeFlightCreate.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeFlightCreate.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeFlightUpdate.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeFlightUpdate.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeFlightUpdate.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeFlightUpdate.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateAircraftCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAircraftCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateAircraftCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAircraftCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateAirportCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAirportCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateAirportCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateAirportCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateFlightCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateFlightCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateFlightCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateFlightCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateSeatCommand.cs b/src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateSeatCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Fakes/FakeValidateCreateSeatCommand.cs rename to src/Services/Flight/tests/UnitTest/Fakes/FakeValidateCreateSeatCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Domains/CreateFlightTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Domains/CreateFlightTests.cs rename to src/Services/Flight/tests/UnitTest/Flight/Features/Domains/CreateFlightTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Domains/UpdateFlightTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Domains/UpdateFlightTests.cs rename to src/Services/Flight/tests/UnitTest/Flight/Features/Domains/UpdateFlightTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs rename to src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandHandlerTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs b/src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs rename to src/Services/Flight/tests/UnitTest/Flight/Features/Handlers/CreateFlight/CreateFlightCommandValidatorTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/FlightMappingTests.cs b/src/Services/Flight/tests/UnitTest/Flight/FlightMappingTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Flight/FlightMappingTests.cs rename to src/Services/Flight/tests/UnitTest/Flight/FlightMappingTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Seat/Features/CreateSeatCommandHandlerTests.cs b/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandHandlerTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Seat/Features/CreateSeatCommandHandlerTests.cs rename to src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandHandlerTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Seat/Features/CreateSeatCommandValidatorTests.cs b/src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandValidatorTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Seat/Features/CreateSeatCommandValidatorTests.cs rename to src/Services/Flight/tests/UnitTest/Seat/Features/CreateSeatCommandValidatorTests.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Seat/SeatMappingTests.cs b/src/Services/Flight/tests/UnitTest/Seat/SeatMappingTests.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/Seat/SeatMappingTests.cs rename to src/Services/Flight/tests/UnitTest/Seat/SeatMappingTests.cs diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Unit.Test.csproj b/src/Services/Flight/tests/UnitTest/Unit.Test.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Flight/tests/UnitTest/Unit.Test.csproj rename to src/Services/Flight/tests/UnitTest/Unit.Test.csproj diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/xunit.runner.json b/src/Services/Flight/tests/UnitTest/xunit.runner.json similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/tests/Unit.Test/xunit.runner.json rename to src/Services/Flight/tests/UnitTest/xunit.runner.json diff --git a/3-microservices-architecture-style/src/Services/Flight/tests/tests.sln b/src/Services/Flight/tests/tests.sln similarity index 99% rename from 3-microservices-architecture-style/src/Services/Flight/tests/tests.sln rename to src/Services/Flight/tests/tests.sln index f3624ac..1734b83 100644 --- a/3-microservices-architecture-style/src/Services/Flight/tests/tests.sln +++ b/src/Services/Flight/tests/tests.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 diff --git a/src/Services/Identity/Dockerfile b/src/Services/Identity/Dockerfile new file mode 100644 index 0000000..24ce752 --- /dev/null +++ b/src/Services/Identity/Dockerfile @@ -0,0 +1,47 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder + +# Setup working directory for the project +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Identity/src/Identity/Identity.csproj ./src/Services/Identity/src/Identity/ +COPY ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./src/Services/Identity/src/Identity.Api/ + +# Restore nuget packages +RUN dotnet restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Identity/src/Identity/ ./src/Services/Identity/src/Identity/ +COPY ./src/Services/Identity/src/Identity.Api/ ./src/Services/Identity/src/Identity.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN dotnet build -c Release --no-restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj + +WORKDIR /src/Services/Identity/src/Identity.Api + +# Publish project to output folder +# and no build, as we did it already +RUN dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Identity/src/Identity.Api/out . + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Identity.Api.dll"] + diff --git a/src/Services/Identity/dev.Dockerfile b/src/Services/Identity/dev.Dockerfile new file mode 100644 index 0000000..ff89f98 --- /dev/null +++ b/src/Services/Identity/dev.Dockerfile @@ -0,0 +1,50 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder + +# Setup working directory for the project +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Identity/src/Identity/Identity.csproj ./src/Services/Identity/src/Identity/ +COPY ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj ./src/Services/Identity/src/Identity.Api/ + +# Restore nuget packages +RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ + dotnet restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Identity/src/Identity/ ./src/Services/Identity/src/Identity/ +COPY ./src/Services/Identity/src/Identity.Api/ ./src/Services/Identity/src/Identity.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ + dotnet build -c Release --no-restore ./src/Services/Identity/src/Identity.Api/Identity.Api.csproj + +WORKDIR /src/Services/Identity/src/Identity.Api + +# Publish project to output folder +# and no build, as we did it already +RUN --mount=type=cache,id=identity_nuget,target=/root/.nuget/packages \ + dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Identity/src/Identity.Api/out . + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Identity.Api.dll"] + diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj b/src/Services/Identity/src/Identity.Api/Identity.Api.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Identity.Api.csproj rename to src/Services/Identity/src/Identity.Api/Identity.Api.csproj diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Program.cs b/src/Services/Identity/src/Identity.Api/Program.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Program.cs rename to src/Services/Identity/src/Identity.Api/Program.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json b/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json similarity index 98% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json rename to src/Services/Identity/src/Identity.Api/Properties/launchSettings.json index 36f5b8f..4b5b5ee 100644 --- a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json +++ b/src/Services/Identity/src/Identity.Api/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "Identity.Api": { diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.Development.json b/src/Services/Identity/src/Identity.Api/appsettings.Development.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.Development.json rename to src/Services/Identity/src/Identity.Api/appsettings.Development.json diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.docker.json b/src/Services/Identity/src/Identity.Api/appsettings.docker.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.docker.json rename to src/Services/Identity/src/Identity.Api/appsettings.docker.json diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.json b/src/Services/Identity/src/Identity.Api/appsettings.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.json rename to src/Services/Identity/src/Identity.Api/appsettings.json diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.test.json b/src/Services/Identity/src/Identity.Api/appsettings.test.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity.Api/appsettings.test.json rename to src/Services/Identity/src/Identity.Api/appsettings.test.json diff --git a/src/Services/Identity/src/Identity.Api/keys/is-signing-key-0AC3347A09AA5E44E947F3E30ED54871.json b/src/Services/Identity/src/Identity.Api/keys/is-signing-key-0AC3347A09AA5E44E947F3E30ED54871.json new file mode 100644 index 0000000..d0cc8de --- /dev/null +++ b/src/Services/Identity/src/Identity.Api/keys/is-signing-key-0AC3347A09AA5E44E947F3E30ED54871.json @@ -0,0 +1 @@ +{"Version":1,"Id":"0AC3347A09AA5E44E947F3E30ED54871","Created":"2023-02-22T21:06:15.7901014Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8Pno3caweVxDrMdMtoqjLU9W7bGGdPAEm8VDpWIg5fNfBATZdniIo9r5lhBSMZ3OFJya6SlNGIFe9JkbzJBa5fwNa-omLt15Kjlu3QNX4bAWI3V87P70NAfKDKe4xBVF12B3ooXFXKJ2U5QzFBY8U_1tBXkeUTQKfioQ1lTPxIbQtmSyD-uSc5anbDjtqIWhDq1OlujSJpVHRJV9EzRCms4yZdUc506aWg_KrkpVITZyywj1X1cz-SaUGUqy01wJSXgEj70OdVo2DoPIEYTDAlymi40-R2jQsnseFEG3W7XQlYX29joTygtkumnVED2WF9y9Boy80Kj5XN5XZvL1opV-qtxA8aekkp3XuwMJtBmnMeslHK8TyvBl5JjdZwULdYJFo-rGSDEuI4bswDzMWUgv6oAxgqE6e7SQiFlHuLgWHkmEis4-r-EphCl7B_lNOMQViifon6L8t0lUGdPFhFfN5Fo7cj_lZPx5uqymwVUwIEPrEisZtkwsPYZeKuVdSaRnl5xDlU6AgbQvcNeTtg9_kyB6Z43rEPTvtwMkoBjVe5iTQ5ZtubByEGKVIugxNMfHzPc1E9FNTT3uW928Uq6RQiNah17cNBQsVmYAq_iRggDJwAeFnUgqnh0hFuve2_9T4Nt6XFSV-0OQ7aM8C8VPpEzROYhs_MMrzYuJAnV7VuvgUm4Zk9A2OFx9nGQXjL8WZ1-CcNV-TGESRUc9tfFizHPnd417h_qBYb8rJ-znet07KYs0Hwo_S8nbc4fAeG7OEj8cgn0nwgnDMa0_ROzvfFhmeWkkY5LdwtF0pgbO-_xdQwrx3mD2u6Nq5kABizd8ixH1urwvlfY5Z-MGwohf4HDjebiP49PsT96PAaj9ZFxz1HPfz4lOSCob7CBapIEt2exK0-OIhxkkU6i5_7iRvI_oFshzTvg2mSmR0zDWYfhiLZFoWGIlPi_B-pJvMEYgsyXW294yiAdVIJHXxs1nJRzgGBblY_FXM7IOzzwzpBtXH0odO8OPK6m8VBumDs9Q6iGiArFHwO5jKfvTxWYCM-PnTqW3ZselPIjZHSXbpGEU3o-HYg4rAGSIP9P_GoEJvSrQXqpYvhvPPbLh70OTwTtc8qG9GNW7XMoLpi6c8wUsapvrrYUBStlUWQ11UgvYSX1Nu4uCqTNTy6O1QHerbOHxWxfIOHzZyYfYnqQaF3bZZcMVJK3pOorcJKiMRCUp-hu5ismZ6T5Q2zfq93uqI3DpG2Wuov53o2s0QFmC4c5K6CCQVgLYBcib69twXjrWkVmGeM2CswLukOf8flUpGp_923M1TA4E89xkHxVhYESPfLB8FAULwNHOAW60U0tUksX-bcaAG1NUo3UEmaku2YfVbDJ7t5PJv8gc4zcPC0iXdBEL00G4FtSE2-r1TUhqK64iASEaAv3UTwefOMUR3qzxZC3HB7wH4iiUESH70s1RXvNIQoKz_ZirEa9WoR0tgk0MFyr4VDow-q-embX06vesnwyHhCdZBr8el_KT_yGWwlkR_xx18fR6mHT5G_BYuW-cK8ADvJe-Y_vns2yQprfGGgeVUQ5t4IKacpqnNNB9J2lLMisQ9fjYJCRhMP41CB7vk7oUXu49PgvJ_LkqtM5LAngo5f5DVdrzgX1-9I_KtyamJ9ic8nLqVsI5Z9iof9u9cRyDKhwQ4KPpD3uovwGnK7if25F9UaHFLvAJk2iOQjkA1rQyjCIJzi8dqpdw3W_L3Gc2m9Gr7HS1D0ZtWIk8z-TMNtR2PQcmlWiTJ9ZhLyMs67LWnLZri0jchEw4TJ46EAAUHE1hGhbs8xsmtta1yiu9VaZwCjDb5OJwnnl_2tA1ZkCE5Mh9NGSAZSCYLJCSRaCE53KypCYZBtJhR7Jcl1cz0OY9nNNUpzpPrcmCEz1cLw4z2H1OtujncZHDiyKqh57zQOTs--q9Nx8ytyhg7hBYIcqJFP8Gb0xQPjSkN1oO5ScAPIyPNY54VdIR7sk-99995Y-U6pnLQ_1JdIJZRYYnaYa4c5cqQaRE1n_G-L4_g20aBCX65SKkck5bwsAMJL371t4CqCBfPjzFugoNxR37DWicLUd9sJGBUMjj_lhWsk709om6shSJAy4loiz1qViwPi1K5XcFI7oyH735wg8X05Qxe1tby83X9FSd1FlTpVPRe1btEHddVubt9oeaZ0kOiN5BagaEF4wjIiQttnnzBfjKqcpuyd0zMhDTL_CqlmrTE09HH01VSnZ6lVllzCXGYI2hZKJFeOL7quHV4cDSoEVHOBL7SbChhm62iWOVTe2ho8V1NGnGFMmMfeplVWKorv-k2-L0H-K8rtg9d2vUdt-s5bxKkesUjxJhScBVOlFVcX6GdDa0o2R1W6qszC7D-_UILhIEtkQwnEg9SR-dDMulOotrHp5_LrsMCJLCgqGfzrjVymq7vkHbkh-8XIUzopyXgS4yr__N1MT2lI-7sFBG8fTa-GbN","DataProtected":true} diff --git a/src/Services/Identity/src/Identity.Api/keys/is-signing-key-A57781A0405849BDE786A79636460E49.json b/src/Services/Identity/src/Identity.Api/keys/is-signing-key-A57781A0405849BDE786A79636460E49.json new file mode 100644 index 0000000..347f69c --- /dev/null +++ b/src/Services/Identity/src/Identity.Api/keys/is-signing-key-A57781A0405849BDE786A79636460E49.json @@ -0,0 +1 @@ +{"Version":1,"Id":"A57781A0405849BDE786A79636460E49","Created":"2023-05-11T21:58:42.4707649Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8Hnjqxp4tLpCov-J-Y0BVs7wR0CVu4eqUuKwsY0rf0WJyME4aNzhKfD2Z2K08hK8_8svrjSptVpC1ttyCPtXtPVMsQQRukJef7SjEUNlC-US2KuwQGOLMYIDNHkTHrnXN7GYHoFtZ1SQWdL61GJ43LYCyFY7_L_Sn9SFepnDcT9H3aA9-M3ZjDJNU8_qknPTEUhSjV1i7AMkYnCHHow0ttlYhcQGwXoiuMMI9oqu26yr79i7sG6m_BAK1f1eg_1cBGozNe4yRPHsRk4qCLKgG-JRaNfV8sXHM-3SpEeFx7iUYHLHl7SiQwsqrODIujk7sz_vJaDbiFqwSVxUTDBEBLPpmPULLGKzjGoPrGtpmvgHkghEsHtvXY6aTzWwDLBmOT4ao8IjImv8D3_ub_KgNC5rg5pBzYA-gKAhtE_RznEKP_DVR836v5Xpw7zMVxbYVNwLrJ5-QtD503G5QhywFUHO9pRiL-dtDHJTpSmq5esy-OKBl2QJ12WxfeeMUQ7tIkTSsj0ALMyJS-a7uVUkITxOkXxrBI5rF6OIK8GZwnmsxJK5L3Urbn76EgiFKVoqgyhBRs0GvRl5-WJyc69m3ltuhp1z7hYOh0BYjlecDd9WOqNbFE68BCYUi7O--mSE0Bv94K4eUs81ccSb3lwC0AtPWPWjG31E9cg8Sd-A1gXhAcYuLmeWSoAP2Issoi5blxeafWUadjbjdCtGI_lA1trpg9LpClEDZZt5uJ5DQa5yUVzdz7l-RnlF7C8ReBtM8qBxJYnaCnc4WC7WE5cKMYG6mGJY55o_EAR4urjsxy2Bdjh34cFIIEQwfh-tnex3uBvYFUzoCPp8KJY-eRhUXEjtZzeds51OVeLKkeyFtSVEZsFTCnmc3tTsOAtkpa7sjsU0Xe0sgMG_E1XS8P_BqfIm9RR8rPblmA6JytNt_Gs2f00ND28PAnj_UuLeOaFpl2sipa228-1JimzFxKnVN7ZtU_ztZtUCGCSELoNbana8ZyLuFRGjFxQnkVZarwEFVyl7w_4scMujShb3ttaJDul51tsSJJTY43nC-Vlo1UBtYUjjNKuexpmOKGXaYRPygy_g4EXsqiN4FTc3mcG7jRoHmd5mUcvXfI66WbDmpXn4DB4x1VrWs2MVrLJw1ioON42IgjhoUCklrYJx4cxEWrIC3EURILE_jTy2ThAhGF24Z6jdTM8iVN9W7wwrnUxoFJCflr_-jiWwCToUWxPfolVu4mpQDhWJ1K9vuTVhQNrbMbc95TH7-Z_HFKiZkw23U0Xvjd4dqBJol2POIdQkDDg_L2omPtlMdNwo8eJ9rLEycbqQzcFzbyZBr__BU7J16wpu2lwZZVGgYfiofb6E01Iq_2_VQw8WH7d6onBJNCRq6QIDfZ3VdEMjdlm3kGrcY-_kzsfM9x9H_a-EpzT0_PwZO6gWUvfEfI84fNgPhM0Gq4vkv4l0NSpvIpivmgU9g3J2yQpO4QXVyQGOcXSUvUGKDIBRMKch1IOIEB6qYi34muu8Et0pbHsDsXECCnkfs5FAnKlG-zuf6W2cNRsF7QyaoUpDSpRD8u_R_mcQEVA2VJb4NWPSV1zgJ6-ne7HO_DL1mW7F-0jl2yHqOJ5z8GMTNdl7Nh4LfvHEB7xs0M2fgPByq3JImX1M-KUZDyIxfqxUM8L44zPyjiHvpMgXDvaA21aytu7G4r3vlgFyuMnSPKJ-fV8LBYDUKZ7TSOtTL2yCV2D5Z_VE3uZzBrpmJzzPG1_OXgmqV57KsPnDdwVefeu9UbCaDzG0R_xGReJveQcf5be8iJtTRDwqB2qlYm01VuIUSxabFTb_MypnKoIFaOxonW1faOgZ0zV8ocbgDfKO-8T21BBAJryw76yHxEVm59_X7Oa1VS_TM7i2sB67DWQadn4i4VMrF34LQyyhwPguKPSey1k7DcsHMxJ9zwUbC22HURwqVRn9zzxz9vHHiCUskytu3bItRkSpwDD2z_ngL9hVUF3C4QM3d4vgoL4sWS7X1One8z-vyZpZH_BDUg4nwEx95KClv2XieWXTHep8_3rdSIyTPrLLqErhCur6U69boZlvoCmoYtgbYN7dA1VkdTzdnzU-zSRLRkOY_hsa2gEElHqdtjHHTdt9g3kNhnvBMmgTQcEsAKZFjnwSbC-BogTSYNiZYCUu9eYOmenwlF4X4Yti-bVpMCEn6_6H8dWjumdBb7hgsvm47Sbuna5vAnlfnPKZBgji-38Y5lPE3NRF0ImhrsaURNUFktoNhp2gwFh8R0nLRzoLr3jWF2pBMMbvKGGzEBxOGN0_3nodoSyjFJFyAHgTwNcxB0AeYImM_-mxFtjiCDESqZoZGWtg6MvXmXPnat_uaI-jwl6TFBUChTjWujfil5doh32BtImNFO8VQakhrpTCaVm6yBKH77eF6aCX50iTuVVBuMec3IJZNPdnsc_65R4VGpqLwdscWiJqtmaRt_Umj-eJ","DataProtected":true} diff --git a/src/Services/Identity/src/Identity.Api/keys/is-signing-key-B3C31EEE2718D3C5004C6E85AD74F26C.json b/src/Services/Identity/src/Identity.Api/keys/is-signing-key-B3C31EEE2718D3C5004C6E85AD74F26C.json new file mode 100644 index 0000000..8487747 --- /dev/null +++ b/src/Services/Identity/src/Identity.Api/keys/is-signing-key-B3C31EEE2718D3C5004C6E85AD74F26C.json @@ -0,0 +1 @@ +{"Version":1,"Id":"B3C31EEE2718D3C5004C6E85AD74F26C","Created":"2025-04-08T16:45:11.9802139Z","Algorithm":"RS256","IsX509Certificate":false,"Data":"CfDJ8KNpFTgHKl5Nl-o13RQ8rse7iqNX7fzIuFQawPXYLwTCbj1HOrmv2WHbV51cOwFkSjECACMh5ad32vYQMXHgU7-l9gMNU0QwhV5gdoDScJLFzFf-_gBCqNPsUWJxNebIFDHwSn12y9Kg56DzaRq9o4XO_wGEc3KsQjDjHuh0p-3n8qiliIxl_sBXTs8UCXhWMBqU5srioHUKwFu6nyAlhkDlsA9J6Syb9w6_WESzli6DpR9UphBKbjoV85ajrkuZzjd9GItRJ6C-OICEKUUoFXh5meVGuV-JmWhE1_nzASToml0vI6GZt8kxrJQkICt1MI7K2ZIQtHcoKhC09rWu7RpuOvKY8sLm0b8gbJQ1dVMNuZEnOczi-E3b6kKrYFwV_I3TFK4UZP7I90-cojBGpaWwX3IzkB8-Uwf-5qU2KXUZanO0tXEqw187ZVPDuvKkAUeAtphWFbV2ZNH12DGcXTvnvJfRxV5lRAuzH3N-Dhgz10F3VOQZtgoQyQ4wJE-B-04j3pqN_76NIh4Yx7GvArlWYMQTNBePMaLW33ycLlCrjov1nKK2BIhk4wykUeFT_rorXcf01PHJd3uqbtBDrP7ZoUqz8qWdY9-on3dvNi6cruyJ5rbmmE4hLAsWHLOqYLcceBF7LaZUthglcMtLlufU5C3wpXjoqpJZb1KiC7QR5sQE_KPfEiQsCO_hyXnFUvavOaGIiWWAhqADfGdD3wNma3qCAMwmV5T-_4_yW3wvYbrM8YFrHmQty6ks4W6qKJow1uwfAziDoobdV7bSLSxddWiO5zOuCeFNxIzsmMkk8PfxUyb-JySYFh_tA8D3Tn5kvTbFIRibfiBJXtB8Kk4ouvQxd6ydHCHOAHzuPgxs_nP6s3u0Xa12fmPpiCLaUjeNFHNP_wzh4l5Tn7GN4S07nOiFE1PyQUjT7xnYxcUuzySpiqLl2k9Bu98MMagGg6gqWnl5zV_Adxkq_aIvuvZF25JlE9SzAJkuJFBNqnXJ_ep-BCFogdHPgtjL_Y250A5DsiFnKrlJLuBIz88V_oLEj54iSi4hiJ66YT0H8lagPUIrL4h6cPCVWFeMiCf8yNeQVHCnRkIyXtID4CrSOr8KN5Qv_nKeAUxw_5BOgs5yEGxj4OGLLYViAobOCFOA1uCurA3OqyoI65CCyoPERAXm7dyKcIN8l0ChIHhCX2VBtwEoSG2QXlEjKLxmmMmHQrTuMMRNkd2_GlY6XNRw6MELf7W4SrxyZ-eWNY9nfye7z9Q-hv_dDkf5FGmd8qGpVUenIjH0GUz4JqWOQ6GmHb7b_9u5g5vNIqi5YHf59SuNGAUbE3PFpDGpIeh5YVrCV-msoaUEkYxXvsBcUsOIiC32kQy-u-fDPxYSg-aNCgBrKDnTK4IFFBNYjT1IIApIiz-Xq8mjTsJvgaYKOLsVfqPlWX_Fr63Fnnygt9zO1tNZjW6JSj34nZJ_6120mGZcNueXtUy66QJeF8DqVdt4DbXMWYk-rQcHvqk3lQ_r7u7r88hIwzXgE3YtFFlesUK_7DVcblSuTxNxDXO5M7U_2EO4KIJbDfQ6BYxovJrWwtPcSXb_Nq25St_X3wSMk3eSGO7GNHL89t_muN5tE97As0s89h8OM5cISROR72zLWyvki2aB4L5WFWpBg1xylymZBzWGF-VKbDpoIb09PsyuuWy502OONDxmsheeadUZCNZYlxiSkmGLXrjSgsAhQHmLr7BwZ2FmVJGHtWD-nUPMj32NljxYQ1Bzv0aYXmJhHT8lcmTcWxb8yQKhOk-S6oP7m3ftq-gzsmE4lATEAHFGtO9a_xJlNYivB0zMsOYfY7YJzRSYEgLCSxS4HiUysv3WYXYjAQaGJNoSJX1YMMvCDu1rt29oV17Td58wHWvnnsCFlckVah6y_DCfez9ucTpQPHsQMsW1Hwl-3xgndEyTuynTHZNgqCcxQWBFlo1Ay9HHl68ppFpxm7FvSScyTdjtMPD89qZ84P_V38Qlz9ye0J2LXWoH1np7jAnaRiEzc-_Dcra3Yv792ks_ZlLS3Tu9-m-iZiGILHxIaccR53BSbjjgKS7LXMPsWZ_kf4pBNspcIbnn1dm_L47sEKCeA_2J0BVQeG_x7ZXG38M100wreTadW_PE5WysYyFIbHy5_wvfVVIEPZ3cMFt66LjoFfAmn52kQUG2w65Nnr95bavMBNdKk9oo22QpRy3YJsrABp9DtUqh4CwCqZCu7KvD2yx5u6UKAOK-XWlU1UJ-dPxxcuoPsjeuG1ER8ySYexec7iXzg-tbKjeGGSnyj2z1fnTihIiQIw_CAiZwXuyD4e0zowAmjEF2RWRsWvacoU7n_TCFwx4dX5bEG41-J2KHGJVX1X9D2tBX7R963ICgP8xeoE5wxWEiQLrsED68PKsnMasLGW2oOtLR8DwERbydMYHRH2f63mexVE5gbdf_4UXpaYMC8bNUc3HWY3-Sb_Fbc46r","DataProtected":true} diff --git a/2-modular-monolith-architecture-style/src/Modules/Flight/src/AssemblyInfo.cs b/src/Services/Identity/src/Identity/AssemblyInfo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Flight/src/AssemblyInfo.cs rename to src/Services/Identity/src/Identity/AssemblyInfo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/AuthOptions.cs b/src/Services/Identity/src/Identity/Configurations/AuthOptions.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/AuthOptions.cs rename to src/Services/Identity/src/Identity/Configurations/AuthOptions.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/Config.cs b/src/Services/Identity/src/Identity/Configurations/Config.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity/Configurations/Config.cs rename to src/Services/Identity/src/Identity/Configurations/Config.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/UserValidator.cs b/src/Services/Identity/src/Identity/Configurations/UserValidator.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Configurations/UserValidator.cs rename to src/Services/Identity/src/Identity/Configurations/UserValidator.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/RoleClaimConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/RoleClaimConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/RoleClaimConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/RoleClaimConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/RoleConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/RoleConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/RoleConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/RoleConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserClaimConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/UserClaimConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserClaimConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/UserClaimConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/UserConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/UserConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserLoginConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/UserLoginConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserLoginConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/UserLoginConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserRoleConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/UserRoleConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserRoleConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/UserRoleConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserTokenConfiguration.cs b/src/Services/Identity/src/Identity/Data/Configurations/UserTokenConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Configurations/UserTokenConfiguration.cs rename to src/Services/Identity/src/Identity/Data/Configurations/UserTokenConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/DesignTimeDbContextFactory.cs b/src/Services/Identity/src/Identity/Data/DesignTimeDbContextFactory.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/DesignTimeDbContextFactory.cs rename to src/Services/Identity/src/Identity/Data/DesignTimeDbContextFactory.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/IdentityContext.cs b/src/Services/Identity/src/Identity/Data/IdentityContext.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/IdentityContext.cs rename to src/Services/Identity/src/Identity/Data/IdentityContext.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/20230331193410_initial.Designer.cs b/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.Designer.cs similarity index 99% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/20230331193410_initial.Designer.cs rename to src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.Designer.cs index 40c2889..c387439 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/20230331193410_initial.Designer.cs +++ b/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using Identity.Data; using Microsoft.EntityFrameworkCore; diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/20230331193410_initial.cs b/src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/20230331193410_initial.cs rename to src/Services/Identity/src/Identity/Data/Migrations/20230331193410_initial.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/IdentityContextModelSnapshot.cs b/src/Services/Identity/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs similarity index 99% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/IdentityContextModelSnapshot.cs rename to src/Services/Identity/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs index ce8faa3..c074464 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Migrations/IdentityContextModelSnapshot.cs +++ b/src/Services/Identity/src/Identity/Data/Migrations/IdentityContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using Identity.Data; using Microsoft.EntityFrameworkCore; diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Seed/IdentityDataSeeder.cs b/src/Services/Identity/src/Identity/Data/Seed/IdentityDataSeeder.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity/Data/Seed/IdentityDataSeeder.cs rename to src/Services/Identity/src/Identity/Data/Seed/IdentityDataSeeder.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Seed/InitialData.cs b/src/Services/Identity/src/Identity/Data/Seed/InitialData.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/Seed/InitialData.cs rename to src/Services/Identity/src/Identity/Data/Seed/InitialData.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/readme.md b/src/Services/Identity/src/Identity/Data/readme.md similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Data/readme.md rename to src/Services/Identity/src/Identity/Data/readme.md diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/IdentityServerExtensions.cs b/src/Services/Identity/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Extensions/Infrastructure/IdentityServerExtensions.cs rename to src/Services/Identity/src/Identity/Extensions/Infrastructure/IdentityServerExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/InfrastructureExtensions.cs b/src/Services/Identity/src/Identity/Extensions/Infrastructure/InfrastructureExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/InfrastructureExtensions.cs rename to src/Services/Identity/src/Identity/Extensions/Infrastructure/InfrastructureExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/MediatRExtensions.cs b/src/Services/Identity/src/Identity/Extensions/Infrastructure/MediatRExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity/Extensions/Infrastructure/MediatRExtensions.cs rename to src/Services/Identity/src/Identity/Extensions/Infrastructure/MediatRExtensions.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity.csproj b/src/Services/Identity/src/Identity/Identity.csproj similarity index 83% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity.csproj rename to src/Services/Identity/src/Identity/Identity.csproj index 546c9fa..18ea371 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity.csproj +++ b/src/Services/Identity/src/Identity/Identity.csproj @@ -12,7 +12,7 @@ - + diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Constants/Constants.cs b/src/Services/Identity/src/Identity/Identity/Constants/Constants.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Constants/Constants.cs rename to src/Services/Identity/src/Identity/Identity/Constants/Constants.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Exceptions/RegisterIdentityUserException.cs b/src/Services/Identity/src/Identity/Identity/Exceptions/RegisterIdentityUserException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Exceptions/RegisterIdentityUserException.cs rename to src/Services/Identity/src/Identity/Identity/Exceptions/RegisterIdentityUserException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Features/IdentityMappings.cs b/src/Services/Identity/src/Identity/Identity/Features/IdentityMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Features/IdentityMappings.cs rename to src/Services/Identity/src/Identity/Identity/Features/IdentityMappings.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs b/src/Services/Identity/src/Identity/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/src/Identity/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs rename to src/Services/Identity/src/Identity/Identity/Features/RegisteringNewUser/V1/RegisterNewUser.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/Role.cs b/src/Services/Identity/src/Identity/Identity/Models/Role.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/Role.cs rename to src/Services/Identity/src/Identity/Identity/Models/Role.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/RoleClaim.cs b/src/Services/Identity/src/Identity/Identity/Models/RoleClaim.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/RoleClaim.cs rename to src/Services/Identity/src/Identity/Identity/Models/RoleClaim.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/User.cs b/src/Services/Identity/src/Identity/Identity/Models/User.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/User.cs rename to src/Services/Identity/src/Identity/Identity/Models/User.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserClaim.cs b/src/Services/Identity/src/Identity/Identity/Models/UserClaim.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserClaim.cs rename to src/Services/Identity/src/Identity/Identity/Models/UserClaim.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserLogin.cs b/src/Services/Identity/src/Identity/Identity/Models/UserLogin.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserLogin.cs rename to src/Services/Identity/src/Identity/Identity/Models/UserLogin.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserRole.cs b/src/Services/Identity/src/Identity/Identity/Models/UserRole.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserRole.cs rename to src/Services/Identity/src/Identity/Identity/Models/UserRole.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserToken.cs b/src/Services/Identity/src/Identity/Identity/Models/UserToken.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/Identity/Models/UserToken.cs rename to src/Services/Identity/src/Identity/Identity/Models/UserToken.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/IdentityEventMapper.cs b/src/Services/Identity/src/Identity/IdentityEventMapper.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/IdentityEventMapper.cs rename to src/Services/Identity/src/Identity/IdentityEventMapper.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/IdentityRoot.cs b/src/Services/Identity/src/Identity/IdentityRoot.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/IdentityRoot.cs rename to src/Services/Identity/src/Identity/IdentityRoot.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Fakes/FakeRegisterNewUserCommand.cs b/src/Services/Identity/tests/IntegrationTest/Fakes/FakeRegisterNewUserCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/Fakes/FakeRegisterNewUserCommand.cs rename to src/Services/Identity/tests/IntegrationTest/Fakes/FakeRegisterNewUserCommand.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Identity/Features/RegisterNewUserTests.cs b/src/Services/Identity/tests/IntegrationTest/Identity/Features/RegisterNewUserTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Identity/Features/RegisterNewUserTests.cs rename to src/Services/Identity/tests/IntegrationTest/Identity/Features/RegisterNewUserTests.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/IdentityIntegrationTestBase.cs b/src/Services/Identity/tests/IntegrationTest/IdentityIntegrationTestBase.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/IdentityIntegrationTestBase.cs rename to src/Services/Identity/tests/IntegrationTest/IdentityIntegrationTestBase.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/IdentityTestDataSeeder.cs b/src/Services/Identity/tests/IntegrationTest/IdentityTestDataSeeder.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/IdentityTestDataSeeder.cs rename to src/Services/Identity/tests/IntegrationTest/IdentityTestDataSeeder.cs diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Integration.Test.csproj b/src/Services/Identity/tests/IntegrationTest/Integration.Test.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/tests/IntegrationTest/Integration.Test.csproj rename to src/Services/Identity/tests/IntegrationTest/Integration.Test.csproj diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/xunit.runner.json b/src/Services/Identity/tests/IntegrationTest/xunit.runner.json similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/tests/Integration.Test/xunit.runner.json rename to src/Services/Identity/tests/IntegrationTest/xunit.runner.json diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator-ignore b/src/Services/Identity/tests/PerformanceTest/.openapi-generator-ignore similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator-ignore rename to src/Services/Identity/tests/PerformanceTest/.openapi-generator-ignore diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator/FILES b/src/Services/Identity/tests/PerformanceTest/.openapi-generator/FILES similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/.openapi-generator/FILES rename to src/Services/Identity/tests/PerformanceTest/.openapi-generator/FILES diff --git a/src/Services/Identity/tests/PerformanceTest/.openapi-generator/VERSION b/src/Services/Identity/tests/PerformanceTest/.openapi-generator/VERSION new file mode 100644 index 0000000..6fc4f62 --- /dev/null +++ b/src/Services/Identity/tests/PerformanceTest/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0-SNAPSHOT diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/README.md b/src/Services/Identity/tests/PerformanceTest/README.md similarity index 100% rename from 3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/README.md rename to src/Services/Identity/tests/PerformanceTest/README.md diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/script.js b/src/Services/Identity/tests/PerformanceTest/script.js similarity index 99% rename from 3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/script.js rename to src/Services/Identity/tests/PerformanceTest/script.js index 2ed5474..6673179 100644 --- a/3-microservices-architecture-style/src/Services/Identity/tests/PerformanceTest/script.js +++ b/src/Services/Identity/tests/PerformanceTest/script.js @@ -3,7 +3,7 @@ * An example application with OpenAPI, Swashbuckle, and API versioning. * * OpenAPI spec version: 1.0 - * Contact: + * Contact: * * NOTE: This class is auto generated by OpenAPI Generator. * https://github.com/OpenAPITools/openapi-generator diff --git a/3-microservices-architecture-style/src/Services/Identity/tests/tests.sln b/src/Services/Identity/tests/tests.sln similarity index 99% rename from 3-microservices-architecture-style/src/Services/Identity/tests/tests.sln rename to src/Services/Identity/tests/tests.sln index 97000aa..ebf6612 100644 --- a/3-microservices-architecture-style/src/Services/Identity/tests/tests.sln +++ b/src/Services/Identity/tests/tests.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 diff --git a/src/Services/Passenger/Dockerfile b/src/Services/Passenger/Dockerfile new file mode 100644 index 0000000..b0af094 --- /dev/null +++ b/src/Services/Passenger/Dockerfile @@ -0,0 +1,47 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +# Setup working directory for the project +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Passenger/src/Passenger/Passenger.csproj ./src/Services/Passenger/src/Passenger/ +COPY ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./src/Services/Passenger/src/Passenger.Api/ + + +# Restore nuget packages +RUN dotnet restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Passenger/src/Passenger/ ./src/Services/Passenger/src/Passenger/ +COPY ./src/Services/Passenger/src/Passenger.Api/ ./src/Services/Passenger/src/Passenger.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN dotnet build -c Release --no-restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj + +WORKDIR /src/Services/Passenger/src/Passenger.Api + +# Publish project to output folder +# and no build, as we did it already +RUN dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Passenger/src/Passenger.Api/out . + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Passenger.Api.dll"] + diff --git a/src/Services/Passenger/dev.Dockerfile b/src/Services/Passenger/dev.Dockerfile new file mode 100644 index 0000000..0836f9d --- /dev/null +++ b/src/Services/Passenger/dev.Dockerfile @@ -0,0 +1,50 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS builder +WORKDIR / + +COPY ./.editorconfig ./ +COPY ./global.json ./ +COPY ./Directory.Build.props ./ + +# Setup working directory for the project +COPY ./building-blocks/BuildingBlocks.csproj ./building-blocks/ +COPY ./src/Services/Passenger/src/Passenger/Passenger.csproj ./src/Services/Passenger/src/Passenger/ +COPY ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj ./src/Services/Passenger/src/Passenger.Api/ + + +# Restore nuget packages +RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ + dotnet restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj + +# Copy project files +COPY ./building-blocks ./building-blocks/ +COPY ./src/Services/Passenger/src/Passenger/ ./src/Services/Passenger/src/Passenger/ +COPY ./src/Services/Passenger/src/Passenger.Api/ ./src/Services/Passenger/src/Passenger.Api/ + +# Build project with Release configuration +# and no restore, as we did it already + +RUN ls +RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ + dotnet build -c Release --no-restore ./src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj + +WORKDIR /src/Services/Passenger/src/Passenger.Api + +# Publish project to output folder +# and no build, as we did it already +RUN --mount=type=cache,id=passenger_nuget,target=/root/.nuget/packages \ + dotnet publish -c Release --no-build -o out + +FROM mcr.microsoft.com/dotnet/aspnet:9.0 + +# Setup working directory for the project +WORKDIR / +COPY --from=builder /src/Services/Passenger/src/Passenger.Api/out . + +ENV ASPNETCORE_URLS https://*:443, http://*:80 +ENV ASPNETCORE_ENVIRONMENT docker + +EXPOSE 80 +EXPOSE 443 + +ENTRYPOINT ["dotnet", "Passenger.Api.dll"] + diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj b/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj rename to src/Services/Passenger/src/Passenger.Api/Passenger.Api.csproj diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Program.cs b/src/Services/Passenger/src/Passenger.Api/Program.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Program.cs rename to src/Services/Passenger/src/Passenger.Api/Program.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json b/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json similarity index 98% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json rename to src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json index 0b36576..de89984 100644 --- a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json +++ b/src/Services/Passenger/src/Passenger.Api/Properties/launchSettings.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { "Passenger.Api": { diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.Development.json b/src/Services/Passenger/src/Passenger.Api/appsettings.Development.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.Development.json rename to src/Services/Passenger/src/Passenger.Api/appsettings.Development.json diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json b/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.docker.json rename to src/Services/Passenger/src/Passenger.Api/appsettings.docker.json diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.json b/src/Services/Passenger/src/Passenger.Api/appsettings.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.json rename to src/Services/Passenger/src/Passenger.Api/appsettings.json diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.test.json b/src/Services/Passenger/src/Passenger.Api/appsettings.test.json similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger.Api/appsettings.test.json rename to src/Services/Passenger/src/Passenger.Api/appsettings.test.json diff --git a/2-modular-monolith-architecture-style/src/Modules/Identity/src/AssemblyInfo.cs b/src/Services/Passenger/src/Passenger/AssemblyInfo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Identity/src/AssemblyInfo.cs rename to src/Services/Passenger/src/Passenger/AssemblyInfo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Configurations/PassengerConfiguration.cs b/src/Services/Passenger/src/Passenger/Data/Configurations/PassengerConfiguration.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Configurations/PassengerConfiguration.cs rename to src/Services/Passenger/src/Passenger/Data/Configurations/PassengerConfiguration.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/DesignTimeDbContextFactory.cs b/src/Services/Passenger/src/Passenger/Data/DesignTimeDbContextFactory.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/DesignTimeDbContextFactory.cs rename to src/Services/Passenger/src/Passenger/Data/DesignTimeDbContextFactory.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/20230611213031_initial.Designer.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs similarity index 99% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/20230611213031_initial.Designer.cs rename to src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs index d471cb8..5c8dd84 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/20230611213031_initial.Designer.cs +++ b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/20230611213031_initial.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/20230611213031_initial.cs rename to src/Services/Passenger/src/Passenger/Data/Migrations/20230611213031_initial.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/PassengerDbContextModelSnapshot.cs b/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs similarity index 99% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/PassengerDbContextModelSnapshot.cs rename to src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs index 122b184..0cc2772 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/Migrations/PassengerDbContextModelSnapshot.cs +++ b/src/Services/Passenger/src/Passenger/Data/Migrations/PassengerDbContextModelSnapshot.cs @@ -1,4 +1,4 @@ -// +// using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/PassengerDbContext.cs b/src/Services/Passenger/src/Passenger/Data/PassengerDbContext.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/PassengerDbContext.cs rename to src/Services/Passenger/src/Passenger/Data/PassengerDbContext.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/PassengerReadDbContext.cs b/src/Services/Passenger/src/Passenger/Data/PassengerReadDbContext.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/PassengerReadDbContext.cs rename to src/Services/Passenger/src/Passenger/Data/PassengerReadDbContext.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/readme.md b/src/Services/Passenger/src/Passenger/Data/readme.md similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Data/readme.md rename to src/Services/Passenger/src/Passenger/Data/readme.md diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidAgeException.cs b/src/Services/Passenger/src/Passenger/Exceptions/InvalidAgeException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidAgeException.cs rename to src/Services/Passenger/src/Passenger/Exceptions/InvalidAgeException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidNameException.cs b/src/Services/Passenger/src/Passenger/Exceptions/InvalidNameException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidNameException.cs rename to src/Services/Passenger/src/Passenger/Exceptions/InvalidNameException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidPassengerIdException.cs b/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassengerIdException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidPassengerIdException.cs rename to src/Services/Passenger/src/Passenger/Exceptions/InvalidPassengerIdException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidPassportNumberException.cs b/src/Services/Passenger/src/Passenger/Exceptions/InvalidPassportNumberException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/InvalidPassportNumberException.cs rename to src/Services/Passenger/src/Passenger/Exceptions/InvalidPassportNumberException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/PassengerAlreadyExist.cs b/src/Services/Passenger/src/Passenger/Exceptions/PassengerAlreadyExist.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/PassengerAlreadyExist.cs rename to src/Services/Passenger/src/Passenger/Exceptions/PassengerAlreadyExist.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/PassengerNotFoundException.cs b/src/Services/Passenger/src/Passenger/Exceptions/PassengerNotFoundException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Exceptions/PassengerNotFoundException.cs rename to src/Services/Passenger/src/Passenger/Exceptions/PassengerNotFoundException.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Extensions/Infrastructure/InfrastructureExtensions.cs b/src/Services/Passenger/src/Passenger/Extensions/Infrastructure/InfrastructureExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Extensions/Infrastructure/InfrastructureExtensions.cs rename to src/Services/Passenger/src/Passenger/Extensions/Infrastructure/InfrastructureExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Extensions/Infrastructure/MediatRExtensions.cs b/src/Services/Passenger/src/Passenger/Extensions/Infrastructure/MediatRExtensions.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Extensions/Infrastructure/MediatRExtensions.cs rename to src/Services/Passenger/src/Passenger/Extensions/Infrastructure/MediatRExtensions.cs diff --git a/3-microservices-architecture-style/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto b/src/Services/Passenger/src/Passenger/GrpcServer/Protos/passenger.proto similarity index 96% rename from 3-microservices-architecture-style/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto rename to src/Services/Passenger/src/Passenger/GrpcServer/Protos/passenger.proto index bb98c29..bc133d3 100644 --- a/3-microservices-architecture-style/src/Services/Booking/src/Booking/GrpcClient/Protos/passenger.proto +++ b/src/Services/Passenger/src/Passenger/GrpcServer/Protos/passenger.proto @@ -1,4 +1,4 @@ -syntax = "proto3"; +syntax = "proto3"; package passenger; diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/GrpcServer/Services/PassengerGrpcServices.cs b/src/Services/Passenger/src/Passenger/GrpcServer/Services/PassengerGrpcServices.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/GrpcServer/Services/PassengerGrpcServices.cs rename to src/Services/Passenger/src/Passenger/GrpcServer/Services/PassengerGrpcServices.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs b/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs rename to src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/PassengerCreatedDomainEvent.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs b/src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs rename to src/Services/Passenger/src/Passenger/Identity/Consumers/RegisteringNewUser/V1/RegisterNewUser.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passenger.csproj b/src/Services/Passenger/src/Passenger/Passenger.csproj similarity index 87% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passenger.csproj rename to src/Services/Passenger/src/Passenger/Passenger.csproj index 17488b9..b19c894 100644 --- a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passenger.csproj +++ b/src/Services/Passenger/src/Passenger/Passenger.csproj @@ -17,7 +17,7 @@ - + diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/PassengerEventMapper.cs b/src/Services/Passenger/src/Passenger/PassengerEventMapper.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/PassengerEventMapper.cs rename to src/Services/Passenger/src/Passenger/PassengerEventMapper.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/PassengerRoot.cs b/src/Services/Passenger/src/Passenger/PassengerRoot.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/PassengerRoot.cs rename to src/Services/Passenger/src/Passenger/PassengerRoot.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Dtos/PassengerDto.cs b/src/Services/Passenger/src/Passenger/Passengers/Dtos/PassengerDto.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Dtos/PassengerDto.cs rename to src/Services/Passenger/src/Passenger/Passengers/Dtos/PassengerDto.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Enums/PassengerType.cs b/src/Services/Passenger/src/Passenger/Passengers/Enums/PassengerType.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Enums/PassengerType.cs rename to src/Services/Passenger/src/Passenger/Passengers/Enums/PassengerType.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/InvalidAgeException.cs b/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/InvalidAgeException.cs rename to src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidAgeException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/InvalidNameException.cs b/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidNameException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/InvalidNameException.cs rename to src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidNameException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/InvalidPassportNumberException.cs b/src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/InvalidPassportNumberException.cs rename to src/Services/Passenger/src/Passenger/Passengers/Exceptions/InvalidPassportNumberException.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/PassengerAlreadyExist.cs b/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/PassengerAlreadyExist.cs rename to src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerAlreadyExist.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/PassengerNotFoundException.cs b/src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Exceptions/PassengerNotFoundException.cs rename to src/Services/Passenger/src/Passenger/Passengers/Exceptions/PassengerNotFoundException.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs b/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs rename to src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassenger.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs b/src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs rename to src/Services/Passenger/src/Passenger/Passengers/Features/CompletingRegisterPassenger/V1/CompleteRegisterPassengerMongo.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs b/src/Services/Passenger/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs rename to src/Services/Passenger/src/Passenger/Passengers/Features/GettingPassengerById/V1/GetPassengerById.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/PassengerMappings.cs b/src/Services/Passenger/src/Passenger/Passengers/Features/PassengerMappings.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Features/PassengerMappings.cs rename to src/Services/Passenger/src/Passenger/Passengers/Features/PassengerMappings.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Models/Passenger.cs b/src/Services/Passenger/src/Passenger/Passengers/Models/Passenger.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Models/Passenger.cs rename to src/Services/Passenger/src/Passenger/Passengers/Models/Passenger.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Models/PassengerReadModel.cs b/src/Services/Passenger/src/Passenger/Passengers/Models/PassengerReadModel.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/Models/PassengerReadModel.cs rename to src/Services/Passenger/src/Passenger/Passengers/Models/PassengerReadModel.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/Age.cs b/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Age.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/Age.cs rename to src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Age.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/Name.cs b/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Name.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/Name.cs rename to src/Services/Passenger/src/Passenger/Passengers/ValueObjects/Name.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/PassengerId.cs b/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassengerId.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/PassengerId.cs rename to src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassengerId.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/PassportNumber.cs b/src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassportNumber.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/src/Passengers/ValueObjects/PassportNumber.cs rename to src/Services/Passenger/src/Passenger/Passengers/ValueObjects/PassportNumber.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Fakes/FakeCompleteRegisterPassengerCommand.cs b/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Fakes/FakeCompleteRegisterPassengerCommand.cs rename to src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs b/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs rename to src/Services/Passenger/tests/IntegrationTest/Fakes/FakeCompleteRegisterPassengerMongoCommand.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Fakes/FakeUserCreated.cs b/src/Services/Passenger/tests/IntegrationTest/Fakes/FakeUserCreated.cs similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/Fakes/FakeUserCreated.cs rename to src/Services/Passenger/tests/IntegrationTest/Fakes/FakeUserCreated.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Integration.Test.csproj b/src/Services/Passenger/tests/IntegrationTest/Integration.Test.csproj similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Integration.Test.csproj rename to src/Services/Passenger/tests/IntegrationTest/Integration.Test.csproj diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Passenger/Features/CompleteRegisterPassengerTests.cs b/src/Services/Passenger/tests/IntegrationTest/Passenger/Features/CompleteRegisterPassengerTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Passenger/Features/CompleteRegisterPassengerTests.cs rename to src/Services/Passenger/tests/IntegrationTest/Passenger/Features/CompleteRegisterPassengerTests.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Passenger/Features/GetPassengerByIdTests.cs b/src/Services/Passenger/tests/IntegrationTest/Passenger/Features/GetPassengerByIdTests.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/Passenger/Features/GetPassengerByIdTests.cs rename to src/Services/Passenger/tests/IntegrationTest/Passenger/Features/GetPassengerByIdTests.cs diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/PassengerIntegrationTestBase.cs b/src/Services/Passenger/tests/IntegrationTest/PassengerIntegrationTestBase.cs similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/IntegrationTest/PassengerIntegrationTestBase.cs rename to src/Services/Passenger/tests/IntegrationTest/PassengerIntegrationTestBase.cs diff --git a/2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/xunit.runner.json b/src/Services/Passenger/tests/IntegrationTest/xunit.runner.json similarity index 100% rename from 2-modular-monolith-architecture-style/src/Modules/Passenger/tests/Integration.Test/xunit.runner.json rename to src/Services/Passenger/tests/IntegrationTest/xunit.runner.json diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator-ignore b/src/Services/Passenger/tests/PerformanceTest/.openapi-generator-ignore similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator-ignore rename to src/Services/Passenger/tests/PerformanceTest/.openapi-generator-ignore diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/FILES b/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/FILES similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/FILES rename to src/Services/Passenger/tests/PerformanceTest/.openapi-generator/FILES diff --git a/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/VERSION b/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/VERSION new file mode 100644 index 0000000..6fc4f62 --- /dev/null +++ b/src/Services/Passenger/tests/PerformanceTest/.openapi-generator/VERSION @@ -0,0 +1 @@ +6.6.0-SNAPSHOT diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/README.md b/src/Services/Passenger/tests/PerformanceTest/README.md similarity index 100% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/README.md rename to src/Services/Passenger/tests/PerformanceTest/README.md diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/script.js b/src/Services/Passenger/tests/PerformanceTest/script.js similarity index 99% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/script.js rename to src/Services/Passenger/tests/PerformanceTest/script.js index e99a85f..6065441 100644 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/PerformanceTest/script.js +++ b/src/Services/Passenger/tests/PerformanceTest/script.js @@ -3,7 +3,7 @@ * An example application with OpenAPI, Swashbuckle, and API versioning. * * OpenAPI spec version: 1.0 - * Contact: + * Contact: * * NOTE: This class is auto generated by OpenAPI Generator. * https://github.com/OpenAPITools/openapi-generator diff --git a/3-microservices-architecture-style/src/Services/Passenger/tests/tests.sln b/src/Services/Passenger/tests/tests.sln similarity index 99% rename from 3-microservices-architecture-style/src/Services/Passenger/tests/tests.sln rename to src/Services/Passenger/tests/tests.sln index 00ced03..6685cc5 100644 --- a/3-microservices-architecture-style/src/Services/Passenger/tests/tests.sln +++ b/src/Services/Passenger/tests/tests.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59