From 89ee49792219ca504ef696814421c0ffab9dbb5c Mon Sep 17 00:00:00 2001 From: Mehdi Hadeli Date: Wed, 9 Aug 2023 00:13:18 +0330 Subject: [PATCH] ci: :construction_worker: some changes in ci and formating code (#69) --- .github/workflows/ci.yml | 46 +- .github/workflows/golangci-lint.yml | 16 +- Makefile | 128 ++-- api/openapi/.gitkeep | 0 api/openapi/catalog_read_service/docs.go | 252 +++++++ api/openapi/catalog_read_service/swagger.json | 225 ++++++ api/openapi/catalog_read_service/swagger.yaml | 144 ++++ api/openapi/catalog_write_service/docs.go | 380 ++++++++++ .../catalog_write_service/swagger.json | 353 ++++++++++ .../catalog_write_service/swagger.yaml | 228 ++++++ api/openapi/order_service/docs.go | 315 +++++++++ api/openapi/order_service/swagger.json | 288 ++++++++ api/openapi/order_service/swagger.yaml | 186 +++++ .../catalog_write_service}/products.proto | 0 api/{proto => protobuf}/common.proto | 0 .../order_service}/orders.proto | 0 internal/pkg/bun/postgres/bun_postgres.go | 18 +- internal/pkg/core/custom_types/custom_time.go | 2 - internal/pkg/core/data/generic_repository.go | 8 +- internal/pkg/core/domain/entity.go | 9 +- .../pkg/es/contracts/projection/projection.go | 6 +- .../projection/projection_publisher.go | 6 +- .../pkg/es/contracts/store/aggregate_store.go | 20 +- .../pkg/es/contracts/store/event_store.go | 14 +- internal/pkg/es/errors/errors.go | 8 +- ...mory_subscription_checkpoint_repository.go | 6 +- internal/pkg/es/models/stream_event.go | 6 +- .../errors/aggregate_not_found_error.go | 8 +- .../errors/append_to_stream_error.go | 36 +- .../errors/delete_stream_error.go | 2 - .../eventstroredb/errors/read_stream_error.go | 4 +- .../errors/stream_not_found_error.go | 6 +- .../errors/truncate_stream_error.go | 36 +- .../repository/gorm_generic_repository.go | 83 ++- .../gorm_generic_repository_test.go | 47 +- .../pkg/grpc/grpcErrors/custom_grpc_errors.go | 150 ++-- .../pkg/grpc/grpcErrors/grpc_error_parser.go | 23 +- .../grpc_error/error_interceptor.go | 94 +-- .../request_status_interceptor.go | 10 +- internal/pkg/grpc/otel/tracing/utils.go | 52 +- internal/pkg/http/client/http_client.go | 3 +- .../http/custom_echo/otel/tracing/utils.go | 16 +- .../http/http_errors/contracts/contracts.go | 3 +- .../custom_errors/bad_request_error.go | 5 +- .../custom_errors/conflict_error.go | 3 +- .../custom_errors/custom_errors.go | 8 +- .../custom_errors/custom_errors_test.go | 18 +- .../custom_errors/forbiden_error.go | 3 +- .../custom_errors/internal_server_error.go | 3 +- .../custom_errors/not_found_error.go | 3 +- .../custom_errors/unauthorized_error.go | 3 +- .../custom_problem_details_errors.go | 170 ++--- .../problemDetails/problem_detail_parser.go | 27 +- .../problemDetails/problem_details_test.go | 10 +- internal/pkg/mapper/mapper.go | 32 +- .../messaging/consumer/consumer_handler.go | 6 +- .../metadata_message_extentions.go | 4 +- .../otel/tracing/consumer/consumer.go | 48 +- .../otel/tracing/producer/producer.go | 50 +- internal/pkg/messaging/otel/tracing/utils.go | 50 +- .../messaging/pipeline/consumer_pipeline.go | 6 +- ...consumer_pipeline_configuration_builder.go | 4 +- .../types/message_consume_context.go | 83 ++- internal/pkg/migrate/mongo.go | 2 +- internal/pkg/migrate/postgres.go | 12 +- .../repository/mongo_generic_repository.go | 95 ++- .../mongo_generic_repository_test.go | 69 +- internal/pkg/otel/tracing/utils.go | 24 +- internal/pkg/postgres_pgx/interface.go | 16 +- .../reflection_helper_test.go | 3 +- .../type_mappper/type_mapper_test.go | 3 +- .../dockertest/gorm/gorm_container.go | 47 +- .../dockertest/gorm/gorm_container_test.go | 3 +- .../dockertest/mongo/mongo_container.go | 51 +- .../containers/gnomock/gorm/gorm_container.go | 25 +- .../eventstoredb/eventstoredb_container.go | 2 +- .../testcontainer/gorm/gorm_container_test.go | 3 +- .../mongo/mongo_container_test.go | 3 +- .../redis/redis_container_test.go | 3 +- internal/pkg/test/hypothesis/hypothesis.go | 2 - .../pkg/testfixture/postgres_testfixture.go | 3 +- internal/pkg/utils/error_utils/errors.go | 17 +- internal/pkg/utils/error_utils/errors_test.go | 5 +- .../catalog_read_service/cmd/app/main.go | 2 + .../config/config.test.json | 2 +- .../catalog_read_service/docs/docs.go | 84 ++- .../catalog_read_service/docs/swagger.json | 78 ++- .../catalog_read_service/docs/swagger.yaml | 63 +- internal/services/catalog_read_service/go.mod | 6 +- internal/services/catalog_read_service/go.sum | 4 +- .../v1/commands/create_product.go | 17 +- .../v1/dtos/search_products_request_dto.go | 2 +- .../v1/commands/update_product.go | 11 +- .../external_events/product_updated.go | 16 +- .../products_service_client.pb.go | 650 ------------------ .../products_service_client_grpc.pb.go | 175 ----- .../internal/products/models/product.go | 18 +- .../mocks/ProductsServiceClient.go | 250 ------- .../mocks/ProductsServiceServer.go | 202 ------ .../catalog_write_service/cmd/app/main.go | 2 + .../config/config.test.json | 2 +- .../catalog_write_service/docs/docs.go | 100 ++- .../catalog_write_service/docs/swagger.json | 94 ++- .../catalog_write_service/docs/swagger.yaml | 85 ++- .../services/catalog_write_service/go.mod | 2 +- .../services/catalog_write_service/go.sum | 4 +- .../mappings/mapping_profile.go | 6 +- .../products_module_configurator.go | 13 +- .../internal/products/dto/v1/product_dto.go | 3 +- .../v1/commands/create_product.go | 8 +- .../v1/dtos/delete_product_request_dto.go | 2 +- .../v1/dtos/get_products_request_dto.go | 6 +- .../v1/dtos/search_products_request_dto.go | 2 +- .../v1/commands/update_product.go | 8 +- .../v1/dtos/update_product_request_dto.go | 2 +- .../internal/products/products_fx.go | 2 +- .../internal/shared/app/test/test_app.go | 9 +- .../grpc/genproto/products.pb.go} | 239 ++++--- .../grpc/genproto/products_grpc.pb.go} | 26 +- .../grpc/product_grpc_service_server.go | 4 +- .../integration/integration_test_fixture.go | 2 +- .../unit_test/unit_test_fixture.go | 17 +- .../mocks/ProductsServiceClient.go | 62 +- .../mocks/ProductsServiceServer.go | 63 +- .../grpc/product_grpc_service_server_test.go | 2 +- .../get_product_by_id_handler_unit_test.go | 3 +- .../update_product_handler_unit_test.go | 45 -- .../services/order_service/cmd/app/main.go | 2 + .../order_service/config/config.test.json | 4 +- internal/services/order_service/docs/docs.go | 133 ++-- .../services/order_service/docs/swagger.json | 127 ++-- .../services/order_service/docs/swagger.yaml | 87 ++- internal/services/order_service/go.mod | 2 +- internal/services/order_service/go.sum | 4 +- .../mappings/mappings_profile.go | 3 +- .../orders_module_configurator.go | 15 +- .../internal/orders/dtos/v1/order_dto.go | 3 +- .../order_domain_errors_test.go | 8 +- .../order_not_found_error.go | 6 +- .../endpoints/getting_orders_endpoint_test.go | 27 - .../v1/queries/get_orders_handler_test.go | 40 -- .../models/orders/read_models/order_read.go | 43 +- .../orders/read_models/shop_item_read.go | 6 +- .../internal/shared/app/test/test_app.go | 13 +- .../grpc/genproto/orders.pb.go} | 547 ++++++++------- .../grpc/genproto/orders_grpc.pb.go} | 36 +- .../grpc/order_grpc_service_server.go | 6 +- .../grpc/order_grpc_service_server_test.go | 2 +- .../integration/integration_test_fixture.go | 15 +- .../mocks/OrdersServiceClient.go | 2 +- .../mocks/OrdersServiceServer.go | 3 +- .../creating_order/v1/create_order_test.go | 5 +- .../v1/get_order_by_id_test.go | 3 + .../v1/get_order_by_id_test.go | 3 + scripts/.gitkeep | 0 scripts/build-docker.sh | 6 +- scripts/build.sh | 9 +- scripts/format.sh | 11 +- scripts/install-dependencies.sh | 17 + scripts/install-tools.sh | 14 +- scripts/k6-generator.sh | 1 + scripts/lint.sh | 4 + scripts/openapi.sh | 2 + scripts/proto.sh | 13 +- scripts/run.sh | 5 +- scripts/test.sh | 6 +- taskfile.yml | 113 ++- taskfile_test.yml | 33 - 168 files changed, 4794 insertions(+), 3139 deletions(-) delete mode 100644 api/openapi/.gitkeep create mode 100644 api/openapi/catalog_read_service/docs.go create mode 100644 api/openapi/catalog_read_service/swagger.json create mode 100644 api/openapi/catalog_read_service/swagger.yaml create mode 100644 api/openapi/catalog_write_service/docs.go create mode 100644 api/openapi/catalog_write_service/swagger.json create mode 100644 api/openapi/catalog_write_service/swagger.yaml create mode 100644 api/openapi/order_service/docs.go create mode 100644 api/openapi/order_service/swagger.json create mode 100644 api/openapi/order_service/swagger.yaml rename api/{proto/catalogs => protobuf/catalog_write_service}/products.proto (100%) rename api/{proto => protobuf}/common.proto (100%) rename api/{proto/orders => protobuf/order_service}/orders.proto (100%) delete mode 100644 internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go delete mode 100644 internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go delete mode 100644 internal/services/catalog_read_service/mocks/ProductsServiceClient.go delete mode 100644 internal/services/catalog_read_service/mocks/ProductsServiceServer.go rename internal/services/catalog_write_service/internal/{products/grpc/proto/service_clients/products_service_client.pb.go => shared/grpc/genproto/products.pb.go} (52%) rename internal/services/catalog_write_service/internal/{products/grpc/proto/service_clients/products_service_client_grpc.pb.go => shared/grpc/genproto/products_grpc.pb.go} (87%) rename internal/services/catalog_write_service/internal/{products => shared}/grpc/product_grpc_service_server.go (98%) delete mode 100644 internal/services/order_service/internal/orders/features/getting_orders/v1/endpoints/getting_orders_endpoint_test.go delete mode 100644 internal/services/order_service/internal/orders/features/getting_orders/v1/queries/get_orders_handler_test.go rename internal/services/order_service/internal/{orders/contracts/proto/service_clients/orders_service_client.pb.go => shared/grpc/genproto/orders.pb.go} (55%) rename internal/services/order_service/internal/{orders/contracts/proto/service_clients/orders_service_client_grpc.pb.go => shared/grpc/genproto/orders_grpc.pb.go} (86%) rename internal/services/order_service/internal/{orders => shared}/grpc/order_grpc_service_server.go (98%) rename internal/services/order_service/internal/{orders => shared}/grpc/order_grpc_service_server_test.go (99%) delete mode 100644 scripts/.gitkeep create mode 100644 scripts/install-dependencies.sh delete mode 100644 taskfile_test.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 126c4969..1e3fb777 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,13 +2,19 @@ name: CI on: push: - branches: ["main", "develop"] + branches: ["main"] + paths-ignore: [ "*.md", "docs", "deploy", "config", ".github", "scripts" ] + pull_request: - branches: ["main", "develop"] + branches: ["main"] + paths-ignore: [ "*.md", "docs", "deploy", "config", ".github", "scripts" ] jobs: - build: + build-test: runs-on: ubuntu-latest + if: | + contains(github.event.commits[0].message, '[skip ci]') == false && + contains(github.event.commits[0].message, '[ci skip]') == false steps: - uses: actions/checkout@v3 @@ -17,25 +23,33 @@ jobs: uses: actions/setup-go@v3 with: go-version: 1.20.x + id: go + + - name: Cache go modules + id: cache + uses: actions/cache@preview + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install Dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: make install-dependencies # https://pkg.go.dev/cmd/go#hdr-Compile_packages_and_dependencies # https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns - name: Build - run: go build -v ./... + run: make build # https://go.dev/doc/articles/race_detector # https://dev.to/s0xzwasd/run-tests-with-race-flag-in-goland-512j - - name: Building-Blocks Tests - run: go test -v ./... -race - - - name: Catalogs Write Service Tests - working-directory: ./services/catalogs_write/catalogs_write - run: go test -v ./... -race + - name: Unit Tests + run: make unit-test - - name: Catalogs Read Service Tests - working-directory: ./services/catalogs_write/catalogs_read - run: go test -v ./... -race + - name: Integration Tests + run: make integration-test - - name: Order Service Tests - working-directory: ./services/orders - run: go test -v ./... -race + - name: End-To-End Tests + run: make e2e-test diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 3377886c..29730109 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,7 +4,6 @@ on: tags: - v* branches: - - develop - main pull_request: permissions: @@ -16,15 +15,22 @@ jobs: name: lint runs-on: ubuntu-latest steps: + - uses: actions/checkout@v3 + + # https://github.com/actions/setup-go/issues/326 - uses: actions/setup-go@v3 with: - go-version: '1.19' - - uses: actions/checkout@v3 + go-version: 1.20.x + + - name: Get dependencies + run: make install-dependencies + - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.29 + version: latest + skip-pkg-cache: true + skip-build-cache: true # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/Makefile b/Makefile index b560ca4f..c54476af 100644 --- a/Makefile +++ b/Makefile @@ -1,85 +1,93 @@ .PHONY: install-tools install-tools: - ./scripts/install-tools.sh + @./scripts/install-tools.sh -.PHONY: run -run: - @./scripts/run.sh catalogs_write - @./scripts/run.sh catalogs_read - @./scripts/run.sh orders +.PHONY: run-catalogs-write-service +run-catalogs-write-service: + @./scripts/run.sh catalog_write_service +.PHONY: run-catalog-read-service +run-catalog-read-service: + @./scripts/run.sh catalog_read_service + +.PHONY: run-order-service +run-order-service: + @./scripts/run.sh order_service .PHONY: build build: - @./scripts/build.sh catalogs_write - @./scripts/build.sh catalogs_read - @./scripts/build.sh orders + @./scripts/build.sh pkg + @./scripts/build.sh catalog_write_service + @./scripts/build.sh catalog_read_service + @./scripts/build.sh order_service +.PHONY: install-dependencies +install-dependencies: + @./scripts/install-dependencies.sh pkg + @./scripts/install-dependencies.sh catalog_write_service + @./scripts/install-dependencies.sh catalog_read_service + @./scripts/install-dependencies.sh order_service -.PHONY: docker -docker-compose_infra_up: - @echo Starting infrastructure docker-compose - docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml up --build +.PHONY: docker-compose-infra-up +docker-compose-infra-up: + @docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml up --build -d -docker-compose_infra_down: - @echo Stoping infrastructure docker-compose - docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml down +docker-compose-infra-down: + @docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml down .PHONY: openapi openapi: - @./scripts/openapi.sh catalogs_write - @./scripts/openapi.sh catalogs_read - @./scripts/openapi.sh orders + @./scripts/openapi.sh catalog_write_service + @./scripts/openapi.sh catalog_read_service + @./scripts/openapi.sh order_service +# https://stackoverflow.com/questions/13616033/install-protocol-buffers-on-windows .PHONY: proto proto: - @./scripts/proto.sh catalogs_write - @./scripts/proto.sh catalogs_read - @./scripts/proto.sh orders - -.PHONY: unit_test -unit_test: - @./scripts/test.sh catalogs_write unit - @./scripts/test.sh catalogs_read unit - @./scripts/test.sh orders unit - @./scripts/test.sh pkg unit - -.PHONY: integration_test -integration_test: - @./scripts/test.sh catalogs_write integration - @./scripts/test.sh catalogs_read integration - @./scripts/test.sh orders integration - @./scripts/test.sh pkg integration - -.PHONY: e2e_test -e2e_test: - @./scripts/test.sh catalogs_write e2e - @./scripts/test.sh catalogs_read e2e - @./scripts/test.sh orders e2e - -.PHONY: load_test -load_test: - @./scripts/test.sh catalogs_write load-test - @./scripts/test.sh catalogs_read load-test - @./scripts/test.sh orders load-test + @./scripts/proto.sh catalog_write_service + @./scripts/proto.sh order_service + +.PHONY: unit-test +unit-test: + @./scripts/test.sh catalog_write_service unit + @./scripts/test.sh catalog_read_service unit + @./scripts/test.sh order_service unit + +.PHONY: integration-test +integration-test: + @./scripts/test.sh catalog_write_service integration + @./scripts/test.sh catalog_read_service integration + @./scripts/test.sh order_service integration + +.PHONY: e2e-test +e2e-test: + @./scripts/test.sh catalog_write_service e2e + @./scripts/test.sh catalog_read_service e2e + @./scripts/test.sh order_service e2e + +#.PHONY: load-test +#load-test: +# @./scripts/test.sh catalogs_write load-test +# @./scripts/test.sh catalogs_read load-test +# @./scripts/test.sh orders load-test .PHONY: format format: - @./scripts/format.sh catalogs_write - @./scripts/format.sh catalogs_read - @./scripts/format.sh orders + @./scripts/format.sh catalog_write_service + @./scripts/format.sh catalog_read_service + @./scripts/format.sh order_service @./scripts/format.sh pkg .PHONY: lint lint: - @./scripts/lint.sh catalogs_write - @./scripts/lint.sh catalogs_read - @./scripts/lint.sh orders + @./scripts/lint.sh catalog_write_service + @./scripts/lint.sh catalog_read_service + @./scripts/lint.sh order_service @./scripts/lint.sh pkg -.PHONY: c4 -c4: - cd tools/c4 && go mod tidy && sh generate.sh +#.PHONY: c4 +#c4: +# cd tools/c4 && go mod tidy && sh generate.sh # https://medium.com/yemeksepeti-teknoloji/mocking-an-interface-using-mockery-in-go-afbcb83cc773 # https://vektra.github.io/mockery/latest/running/ @@ -92,6 +100,6 @@ pkg-mocks: .PHONY: services-mocks services-mocks: - cd internal/services/catalogs_write && mockery --output mocks --all - cd internal/services/catalogs_read && mockery --output mocks --all - cd internal/services/orders && mockery --output mocks --all + cd internal/services/catalog_write_service && mockery --output mocks --all + cd internal/services/catalog_read_service && mockery --output mocks --all + cd internal/services/order_service && mockery --output mocks --all diff --git a/api/openapi/.gitkeep b/api/openapi/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/api/openapi/catalog_read_service/docs.go b/api/openapi/catalog_read_service/docs.go new file mode 100644 index 00000000..1c44e7b8 --- /dev/null +++ b/api/openapi/catalog_read_service/docs.go @@ -0,0 +1,252 @@ +// Code generated by swaggo/swag. DO NOT EDIT. + +package catalog_read_service + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": { + "name": "Mehdi Hadeli", + "url": "https://github.com/mehdihadeli" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/v1/products": { + "get": { + "description": "Get all products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get all product", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/search": { + "get": { + "description": "Search products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Search products", + "parameters": [ + { + "type": "string", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/{id}": { + "get": { + "description": "Get product by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto" + } + } + } + } + } + }, + "definitions": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "productId": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto": { + "type": "object", + "properties": { + "product": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "Catalogs Read-Service Api", + Description: "Catalogs Read-Service Api.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/api/openapi/catalog_read_service/swagger.json b/api/openapi/catalog_read_service/swagger.json new file mode 100644 index 00000000..f26438f3 --- /dev/null +++ b/api/openapi/catalog_read_service/swagger.json @@ -0,0 +1,225 @@ +{ + "swagger": "2.0", + "info": { + "description": "Catalogs Read-Service Api.", + "title": "Catalogs Read-Service Api", + "contact": { + "name": "Mehdi Hadeli", + "url": "https://github.com/mehdihadeli" + }, + "version": "1.0" + }, + "paths": { + "/api/v1/products": { + "get": { + "description": "Get all products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get all product", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/search": { + "get": { + "description": "Search products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Search products", + "parameters": [ + { + "type": "string", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/{id}": { + "get": { + "description": "Get product by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto" + } + } + } + } + } + }, + "definitions": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "productId": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto": { + "type": "object", + "properties": { + "product": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/api/openapi/catalog_read_service/swagger.yaml b/api/openapi/catalog_read_service/swagger.yaml new file mode 100644 index 00000000..b4c11854 --- /dev/null +++ b/api/openapi/catalog_read_service/swagger.yaml @@ -0,0 +1,144 @@ +definitions: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto: + properties: + createdAt: + type: string + description: + type: string + id: + type: string + name: + type: string + price: + type: number + productId: + type: string + updatedAt: + type: string + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto + : properties: + product: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto + : properties: + products: + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto + : properties: + products: + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto' + type: object + utils.FilterModel: + properties: + comparison: + type: string + field: + type: string + value: + type: string + type: object + utils.ListQuery: + properties: + filters: + items: + $ref: '#/definitions/utils.FilterModel' + type: array + orderBy: + type: string + page: + type: integer + size: + type: integer + type: object + ? utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto + : properties: + items: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto' + type: array + page: + type: integer + size: + type: integer + totalItems: + type: integer + totalPage: + type: integer + type: object +info: + contact: + name: Mehdi Hadeli + url: https://github.com/mehdihadeli + description: Catalogs Read-Service Api. + title: Catalogs Read-Service Api + version: "1.0" +paths: + /api/v1/products: + get: + consumes: + - application/json + description: Get all products + parameters: + - in: query + name: orderBy + type: string + - in: query + name: page + type: integer + - in: query + name: size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto' + summary: Get all product + tags: + - Products + /api/v1/products/{id}: + get: + consumes: + - application/json + description: Get product by id + parameters: + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto' + summary: Get product + tags: + - Products + /api/v1/products/search: + get: + consumes: + - application/json + description: Search products + parameters: + - in: query + name: search + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto' + summary: Search products + tags: + - Products +swagger: "2.0" diff --git a/api/openapi/catalog_write_service/docs.go b/api/openapi/catalog_write_service/docs.go new file mode 100644 index 00000000..5f8aa576 --- /dev/null +++ b/api/openapi/catalog_write_service/docs.go @@ -0,0 +1,380 @@ +// Code generated by swaggo/swag. DO NOT EDIT. + +package catalog_write_service + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": { + "name": "Mehdi Hadeli", + "url": "https://github.com/mehdihadeli" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/v1/products": { + "get": { + "description": "Get all products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get all product", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" + } + } + } + }, + "post": { + "description": "Create new product item", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Create product", + "parameters": [ + { + "description": "Product data", + "name": "CreateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto" + } + } + } + } + }, + "/api/v1/products/search": { + "get": { + "description": "Search products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Search products", + "parameters": [ + { + "type": "string", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/{id}": { + "get": { + "description": "Get product by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get product by id", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto" + } + } + } + }, + "put": { + "description": "Update existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Update product", + "parameters": [ + { + "description": "Product data", + "name": "UpdateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto" + } + }, + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + }, + "delete": { + "description": "Delete existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Delete product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "definitions": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "productId": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto": { + "type": "object", + "properties": { + "productId": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto": { + "type": "object", + "properties": { + "product": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "Catalogs Write-Service Api", + Description: "Catalogs Write-Service Api.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/api/openapi/catalog_write_service/swagger.json b/api/openapi/catalog_write_service/swagger.json new file mode 100644 index 00000000..87ed034e --- /dev/null +++ b/api/openapi/catalog_write_service/swagger.json @@ -0,0 +1,353 @@ +{ + "swagger": "2.0", + "info": { + "description": "Catalogs Write-Service Api.", + "title": "Catalogs Write-Service Api", + "contact": { + "name": "Mehdi Hadeli", + "url": "https://github.com/mehdihadeli" + }, + "version": "1.0" + }, + "paths": { + "/api/v1/products": { + "get": { + "description": "Get all products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get all product", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" + } + } + } + }, + "post": { + "description": "Create new product item", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Create product", + "parameters": [ + { + "description": "Product data", + "name": "CreateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto" + } + } + } + } + }, + "/api/v1/products/search": { + "get": { + "description": "Search products", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Search products", + "parameters": [ + { + "type": "string", + "name": "search", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto" + } + } + } + } + }, + "/api/v1/products/{id}": { + "get": { + "description": "Get product by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Get product by id", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto" + } + } + } + }, + "put": { + "description": "Update existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Update product", + "parameters": [ + { + "description": "Product data", + "name": "UpdateProductRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto" + } + }, + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + }, + "delete": { + "description": "Delete existing product", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Products" + ], + "summary": "Delete product", + "parameters": [ + { + "type": "string", + "description": "Product ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "definitions": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto": { + "type": "object", + "properties": { + "createdAt": { + "type": "string" + }, + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "productId": { + "type": "string" + }, + "updatedAt": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto": { + "type": "object", + "properties": { + "productId": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto": { + "type": "object", + "properties": { + "product": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto": { + "type": "object", + "properties": { + "products": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/api/openapi/catalog_write_service/swagger.yaml b/api/openapi/catalog_write_service/swagger.yaml new file mode 100644 index 00000000..3427a1bf --- /dev/null +++ b/api/openapi/catalog_write_service/swagger.yaml @@ -0,0 +1,228 @@ +definitions: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto: + properties: + createdAt: + type: string + description: + type: string + name: + type: string + price: + type: number + productId: + type: string + updatedAt: + type: string + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto + : properties: + description: + type: string + name: + type: string + price: + type: number + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto + : properties: + productId: + type: string + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto + : properties: + product: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto + : properties: + products: + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto + : properties: + products: + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto + : properties: + description: + type: string + name: + type: string + price: + type: number + type: object + utils.FilterModel: + properties: + comparison: + type: string + field: + type: string + value: + type: string + type: object + utils.ListQuery: + properties: + filters: + items: + $ref: '#/definitions/utils.FilterModel' + type: array + orderBy: + type: string + page: + type: integer + size: + type: integer + type: object + ? utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto + : properties: + items: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto' + type: array + page: + type: integer + size: + type: integer + totalItems: + type: integer + totalPage: + type: integer + type: object +info: + contact: + name: Mehdi Hadeli + url: https://github.com/mehdihadeli + description: Catalogs Write-Service Api. + title: Catalogs Write-Service Api + version: "1.0" +paths: + /api/v1/products: + get: + consumes: + - application/json + description: Get all products + parameters: + - in: query + name: orderBy + type: string + - in: query + name: page + type: integer + - in: query + name: size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto' + summary: Get all product + tags: + - Products + post: + consumes: + - application/json + description: Create new product item + parameters: + - description: Product data + in: body + name: CreateProductRequestDto + required: true + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto' + summary: Create product + tags: + - Products + /api/v1/products/{id}: + delete: + consumes: + - application/json + description: Delete existing product + parameters: + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + summary: Delete product + tags: + - Products + get: + consumes: + - application/json + description: Get product by id + parameters: + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto' + summary: Get product by id + tags: + - Products + put: + consumes: + - application/json + description: Update existing product + parameters: + - description: Product data + in: body + name: UpdateProductRequestDto + required: true + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto' + - description: Product ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "204": + description: No Content + summary: Update product + tags: + - Products + /api/v1/products/search: + get: + consumes: + - application/json + description: Search products + parameters: + - in: query + name: search + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto' + summary: Search products + tags: + - Products +swagger: "2.0" diff --git a/api/openapi/order_service/docs.go b/api/openapi/order_service/docs.go new file mode 100644 index 00000000..934905f3 --- /dev/null +++ b/api/openapi/order_service/docs.go @@ -0,0 +1,315 @@ +// Code generated by swaggo/swag. DO NOT EDIT. + +package order_service + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": { + "name": "Mehdi Hadeli", + "url": "https://github.com/mehdihadeli" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/api/v1/orders": { + "get": { + "description": "Get all orders", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Orders" + ], + "summary": "Get all orders", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto" + } + } + } + }, + "post": { + "description": "Create new order", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Orders" + ], + "summary": "Create order", + "parameters": [ + { + "description": "Order data", + "name": "CreateOrderRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto" + } + } + } + } + }, + "/api/v1/orders/{id}": { + "get": { + "description": "Get order by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Orders" + ], + "summary": "Get order by id", + "parameters": [ + { + "type": "string", + "description": "Order ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto" + } + } + } + } + } + }, + "definitions": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto": { + "type": "object", + "properties": { + "accountEmail": { + "type": "string" + }, + "cancelReason": { + "type": "string" + }, + "canceled": { + "type": "boolean" + }, + "completed": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + }, + "deliveredTime": { + "type": "string" + }, + "deliveryAddress": { + "type": "string" + }, + "id": { + "type": "string" + }, + "orderId": { + "type": "string" + }, + "paid": { + "type": "boolean" + }, + "paymentId": { + "type": "string" + }, + "shopItems": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto" + } + }, + "submitted": { + "type": "boolean" + }, + "totalPrice": { + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "price": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "title": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "price": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "title": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto": { + "type": "object", + "properties": { + "accountEmail": { + "type": "string" + }, + "deliveryAddress": { + "type": "string" + }, + "deliveryTime": { + "type": "string" + }, + "shopItems": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto" + } + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto": { + "type": "object", + "properties": { + "Id": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto": { + "type": "object", + "properties": { + "order": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto": { + "type": "object", + "properties": { + "orders": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "", + BasePath: "", + Schemes: []string{}, + Title: "Orders Service Api", + Description: "Orders Service Api", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/api/openapi/order_service/swagger.json b/api/openapi/order_service/swagger.json new file mode 100644 index 00000000..3af5fd5b --- /dev/null +++ b/api/openapi/order_service/swagger.json @@ -0,0 +1,288 @@ +{ + "swagger": "2.0", + "info": { + "description": "Orders Service Api", + "title": "Orders Service Api", + "contact": { + "name": "Mehdi Hadeli", + "url": "https://github.com/mehdihadeli" + }, + "version": "1.0" + }, + "paths": { + "/api/v1/orders": { + "get": { + "description": "Get all orders", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Orders" + ], + "summary": "Get all orders", + "parameters": [ + { + "type": "string", + "name": "orderBy", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "size", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto" + } + } + } + }, + "post": { + "description": "Create new order", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Orders" + ], + "summary": "Create order", + "parameters": [ + { + "description": "Order data", + "name": "CreateOrderRequestDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto" + } + } + } + } + }, + "/api/v1/orders/{id}": { + "get": { + "description": "Get order by id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Orders" + ], + "summary": "Get order by id", + "parameters": [ + { + "type": "string", + "description": "Order ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto" + } + } + } + } + } + }, + "definitions": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto": { + "type": "object", + "properties": { + "accountEmail": { + "type": "string" + }, + "cancelReason": { + "type": "string" + }, + "canceled": { + "type": "boolean" + }, + "completed": { + "type": "boolean" + }, + "createdAt": { + "type": "string" + }, + "deliveredTime": { + "type": "string" + }, + "deliveryAddress": { + "type": "string" + }, + "id": { + "type": "string" + }, + "orderId": { + "type": "string" + }, + "paid": { + "type": "boolean" + }, + "paymentId": { + "type": "string" + }, + "shopItems": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto" + } + }, + "submitted": { + "type": "boolean" + }, + "totalPrice": { + "type": "number" + }, + "updatedAt": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "price": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "title": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "price": { + "type": "number" + }, + "quantity": { + "type": "integer" + }, + "title": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto": { + "type": "object", + "properties": { + "accountEmail": { + "type": "string" + }, + "deliveryAddress": { + "type": "string" + }, + "deliveryTime": { + "type": "string" + }, + "shopItems": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto" + } + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto": { + "type": "object", + "properties": { + "Id": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto": { + "type": "object", + "properties": { + "order": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto": { + "type": "object", + "properties": { + "orders": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto" + } + } + }, + "utils.FilterModel": { + "type": "object", + "properties": { + "comparison": { + "type": "string" + }, + "field": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/api/openapi/order_service/swagger.yaml b/api/openapi/order_service/swagger.yaml new file mode 100644 index 00000000..8229daac --- /dev/null +++ b/api/openapi/order_service/swagger.yaml @@ -0,0 +1,186 @@ +definitions: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto: + properties: + accountEmail: + type: string + cancelReason: + type: string + canceled: + type: boolean + completed: + type: boolean + createdAt: + type: string + deliveredTime: + type: string + deliveryAddress: + type: string + id: + type: string + orderId: + type: string + paid: + type: boolean + paymentId: + type: string + shopItems: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto' + type: array + submitted: + type: boolean + totalPrice: + type: number + updatedAt: + type: string + type: object + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto: + properties: + description: + type: string + price: + type: number + quantity: + type: integer + title: + type: string + type: object + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto: + properties: + description: + type: string + price: + type: number + quantity: + type: integer + title: + type: string + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto + : properties: + accountEmail: + type: string + deliveryAddress: + type: string + deliveryTime: + type: string + shopItems: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto' + type: array + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto + : properties: + Id: + type: string + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto + : properties: + order: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto + : properties: + orders: + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto' + type: object + utils.FilterModel: + properties: + comparison: + type: string + field: + type: string + value: + type: string + type: object + ? utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto + : properties: + items: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto' + type: array + page: + type: integer + size: + type: integer + totalItems: + type: integer + totalPage: + type: integer + type: object +info: + contact: + name: Mehdi Hadeli + url: https://github.com/mehdihadeli + description: Orders Service Api + title: Orders Service Api + version: "1.0" +paths: + /api/v1/orders: + get: + consumes: + - application/json + description: Get all orders + parameters: + - in: query + name: orderBy + type: string + - in: query + name: page + type: integer + - in: query + name: size + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto' + summary: Get all orders + tags: + - Orders + post: + consumes: + - application/json + description: Create new order + parameters: + - description: Order data + in: body + name: CreateOrderRequestDto + required: true + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto' + summary: Create order + tags: + - Orders + /api/v1/orders/{id}: + get: + consumes: + - application/json + description: Get order by id + parameters: + - description: Order ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto' + summary: Get order by id + tags: + - Orders +swagger: "2.0" diff --git a/api/proto/catalogs/products.proto b/api/protobuf/catalog_write_service/products.proto similarity index 100% rename from api/proto/catalogs/products.proto rename to api/protobuf/catalog_write_service/products.proto diff --git a/api/proto/common.proto b/api/protobuf/common.proto similarity index 100% rename from api/proto/common.proto rename to api/protobuf/common.proto diff --git a/api/proto/orders/orders.proto b/api/protobuf/order_service/orders.proto similarity index 100% rename from api/proto/orders/orders.proto rename to api/protobuf/order_service/orders.proto diff --git a/internal/pkg/bun/postgres/bun_postgres.go b/internal/pkg/bun/postgres/bun_postgres.go index bbd90589..794a58fd 100644 --- a/internal/pkg/bun/postgres/bun_postgres.go +++ b/internal/pkg/bun/postgres/bun_postgres.go @@ -1,17 +1,17 @@ package postgres import ( - "database/sql" - "fmt" + "database/sql" + "fmt" - "emperror.dev/errors" - "github.com/uptrace/bun" - "github.com/uptrace/bun/dialect/pgdialect" - "github.com/uptrace/bun/driver/pgdriver" + "emperror.dev/errors" + "github.com/uptrace/bun" + "github.com/uptrace/bun/dialect/pgdialect" + "github.com/uptrace/bun/driver/pgdriver" - bun2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/bun" - // loading bun's official Postgres driver. - _ "github.com/uptrace/bun/driver/pgdriver" + bun2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/bun" + // loading bun's official Postgres driver. + _ "github.com/uptrace/bun/driver/pgdriver" ) func NewBunDB(cfg *bun2.BunConfig) (*bun.DB, error) { diff --git a/internal/pkg/core/custom_types/custom_time.go b/internal/pkg/core/custom_types/custom_time.go index 23a1cbe6..ebf3e3f5 100644 --- a/internal/pkg/core/custom_types/custom_time.go +++ b/internal/pkg/core/custom_types/custom_time.go @@ -9,8 +9,6 @@ import ( "time" "github.com/araddon/dateparse" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) // CustomTime provides an example of how to declare a new time Type with a custom formatter. diff --git a/internal/pkg/core/data/generic_repository.go b/internal/pkg/core/data/generic_repository.go index 85cf3929..5a5eae80 100644 --- a/internal/pkg/core/data/generic_repository.go +++ b/internal/pkg/core/data/generic_repository.go @@ -1,12 +1,12 @@ package data import ( - "context" + "context" - uuid "github.com/satori/go.uuid" + uuid "github.com/satori/go.uuid" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" ) type GenericRepositoryWithDataModel[TDataModel interface{}, TEntity interface{}] interface { diff --git a/internal/pkg/core/domain/entity.go b/internal/pkg/core/domain/entity.go index b88c7e5c..01794a88 100644 --- a/internal/pkg/core/domain/entity.go +++ b/internal/pkg/core/domain/entity.go @@ -1,8 +1,9 @@ package domain import ( - uuid "github.com/satori/go.uuid" "time" + + uuid "github.com/satori/go.uuid" ) type Entity struct { @@ -13,10 +14,10 @@ type Entity struct { } type EntityDataModel struct { - Id uuid.UUID `json:"id" bson:"id,omitempty"` + Id uuid.UUID `json:"id" bson:"id,omitempty"` EntityType string `json:"entity_type" bson:"entity_type,omitempty"` - CreatedAt time.Time `json:"created_at" bson:"created_at,omitempty"` - UpdatedAt time.Time `json:"updated_at" bson:"updated_at"` + CreatedAt time.Time `json:"created_at" bson:"created_at,omitempty"` + UpdatedAt time.Time `json:"updated_at" bson:"updated_at"` } type IEntity interface { diff --git a/internal/pkg/es/contracts/projection/projection.go b/internal/pkg/es/contracts/projection/projection.go index b74d97ac..6e8e43f3 100644 --- a/internal/pkg/es/contracts/projection/projection.go +++ b/internal/pkg/es/contracts/projection/projection.go @@ -1,11 +1,11 @@ package projection import ( - "context" + "context" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" ) type IProjection interface { - ProcessEvent(ctx context.Context, streamEvent *models.StreamEvent) error + ProcessEvent(ctx context.Context, streamEvent *models.StreamEvent) error } diff --git a/internal/pkg/es/contracts/projection/projection_publisher.go b/internal/pkg/es/contracts/projection/projection_publisher.go index c04d047e..b857e561 100644 --- a/internal/pkg/es/contracts/projection/projection_publisher.go +++ b/internal/pkg/es/contracts/projection/projection_publisher.go @@ -1,11 +1,11 @@ package projection import ( - "context" + "context" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" ) type IProjectionPublisher interface { - Publish(ctx context.Context, streamEvent *models.StreamEvent) error + Publish(ctx context.Context, streamEvent *models.StreamEvent) error } diff --git a/internal/pkg/es/contracts/store/aggregate_store.go b/internal/pkg/es/contracts/store/aggregate_store.go index 2c9e2c54..43145cec 100644 --- a/internal/pkg/es/contracts/store/aggregate_store.go +++ b/internal/pkg/es/contracts/store/aggregate_store.go @@ -1,15 +1,15 @@ package store import ( - "context" + "context" - uuid "github.com/satori/go.uuid" + uuid "github.com/satori/go.uuid" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" - appendResult "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/append_result" - readPosition "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_position/read_position" - expectedStreamVersion "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_version" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" + appendResult "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/append_result" + readPosition "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_position/read_position" + expectedStreamVersion "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_version" ) // AggregateStore is responsible for loading and saving Aggregate. @@ -29,7 +29,11 @@ type AggregateStore[T models.IHaveEventSourcedAggregate] interface { Load(ctx context.Context, aggregateId uuid.UUID) (T, error) // LoadWithReadPosition loads the most recent version of an aggregate to provided into params aggregate with an id and read position. - LoadWithReadPosition(ctx context.Context, aggregateId uuid.UUID, position readPosition.StreamReadPosition) (T, error) + LoadWithReadPosition( + ctx context.Context, + aggregateId uuid.UUID, + position readPosition.StreamReadPosition, + ) (T, error) // Exists check aggregate exists by AggregateId. Exists(ctx context.Context, aggregateId uuid.UUID) (bool, error) diff --git a/internal/pkg/es/contracts/store/event_store.go b/internal/pkg/es/contracts/store/event_store.go index c5ae46e8..690d8619 100644 --- a/internal/pkg/es/contracts/store/event_store.go +++ b/internal/pkg/es/contracts/store/event_store.go @@ -1,14 +1,14 @@ package store import ( - "context" + "context" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" - appendResult "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/append_result" - streamName "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_name" - readPosition "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_position/read_position" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_position/truncatePosition" - expectedStreamVersion "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_version" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models" + appendResult "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/append_result" + streamName "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_name" + readPosition "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_position/read_position" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_position/truncatePosition" + expectedStreamVersion "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/models/stream_version" ) type EventStore interface { diff --git a/internal/pkg/es/errors/errors.go b/internal/pkg/es/errors/errors.go index 6e47c741..55e7e09c 100644 --- a/internal/pkg/es/errors/errors.go +++ b/internal/pkg/es/errors/errors.go @@ -4,11 +4,11 @@ import ( "fmt" "emperror.dev/errors" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) var ( - EventAlreadyExistsError = customErrors.NewConflictError(fmt.Sprintf("domain_events event already exists in event registry")) - InvalidEventTypeError = errors.New("invalid event type") + EventAlreadyExistsError = customErrors.NewConflictError( + fmt.Sprintf("domain_events event already exists in event registry"), + ) + InvalidEventTypeError = errors.New("invalid event type") ) diff --git a/internal/pkg/es/inmemory_subscription_checkpoint_repository.go b/internal/pkg/es/inmemory_subscription_checkpoint_repository.go index 637d47a2..3505b95e 100644 --- a/internal/pkg/es/inmemory_subscription_checkpoint_repository.go +++ b/internal/pkg/es/inmemory_subscription_checkpoint_repository.go @@ -22,7 +22,11 @@ func (i inMemorySubscriptionCheckpointRepository) Load(subscriptionId string, ct return checkpoint, nil } -func (i inMemorySubscriptionCheckpointRepository) Store(subscriptionId string, position uint64, ctx context.Context) error { +func (i inMemorySubscriptionCheckpointRepository) Store( + subscriptionId string, + position uint64, + ctx context.Context, +) error { i.checkpoints[subscriptionId] = position return nil } diff --git a/internal/pkg/es/models/stream_event.go b/internal/pkg/es/models/stream_event.go index 7e333d1c..82e77ebb 100644 --- a/internal/pkg/es/models/stream_event.go +++ b/internal/pkg/es/models/stream_event.go @@ -1,10 +1,10 @@ package models import ( - uuid "github.com/satori/go.uuid" + uuid "github.com/satori/go.uuid" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/domain" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/domain" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" ) type StreamEvent struct { diff --git a/internal/pkg/eventstroredb/errors/aggregate_not_found_error.go b/internal/pkg/eventstroredb/errors/aggregate_not_found_error.go index 501753cf..f0425ab0 100644 --- a/internal/pkg/eventstroredb/errors/aggregate_not_found_error.go +++ b/internal/pkg/eventstroredb/errors/aggregate_not_found_error.go @@ -1,12 +1,12 @@ package errors import ( - "fmt" + "fmt" - "emperror.dev/errors" - uuid "github.com/satori/go.uuid" + "emperror.dev/errors" + uuid "github.com/satori/go.uuid" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) //https://klotzandrew.com/blog/error-handling-in-golang/ diff --git a/internal/pkg/eventstroredb/errors/append_to_stream_error.go b/internal/pkg/eventstroredb/errors/append_to_stream_error.go index 30cd57cd..c71f62d0 100644 --- a/internal/pkg/eventstroredb/errors/append_to_stream_error.go +++ b/internal/pkg/eventstroredb/errors/append_to_stream_error.go @@ -1,41 +1,41 @@ package errors import ( - "fmt" + "fmt" - "emperror.dev/errors" + "emperror.dev/errors" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) type appendToStreamError struct { - customErrors.BadRequestError + customErrors.BadRequestError } type AppendToStreamError interface { - customErrors.BadRequestError - IsAppendToStreamError() bool + customErrors.BadRequestError + IsAppendToStreamError() bool } func NewAppendToStreamError(err error, streamId string) error { - bad := customErrors.NewBadRequestErrorWrap(err, fmt.Sprintf("unable to append events to stream %s", streamId)) - customErr := customErrors.GetCustomError(bad) - br := &appendToStreamError{ - BadRequestError: customErr.(customErrors.BadRequestError), - } + bad := customErrors.NewBadRequestErrorWrap(err, fmt.Sprintf("unable to append events to stream %s", streamId)) + customErr := customErrors.GetCustomError(bad) + br := &appendToStreamError{ + BadRequestError: customErr.(customErrors.BadRequestError), + } - return errors.WithStackIf(br) + return errors.WithStackIf(br) } func (err *appendToStreamError) IsAppendToStreamError() bool { - return true + return true } func IsAppendToStreamError(err error) bool { - var an AppendToStreamError - if errors.As(err, &an) { - return an.IsAppendToStreamError() - } + var an AppendToStreamError + if errors.As(err, &an) { + return an.IsAppendToStreamError() + } - return false + return false } diff --git a/internal/pkg/eventstroredb/errors/delete_stream_error.go b/internal/pkg/eventstroredb/errors/delete_stream_error.go index c8fe18b4..b764c00e 100644 --- a/internal/pkg/eventstroredb/errors/delete_stream_error.go +++ b/internal/pkg/eventstroredb/errors/delete_stream_error.go @@ -4,8 +4,6 @@ import ( "fmt" "emperror.dev/errors" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) type deleteStreamError struct { diff --git a/internal/pkg/eventstroredb/errors/read_stream_error.go b/internal/pkg/eventstroredb/errors/read_stream_error.go index 2c31625f..ba0a518e 100644 --- a/internal/pkg/eventstroredb/errors/read_stream_error.go +++ b/internal/pkg/eventstroredb/errors/read_stream_error.go @@ -1,9 +1,7 @@ package errors import ( - "emperror.dev/errors" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "emperror.dev/errors" ) type readStreamError struct { diff --git a/internal/pkg/eventstroredb/errors/stream_not_found_error.go b/internal/pkg/eventstroredb/errors/stream_not_found_error.go index 982b200c..8dc4d229 100644 --- a/internal/pkg/eventstroredb/errors/stream_not_found_error.go +++ b/internal/pkg/eventstroredb/errors/stream_not_found_error.go @@ -1,11 +1,11 @@ package errors import ( - "fmt" + "fmt" - "emperror.dev/errors" + "emperror.dev/errors" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) type streamNotFoundError struct { diff --git a/internal/pkg/eventstroredb/errors/truncate_stream_error.go b/internal/pkg/eventstroredb/errors/truncate_stream_error.go index bad81955..883dfe7c 100644 --- a/internal/pkg/eventstroredb/errors/truncate_stream_error.go +++ b/internal/pkg/eventstroredb/errors/truncate_stream_error.go @@ -1,41 +1,39 @@ package errors import ( - "fmt" + "fmt" - "emperror.dev/errors" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "emperror.dev/errors" ) type truncateStreamError struct { - customErrors.InternalServerError + customErrors.InternalServerError } type TruncateStreamError interface { - customErrors.InternalServerError - IsTruncateStreamError() bool + customErrors.InternalServerError + IsTruncateStreamError() bool } func NewTruncateStreamError(err error, streamId string) error { - internal := customErrors.NewInternalServerErrorWrap(err, fmt.Sprintf("unable to truncate stream %s", streamId)) - customErr := customErrors.GetCustomError(internal) - br := &truncateStreamError{ - InternalServerError: customErr.(customErrors.InternalServerError), - } + internal := customErrors.NewInternalServerErrorWrap(err, fmt.Sprintf("unable to truncate stream %s", streamId)) + customErr := customErrors.GetCustomError(internal) + br := &truncateStreamError{ + InternalServerError: customErr.(customErrors.InternalServerError), + } - return errors.WithStackIf(br) + return errors.WithStackIf(br) } func (err *truncateStreamError) IsTruncateStreamError() bool { - return true + return true } func IsTruncateStreamError(err error) bool { - var rs TruncateStreamError - if errors.As(err, &rs) { - return rs.IsTruncateStreamError() - } + var rs TruncateStreamError + if errors.As(err, &rs) { + return rs.IsTruncateStreamError() + } - return false + return false } diff --git a/internal/pkg/gorm_postgres/repository/gorm_generic_repository.go b/internal/pkg/gorm_postgres/repository/gorm_generic_repository.go index 0faa91cb..8224f3f8 100644 --- a/internal/pkg/gorm_postgres/repository/gorm_generic_repository.go +++ b/internal/pkg/gorm_postgres/repository/gorm_generic_repository.go @@ -1,25 +1,23 @@ package repository import ( - "context" - "fmt" - "reflect" + "context" + "fmt" + "reflect" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" + "emperror.dev/errors" + "github.com/iancoleman/strcase" + uuid "github.com/satori/go.uuid" + "gorm.io/gorm" - "emperror.dev/errors" - - "github.com/iancoleman/strcase" - uuid "github.com/satori/go.uuid" - "gorm.io/gorm" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/gorm_postgres" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/reflection_helper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" + gormPostgres "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/gorm_postgres" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" + reflectionHelper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/reflection_helper" + typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" ) // gorm generic repository @@ -28,7 +26,9 @@ type gormGenericRepository[TDataModel interface{}, TEntity interface{}] struct { } // NewGenericGormRepositoryWithDataModel create new gorm generic repository -func NewGenericGormRepositoryWithDataModel[TDataModel interface{}, TEntity interface{}](db *gorm.DB) data.GenericRepositoryWithDataModel[TDataModel, TEntity] { +func NewGenericGormRepositoryWithDataModel[TDataModel interface{}, TEntity interface{}]( + db *gorm.DB, +) data.GenericRepositoryWithDataModel[TDataModel, TEntity] { return &gormGenericRepository[TDataModel, TEntity]{ db: db, } @@ -87,9 +87,15 @@ func (r *gormGenericRepository[TDataModel, TEntity]) GetById(ctx context.Context var model TEntity if err := r.db.WithContext(ctx).First(&model, id).Error; err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { - return *new(TEntity), customErrors.NewNotFoundErrorWrap(err, fmt.Sprintf("can't find the entity with id %s into the database.", id.String())) + return *new(TEntity), customErrors.NewNotFoundErrorWrap( + err, + fmt.Sprintf("can't find the entity with id %s into the database.", id.String()), + ) } - return *new(TEntity), errors.WrapIf(err, fmt.Sprintf("can't find the entity with id %s into the database.", id.String())) + return *new(TEntity), errors.WrapIf( + err, + fmt.Sprintf("can't find the entity with id %s into the database.", id.String()), + ) } return model, nil } else { @@ -108,7 +114,10 @@ func (r *gormGenericRepository[TDataModel, TEntity]) GetById(ctx context.Context } } -func (r *gormGenericRepository[TDataModel, TEntity]) GetAll(ctx context.Context, listQuery *utils.ListQuery) (*utils.ListResult[TEntity], error) { +func (r *gormGenericRepository[TDataModel, TEntity]) GetAll( + ctx context.Context, + listQuery *utils.ListQuery, +) (*utils.ListResult[TEntity], error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() if modelType == dataModelType { @@ -130,7 +139,11 @@ func (r *gormGenericRepository[TDataModel, TEntity]) GetAll(ctx context.Context, } } -func (r *gormGenericRepository[TDataModel, TEntity]) Search(ctx context.Context, searchTerm string, listQuery *utils.ListQuery) (*utils.ListResult[TEntity], error) { +func (r *gormGenericRepository[TDataModel, TEntity]) Search( + ctx context.Context, + searchTerm string, + listQuery *utils.ListQuery, +) (*utils.ListResult[TEntity], error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() if modelType == dataModelType { @@ -175,7 +188,10 @@ func (r *gormGenericRepository[TDataModel, TEntity]) Search(ctx context.Context, } } -func (r *gormGenericRepository[TDataModel, TEntity]) GetByFilter(ctx context.Context, filters map[string]interface{}) ([]TEntity, error) { +func (r *gormGenericRepository[TDataModel, TEntity]) GetByFilter( + ctx context.Context, + filters map[string]interface{}, +) ([]TEntity, error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() if modelType == dataModelType { @@ -199,11 +215,17 @@ func (r *gormGenericRepository[TDataModel, TEntity]) GetByFilter(ctx context.Con } } -func (r *gormGenericRepository[TDataModel, TEntity]) GetByFuncFilter(ctx context.Context, filterFunc func(TEntity) bool) ([]TEntity, error) { +func (r *gormGenericRepository[TDataModel, TEntity]) GetByFuncFilter( + ctx context.Context, + filterFunc func(TEntity) bool, +) ([]TEntity, error) { return *new([]TEntity), nil } -func (r *gormGenericRepository[TDataModel, TEntity]) FirstOrDefault(ctx context.Context, filters map[string]interface{}) (TEntity, error) { +func (r *gormGenericRepository[TDataModel, TEntity]) FirstOrDefault( + ctx context.Context, + filters map[string]interface{}, +) (TEntity, error) { return *new(TEntity), nil } @@ -259,7 +281,11 @@ func (r *gormGenericRepository[TDataModel, TEntity]) Delete(ctx context.Context, return nil } -func (r *gormGenericRepository[TDataModel, TEntity]) SkipTake(ctx context.Context, skip int, take int) ([]TEntity, error) { +func (r *gormGenericRepository[TDataModel, TEntity]) SkipTake( + ctx context.Context, + skip int, + take int, +) ([]TEntity, error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() if modelType == dataModelType { @@ -290,7 +316,10 @@ func (r *gormGenericRepository[TDataModel, TEntity]) Count(ctx context.Context) return count } -func (r *gormGenericRepository[TDataModel, TEntity]) Find(ctx context.Context, specification specification.Specification) ([]TEntity, error) { +func (r *gormGenericRepository[TDataModel, TEntity]) Find( + ctx context.Context, + specification specification.Specification, +) ([]TEntity, error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() if modelType == dataModelType { diff --git a/internal/pkg/gorm_postgres/repository/gorm_generic_repository_test.go b/internal/pkg/gorm_postgres/repository/gorm_generic_repository_test.go index 4fcdf9c9..1ee695d3 100644 --- a/internal/pkg/gorm_postgres/repository/gorm_generic_repository_test.go +++ b/internal/pkg/gorm_postgres/repository/gorm_generic_repository_test.go @@ -1,22 +1,22 @@ package repository import ( - "context" - "log" - "testing" - - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - - _ "github.com/lib/pq" // postgres driver - uuid "github.com/satori/go.uuid" - "github.com/stretchr/testify/assert" - "gorm.io/gorm" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - gorm2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/gorm" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" + "context" + "log" + "testing" + + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + + _ "github.com/lib/pq" // postgres driver + uuid "github.com/satori/go.uuid" + "github.com/stretchr/testify/assert" + "gorm.io/gorm" + + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" + gorm2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/gorm" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" ) // Product is a domain_events entity @@ -398,7 +398,10 @@ func Test_Find(t *testing.T) { t.Fatal(err) } - entities, err := repository.Find(ctx, specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1"))) + entities, err := repository.Find( + ctx, + specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1")), + ) if err != nil { return } @@ -412,14 +415,20 @@ func Test_Find_With_Data_Model(t *testing.T) { t.Fatal(err) } - entities, err := repository.Find(ctx, specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1"))) + entities, err := repository.Find( + ctx, + specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1")), + ) if err != nil { return } assert.Equal(t, len(entities), 1) } -func setupGenericGormRepositoryWithDataModel(ctx context.Context, t *testing.T) (data.GenericRepositoryWithDataModel[*ProductGorm, *Product], error) { +func setupGenericGormRepositoryWithDataModel( + ctx context.Context, + t *testing.T, +) (data.GenericRepositoryWithDataModel[*ProductGorm, *Product], error) { db, err := gorm2.NewGormTestContainers().Start(ctx, t) if err != nil { return nil, err diff --git a/internal/pkg/grpc/grpcErrors/custom_grpc_errors.go b/internal/pkg/grpc/grpcErrors/custom_grpc_errors.go index 72d738ff..284212a7 100644 --- a/internal/pkg/grpc/grpcErrors/custom_grpc_errors.go +++ b/internal/pkg/grpc/grpcErrors/custom_grpc_errors.go @@ -1,112 +1,112 @@ package grpcErrors import ( - "time" + "time" - "google.golang.org/grpc/codes" + "google.golang.org/grpc/codes" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" ) func NewValidationGrpcError(detail string, stackTrace string) GrpcErr { - validationError := - &grpcErr{ - Title: constants.ErrBadRequestTitle, - Detail: detail, - Status: codes.InvalidArgument, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + validationError := + &grpcErr{ + Title: constants.ErrBadRequestTitle, + Detail: detail, + Status: codes.InvalidArgument, + Timestamp: time.Now(), + StackTrace: stackTrace, + } - return validationError + return validationError } func NewConflictGrpcError(detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrConflictTitle, - Detail: detail, - Status: codes.AlreadyExists, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrConflictTitle, + Detail: detail, + Status: codes.AlreadyExists, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewBadRequestGrpcError(detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrBadRequestTitle, - Detail: detail, - Status: codes.InvalidArgument, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrBadRequestTitle, + Detail: detail, + Status: codes.InvalidArgument, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewNotFoundErrorGrpcError(detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrNotFoundTitle, - Detail: detail, - Status: codes.NotFound, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrNotFoundTitle, + Detail: detail, + Status: codes.NotFound, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewUnAuthorizedErrorGrpcError(detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrUnauthorizedTitle, - Detail: detail, - Status: codes.Unauthenticated, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrUnauthorizedTitle, + Detail: detail, + Status: codes.Unauthenticated, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewForbiddenGrpcError(detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrForbiddenTitle, - Detail: detail, - Status: codes.PermissionDenied, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrForbiddenTitle, + Detail: detail, + Status: codes.PermissionDenied, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewInternalServerGrpcError(detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrInternalServerErrorTitle, - Detail: detail, - Status: codes.Internal, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrInternalServerErrorTitle, + Detail: detail, + Status: codes.Internal, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewDomainGrpcError(status codes.Code, detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrDomainTitle, - Detail: detail, - Status: status, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrDomainTitle, + Detail: detail, + Status: status, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewApplicationGrpcError(status codes.Code, detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrApplicationTitle, - Detail: detail, - Status: status, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrApplicationTitle, + Detail: detail, + Status: status, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewApiGrpcError(status codes.Code, detail string, stackTrace string) GrpcErr { - return &grpcErr{ - Title: constants.ErrApiTitle, - Detail: detail, - Status: status, - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &grpcErr{ + Title: constants.ErrApiTitle, + Detail: detail, + Status: status, + Timestamp: time.Now(), + StackTrace: stackTrace, + } } diff --git a/internal/pkg/grpc/grpcErrors/grpc_error_parser.go b/internal/pkg/grpc/grpcErrors/grpc_error_parser.go index d35a0bb4..49900e0d 100644 --- a/internal/pkg/grpc/grpcErrors/grpc_error_parser.go +++ b/internal/pkg/grpc/grpcErrors/grpc_error_parser.go @@ -1,16 +1,16 @@ package grpcErrors import ( - "context" - "database/sql" + "context" + "database/sql" - "emperror.dev/errors" - "github.com/go-playground/validator" - "google.golang.org/grpc/codes" + "emperror.dev/errors" + "github.com/go-playground/validator" + "google.golang.org/grpc/codes" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" ) //https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md @@ -44,7 +44,12 @@ func ParseError(err error) GrpcErr { case customErrors.IsInternalServerError(err): return NewInternalServerGrpcError(customErr.Error(), stackTrace) case customErrors.IsCustomError(err): - return NewGrpcError(codes.Code(customErr.Status()), codes.Code(customErr.Status()).String(), customErr.Error(), stackTrace) + return NewGrpcError( + codes.Code(customErr.Status()), + codes.Code(customErr.Status()).String(), + customErr.Error(), + stackTrace, + ) case customErrors.IsUnMarshalingError(err): return NewInternalServerGrpcError(customErr.Error(), stackTrace) case customErrors.IsMarshalingError(err): diff --git a/internal/pkg/grpc/interceptors/grpc_error/error_interceptor.go b/internal/pkg/grpc/interceptors/grpc_error/error_interceptor.go index 8d6b31dc..471011e3 100644 --- a/internal/pkg/grpc/interceptors/grpc_error/error_interceptor.go +++ b/internal/pkg/grpc/interceptors/grpc_error/error_interceptor.go @@ -1,61 +1,61 @@ package grpcError import ( - "context" - "fmt" + "context" + "fmt" - "google.golang.org/grpc" + "google.golang.org/grpc" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc/grpcErrors" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc/grpcErrors" ) // UnaryServerInterceptor returns a problem-detail error to client func UnaryServerInterceptor() grpc.UnaryServerInterceptor { - return func( - ctx context.Context, - req interface{}, - info *grpc.UnaryServerInfo, - handler grpc.UnaryHandler, - ) (interface{}, error) { - - resp, err := handler(ctx, req) - if err != nil { - grpcErr := grpcErrors.ParseError(err) - - if grpcErr != nil { - return nil, grpcErr.ToGrpcResponseErr() - - } else { - prb := grpcErrors.NewInternalServerGrpcError(err.Error(), fmt.Sprintf("%+v\n", err)) - return nil, prb.ToGrpcResponseErr() - } - } - - return resp, err - } + return func( + ctx context.Context, + req interface{}, + info *grpc.UnaryServerInfo, + handler grpc.UnaryHandler, + ) (interface{}, error) { + + resp, err := handler(ctx, req) + if err != nil { + grpcErr := grpcErrors.ParseError(err) + + if grpcErr != nil { + return nil, grpcErr.ToGrpcResponseErr() + + } else { + prb := grpcErrors.NewInternalServerGrpcError(err.Error(), fmt.Sprintf("%+v\n", err)) + return nil, prb.ToGrpcResponseErr() + } + } + + return resp, err + } } // StreamServerInterceptor returns a problem-detail error to client. func StreamServerInterceptor() grpc.StreamServerInterceptor { - return func( - srv interface{}, - ss grpc.ServerStream, - info *grpc.StreamServerInfo, - handler grpc.StreamHandler, - ) error { - err := handler(srv, ss) - - if err != nil { - grpcErr := grpcErrors.ParseError(err) - - if grpcErr != nil { - return grpcErr.ToGrpcResponseErr() - - } else { - prb := grpcErrors.NewInternalServerGrpcError(err.Error(), fmt.Sprintf("%+v\n", err)) - return prb.ToGrpcResponseErr() - } - } - return err - } + return func( + srv interface{}, + ss grpc.ServerStream, + info *grpc.StreamServerInfo, + handler grpc.StreamHandler, + ) error { + err := handler(srv, ss) + + if err != nil { + grpcErr := grpcErrors.ParseError(err) + + if grpcErr != nil { + return grpcErr.ToGrpcResponseErr() + + } else { + prb := grpcErrors.NewInternalServerGrpcError(err.Error(), fmt.Sprintf("%+v\n", err)) + return prb.ToGrpcResponseErr() + } + } + return err + } } diff --git a/internal/pkg/grpc/interceptors/otel_metrics/request_status_interceptor.go b/internal/pkg/grpc/interceptors/otel_metrics/request_status_interceptor.go index bb370934..c46e1a3d 100644 --- a/internal/pkg/grpc/interceptors/otel_metrics/request_status_interceptor.go +++ b/internal/pkg/grpc/interceptors/otel_metrics/request_status_interceptor.go @@ -26,7 +26,10 @@ func UnaryServerInterceptor(meter api.Meter, serviceName string) grpc.UnaryServe ) if err != nil { - counter, err := meter.Float64Counter(fmt.Sprintf("%s_error_grpc_requests_total", serviceName), api.WithDescription("The total number of error grpc requests")) + counter, err := meter.Float64Counter( + fmt.Sprintf("%s_error_grpc_requests_total", serviceName), + api.WithDescription("The total number of error grpc requests"), + ) if err != nil { return nil, err } @@ -60,7 +63,10 @@ func StreamServerInterceptor(meter api.Meter, serviceName string) grpc.StreamSer ctx := ss.Context() if err != nil { - counter, err := meter.Float64Counter(fmt.Sprintf("%s_error_grpc_requests_total", serviceName), api.WithDescription("The total number of error grpc requests")) + counter, err := meter.Float64Counter( + fmt.Sprintf("%s_error_grpc_requests_total", serviceName), + api.WithDescription("The total number of error grpc requests"), + ) if err != nil { return err } diff --git a/internal/pkg/grpc/otel/tracing/utils.go b/internal/pkg/grpc/otel/tracing/utils.go index b8cbd5f5..8a925133 100644 --- a/internal/pkg/grpc/otel/tracing/utils.go +++ b/internal/pkg/grpc/otel/tracing/utils.go @@ -1,41 +1,41 @@ package tracing import ( - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - semconv "go.opentelemetry.io/otel/semconv/v1.12.0" - "go.opentelemetry.io/otel/trace" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/trace" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc/grpcErrors" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc/grpcErrors" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" ) // TraceGrpcErrFromSpan setting span with status error with error message func TraceGrpcErrFromSpan(span trace.Span, err error) error { - if err != nil { - stackTraceError := errorUtils.ErrorsWithStack(err) - span.SetStatus(codes.Error, "") - span.SetAttributes(attribute.String(GrpcErrorMessage, stackTraceError)) - if customErrors.IsCustomError(err) { - grpcErr := grpcErrors.ParseError(err) - span.SetAttributes(semconv.RPCGRPCStatusCodeKey.Int(int(grpcErr.GetStatus()))) - } - span.RecordError(err) - } + if err != nil { + stackTraceError := errorUtils.ErrorsWithStack(err) + span.SetStatus(codes.Error, "") + span.SetAttributes(attribute.String(GrpcErrorMessage, stackTraceError)) + if customErrors.IsCustomError(err) { + grpcErr := grpcErrors.ParseError(err) + span.SetAttributes(semconv.RPCGRPCStatusCodeKey.Int(int(grpcErr.GetStatus()))) + } + span.RecordError(err) + } - return err + return err } // TraceGrpcErrFromSpanWithCode setting span with status error with error message func TraceGrpcErrFromSpanWithCode(span trace.Span, err error, code int) error { - if err != nil { - stackTraceError := errorUtils.ErrorsWithStack(err) - span.SetStatus(codes.Error, "") - span.SetAttributes(semconv.RPCGRPCStatusCodeKey.Int(code)) - span.SetAttributes(attribute.String(GrpcErrorMessage, stackTraceError)) - span.RecordError(err) - } + if err != nil { + stackTraceError := errorUtils.ErrorsWithStack(err) + span.SetStatus(codes.Error, "") + span.SetAttributes(semconv.RPCGRPCStatusCodeKey.Int(code)) + span.SetAttributes(attribute.String(GrpcErrorMessage, stackTraceError)) + span.RecordError(err) + } - return err + return err } diff --git a/internal/pkg/http/client/http_client.go b/internal/pkg/http/client/http_client.go index d36d8c99..788f4c49 100644 --- a/internal/pkg/http/client/http_client.go +++ b/internal/pkg/http/client/http_client.go @@ -1,8 +1,9 @@ package client import ( - "github.com/go-resty/resty/v2" "time" + + "github.com/go-resty/resty/v2" ) const ( diff --git a/internal/pkg/http/custom_echo/otel/tracing/utils.go b/internal/pkg/http/custom_echo/otel/tracing/utils.go index d4157178..e38560d0 100644 --- a/internal/pkg/http/custom_echo/otel/tracing/utils.go +++ b/internal/pkg/http/custom_echo/otel/tracing/utils.go @@ -1,16 +1,16 @@ package tracing import ( - "context" + "context" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - semconv "go.opentelemetry.io/otel/semconv/v1.12.0" - "go.opentelemetry.io/otel/trace" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/trace" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/problemDetails" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/problemDetails" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" ) // TraceHttpErrFromSpan setting span with status error with error message diff --git a/internal/pkg/http/http_errors/contracts/contracts.go b/internal/pkg/http/http_errors/contracts/contracts.go index ee349d12..7ffc698d 100644 --- a/internal/pkg/http/http_errors/contracts/contracts.go +++ b/internal/pkg/http/http_errors/contracts/contracts.go @@ -1,8 +1,9 @@ package contracts import ( - "emperror.dev/errors" "fmt" + + "emperror.dev/errors" ) type Causer interface { diff --git a/internal/pkg/http/http_errors/custom_errors/bad_request_error.go b/internal/pkg/http/http_errors/custom_errors/bad_request_error.go index 0265d8a5..6c38c9df 100644 --- a/internal/pkg/http/http_errors/custom_errors/bad_request_error.go +++ b/internal/pkg/http/http_errors/custom_errors/bad_request_error.go @@ -1,8 +1,9 @@ package customErrors import ( - "emperror.dev/errors" "net/http" + + "emperror.dev/errors" ) func NewBadRequestError(message string) error { @@ -10,7 +11,7 @@ func NewBadRequestError(message string) error { CustomError: NewCustomError(nil, http.StatusBadRequest, message), } stackErr := errors.WithStackIf(br) - + return stackErr } diff --git a/internal/pkg/http/http_errors/custom_errors/conflict_error.go b/internal/pkg/http/http_errors/custom_errors/conflict_error.go index 9a0cc0b9..f9efa01d 100644 --- a/internal/pkg/http/http_errors/custom_errors/conflict_error.go +++ b/internal/pkg/http/http_errors/custom_errors/conflict_error.go @@ -1,8 +1,9 @@ package customErrors import ( - "emperror.dev/errors" "net/http" + + "emperror.dev/errors" ) func NewConflictError(message string) error { diff --git a/internal/pkg/http/http_errors/custom_errors/custom_errors.go b/internal/pkg/http/http_errors/custom_errors/custom_errors.go index 5831a0c3..0798dfa3 100644 --- a/internal/pkg/http/http_errors/custom_errors/custom_errors.go +++ b/internal/pkg/http/http_errors/custom_errors/custom_errors.go @@ -1,12 +1,12 @@ package customErrors import ( - "fmt" - "io" + "fmt" + "io" - "emperror.dev/errors" + "emperror.dev/errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/contracts" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/contracts" ) // https://klotzandrew.com/blog/error-handling-in-golang diff --git a/internal/pkg/http/http_errors/custom_errors/custom_errors_test.go b/internal/pkg/http/http_errors/custom_errors/custom_errors_test.go index 5f8821ac..330a98ca 100644 --- a/internal/pkg/http/http_errors/custom_errors/custom_errors_test.go +++ b/internal/pkg/http/http_errors/custom_errors/custom_errors_test.go @@ -1,14 +1,14 @@ package customErrors import ( - "fmt" - "testing" + "fmt" + "testing" - "emperror.dev/errors" - "github.com/stretchr/testify/assert" + "emperror.dev/errors" + "github.com/stretchr/testify/assert" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/contracts" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/contracts" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" ) func Test_BadRequest_Err(t *testing.T) { @@ -122,7 +122,11 @@ func Test_Application_Err(t *testing.T) { assert.Equal(t, 400, appErr.Status()) assert.Equal(t, "this is a application_exceptions errorUtils", appErr.Message()) - assert.Equal(t, "this is a application_exceptions errorUtils: handling application_exceptions errorUtils", appErr.Error()) + assert.Equal( + t, + "this is a application_exceptions errorUtils: handling application_exceptions errorUtils", + appErr.Error(), + ) assert.NotNil(t, appErr.Unwrap()) assert.NotNil(t, appErr.Cause()) diff --git a/internal/pkg/http/http_errors/custom_errors/forbiden_error.go b/internal/pkg/http/http_errors/custom_errors/forbiden_error.go index 2b9f54ab..e081500c 100644 --- a/internal/pkg/http/http_errors/custom_errors/forbiden_error.go +++ b/internal/pkg/http/http_errors/custom_errors/forbiden_error.go @@ -1,8 +1,9 @@ package customErrors import ( - "emperror.dev/errors" "net/http" + + "emperror.dev/errors" ) func NewForbiddenError(message string) error { diff --git a/internal/pkg/http/http_errors/custom_errors/internal_server_error.go b/internal/pkg/http/http_errors/custom_errors/internal_server_error.go index e38e1d04..5dde24e6 100644 --- a/internal/pkg/http/http_errors/custom_errors/internal_server_error.go +++ b/internal/pkg/http/http_errors/custom_errors/internal_server_error.go @@ -1,8 +1,9 @@ package customErrors import ( - "emperror.dev/errors" "net/http" + + "emperror.dev/errors" ) func NewInternalServerError(message string) error { diff --git a/internal/pkg/http/http_errors/custom_errors/not_found_error.go b/internal/pkg/http/http_errors/custom_errors/not_found_error.go index b0f2c4f7..25b4e191 100644 --- a/internal/pkg/http/http_errors/custom_errors/not_found_error.go +++ b/internal/pkg/http/http_errors/custom_errors/not_found_error.go @@ -1,8 +1,9 @@ package customErrors import ( - "emperror.dev/errors" "net/http" + + "emperror.dev/errors" ) func NewNotFoundError(message string) error { diff --git a/internal/pkg/http/http_errors/custom_errors/unauthorized_error.go b/internal/pkg/http/http_errors/custom_errors/unauthorized_error.go index 03aa9e1f..ea8edefb 100644 --- a/internal/pkg/http/http_errors/custom_errors/unauthorized_error.go +++ b/internal/pkg/http/http_errors/custom_errors/unauthorized_error.go @@ -1,8 +1,9 @@ package customErrors import ( - "emperror.dev/errors" "net/http" + + "emperror.dev/errors" ) func NewUnAuthorizedError(message string) error { diff --git a/internal/pkg/http/http_errors/problemDetails/custom_problem_details_errors.go b/internal/pkg/http/http_errors/problemDetails/custom_problem_details_errors.go index a7d24354..abadb403 100644 --- a/internal/pkg/http/http_errors/problemDetails/custom_problem_details_errors.go +++ b/internal/pkg/http/http_errors/problemDetails/custom_problem_details_errors.go @@ -1,121 +1,121 @@ package problemDetails import ( - "net/http" - "time" + "net/http" + "time" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" ) func NewValidationProblemDetail(detail string, stackTrace string) ProblemDetailErr { - validationError := - &problemDetail{ - Title: constants.ErrBadRequestTitle, - Detail: detail, - Status: http.StatusBadRequest, - Type: getDefaultType(http.StatusBadRequest), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + validationError := + &problemDetail{ + Title: constants.ErrBadRequestTitle, + Detail: detail, + Status: http.StatusBadRequest, + Type: getDefaultType(http.StatusBadRequest), + Timestamp: time.Now(), + StackTrace: stackTrace, + } - return validationError + return validationError } func NewConflictProblemDetail(detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrConflictTitle, - Detail: detail, - Status: http.StatusConflict, - Type: getDefaultType(http.StatusConflict), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrConflictTitle, + Detail: detail, + Status: http.StatusConflict, + Type: getDefaultType(http.StatusConflict), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewBadRequestProblemDetail(detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrBadRequestTitle, - Detail: detail, - Status: http.StatusBadRequest, - Type: getDefaultType(http.StatusBadRequest), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrBadRequestTitle, + Detail: detail, + Status: http.StatusBadRequest, + Type: getDefaultType(http.StatusBadRequest), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewNotFoundErrorProblemDetail(detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrNotFoundTitle, - Detail: detail, - Status: http.StatusNotFound, - Type: getDefaultType(http.StatusNotFound), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrNotFoundTitle, + Detail: detail, + Status: http.StatusNotFound, + Type: getDefaultType(http.StatusNotFound), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewUnAuthorizedErrorProblemDetail(detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrUnauthorizedTitle, - Detail: detail, - Status: http.StatusUnauthorized, - Type: getDefaultType(http.StatusUnauthorized), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrUnauthorizedTitle, + Detail: detail, + Status: http.StatusUnauthorized, + Type: getDefaultType(http.StatusUnauthorized), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewForbiddenProblemDetail(detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrForbiddenTitle, - Detail: detail, - Status: http.StatusForbidden, - Type: getDefaultType(http.StatusForbidden), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrForbiddenTitle, + Detail: detail, + Status: http.StatusForbidden, + Type: getDefaultType(http.StatusForbidden), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewInternalServerProblemDetail(detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrInternalServerErrorTitle, - Detail: detail, - Status: http.StatusInternalServerError, - Type: getDefaultType(http.StatusInternalServerError), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrInternalServerErrorTitle, + Detail: detail, + Status: http.StatusInternalServerError, + Type: getDefaultType(http.StatusInternalServerError), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewDomainProblemDetail(status int, detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrDomainTitle, - Detail: detail, - Status: status, - Type: getDefaultType(http.StatusBadRequest), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrDomainTitle, + Detail: detail, + Status: status, + Type: getDefaultType(http.StatusBadRequest), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewApplicationProblemDetail(status int, detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrApplicationTitle, - Detail: detail, - Status: status, - Type: getDefaultType(status), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrApplicationTitle, + Detail: detail, + Status: status, + Type: getDefaultType(status), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } func NewApiProblemDetail(status int, detail string, stackTrace string) ProblemDetailErr { - return &problemDetail{ - Title: constants.ErrApiTitle, - Detail: detail, - Status: status, - Type: getDefaultType(status), - Timestamp: time.Now(), - StackTrace: stackTrace, - } + return &problemDetail{ + Title: constants.ErrApiTitle, + Detail: detail, + Status: status, + Type: getDefaultType(status), + Timestamp: time.Now(), + StackTrace: stackTrace, + } } diff --git a/internal/pkg/http/http_errors/problemDetails/problem_detail_parser.go b/internal/pkg/http/http_errors/problemDetails/problem_detail_parser.go index f0e77c45..5e2d5d24 100644 --- a/internal/pkg/http/http_errors/problemDetails/problem_detail_parser.go +++ b/internal/pkg/http/http_errors/problemDetails/problem_detail_parser.go @@ -1,18 +1,18 @@ package problemDetails import ( - "context" - "database/sql" - "net/http" - "reflect" + "context" + "database/sql" + "net/http" + "reflect" - "emperror.dev/errors" - "github.com/go-playground/validator" + "emperror.dev/errors" + "github.com/go-playground/validator" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/constants" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" ) type ProblemDetailParser struct { @@ -71,7 +71,12 @@ func ParseError(err error) ProblemDetailErr { case errors.Is(err, sql.ErrNoRows): return NewNotFoundErrorProblemDetail(err.Error(), stackTrace) case errors.Is(err, context.DeadlineExceeded): - return NewProblemDetail(http.StatusRequestTimeout, constants.ErrRequestTimeoutTitle, err.Error(), stackTrace) + return NewProblemDetail( + http.StatusRequestTimeout, + constants.ErrRequestTimeoutTitle, + err.Error(), + stackTrace, + ) case errors.As(err, &validatorErr): return NewValidationProblemDetail(validatorErr.Error(), stackTrace) default: diff --git a/internal/pkg/http/http_errors/problemDetails/problem_details_test.go b/internal/pkg/http/http_errors/problemDetails/problem_details_test.go index ad060a2f..7104df5c 100644 --- a/internal/pkg/http/http_errors/problemDetails/problem_details_test.go +++ b/internal/pkg/http/http_errors/problemDetails/problem_details_test.go @@ -1,13 +1,13 @@ package problemDetails import ( - "net/http" - "testing" + "net/http" + "testing" - "emperror.dev/errors" - "github.com/stretchr/testify/assert" + "emperror.dev/errors" + "github.com/stretchr/testify/assert" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) func Test_Domain_Err(t *testing.T) { diff --git a/internal/pkg/mapper/mapper.go b/internal/pkg/mapper/mapper.go index c8a71886..cf7d2d6c 100644 --- a/internal/pkg/mapper/mapper.go +++ b/internal/pkg/mapper/mapper.go @@ -73,7 +73,8 @@ func CreateMap[TSrc any, TDst any]() error { srcType := reflect.TypeOf(&src).Elem() desType := reflect.TypeOf(&dst).Elem() - if (srcType.Kind() != reflect.Struct && (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() != reflect.Struct)) || (desType.Kind() != reflect.Struct && (desType.Kind() == reflect.Ptr && desType.Elem().Kind() != reflect.Struct)) { + if (srcType.Kind() != reflect.Struct && (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() != reflect.Struct)) || + (desType.Kind() != reflect.Struct && (desType.Kind() == reflect.Ptr && desType.Elem().Kind() != reflect.Struct)) { return ErrUnsupportedMap } @@ -127,7 +128,8 @@ func CreateCustomMap[TSrc any, TDst any](fn MapFunc[TSrc, TDst]) error { srcType := reflect.TypeOf(&src).Elem() desType := reflect.TypeOf(&dst).Elem() - if (srcType.Kind() != reflect.Struct && (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() != reflect.Struct)) || (desType.Kind() != reflect.Struct && (desType.Kind() == reflect.Ptr && desType.Elem().Kind() != reflect.Struct)) { + if (srcType.Kind() != reflect.Struct && (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() != reflect.Struct)) || + (desType.Kind() != reflect.Struct && (desType.Kind() == reflect.Ptr && desType.Elem().Kind() != reflect.Struct)) { return ErrUnsupportedMap } @@ -159,12 +161,16 @@ func Map[TDes any, TSrc any](src TSrc) (TDes, error) { desIsArray := false srcIsArray := false - if srcType.Kind() == reflect.Array || (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() == reflect.Array) || srcType.Kind() == reflect.Slice || (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() == reflect.Slice) { + if srcType.Kind() == reflect.Array || (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() == reflect.Array) || + srcType.Kind() == reflect.Slice || + (srcType.Kind() == reflect.Ptr && srcType.Elem().Kind() == reflect.Slice) { srcType = srcType.Elem() srcIsArray = true } - if desType.Kind() == reflect.Array || (desType.Kind() == reflect.Ptr && desType.Elem().Kind() == reflect.Array) || desType.Kind() == reflect.Slice || (desType.Kind() == reflect.Ptr && desType.Elem().Kind() == reflect.Slice) { + if desType.Kind() == reflect.Array || (desType.Kind() == reflect.Ptr && desType.Elem().Kind() == reflect.Array) || + desType.Kind() == reflect.Slice || + (desType.Kind() == reflect.Ptr && desType.Elem().Kind() == reflect.Slice) { desType = desType.Elem() desIsArray = true } @@ -201,11 +207,19 @@ func configProfile(srcType reflect.Type, destType reflect.Type) { // check for provided types kind. // if not struct - skip. if srcType.Kind() != reflect.Struct { - defaultLogger.Logger.Errorf("expected reflect.Struct kind for type %s, but got %s", srcType.String(), srcType.Kind().String()) + defaultLogger.Logger.Errorf( + "expected reflect.Struct kind for type %s, but got %s", + srcType.String(), + srcType.Kind().String(), + ) } if destType.Kind() != reflect.Struct { - defaultLogger.Logger.Errorf("expected reflect.Struct kind for type %s, but got %s", destType.String(), destType.Kind().String()) + defaultLogger.Logger.Errorf( + "expected reflect.Struct kind for type %s, but got %s", + destType.String(), + destType.Kind().String(), + ) } // profile is slice of src and dest structs fields names @@ -303,7 +317,11 @@ func mapStructs[TDes any, TSrc any](src reflect.Value, dest reflect.Value) { // if types or their slices were not registered - abort profile, ok := profiles[getProfileKey(src.Type(), dest.Type())] if !ok { - defaultLogger.Logger.Errorf("no conversion specified for types %s and %s", src.Type().String(), dest.Type().String()) + defaultLogger.Logger.Errorf( + "no conversion specified for types %s and %s", + src.Type().String(), + dest.Type().String(), + ) return } diff --git a/internal/pkg/messaging/consumer/consumer_handler.go b/internal/pkg/messaging/consumer/consumer_handler.go index ca7ea322..677c527e 100644 --- a/internal/pkg/messaging/consumer/consumer_handler.go +++ b/internal/pkg/messaging/consumer/consumer_handler.go @@ -1,11 +1,11 @@ package consumer import ( - "context" + "context" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" ) type ConsumerHandler interface { - Handle(ctx context.Context, consumeContext types.MessageConsumeContext) error + Handle(ctx context.Context, consumeContext types.MessageConsumeContext) error } diff --git a/internal/pkg/messaging/message_header/metadata_message_extentions.go b/internal/pkg/messaging/message_header/metadata_message_extentions.go index b9e60dfd..80226289 100644 --- a/internal/pkg/messaging/message_header/metadata_message_extentions.go +++ b/internal/pkg/messaging/message_header/metadata_message_extentions.go @@ -1,9 +1,9 @@ package messageHeader import ( - "time" + "time" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" ) func GetCorrelationId(m metadata.Metadata) string { diff --git a/internal/pkg/messaging/otel/tracing/consumer/consumer.go b/internal/pkg/messaging/otel/tracing/consumer/consumer.go index 3630486c..e284b7e9 100644 --- a/internal/pkg/messaging/otel/tracing/consumer/consumer.go +++ b/internal/pkg/messaging/otel/tracing/consumer/consumer.go @@ -1,21 +1,21 @@ package consumer import ( - "context" - "fmt" - "time" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/baggage" - semconv "go.opentelemetry.io/otel/semconv/v1.12.0" - "go.opentelemetry.io/otel/trace" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" - messageHeader "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/message_header" - messageTracing "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/otel/tracing" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" - tracingHeaders "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing/tracing_headers" + "context" + "fmt" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/baggage" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/trace" + + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" + messageHeader "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/message_header" + messageTracing "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/otel/tracing" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" + tracingHeaders "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing/tracing_headers" ) //https://devandchill.com/posts/2021/12/go-step-by-step-guide-for-implementing-tracing-on-a-microservices-architecture-2/2/ @@ -25,7 +25,12 @@ import ( //https://opentelemetry.io/docs/instrumentation/go/manual/#semantic-attributes //https://trstringer.com/otel-part5-propagation/ -func StartConsumerSpan(ctx context.Context, meta *metadata.Metadata, payload string, consumerTracingOptions *ConsumerTracingOptions) (context.Context, trace.Span) { +func StartConsumerSpan( + ctx context.Context, + meta *metadata.Metadata, + payload string, + consumerTracingOptions *ConsumerTracingOptions, +) (context.Context, trace.Span) { ctx = addAfterBaggage(ctx, meta) // If there's a span context in the message, use that as the parent context. @@ -37,7 +42,10 @@ func StartConsumerSpan(ctx context.Context, meta *metadata.Metadata, payload str //https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#span-name // SpanName = Destination Name + Operation Name - ctx, span := messageTracing.MessagingTracer.Start(parentSpanContext, fmt.Sprintf("%s %s", consumerTracingOptions.Destination, "receive"), opts...) + ctx, span := messageTracing.MessagingTracer.Start( + parentSpanContext, + fmt.Sprintf("%s %s", consumerTracingOptions.Destination, "receive"), + opts...) span.AddEvent(fmt.Sprintf("start consuming message '%s' from the broker", messageHeader.GetMessageName(*meta))) @@ -66,7 +74,11 @@ func FinishConsumerSpan(span trace.Span, err error) error { return err } -func getTraceOptions(meta *metadata.Metadata, payload string, consumerTracingOptions *ConsumerTracingOptions) []trace.SpanStartOption { +func getTraceOptions( + meta *metadata.Metadata, + payload string, + consumerTracingOptions *ConsumerTracingOptions, +) []trace.SpanStartOption { correlationId := messageHeader.GetCorrelationId(*meta) //https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#topic-with-multiple-consumers diff --git a/internal/pkg/messaging/otel/tracing/producer/producer.go b/internal/pkg/messaging/otel/tracing/producer/producer.go index d3abc4e8..5f9b3a32 100644 --- a/internal/pkg/messaging/otel/tracing/producer/producer.go +++ b/internal/pkg/messaging/otel/tracing/producer/producer.go @@ -1,21 +1,21 @@ package producer import ( - "context" - "fmt" - "time" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/baggage" - semconv "go.opentelemetry.io/otel/semconv/v1.12.0" - "go.opentelemetry.io/otel/trace" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" - messageHeader "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/message_header" - messageTracing "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/otel/tracing" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" + "context" + "fmt" + "time" + + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/baggage" + semconv "go.opentelemetry.io/otel/semconv/v1.12.0" + "go.opentelemetry.io/otel/trace" + + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" + messageHeader "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/message_header" + messageTracing "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/otel/tracing" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" ) //https://devandchill.com/posts/2021/12/go-step-by-step-guide-for-implementing-tracing-on-a-microservices-architecture-2/2/ @@ -25,7 +25,13 @@ import ( //https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#messaging-attributes //https://trstringer.com/otel-part5-propagation/ -func StartProducerSpan(ctx context.Context, message types.IMessage, meta *metadata.Metadata, payload string, producerTracingOptions *ProducerTracingOptions) (context.Context, trace.Span) { +func StartProducerSpan( + ctx context.Context, + message types.IMessage, + meta *metadata.Metadata, + payload string, + producerTracingOptions *ProducerTracingOptions, +) (context.Context, trace.Span) { ctx = addAfterBaggage(ctx, message, meta) // If there's a span context in the message, use that as the parent context. @@ -37,7 +43,10 @@ func StartProducerSpan(ctx context.Context, message types.IMessage, meta *metada //https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#span-name // SpanName = Destination Name + Operation Name - ctx, span := messageTracing.MessagingTracer.Start(parentSpanContext, fmt.Sprintf("%s %s", producerTracingOptions.Destination, "send"), opts...) + ctx, span := messageTracing.MessagingTracer.Start( + parentSpanContext, + fmt.Sprintf("%s %s", producerTracingOptions.Destination, "send"), + opts...) span.AddEvent(fmt.Sprintf("start publishing message '%s' to the broker", messageHeader.GetMessageName(*meta))) @@ -67,7 +76,12 @@ func FinishProducerSpan(span trace.Span, err error) error { return err } -func getTraceOptions(meta *metadata.Metadata, message types.IMessage, payload string, producerTracingOptions *ProducerTracingOptions) []trace.SpanStartOption { +func getTraceOptions( + meta *metadata.Metadata, + message types.IMessage, + payload string, + producerTracingOptions *ProducerTracingOptions, +) []trace.SpanStartOption { correlationId := messageHeader.GetCorrelationId(*meta) //https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/messaging.md#topic-with-multiple-consumers diff --git a/internal/pkg/messaging/otel/tracing/utils.go b/internal/pkg/messaging/otel/tracing/utils.go index 7fa21d62..a662e2bf 100644 --- a/internal/pkg/messaging/otel/tracing/utils.go +++ b/internal/pkg/messaging/otel/tracing/utils.go @@ -1,38 +1,38 @@ package tracing import ( - "context" + "context" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/codes" - "go.opentelemetry.io/otel/trace" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/trace" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" ) // TraceMessagingErrFromSpan setting span with status error with error message func TraceMessagingErrFromSpan(span trace.Span, err error) error { - if err != nil { - stackTraceError := errorUtils.ErrorsWithStack(err) - span.SetStatus(codes.Error, "") - span.SetAttributes(attribute.String(MessagingErrorMessage, stackTraceError)) - span.RecordError(err) - } - - return err + if err != nil { + stackTraceError := errorUtils.ErrorsWithStack(err) + span.SetStatus(codes.Error, "") + span.SetAttributes(attribute.String(MessagingErrorMessage, stackTraceError)) + span.RecordError(err) + } + + return err } func TraceMessagingErrFromContext(ctx context.Context, err error) error { - //https://opentelemetry.io/docs/instrumentation/go/manual/#record-errors - span := trace.SpanFromContext(ctx) - defer span.End() - - if err != nil { - stackTraceError := errorUtils.ErrorsWithStack(err) - span.SetStatus(codes.Error, "") - span.SetAttributes(attribute.String(MessagingErrorMessage, stackTraceError)) - span.RecordError(err) - } - - return err + //https://opentelemetry.io/docs/instrumentation/go/manual/#record-errors + span := trace.SpanFromContext(ctx) + defer span.End() + + if err != nil { + stackTraceError := errorUtils.ErrorsWithStack(err) + span.SetStatus(codes.Error, "") + span.SetAttributes(attribute.String(MessagingErrorMessage, stackTraceError)) + span.RecordError(err) + } + + return err } diff --git a/internal/pkg/messaging/pipeline/consumer_pipeline.go b/internal/pkg/messaging/pipeline/consumer_pipeline.go index 8a5a9817..05c2165b 100644 --- a/internal/pkg/messaging/pipeline/consumer_pipeline.go +++ b/internal/pkg/messaging/pipeline/consumer_pipeline.go @@ -1,9 +1,9 @@ package pipeline import ( - "context" + "context" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" ) // ConsumerHandlerFunc is a continuation for the next task to execute in the pipeline @@ -11,5 +11,5 @@ type ConsumerHandlerFunc func() error // ConsumerPipeline is a Pipeline for wrapping the inner consumer handler. type ConsumerPipeline interface { - Handle(ctx context.Context, consumerContext types.MessageConsumeContext, next ConsumerHandlerFunc) error + Handle(ctx context.Context, consumerContext types.MessageConsumeContext, next ConsumerHandlerFunc) error } diff --git a/internal/pkg/messaging/pipeline/consumer_pipeline_configuration_builder.go b/internal/pkg/messaging/pipeline/consumer_pipeline_configuration_builder.go index 36b7c515..7a19a7be 100644 --- a/internal/pkg/messaging/pipeline/consumer_pipeline_configuration_builder.go +++ b/internal/pkg/messaging/pipeline/consumer_pipeline_configuration_builder.go @@ -15,7 +15,9 @@ func NewConsumerPipelineConfigurationBuilder() ConsumerPipelineConfigurationBuil return &consumerPipelineConfigurationBuilder{pipelineConfigurations: &ConsumerPipelineConfiguration{}} } -func (c *consumerPipelineConfigurationBuilder) AddPipeline(pipeline ConsumerPipeline) ConsumerPipelineConfigurationBuilder { +func (c *consumerPipelineConfigurationBuilder) AddPipeline( + pipeline ConsumerPipeline, +) ConsumerPipelineConfigurationBuilder { c.pipelineConfigurations.Pipelines = append(c.pipelineConfigurations.Pipelines, pipeline) return c } diff --git a/internal/pkg/messaging/types/message_consume_context.go b/internal/pkg/messaging/types/message_consume_context.go index 21351cf9..6d214c37 100644 --- a/internal/pkg/messaging/types/message_consume_context.go +++ b/internal/pkg/messaging/types/message_consume_context.go @@ -1,74 +1,83 @@ package types import ( - "time" + "time" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/metadata" ) type MessageConsumeContext interface { - MessageId() string - CorrelationId() string - MessageType() string - Created() time.Time - ContentType() string - DeliveryTag() uint64 - Metadata() metadata.Metadata - Message() IMessage + MessageId() string + CorrelationId() string + MessageType() string + Created() time.Time + ContentType() string + DeliveryTag() uint64 + Metadata() metadata.Metadata + Message() IMessage } type messageConsumeContext struct { - metadata metadata.Metadata - contentType string - messageType string - messageId string - created time.Time - tag uint64 - correlationId string - message IMessage + metadata metadata.Metadata + contentType string + messageType string + messageId string + created time.Time + tag uint64 + correlationId string + message IMessage } -func NewMessageConsumeContext(message IMessage, meta metadata.Metadata, contentType string, messageType string, created time.Time, deliveryTag uint64, messageId string, correlationId string) MessageConsumeContext { - return &messageConsumeContext{ - message: message, - metadata: meta, - contentType: contentType, - messageId: messageId, - tag: deliveryTag, - created: created, - messageType: messageType, - correlationId: correlationId, - } +func NewMessageConsumeContext( + message IMessage, + meta metadata.Metadata, + contentType string, + messageType string, + created time.Time, + deliveryTag uint64, + messageId string, + correlationId string, +) MessageConsumeContext { + return &messageConsumeContext{ + message: message, + metadata: meta, + contentType: contentType, + messageId: messageId, + tag: deliveryTag, + created: created, + messageType: messageType, + correlationId: correlationId, + } } func (m *messageConsumeContext) Message() IMessage { - return m.message + return m.message } func (m *messageConsumeContext) MessageId() string { - return m.messageId + return m.messageId } func (m *messageConsumeContext) CorrelationId() string { - return m.correlationId + return m.correlationId } func (m *messageConsumeContext) MessageType() string { - return m.messageType + return m.messageType } func (m *messageConsumeContext) ContentType() string { - return m.contentType + return m.contentType } func (m *messageConsumeContext) Metadata() metadata.Metadata { - return m.metadata + return m.metadata } func (m *messageConsumeContext) Created() time.Time { - return m.created + return m.created } func (m *messageConsumeContext) DeliveryTag() uint64 { - return m.tag + return m.tag } diff --git a/internal/pkg/migrate/mongo.go b/internal/pkg/migrate/mongo.go index dd9564cf..985a8b68 100644 --- a/internal/pkg/migrate/mongo.go +++ b/internal/pkg/migrate/mongo.go @@ -24,7 +24,7 @@ func (config *MigrationConfig) Migrate(ctx context.Context) error { return errors.New("DBName is required in the config.") } - db, err := mongodb2.NewMongoDB(ctx, &mongodb2.MongoDbOptions{ + db, err := mongodb2.NewMongoDB(&mongodb2.MongoDbOptions{ Host: config.Host, Port: config.Port, User: config.User, diff --git a/internal/pkg/migrate/postgres.go b/internal/pkg/migrate/postgres.go index 50b22f05..72820b7d 100644 --- a/internal/pkg/migrate/postgres.go +++ b/internal/pkg/migrate/postgres.go @@ -3,14 +3,15 @@ package migrate import ( "context" "database/sql" - "emperror.dev/errors" "fmt" + "path/filepath" + "runtime" + + "emperror.dev/errors" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/postgres" "github.com/jackc/pgx/v4/pgxpool" "go.uber.org/zap" - "path/filepath" - "runtime" ) // Up executes all migrations found at the given source path against the @@ -108,7 +109,10 @@ func createDB(cfg *MigrationConfig, ctx context.Context) error { } var exists int - rows, err := connPool.Query(context.Background(), fmt.Sprintf("SELECT 1 FROM pg_catalog.pg_database WHERE datname='%s'", cfg.DBName)) + rows, err := connPool.Query( + context.Background(), + fmt.Sprintf("SELECT 1 FROM pg_catalog.pg_database WHERE datname='%s'", cfg.DBName), + ) if err != nil { return err } diff --git a/internal/pkg/mongodb/repository/mongo_generic_repository.go b/internal/pkg/mongodb/repository/mongo_generic_repository.go index 6427773e..5b45b4e0 100644 --- a/internal/pkg/mongodb/repository/mongo_generic_repository.go +++ b/internal/pkg/mongodb/repository/mongo_generic_repository.go @@ -1,29 +1,29 @@ package repository import ( - "context" - "fmt" + "context" + "fmt" - "github.com/goccy/go-reflect" + "github.com/goccy/go-reflect" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" - "emperror.dev/errors" + "emperror.dev/errors" - "github.com/iancoleman/strcase" - uuid "github.com/satori/go.uuid" - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" + "github.com/iancoleman/strcase" + uuid "github.com/satori/go.uuid" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mongodb" - reflectionHelper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/reflection_helper" - typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mongodb" + reflectionHelper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/reflection_helper" + typeMapper "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/reflection/type_mappper" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" ) // https://github.com/Kamva/mgm @@ -39,7 +39,11 @@ type mongoGenericRepository[TDataModel interface{}, TEntity interface{}] struct } // NewGenericMongoRepositoryWithDataModel create new gorm generic repository -func NewGenericMongoRepositoryWithDataModel[TDataModel interface{}, TEntity interface{}](db *mongo.Client, databaseName string, collectionName string) data.GenericRepositoryWithDataModel[TDataModel, TEntity] { +func NewGenericMongoRepositoryWithDataModel[TDataModel interface{}, TEntity interface{}]( + db *mongo.Client, + databaseName string, + collectionName string, +) data.GenericRepositoryWithDataModel[TDataModel, TEntity] { return &mongoGenericRepository[TDataModel, TEntity]{ db: db, collectionName: collectionName, @@ -48,7 +52,11 @@ func NewGenericMongoRepositoryWithDataModel[TDataModel interface{}, TEntity inte } // NewGenericMongoRepository create new gorm generic repository -func NewGenericMongoRepository[TEntity interface{}](db *mongo.Client, databaseName string, collectionName string) data.GenericRepository[TEntity] { +func NewGenericMongoRepository[TEntity interface{}]( + db *mongo.Client, + databaseName string, + collectionName string, +) data.GenericRepository[TEntity] { return &mongoGenericRepository[TEntity, TEntity]{ db: db, collectionName: collectionName, @@ -111,9 +119,15 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) GetById(ctx context.Contex if err := collection.FindOne(ctx, bson.M{"_id": id.String()}).Decode(&model); err != nil { // ErrNoDocuments means that the filter did not match any documents in the collection if err == mongo.ErrNoDocuments { - return *new(TEntity), customErrors.NewNotFoundErrorWrap(err, fmt.Sprintf("can't find the entity with id %s into the database.", id.String())) + return *new(TEntity), customErrors.NewNotFoundErrorWrap( + err, + fmt.Sprintf("can't find the entity with id %s into the database.", id.String()), + ) } - return *new(TEntity), errors.WrapIf(err, fmt.Sprintf("can't find the entity with id %s into the database.", id.String())) + return *new(TEntity), errors.WrapIf( + err, + fmt.Sprintf("can't find the entity with id %s into the database.", id.String()), + ) } return model, nil } else { @@ -133,7 +147,10 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) GetById(ctx context.Contex } } -func (m *mongoGenericRepository[TDataModel, TEntity]) GetAll(ctx context.Context, listQuery *utils.ListQuery) (*utils.ListResult[TEntity], error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) GetAll( + ctx context.Context, + listQuery *utils.ListQuery, +) (*utils.ListResult[TEntity], error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() collection := m.db.Database(m.databaseName).Collection(m.collectionName) @@ -157,7 +174,11 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) GetAll(ctx context.Context } } -func (m *mongoGenericRepository[TDataModel, TEntity]) Search(ctx context.Context, searchTerm string, listQuery *utils.ListQuery) (*utils.ListResult[TEntity], error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) Search( + ctx context.Context, + searchTerm string, + listQuery *utils.ListQuery, +) (*utils.ListResult[TEntity], error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() collection := m.db.Database(m.databaseName).Collection(m.collectionName) @@ -205,7 +226,10 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) Search(ctx context.Context } } -func (m *mongoGenericRepository[TDataModel, TEntity]) GetByFilter(ctx context.Context, filters map[string]interface{}) ([]TEntity, error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) GetByFilter( + ctx context.Context, + filters map[string]interface{}, +) ([]TEntity, error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() collection := m.db.Database(m.databaseName).Collection(m.collectionName) @@ -249,11 +273,17 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) GetByFilter(ctx context.Co } } -func (m *mongoGenericRepository[TDataModel, TEntity]) GetByFuncFilter(ctx context.Context, filterFunc func(TEntity) bool) ([]TEntity, error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) GetByFuncFilter( + ctx context.Context, + filterFunc func(TEntity) bool, +) ([]TEntity, error) { return nil, nil } -func (m *mongoGenericRepository[TDataModel, TEntity]) FirstOrDefault(ctx context.Context, filters map[string]interface{}) (TEntity, error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) FirstOrDefault( + ctx context.Context, + filters map[string]interface{}, +) (TEntity, error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() collection := m.db.Database(m.databaseName).Collection(m.collectionName) @@ -361,7 +391,11 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) Delete(ctx context.Context return nil } -func (m *mongoGenericRepository[TDataModel, TEntity]) SkipTake(ctx context.Context, skip int, take int) ([]TEntity, error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) SkipTake( + ctx context.Context, + skip int, + take int, +) ([]TEntity, error) { dataModelType := typeMapper.GetTypeFromGeneric[TDataModel]() modelType := typeMapper.GetTypeFromGeneric[TEntity]() collection := m.db.Database(m.databaseName).Collection(m.collectionName) @@ -414,7 +448,10 @@ func (m *mongoGenericRepository[TDataModel, TEntity]) Count(ctx context.Context) return count } -func (m *mongoGenericRepository[TDataModel, TEntity]) Find(ctx context.Context, specification specification.Specification) ([]TEntity, error) { +func (m *mongoGenericRepository[TDataModel, TEntity]) Find( + ctx context.Context, + specification specification.Specification, +) ([]TEntity, error) { // TODO implement me panic("implement me") } diff --git a/internal/pkg/mongodb/repository/mongo_generic_repository_test.go b/internal/pkg/mongodb/repository/mongo_generic_repository_test.go index 0ab2cac3..98ec0c91 100644 --- a/internal/pkg/mongodb/repository/mongo_generic_repository_test.go +++ b/internal/pkg/mongodb/repository/mongo_generic_repository_test.go @@ -1,22 +1,22 @@ package repository import ( - "context" - "log" - "testing" - - mongo2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/mongo" - - uuid "github.com/satori/go.uuid" - "github.com/stretchr/testify/assert" - "go.mongodb.org/mongo-driver/mongo" - "go.mongodb.org/mongo-driver/mongo/options" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" + "context" + "log" + "testing" + + mongo2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/mongo" + + uuid "github.com/satori/go.uuid" + "github.com/stretchr/testify/assert" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" + + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/core/data/specification" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" ) const ( @@ -33,9 +33,9 @@ type Product struct { } type ProductMongo struct { - ID string `json:"id" bson:"_id,omitempty"` // https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#the-_id-field - Name string `json:"name" bson:"name"` - Weight int `json:"weight" bson:"weight"` + ID string `json:"id" bson:"_id,omitempty"` // https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#the-_id-field + Name string `json:"name" bson:"name"` + Weight int `json:"weight" bson:"weight"` IsAvailable bool `json:"isAvailable" bson:"isAvailable"` } @@ -56,7 +56,9 @@ func Test_Add(t *testing.T) { repository, err := setupGenericMongoRepository(ctx, t) product := &ProductMongo{ - ID: uuid.NewV4().String(), // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid + ID: uuid.NewV4(). + String(), + // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid Name: "added_product", Weight: 100, IsAvailable: true, @@ -89,7 +91,9 @@ func Test_Add_With_Data_Model(t *testing.T) { } product := &Product{ - ID: uuid.NewV4().String(), // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid + ID: uuid.NewV4(). + String(), + // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid Name: "added_product", Weight: 100, IsAvailable: true, @@ -503,7 +507,10 @@ func Test_Find(t *testing.T) { t.Fatal(err) } - entities, err := repository.Find(ctx, specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1"))) + entities, err := repository.Find( + ctx, + specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1")), + ) if err != nil { return } @@ -517,14 +524,20 @@ func Test_Find_With_Data_Model(t *testing.T) { t.Fatal(err) } - entities, err := repository.Find(ctx, specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1"))) + entities, err := repository.Find( + ctx, + specification.And(specification.Equal("is_available", true), specification.Equal("name", "seed_product1")), + ) if err != nil { return } assert.Equal(t, len(entities), 1) } -func setupGenericMongoRepositoryWithDataModel(ctx context.Context, t *testing.T) (data.GenericRepositoryWithDataModel[*ProductMongo, *Product], error) { +func setupGenericMongoRepositoryWithDataModel( + ctx context.Context, + t *testing.T, +) (data.GenericRepositoryWithDataModel[*ProductMongo, *Product], error) { db, err := mongo2.NewMongoTestContainers().Start(ctx, t) if err != nil { return nil, err @@ -555,13 +568,17 @@ func setupGenericMongoRepository(ctx context.Context, t *testing.T) (data.Generi func seedAndMigration(ctx context.Context, db *mongo.Client) error { seedProducts := []*ProductMongo{ { - ID: uuid.NewV4().String(), // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid + ID: uuid.NewV4(). + String(), + // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid Name: "seed_product1", Weight: 100, IsAvailable: true, }, { - ID: uuid.NewV4().String(), // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid + ID: uuid.NewV4(). + String(), + // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid Name: "seed_product2", Weight: 100, IsAvailable: true, diff --git a/internal/pkg/otel/tracing/utils.go b/internal/pkg/otel/tracing/utils.go index 51ac119b..926fd86e 100644 --- a/internal/pkg/otel/tracing/utils.go +++ b/internal/pkg/otel/tracing/utils.go @@ -68,7 +68,12 @@ func ParentSpanFromContext(ctx context.Context) trace.Span { return nopSpan } -func CopyFromParentSpanAttribute(ctx context.Context, span trace.Span, attributeName string, parentAttributeName string) { +func CopyFromParentSpanAttribute( + ctx context.Context, + span trace.Span, + attributeName string, + parentAttributeName string, +) { parentAtt := GetParentSpanAttribute(ctx, parentAttributeName) if reflect.ValueOf(parentAtt).IsZero() { return @@ -76,7 +81,13 @@ func CopyFromParentSpanAttribute(ctx context.Context, span trace.Span, attribute span.SetAttributes(attribute.String(attributeName, parentAtt.Value.AsString())) } -func CopyFromParentSpanAttributeIfNotSet(ctx context.Context, span trace.Span, attributeName string, attributeValue string, parentAttributeName string) { +func CopyFromParentSpanAttributeIfNotSet( + ctx context.Context, + span trace.Span, + attributeName string, + attributeValue string, + parentAttributeName string, +) { if attributeValue != "" { span.SetAttributes(attribute.String(attributeName, attributeValue)) return @@ -90,7 +101,8 @@ func GetParentSpanAttribute(ctx context.Context, parentAttributeName string) att if !ok { return *new(attribute.KeyValue) } - att := linq.From(readWriteSpan.Attributes()).FirstWithT(func(att attribute.KeyValue) bool { return string(att.Key) == parentAttributeName }) + att := linq.From(readWriteSpan.Attributes()). + FirstWithT(func(att attribute.KeyValue) bool { return string(att.Key) == parentAttributeName }) return att.(attribute.KeyValue) } @@ -101,7 +113,8 @@ func GetSpanAttributeFromCurrentContext(ctx context.Context, attributeName strin if !ok { return *new(attribute.KeyValue) } - att := linq.From(readWriteSpan.Attributes()).FirstWithT(func(att attribute.KeyValue) bool { return string(att.Key) == attributeName }) + att := linq.From(readWriteSpan.Attributes()). + FirstWithT(func(att attribute.KeyValue) bool { return string(att.Key) == attributeName }) return att.(attribute.KeyValue) } @@ -111,7 +124,8 @@ func GetSpanAttribute(span trace.Span, attributeName string) attribute.KeyValue if !ok { return *new(attribute.KeyValue) } - att := linq.From(readWriteSpan.Attributes()).FirstWithT(func(att attribute.KeyValue) bool { return string(att.Key) == attributeName }) + att := linq.From(readWriteSpan.Attributes()). + FirstWithT(func(att attribute.KeyValue) bool { return string(att.Key) == attributeName }) return att.(attribute.KeyValue) } diff --git a/internal/pkg/postgres_pgx/interface.go b/internal/pkg/postgres_pgx/interface.go index 54a12a9d..8e1b4cef 100644 --- a/internal/pkg/postgres_pgx/interface.go +++ b/internal/pkg/postgres_pgx/interface.go @@ -3,6 +3,7 @@ package postgres // Ref:https://github.com/henvic/pgxtutorial/blob/668784624474abea3619433c6e45510f4d156649/internal/database/interface.go import ( "context" + "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" @@ -46,7 +47,12 @@ type PGXQuerier interface { // CopyFrom requires all values use the binary format. Almost all types // implemented by pgx use the binary format by defaultLogger. Types implementing // Encoder can only be used if they encode to the binary format. - CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) + CopyFrom( + ctx context.Context, + tableName pgx.Identifier, + columnNames []string, + rowSrc pgx.CopyFromSource, + ) (int64, error) // Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced // positionally from the sql string as $1, $2, etc. @@ -63,7 +69,13 @@ type PGXQuerier interface { // QueryFunc executes sql with args. For each row returned by the query the values will scanned into the elements of // scans and f will be called. If any row fails to scan or f returns an error the query will be aborted and the error // will be returned. - QueryFunc(ctx context.Context, sql string, args []any, scans []any, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error) + QueryFunc( + ctx context.Context, + sql string, + args []any, + scans []any, + f func(pgx.QueryFuncRow) error, + ) (pgconn.CommandTag, error) // QueryRow is a convenience wrapper over Query. Any error that occurs while // querying is deferred until calling Scan on the returned Row. That Row will diff --git a/internal/pkg/reflection/reflection_helper/reflection_helper_test.go b/internal/pkg/reflection/reflection_helper/reflection_helper_test.go index 23b33be9..c37a9632 100644 --- a/internal/pkg/reflection/reflection_helper/reflection_helper_test.go +++ b/internal/pkg/reflection/reflection_helper/reflection_helper_test.go @@ -1,9 +1,10 @@ package reflectionHelper import ( - "github.com/stretchr/testify/assert" "reflect" "testing" + + "github.com/stretchr/testify/assert" ) // ref: https://gist.github.com/drewolson/4771479 diff --git a/internal/pkg/reflection/type_mappper/type_mapper_test.go b/internal/pkg/reflection/type_mappper/type_mapper_test.go index 9d1f8512..36141d6b 100644 --- a/internal/pkg/reflection/type_mappper/type_mapper_test.go +++ b/internal/pkg/reflection/type_mappper/type_mapper_test.go @@ -1,8 +1,9 @@ package typeMapper import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestTypes(t *testing.T) { diff --git a/internal/pkg/test/containers/dockertest/gorm/gorm_container.go b/internal/pkg/test/containers/dockertest/gorm/gorm_container.go index 4c5c1a0f..546bcf4b 100644 --- a/internal/pkg/test/containers/dockertest/gorm/gorm_container.go +++ b/internal/pkg/test/containers/dockertest/gorm/gorm_container.go @@ -11,6 +11,7 @@ import ( "github.com/phayes/freeport" "gorm.io/gorm" + gormPostgres "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/gorm_postgres" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/contracts" ) @@ -34,11 +35,11 @@ func NewGormDockerTest() contracts.GormContainer { } } -func (g *gormDockerTest) Start( +func (g *gormDockerTest) CreatingContainerOptions( ctx context.Context, t *testing.T, options ...*contracts.PostgresContainerOptions, -) (*gorm.DB, error) { +) (*gormPostgres.GormOptions, error) { //https://github.com/ory/dockertest/blob/v3/examples/PostgreSQL.md //https://github.com/bozd4g/fb.testcontainers pool, err := dockertest.NewPool("") @@ -63,45 +64,45 @@ func (g *gormDockerTest) Start( 120, ) // Tell docker to hard kill the container in 120 seconds exponential backoff-retry, because the application_exceptions in the container might not be ready to accept connections yet - //g.resource = resource - //i, _ = strconv.Atoi(resource.GetPort("5432/tcp")) - //g.defaultOptions.HostPort = i + g.resource = resource + port, _ := strconv.Atoi(resource.GetPort("5432/tcp")) + g.defaultOptions.HostPort = port t.Cleanup(func() { _ = resource.Close() }) - go func() { - for { - select { - case <-ctx.Done(): - _ = resource.Close() - return - } - } - }() - - var db *gorm.DB + var postgresoptions *gormPostgres.GormOptions if err = pool.Retry(func() error { - gormDb, err := gormPostgres.NewGorm(&gormPostgres.GormOptions{ + postgresoptions = &gormPostgres.GormOptions{ Port: g.defaultOptions.HostPort, Host: g.defaultOptions.Host, Password: g.defaultOptions.Password, DBName: g.defaultOptions.Database, SSLMode: false, User: g.defaultOptions.UserName, - }) - if err != nil { - return err } - db = gormDb - sqlDb, _ := db.DB() - return sqlDb.Ping() + return nil }); err != nil { log.Fatalf("Could not connect to docker: %s", err) return nil, err } + return postgresoptions, nil +} + +func (g *gormDockerTest) Start( + ctx context.Context, + t *testing.T, + options ...*contracts.PostgresContainerOptions, +) (*gorm.DB, error) { + gormOptions, err := g.CreatingContainerOptions(ctx, t, options...) + if err != nil { + return nil, err + } + + db, err := gormPostgres.NewGorm(gormOptions) + return db, nil } diff --git a/internal/pkg/test/containers/dockertest/gorm/gorm_container_test.go b/internal/pkg/test/containers/dockertest/gorm/gorm_container_test.go index 9750b880..ebee5aba 100644 --- a/internal/pkg/test/containers/dockertest/gorm/gorm_container_test.go +++ b/internal/pkg/test/containers/dockertest/gorm/gorm_container_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -12,5 +11,5 @@ func Test_Gorm_Container(t *testing.T) { gorm, err := NewGormDockerTest().Start(context.Background(), t) require.NoError(t, err) - assert.NotNil(t, gorm) + require.NotNil(t, gorm) } diff --git a/internal/pkg/test/containers/dockertest/mongo/mongo_container.go b/internal/pkg/test/containers/dockertest/mongo/mongo_container.go index cafc90e4..4f27d298 100644 --- a/internal/pkg/test/containers/dockertest/mongo/mongo_container.go +++ b/internal/pkg/test/containers/dockertest/mongo/mongo_container.go @@ -35,11 +35,11 @@ func NewMongoDockerTest() contracts.MongoContainer { } } -func (g *mongoDockerTest) Start( +func (g *mongoDockerTest) CreatingContainerOptions( ctx context.Context, t *testing.T, options ...*contracts.MongoContainerOptions, -) (*mongo.Client, error) { +) (*mongodb.MongoDbOptions, error) { pool, err := dockertest.NewPool("") if err != nil { log.Fatalf("Could not connect to docker: %s", err) @@ -64,8 +64,8 @@ func (g *mongoDockerTest) Start( ) // Tell docker to hard kill the container in 120 seconds exponential backoff-retry, because the application_exceptions in the container might not be ready to accept connections yet g.resource = resource - i, _ := strconv.Atoi(resource.GetPort(fmt.Sprintf("%s/tcp", g.defaultOptions.Port))) - g.defaultOptions.HostPort = i + port, _ := strconv.Atoi(resource.GetPort(fmt.Sprintf("%s/tcp", g.defaultOptions.Port))) + g.defaultOptions.HostPort = port t.Cleanup(func() { _ = resource.Close() }) @@ -79,27 +79,34 @@ func (g *mongoDockerTest) Start( } }() - var mongoClient *mongo.Client - if err = pool.Retry(func() error { - db, err := mongodb.NewMongoDB(ctx, &mongodb.MongoDbOptions{ - User: g.defaultOptions.UserName, - Password: g.defaultOptions.Password, - UseAuth: false, - Host: g.defaultOptions.Host, - Port: g.defaultOptions.HostPort, - Database: g.defaultOptions.Database, - }) - if err != nil { - return err - } - mongoClient = db - return mongoClient.Ping(context.TODO(), nil) - }); err != nil { - log.Fatalf("Could not connect to docker: %s", err) + mongoOptions := &mongodb.MongoDbOptions{ + User: g.defaultOptions.UserName, + Password: g.defaultOptions.Password, + UseAuth: false, + Host: g.defaultOptions.Host, + Port: g.defaultOptions.HostPort, + Database: g.defaultOptions.Database, + } + + return mongoOptions, nil +} + +func (g *mongoDockerTest) Start( + ctx context.Context, + t *testing.T, + options ...*contracts.MongoContainerOptions, +) (*mongo.Client, error) { + mongoOptions, err := g.CreatingContainerOptions(ctx, t, options...) + if err != nil { + return nil, err + } + + db, err := mongodb.NewMongoDB(mongoOptions) + if err != nil { return nil, err } - return mongoClient, nil + return db, nil } func (g *mongoDockerTest) Cleanup(ctx context.Context) error { diff --git a/internal/pkg/test/containers/gnomock/gorm/gorm_container.go b/internal/pkg/test/containers/gnomock/gorm/gorm_container.go index 3ee5833b..16f0c908 100644 --- a/internal/pkg/test/containers/gnomock/gorm/gorm_container.go +++ b/internal/pkg/test/containers/gnomock/gorm/gorm_container.go @@ -10,6 +10,7 @@ import ( "github.com/orlangure/gnomock/preset/postgres" "gorm.io/gorm" + gormPostgres "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/gorm_postgres" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/contracts" ) @@ -33,11 +34,11 @@ func NewGnoMockGormContainer() contracts.GormContainer { } } -func (g *gnoMockGormContainer) Start( +func (g *gnoMockGormContainer) CreatingContainerOptions( ctx context.Context, t *testing.T, options ...*contracts.PostgresContainerOptions, -) (*gorm.DB, error) { +) (*gormPostgres.GormOptions, error) { //https://github.com/orlangure/gnomock gnomock.WithContext(ctx) runOption := g.getRunOptions(options...) @@ -52,14 +53,30 @@ func (g *gnoMockGormContainer) Start( t.Cleanup(func() { _ = gnomock.Stop(container) }) - db, err := gormPostgres.NewGorm(&gormPostgres.GormOptions{ + gormContainerOptions := &gormPostgres.GormOptions{ Port: g.defaultOptions.HostPort, Host: container.Host, Password: g.defaultOptions.Password, DBName: g.defaultOptions.Database, SSLMode: false, User: g.defaultOptions.UserName, - }) + } + + return gormContainerOptions, nil +} + +func (g *gnoMockGormContainer) Start( + ctx context.Context, + t *testing.T, + options ...*contracts.PostgresContainerOptions, +) (*gorm.DB, error) { + + gormOptions, err := g.CreatingContainerOptions(ctx, t, options...) + if err != nil { + return nil, err + } + + db, err := gormPostgres.NewGorm(gormOptions) return db, nil } diff --git a/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go b/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go index 26061d29..58b63446 100644 --- a/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go +++ b/internal/pkg/test/containers/testcontainer/eventstoredb/eventstoredb_container.go @@ -135,7 +135,7 @@ func (g *eventstoredbTestContainers) getRunOptions( "EVENTSTORE_INSECURE": "true", "EVENTSTORE_ENABLE_EXTERNAL_TCP": "true", "EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP": "true", - //"EVENTSTORE_IN_MEM": "true", + "EVENTSTORE_MEM_DB": "true", }, } diff --git a/internal/pkg/test/containers/testcontainer/gorm/gorm_container_test.go b/internal/pkg/test/containers/testcontainer/gorm/gorm_container_test.go index f59acc7b..105d7e7f 100644 --- a/internal/pkg/test/containers/testcontainer/gorm/gorm_container_test.go +++ b/internal/pkg/test/containers/testcontainer/gorm/gorm_container_test.go @@ -2,9 +2,10 @@ package gorm import ( "context" + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_Gorm_Container(t *testing.T) { diff --git a/internal/pkg/test/containers/testcontainer/mongo/mongo_container_test.go b/internal/pkg/test/containers/testcontainer/mongo/mongo_container_test.go index b048b053..1268d48d 100644 --- a/internal/pkg/test/containers/testcontainer/mongo/mongo_container_test.go +++ b/internal/pkg/test/containers/testcontainer/mongo/mongo_container_test.go @@ -2,9 +2,10 @@ package mongo import ( "context" + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_Mongo_Container(t *testing.T) { diff --git a/internal/pkg/test/containers/testcontainer/redis/redis_container_test.go b/internal/pkg/test/containers/testcontainer/redis/redis_container_test.go index da53de58..b42cc6bf 100644 --- a/internal/pkg/test/containers/testcontainer/redis/redis_container_test.go +++ b/internal/pkg/test/containers/testcontainer/redis/redis_container_test.go @@ -2,9 +2,10 @@ package redis import ( "context" + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" ) func Test_Redis_Container(t *testing.T) { diff --git a/internal/pkg/test/hypothesis/hypothesis.go b/internal/pkg/test/hypothesis/hypothesis.go index 96bfd0e4..84df07f2 100644 --- a/internal/pkg/test/hypothesis/hypothesis.go +++ b/internal/pkg/test/hypothesis/hypothesis.go @@ -6,8 +6,6 @@ import ( "github.com/goccy/go-reflect" "github.com/stretchr/testify/assert" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/utils" ) type Hypothesis[T any] interface { diff --git a/internal/pkg/testfixture/postgres_testfixture.go b/internal/pkg/testfixture/postgres_testfixture.go index 4cc330d0..b2d851a2 100644 --- a/internal/pkg/testfixture/postgres_testfixture.go +++ b/internal/pkg/testfixture/postgres_testfixture.go @@ -3,9 +3,10 @@ package testfixture import ( "database/sql" "fmt" - "github.com/go-testfixtures/testfixtures/v3" "path/filepath" "runtime" + + "github.com/go-testfixtures/testfixtures/v3" ) func RunPostgresFixture(db *sql.DB, fixturePaths []string, data map[string]interface{}) error { diff --git a/internal/pkg/utils/error_utils/errors.go b/internal/pkg/utils/error_utils/errors.go index c8ecde92..42fb71b2 100644 --- a/internal/pkg/utils/error_utils/errors.go +++ b/internal/pkg/utils/error_utils/errors.go @@ -1,20 +1,23 @@ package errorUtils import ( - "fmt" - "runtime/debug" - "strings" + "fmt" + "runtime/debug" + "strings" - "emperror.dev/errors" + "emperror.dev/errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/contracts" - defaultLogger "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger/default_logger" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/contracts" + defaultLogger "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger/default_logger" ) // CheckErrMessages check for specific messages contains in the error func CheckErrMessages(err error, messages ...string) bool { for _, message := range messages { - if strings.Contains(strings.TrimSpace(strings.ToLower(err.Error())), strings.TrimSpace(strings.ToLower(message))) { + if strings.Contains( + strings.TrimSpace(strings.ToLower(err.Error())), + strings.TrimSpace(strings.ToLower(message)), + ) { return true } } diff --git a/internal/pkg/utils/error_utils/errors_test.go b/internal/pkg/utils/error_utils/errors_test.go index 1ecfa60c..558c4c2e 100644 --- a/internal/pkg/utils/error_utils/errors_test.go +++ b/internal/pkg/utils/error_utils/errors_test.go @@ -1,10 +1,11 @@ package errorUtils import ( - "emperror.dev/errors" "fmt" - "github.com/stretchr/testify/assert" "testing" + + "emperror.dev/errors" + "github.com/stretchr/testify/assert" ) func Test_StackTraceWithErrors(t *testing.T) { diff --git a/internal/services/catalog_read_service/cmd/app/main.go b/internal/services/catalog_read_service/cmd/app/main.go index 46bd854e..fc519dd6 100644 --- a/internal/services/catalog_read_service/cmd/app/main.go +++ b/internal/services/catalog_read_service/cmd/app/main.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/spf13/cobra" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogreadservice/internal/shared/app" diff --git a/internal/services/catalog_read_service/config/config.test.json b/internal/services/catalog_read_service/config/config.test.json index 284bc504..1a52d455 100644 --- a/internal/services/catalog_read_service/config/config.test.json +++ b/internal/services/catalog_read_service/config/config.test.json @@ -11,7 +11,7 @@ }, "echoHttpOptions": { "name": "catalogs_read_service", - "port": ":7001", + "port": ":5200", "development": true, "timeout": 30, "basePath": "/api/v1", diff --git a/internal/services/catalog_read_service/docs/docs.go b/internal/services/catalog_read_service/docs/docs.go index 2722890d..3fc59951 100644 --- a/internal/services/catalog_read_service/docs/docs.go +++ b/internal/services/catalog_read_service/docs/docs.go @@ -1,5 +1,5 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -53,7 +53,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" } } } @@ -73,32 +73,17 @@ const docTemplate = `{ ], "summary": "Search products", "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, { "type": "string", "name": "search", "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.SearchProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto" } } } @@ -130,7 +115,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductByIdResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto" } } } @@ -138,7 +123,7 @@ const docTemplate = `{ } }, "definitions": { - "dto.ProductDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto": { "type": "object", "properties": { "createdAt": { @@ -164,27 +149,27 @@ const docTemplate = `{ } } }, - "dtos.GetProductByIdResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto": { "type": "object", "properties": { "product": { - "$ref": "#/definitions/dto.ProductDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" } } }, - "dtos.GetProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" } } }, - "dtos.SearchProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" } } }, @@ -201,6 +186,49 @@ const docTemplate = `{ "type": "string" } } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } } } }` @@ -215,6 +243,8 @@ var SwaggerInfo = &swag.Spec{ Description: "Catalogs Read-Service Api.", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/internal/services/catalog_read_service/docs/swagger.json b/internal/services/catalog_read_service/docs/swagger.json index 2754dc89..f26438f3 100644 --- a/internal/services/catalog_read_service/docs/swagger.json +++ b/internal/services/catalog_read_service/docs/swagger.json @@ -44,7 +44,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" } } } @@ -64,32 +64,17 @@ ], "summary": "Search products", "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, { "type": "string", "name": "search", "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.SearchProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto" } } } @@ -121,7 +106,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductByIdResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto" } } } @@ -129,7 +114,7 @@ } }, "definitions": { - "dto.ProductDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto": { "type": "object", "properties": { "createdAt": { @@ -155,27 +140,27 @@ } } }, - "dtos.GetProductByIdResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto": { "type": "object", "properties": { "product": { - "$ref": "#/definitions/dto.ProductDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" } } }, - "dtos.GetProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" } } }, - "dtos.SearchProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto" } } }, @@ -192,6 +177,49 @@ "type": "string" } } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } } } } \ No newline at end of file diff --git a/internal/services/catalog_read_service/docs/swagger.yaml b/internal/services/catalog_read_service/docs/swagger.yaml index bf68d5d7..b4c11854 100644 --- a/internal/services/catalog_read_service/docs/swagger.yaml +++ b/internal/services/catalog_read_service/docs/swagger.yaml @@ -1,5 +1,5 @@ definitions: - dto.ProductDto: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto: properties: createdAt: type: string @@ -16,20 +16,20 @@ definitions: updatedAt: type: string type: object - dtos.GetProductByIdResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto + : properties: product: - $ref: '#/definitions/dto.ProductDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto' type: object - dtos.GetProductsResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto + : properties: products: - type: object + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto' type: object - dtos.SearchProductsResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto + : properties: products: - type: object + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto' type: object utils.FilterModel: properties: @@ -40,6 +40,34 @@ definitions: value: type: string type: object + utils.ListQuery: + properties: + filters: + items: + $ref: '#/definitions/utils.FilterModel' + type: array + orderBy: + type: string + page: + type: integer + size: + type: integer + type: object + ? utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto_ProductDto + : properties: + items: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_dto.ProductDto' + type: array + page: + type: integer + size: + type: integer + totalItems: + type: integer + totalPage: + type: integer + type: object info: contact: name: Mehdi Hadeli @@ -69,7 +97,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dtos.GetProductsResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto' summary: Get all product tags: - Products @@ -90,7 +118,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dtos.GetProductByIdResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_get_product_by_id_v1_dtos.GetProductByIdResponseDto' summary: Get product tags: - Products @@ -100,25 +128,16 @@ paths: - application/json description: Search products parameters: - - in: query - name: orderBy - type: string - - in: query - name: page - type: integer - in: query name: search type: string - - in: query - name: size - type: integer produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/dtos.SearchProductsResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogreadservice_internal_products_features_searching_products_v1_dtos.SearchProductsResponseDto' summary: Search products tags: - Products diff --git a/internal/services/catalog_read_service/go.mod b/internal/services/catalog_read_service/go.mod index 02740bb2..041ace9c 100644 --- a/internal/services/catalog_read_service/go.mod +++ b/internal/services/catalog_read_service/go.mod @@ -20,14 +20,12 @@ require ( github.com/spf13/viper v1.12.0 github.com/stretchr/testify v1.8.3 github.com/swaggo/echo-swagger v1.3.3 - github.com/swaggo/swag v1.8.3 + github.com/swaggo/swag v1.16.1 go.mongodb.org/mongo-driver v1.11.6 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/metric v1.16.0 go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/fx v1.20.0 - google.golang.org/grpc v1.55.0 - google.golang.org/protobuf v1.30.0 ) require ( @@ -173,6 +171,8 @@ require ( golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.7.0 // indirect google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect + google.golang.org/grpc v1.55.0 // indirect + google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/internal/services/catalog_read_service/go.sum b/internal/services/catalog_read_service/go.sum index f5bdc7b7..2bf2bfdc 100644 --- a/internal/services/catalog_read_service/go.sum +++ b/internal/services/catalog_read_service/go.sum @@ -1261,8 +1261,8 @@ github.com/swaggo/echo-swagger v1.3.3/go.mod h1:vbKcEBeJgOexLuPcsdZhrRAV508fsE79 github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= -github.com/swaggo/swag v1.8.3 h1:3pZSSCQ//gAH88lfmxM3Cd1+JCsxV8Md6f36b9hrZ5s= -github.com/swaggo/swag v1.8.3/go.mod h1:jMLeXOOmYyjk8PvHTsXBdrubsNd9gUJTTCzL5iBnseg= +github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= +github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= diff --git a/internal/services/catalog_read_service/internal/products/features/creating_product/v1/commands/create_product.go b/internal/services/catalog_read_service/internal/products/features/creating_product/v1/commands/create_product.go index 296ff8f2..ed90bf36 100644 --- a/internal/services/catalog_read_service/internal/products/features/creating_product/v1/commands/create_product.go +++ b/internal/services/catalog_read_service/internal/products/features/creating_product/v1/commands/create_product.go @@ -18,8 +18,21 @@ type CreateProduct struct { CreatedAt time.Time `validate:"required"` } -func NewCreateProduct(productId string, name string, description string, price float64, createdAt time.Time) (*CreateProduct, error) { - command := &CreateProduct{Id: uuid.NewV4().String(), ProductId: productId, Name: name, Description: description, Price: price, CreatedAt: createdAt} +func NewCreateProduct( + productId string, + name string, + description string, + price float64, + createdAt time.Time, +) (*CreateProduct, error) { + command := &CreateProduct{ + Id: uuid.NewV4().String(), + ProductId: productId, + Name: name, + Description: description, + Price: price, + CreatedAt: createdAt, + } err := validator.Validate(command) if err != nil { return nil, err diff --git a/internal/services/catalog_read_service/internal/products/features/searching_products/v1/dtos/search_products_request_dto.go b/internal/services/catalog_read_service/internal/products/features/searching_products/v1/dtos/search_products_request_dto.go index 1e28eab9..a427a2c4 100644 --- a/internal/services/catalog_read_service/internal/products/features/searching_products/v1/dtos/search_products_request_dto.go +++ b/internal/services/catalog_read_service/internal/products/features/searching_products/v1/dtos/search_products_request_dto.go @@ -6,5 +6,5 @@ import ( type SearchProductsRequestDto struct { SearchText string `query:"search" json:"search"` - *utils.ListQuery `json:"listQuery"` + *utils.ListQuery ` json:"listQuery"` } diff --git a/internal/services/catalog_read_service/internal/products/features/updating_products/v1/commands/update_product.go b/internal/services/catalog_read_service/internal/products/features/updating_products/v1/commands/update_product.go index d8b68408..0bb0884e 100644 --- a/internal/services/catalog_read_service/internal/products/features/updating_products/v1/commands/update_product.go +++ b/internal/services/catalog_read_service/internal/products/features/updating_products/v1/commands/update_product.go @@ -1,8 +1,9 @@ package commands import ( - uuid "github.com/satori/go.uuid" "time" + + uuid "github.com/satori/go.uuid" ) type UpdateProduct struct { @@ -14,5 +15,11 @@ type UpdateProduct struct { } func NewUpdateProduct(productId uuid.UUID, name string, description string, price float64) *UpdateProduct { - return &UpdateProduct{ProductId: productId, Name: name, Description: description, Price: price, UpdatedAt: time.Now()} + return &UpdateProduct{ + ProductId: productId, + Name: name, + Description: description, + Price: price, + UpdatedAt: time.Now(), + } } diff --git a/internal/services/catalog_read_service/internal/products/features/updating_products/v1/events/integration_events/external_events/product_updated.go b/internal/services/catalog_read_service/internal/products/features/updating_products/v1/events/integration_events/external_events/product_updated.go index 98264fca..289e1342 100644 --- a/internal/services/catalog_read_service/internal/products/features/updating_products/v1/events/integration_events/external_events/product_updated.go +++ b/internal/services/catalog_read_service/internal/products/features/updating_products/v1/events/integration_events/external_events/product_updated.go @@ -1,16 +1,16 @@ package externalEvents import ( - "time" + "time" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/types" ) type ProductUpdatedV1 struct { - *types.Message - ProductId string `json:"productId,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - Price float64 `json:"price,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty"` + *types.Message + ProductId string `json:"productId,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + Price float64 `json:"price,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` } diff --git a/internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go b/internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go deleted file mode 100644 index 18c1c182..00000000 --- a/internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go +++ /dev/null @@ -1,650 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.0 -// protoc v3.20.1 -// source: api_docs/catalogs_write/catalogs_read/protobuf/products/service_clients/products.proto - -package products_service - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Product struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProductId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=Description,proto3" json:"Description,omitempty"` - Price float64 `protobuf:"fixed64,4,opt,name=Price,proto3" json:"Price,omitempty"` - CreatedAt *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=CreatedAt,proto3" json:"CreatedAt,omitempty"` - UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=UpdatedAt,proto3" json:"UpdatedAt,omitempty"` -} - -func (x *Product) Reset() { - *x = Product{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Product) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Product) ProtoMessage() {} - -func (x *Product) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Product.ProtoReflect.Descriptor instead. -func (*Product) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{0} -} - -func (x *Product) GetProductId() string { - if x != nil { - return x.ProductId - } - return "" -} - -func (x *Product) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Product) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Product) GetPrice() float64 { - if x != nil { - return x.Price - } - return 0 -} - -func (x *Product) GetCreatedAt() *timestamppb.Timestamp { - if x != nil { - return x.CreatedAt - } - return nil -} - -func (x *Product) GetUpdatedAt() *timestamppb.Timestamp { - if x != nil { - return x.UpdatedAt - } - return nil -} - -type CreateProductReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` - Description string `protobuf:"bytes,2,opt,name=Description,proto3" json:"Description,omitempty"` - Price float64 `protobuf:"fixed64,3,opt,name=Price,proto3" json:"Price,omitempty"` -} - -func (x *CreateProductReq) Reset() { - *x = CreateProductReq{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateProductReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateProductReq) ProtoMessage() {} - -func (x *CreateProductReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateProductReq.ProtoReflect.Descriptor instead. -func (*CreateProductReq) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{1} -} - -func (x *CreateProductReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *CreateProductReq) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *CreateProductReq) GetPrice() float64 { - if x != nil { - return x.Price - } - return 0 -} - -type CreateProductRes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProductId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` -} - -func (x *CreateProductRes) Reset() { - *x = CreateProductRes{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *CreateProductRes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateProductRes) ProtoMessage() {} - -func (x *CreateProductRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CreateProductRes.ProtoReflect.Descriptor instead. -func (*CreateProductRes) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{2} -} - -func (x *CreateProductRes) GetProductId() string { - if x != nil { - return x.ProductId - } - return "" -} - -type UpdateProductReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProductId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` - Description string `protobuf:"bytes,3,opt,name=Description,proto3" json:"Description,omitempty"` - Price float64 `protobuf:"fixed64,4,opt,name=Price,proto3" json:"Price,omitempty"` -} - -func (x *UpdateProductReq) Reset() { - *x = UpdateProductReq{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateProductReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateProductReq) ProtoMessage() {} - -func (x *UpdateProductReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateProductReq.ProtoReflect.Descriptor instead. -func (*UpdateProductReq) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{3} -} - -func (x *UpdateProductReq) GetProductId() string { - if x != nil { - return x.ProductId - } - return "" -} - -func (x *UpdateProductReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *UpdateProductReq) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *UpdateProductReq) GetPrice() float64 { - if x != nil { - return x.Price - } - return 0 -} - -type UpdateProductRes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *UpdateProductRes) Reset() { - *x = UpdateProductRes{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *UpdateProductRes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateProductRes) ProtoMessage() {} - -func (x *UpdateProductRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateProductRes.ProtoReflect.Descriptor instead. -func (*UpdateProductRes) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{4} -} - -type GetProductByIdReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProductId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` -} - -func (x *GetProductByIdReq) Reset() { - *x = GetProductByIdReq{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetProductByIdReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetProductByIdReq) ProtoMessage() {} - -func (x *GetProductByIdReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetProductByIdReq.ProtoReflect.Descriptor instead. -func (*GetProductByIdReq) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{5} -} - -func (x *GetProductByIdReq) GetProductId() string { - if x != nil { - return x.ProductId - } - return "" -} - -type GetProductByIdRes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Product *Product `protobuf:"bytes,1,opt,name=Product,proto3" json:"Product,omitempty"` -} - -func (x *GetProductByIdRes) Reset() { - *x = GetProductByIdRes{} - if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetProductByIdRes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetProductByIdRes) ProtoMessage() {} - -func (x *GetProductByIdRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetProductByIdRes.ProtoReflect.Descriptor instead. -func (*GetProductByIdRes) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{6} -} - -func (x *GetProductByIdRes) GetProduct() *Product { - if x != nil { - return x.Product - } - return nil -} - -var File_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto protoreflect.FileDescriptor - -var file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDesc = []byte{ - 0x0a, 0x5e, 0x61, 0x70, 0x69, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x2f, 0x63, 0x61, 0x74, 0x61, 0x6c, - 0x6f, 0x67, 0x73, 0x2f, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xe7, 0x01, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, - 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x5e, 0x0a, - 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, - 0x71, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0x30, 0x0a, - 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, - 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, - 0x7c, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0x12, 0x0a, - 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, - 0x73, 0x22, 0x31, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, - 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x50, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x72, - 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x32, 0x9f, - 0x02, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x57, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x12, 0x57, 0x0a, 0x0d, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x22, 0x2e, 0x70, - 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, - 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x52, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x23, 0x2e, 0x70, 0x72, - 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, - 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x73, - 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescOnce sync.Once - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescData = file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDesc -) - -func file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP() []byte { - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescOnce.Do(func() { - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescData) - }) - return file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDescData -} - -var file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_goTypes = []interface{}{ - (*Product)(nil), // 0: products_service.Product - (*CreateProductReq)(nil), // 1: products_service.CreateProductReq - (*CreateProductRes)(nil), // 2: products_service.CreateProductRes - (*UpdateProductReq)(nil), // 3: products_service.UpdateProductReq - (*UpdateProductRes)(nil), // 4: products_service.UpdateProductRes - (*GetProductByIdReq)(nil), // 5: products_service.GetProductByIdReq - (*GetProductByIdRes)(nil), // 6: products_service.GetProductByIdRes - (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp -} -var file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_depIdxs = []int32{ - 7, // 0: products_service.Product.CreatedAt:type_name -> google.protobuf.Timestamp - 7, // 1: products_service.Product.UpdatedAt:type_name -> google.protobuf.Timestamp - 0, // 2: products_service.GetProductByIdRes.Product:type_name -> products_service.Product - 1, // 3: products_service.ProductsService.CreateProduct:input_type -> products_service.CreateProductReq - 3, // 4: products_service.ProductsService.UpdateProduct:input_type -> products_service.UpdateProductReq - 5, // 5: products_service.ProductsService.GetProductById:input_type -> products_service.GetProductByIdReq - 2, // 6: products_service.ProductsService.CreateProduct:output_type -> products_service.CreateProductRes - 4, // 7: products_service.ProductsService.UpdateProduct:output_type -> products_service.UpdateProductRes - 6, // 8: products_service.ProductsService.GetProductById:output_type -> products_service.GetProductByIdRes - 6, // [6:9] is the sub-list for method output_type - 3, // [3:6] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_init() -} -func file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_init() { - if File_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Product); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateProductReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateProductRes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateProductReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UpdateProductRes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetProductByIdReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GetProductByIdRes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDesc, - NumEnums: 0, - NumMessages: 7, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_goTypes, - DependencyIndexes: file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_depIdxs, - MessageInfos: file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_msgTypes, - }.Build() - File_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto = out.File - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_rawDesc = nil - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_goTypes = nil - file_api_docs_catalogs_read_service_protobuf_products_service_clients_products_service_client_proto_depIdxs = nil -} diff --git a/internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go b/internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go deleted file mode 100644 index 771be7b3..00000000 --- a/internal/services/catalog_read_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go +++ /dev/null @@ -1,175 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.20.1 -// source: api_docs/catalogs_write/catalogs_read/protobuf/products/service_clients/products.proto - -package products_service - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// ProductsServiceClient is the client API for ProductsService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type ProductsServiceClient interface { - CreateProduct(ctx context.Context, in *CreateProductReq, opts ...grpc.CallOption) (*CreateProductRes, error) - UpdateProduct(ctx context.Context, in *UpdateProductReq, opts ...grpc.CallOption) (*UpdateProductRes, error) - GetProductById(ctx context.Context, in *GetProductByIdReq, opts ...grpc.CallOption) (*GetProductByIdRes, error) -} - -type productsServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewProductsServiceClient(cc grpc.ClientConnInterface) ProductsServiceClient { - return &productsServiceClient{cc} -} - -func (c *productsServiceClient) CreateProduct(ctx context.Context, in *CreateProductReq, opts ...grpc.CallOption) (*CreateProductRes, error) { - out := new(CreateProductRes) - err := c.cc.Invoke(ctx, "/products_service.ProductsService/CreateProduct", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *productsServiceClient) UpdateProduct(ctx context.Context, in *UpdateProductReq, opts ...grpc.CallOption) (*UpdateProductRes, error) { - out := new(UpdateProductRes) - err := c.cc.Invoke(ctx, "/products_service.ProductsService/UpdateProduct", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *productsServiceClient) GetProductById(ctx context.Context, in *GetProductByIdReq, opts ...grpc.CallOption) (*GetProductByIdRes, error) { - out := new(GetProductByIdRes) - err := c.cc.Invoke(ctx, "/products_service.ProductsService/GetProductById", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ProductsServiceServer is the server API for ProductsService service. -// All implementations should embed UnimplementedProductsServiceServer -// for forward compatibility -type ProductsServiceServer interface { - CreateProduct(context.Context, *CreateProductReq) (*CreateProductRes, error) - UpdateProduct(context.Context, *UpdateProductReq) (*UpdateProductRes, error) - GetProductById(context.Context, *GetProductByIdReq) (*GetProductByIdRes, error) -} - -// UnimplementedProductsServiceServer should be embedded to have forward compatible implementations. -type UnimplementedProductsServiceServer struct { -} - -func (UnimplementedProductsServiceServer) CreateProduct(context.Context, *CreateProductReq) (*CreateProductRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") -} -func (UnimplementedProductsServiceServer) UpdateProduct(context.Context, *UpdateProductReq) (*UpdateProductRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateProduct not implemented") -} -func (UnimplementedProductsServiceServer) GetProductById(context.Context, *GetProductByIdReq) (*GetProductByIdRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetProductById not implemented") -} - -// UnsafeProductsServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ProductsServiceServer will -// result in compilation errors. -type UnsafeProductsServiceServer interface { - mustEmbedUnimplementedProductsServiceServer() -} - -func RegisterProductsServiceServer(s grpc.ServiceRegistrar, srv ProductsServiceServer) { - s.RegisterService(&ProductsService_ServiceDesc, srv) -} - -func _ProductsService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateProductReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProductsServiceServer).CreateProduct(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/products_service.ProductsService/CreateProduct", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProductsServiceServer).CreateProduct(ctx, req.(*CreateProductReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ProductsService_UpdateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateProductReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProductsServiceServer).UpdateProduct(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/products_service.ProductsService/UpdateProduct", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProductsServiceServer).UpdateProduct(ctx, req.(*UpdateProductReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _ProductsService_GetProductById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetProductByIdReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProductsServiceServer).GetProductById(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/products_service.ProductsService/GetProductById", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProductsServiceServer).GetProductById(ctx, req.(*GetProductByIdReq)) - } - return interceptor(ctx, in, info, handler) -} - -// ProductsService_ServiceDesc is the grpc.ServiceDesc for ProductsService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ProductsService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "products_service.ProductsService", - HandlerType: (*ProductsServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateProduct", - Handler: _ProductsService_CreateProduct_Handler, - }, - { - MethodName: "UpdateProduct", - Handler: _ProductsService_UpdateProduct_Handler, - }, - { - MethodName: "GetProductById", - Handler: _ProductsService_GetProductById_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "api_docs/catalogs_write/catalogs_read/protobuf/products/service_clients/products.proto", -} diff --git a/internal/services/catalog_read_service/internal/products/models/product.go b/internal/services/catalog_read_service/internal/products/models/product.go index fcbd0e41..57c72f1d 100644 --- a/internal/services/catalog_read_service/internal/products/models/product.go +++ b/internal/services/catalog_read_service/internal/products/models/product.go @@ -6,19 +6,19 @@ import ( type Product struct { // we generate id ourselves because auto generate mongo string id column with type _id is not an uuid - Id string `json:"id" bson:"_id,omitempty"` //https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#the-_id-field - ProductId string `json:"productId" bson:"productId"` - Name string `json:"name,omitempty" bson:"name,omitempty"` + Id string `json:"id" bson:"_id,omitempty"` //https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#the-_id-field + ProductId string `json:"productId" bson:"productId"` + Name string `json:"name,omitempty" bson:"name,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` - Price float64 `json:"price,omitempty" bson:"price,omitempty" ` - CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"` + Price float64 `json:"price,omitempty" bson:"price,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"` } type ProductsList struct { TotalCount int64 `json:"totalCount" bson:"totalCount"` TotalPages int64 `json:"totalPages" bson:"totalPages"` - Page int64 `json:"page" bson:"page"` - Size int64 `json:"size" bson:"size"` - Products []*Product `json:"products" bson:"products"` + Page int64 `json:"page" bson:"page"` + Size int64 `json:"size" bson:"size"` + Products []*Product `json:"products" bson:"products"` } diff --git a/internal/services/catalog_read_service/mocks/ProductsServiceClient.go b/internal/services/catalog_read_service/mocks/ProductsServiceClient.go deleted file mode 100644 index 01660a8b..00000000 --- a/internal/services/catalog_read_service/mocks/ProductsServiceClient.go +++ /dev/null @@ -1,250 +0,0 @@ -// Code generated by mockery v2.30.16. DO NOT EDIT. - -package mocks - -import ( - context "context" - - grpc "google.golang.org/grpc" - - mock "github.com/stretchr/testify/mock" - - products_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogreadservice/internal/products/grpc/proto/service_clients" -) - -// ProductsServiceClient is an autogenerated mock type for the ProductsServiceClient type -type ProductsServiceClient struct { - mock.Mock -} - -type ProductsServiceClient_Expecter struct { - mock *mock.Mock -} - -func (_m *ProductsServiceClient) EXPECT() *ProductsServiceClient_Expecter { - return &ProductsServiceClient_Expecter{mock: &_m.Mock} -} - -// CreateProduct provides a mock function with given fields: ctx, in, opts -func (_m *ProductsServiceClient) CreateProduct(ctx context.Context, in *products_service.CreateProductReq, opts ...grpc.CallOption) (*products_service.CreateProductRes, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *products_service.CreateProductRes - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) (*products_service.CreateProductRes, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) *products_service.CreateProductRes); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.CreateProductRes) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ProductsServiceClient_CreateProduct_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateProduct' -type ProductsServiceClient_CreateProduct_Call struct { - *mock.Call -} - -// CreateProduct is a helper method to define mock.On call -// - ctx context.Context -// - in *products_service.CreateProductReq -// - opts ...grpc.CallOption -func (_e *ProductsServiceClient_Expecter) CreateProduct(ctx interface{}, in interface{}, opts ...interface{}) *ProductsServiceClient_CreateProduct_Call { - return &ProductsServiceClient_CreateProduct_Call{Call: _e.mock.On("CreateProduct", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *ProductsServiceClient_CreateProduct_Call) Run(run func(ctx context.Context, in *products_service.CreateProductReq, opts ...grpc.CallOption)) *ProductsServiceClient_CreateProduct_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*products_service.CreateProductReq), variadicArgs...) - }) - return _c -} - -func (_c *ProductsServiceClient_CreateProduct_Call) Return(_a0 *products_service.CreateProductRes, _a1 error) *ProductsServiceClient_CreateProduct_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *ProductsServiceClient_CreateProduct_Call) RunAndReturn(run func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) (*products_service.CreateProductRes, error)) *ProductsServiceClient_CreateProduct_Call { - _c.Call.Return(run) - return _c -} - -// GetProductById provides a mock function with given fields: ctx, in, opts -func (_m *ProductsServiceClient) GetProductById(ctx context.Context, in *products_service.GetProductByIdReq, opts ...grpc.CallOption) (*products_service.GetProductByIdRes, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *products_service.GetProductByIdRes - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) (*products_service.GetProductByIdRes, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) *products_service.GetProductByIdRes); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.GetProductByIdRes) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ProductsServiceClient_GetProductById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProductById' -type ProductsServiceClient_GetProductById_Call struct { - *mock.Call -} - -// GetProductById is a helper method to define mock.On call -// - ctx context.Context -// - in *products_service.GetProductByIdReq -// - opts ...grpc.CallOption -func (_e *ProductsServiceClient_Expecter) GetProductById(ctx interface{}, in interface{}, opts ...interface{}) *ProductsServiceClient_GetProductById_Call { - return &ProductsServiceClient_GetProductById_Call{Call: _e.mock.On("GetProductById", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *ProductsServiceClient_GetProductById_Call) Run(run func(ctx context.Context, in *products_service.GetProductByIdReq, opts ...grpc.CallOption)) *ProductsServiceClient_GetProductById_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*products_service.GetProductByIdReq), variadicArgs...) - }) - return _c -} - -func (_c *ProductsServiceClient_GetProductById_Call) Return(_a0 *products_service.GetProductByIdRes, _a1 error) *ProductsServiceClient_GetProductById_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *ProductsServiceClient_GetProductById_Call) RunAndReturn(run func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) (*products_service.GetProductByIdRes, error)) *ProductsServiceClient_GetProductById_Call { - _c.Call.Return(run) - return _c -} - -// UpdateProduct provides a mock function with given fields: ctx, in, opts -func (_m *ProductsServiceClient) UpdateProduct(ctx context.Context, in *products_service.UpdateProductReq, opts ...grpc.CallOption) (*products_service.UpdateProductRes, error) { - _va := make([]interface{}, len(opts)) - for _i := range opts { - _va[_i] = opts[_i] - } - var _ca []interface{} - _ca = append(_ca, ctx, in) - _ca = append(_ca, _va...) - ret := _m.Called(_ca...) - - var r0 *products_service.UpdateProductRes - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) (*products_service.UpdateProductRes, error)); ok { - return rf(ctx, in, opts...) - } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) *products_service.UpdateProductRes); ok { - r0 = rf(ctx, in, opts...) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.UpdateProductRes) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) error); ok { - r1 = rf(ctx, in, opts...) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ProductsServiceClient_UpdateProduct_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateProduct' -type ProductsServiceClient_UpdateProduct_Call struct { - *mock.Call -} - -// UpdateProduct is a helper method to define mock.On call -// - ctx context.Context -// - in *products_service.UpdateProductReq -// - opts ...grpc.CallOption -func (_e *ProductsServiceClient_Expecter) UpdateProduct(ctx interface{}, in interface{}, opts ...interface{}) *ProductsServiceClient_UpdateProduct_Call { - return &ProductsServiceClient_UpdateProduct_Call{Call: _e.mock.On("UpdateProduct", - append([]interface{}{ctx, in}, opts...)...)} -} - -func (_c *ProductsServiceClient_UpdateProduct_Call) Run(run func(ctx context.Context, in *products_service.UpdateProductReq, opts ...grpc.CallOption)) *ProductsServiceClient_UpdateProduct_Call { - _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]grpc.CallOption, len(args)-2) - for i, a := range args[2:] { - if a != nil { - variadicArgs[i] = a.(grpc.CallOption) - } - } - run(args[0].(context.Context), args[1].(*products_service.UpdateProductReq), variadicArgs...) - }) - return _c -} - -func (_c *ProductsServiceClient_UpdateProduct_Call) Return(_a0 *products_service.UpdateProductRes, _a1 error) *ProductsServiceClient_UpdateProduct_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *ProductsServiceClient_UpdateProduct_Call) RunAndReturn(run func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) (*products_service.UpdateProductRes, error)) *ProductsServiceClient_UpdateProduct_Call { - _c.Call.Return(run) - return _c -} - -// NewProductsServiceClient creates a new instance of ProductsServiceClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewProductsServiceClient(t interface { - mock.TestingT - Cleanup(func()) -}) *ProductsServiceClient { - mock := &ProductsServiceClient{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/services/catalog_read_service/mocks/ProductsServiceServer.go b/internal/services/catalog_read_service/mocks/ProductsServiceServer.go deleted file mode 100644 index e4849433..00000000 --- a/internal/services/catalog_read_service/mocks/ProductsServiceServer.go +++ /dev/null @@ -1,202 +0,0 @@ -// Code generated by mockery v2.30.16. DO NOT EDIT. - -package mocks - -import ( - context "context" - - products_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogreadservice/internal/products/grpc/proto/service_clients" - mock "github.com/stretchr/testify/mock" -) - -// ProductsServiceServer is an autogenerated mock type for the ProductsServiceServer type -type ProductsServiceServer struct { - mock.Mock -} - -type ProductsServiceServer_Expecter struct { - mock *mock.Mock -} - -func (_m *ProductsServiceServer) EXPECT() *ProductsServiceServer_Expecter { - return &ProductsServiceServer_Expecter{mock: &_m.Mock} -} - -// CreateProduct provides a mock function with given fields: _a0, _a1 -func (_m *ProductsServiceServer) CreateProduct(_a0 context.Context, _a1 *products_service.CreateProductReq) (*products_service.CreateProductRes, error) { - ret := _m.Called(_a0, _a1) - - var r0 *products_service.CreateProductRes - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq) (*products_service.CreateProductRes, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq) *products_service.CreateProductRes); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.CreateProductRes) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *products_service.CreateProductReq) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ProductsServiceServer_CreateProduct_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateProduct' -type ProductsServiceServer_CreateProduct_Call struct { - *mock.Call -} - -// CreateProduct is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *products_service.CreateProductReq -func (_e *ProductsServiceServer_Expecter) CreateProduct(_a0 interface{}, _a1 interface{}) *ProductsServiceServer_CreateProduct_Call { - return &ProductsServiceServer_CreateProduct_Call{Call: _e.mock.On("CreateProduct", _a0, _a1)} -} - -func (_c *ProductsServiceServer_CreateProduct_Call) Run(run func(_a0 context.Context, _a1 *products_service.CreateProductReq)) *ProductsServiceServer_CreateProduct_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*products_service.CreateProductReq)) - }) - return _c -} - -func (_c *ProductsServiceServer_CreateProduct_Call) Return(_a0 *products_service.CreateProductRes, _a1 error) *ProductsServiceServer_CreateProduct_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *ProductsServiceServer_CreateProduct_Call) RunAndReturn(run func(context.Context, *products_service.CreateProductReq) (*products_service.CreateProductRes, error)) *ProductsServiceServer_CreateProduct_Call { - _c.Call.Return(run) - return _c -} - -// GetProductById provides a mock function with given fields: _a0, _a1 -func (_m *ProductsServiceServer) GetProductById(_a0 context.Context, _a1 *products_service.GetProductByIdReq) (*products_service.GetProductByIdRes, error) { - ret := _m.Called(_a0, _a1) - - var r0 *products_service.GetProductByIdRes - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq) (*products_service.GetProductByIdRes, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq) *products_service.GetProductByIdRes); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.GetProductByIdRes) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *products_service.GetProductByIdReq) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ProductsServiceServer_GetProductById_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProductById' -type ProductsServiceServer_GetProductById_Call struct { - *mock.Call -} - -// GetProductById is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *products_service.GetProductByIdReq -func (_e *ProductsServiceServer_Expecter) GetProductById(_a0 interface{}, _a1 interface{}) *ProductsServiceServer_GetProductById_Call { - return &ProductsServiceServer_GetProductById_Call{Call: _e.mock.On("GetProductById", _a0, _a1)} -} - -func (_c *ProductsServiceServer_GetProductById_Call) Run(run func(_a0 context.Context, _a1 *products_service.GetProductByIdReq)) *ProductsServiceServer_GetProductById_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*products_service.GetProductByIdReq)) - }) - return _c -} - -func (_c *ProductsServiceServer_GetProductById_Call) Return(_a0 *products_service.GetProductByIdRes, _a1 error) *ProductsServiceServer_GetProductById_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *ProductsServiceServer_GetProductById_Call) RunAndReturn(run func(context.Context, *products_service.GetProductByIdReq) (*products_service.GetProductByIdRes, error)) *ProductsServiceServer_GetProductById_Call { - _c.Call.Return(run) - return _c -} - -// UpdateProduct provides a mock function with given fields: _a0, _a1 -func (_m *ProductsServiceServer) UpdateProduct(_a0 context.Context, _a1 *products_service.UpdateProductReq) (*products_service.UpdateProductRes, error) { - ret := _m.Called(_a0, _a1) - - var r0 *products_service.UpdateProductRes - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq) (*products_service.UpdateProductRes, error)); ok { - return rf(_a0, _a1) - } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq) *products_service.UpdateProductRes); ok { - r0 = rf(_a0, _a1) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.UpdateProductRes) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *products_service.UpdateProductReq) error); ok { - r1 = rf(_a0, _a1) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// ProductsServiceServer_UpdateProduct_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateProduct' -type ProductsServiceServer_UpdateProduct_Call struct { - *mock.Call -} - -// UpdateProduct is a helper method to define mock.On call -// - _a0 context.Context -// - _a1 *products_service.UpdateProductReq -func (_e *ProductsServiceServer_Expecter) UpdateProduct(_a0 interface{}, _a1 interface{}) *ProductsServiceServer_UpdateProduct_Call { - return &ProductsServiceServer_UpdateProduct_Call{Call: _e.mock.On("UpdateProduct", _a0, _a1)} -} - -func (_c *ProductsServiceServer_UpdateProduct_Call) Run(run func(_a0 context.Context, _a1 *products_service.UpdateProductReq)) *ProductsServiceServer_UpdateProduct_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*products_service.UpdateProductReq)) - }) - return _c -} - -func (_c *ProductsServiceServer_UpdateProduct_Call) Return(_a0 *products_service.UpdateProductRes, _a1 error) *ProductsServiceServer_UpdateProduct_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *ProductsServiceServer_UpdateProduct_Call) RunAndReturn(run func(context.Context, *products_service.UpdateProductReq) (*products_service.UpdateProductRes, error)) *ProductsServiceServer_UpdateProduct_Call { - _c.Call.Return(run) - return _c -} - -// NewProductsServiceServer creates a new instance of ProductsServiceServer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewProductsServiceServer(t interface { - mock.TestingT - Cleanup(func()) -}) *ProductsServiceServer { - mock := &ProductsServiceServer{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/services/catalog_write_service/cmd/app/main.go b/internal/services/catalog_write_service/cmd/app/main.go index a0aaaf19..46ce881f 100644 --- a/internal/services/catalog_write_service/cmd/app/main.go +++ b/internal/services/catalog_write_service/cmd/app/main.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/spf13/cobra" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/app" diff --git a/internal/services/catalog_write_service/config/config.test.json b/internal/services/catalog_write_service/config/config.test.json index 36d736d6..1b5df445 100644 --- a/internal/services/catalog_write_service/config/config.test.json +++ b/internal/services/catalog_write_service/config/config.test.json @@ -11,7 +11,7 @@ }, "echoHttpOptions": { "name": "catalogs_write_service", - "port": ":7000", + "port": ":6001", "development": true, "timeout": 30, "basePath": "/api/v1", diff --git a/internal/services/catalog_write_service/docs/docs.go b/internal/services/catalog_write_service/docs/docs.go index 7d271dd3..d426eb81 100644 --- a/internal/services/catalog_write_service/docs/docs.go +++ b/internal/services/catalog_write_service/docs/docs.go @@ -1,5 +1,5 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -53,7 +53,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" } } } @@ -77,7 +77,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dtos.CreateProductRequestDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto" } } ], @@ -85,7 +85,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dtos.CreateProductResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto" } } } @@ -105,32 +105,17 @@ const docTemplate = `{ ], "summary": "Search products", "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, { "type": "string", "name": "search", "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.SearchProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto" } } } @@ -162,7 +147,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductByIdResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto" } } } @@ -186,7 +171,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dtos.UpdateProductRequestDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto" } }, { @@ -199,7 +184,7 @@ const docTemplate = `{ ], "responses": { "204": { - "description": "" + "description": "No Content" } } }, @@ -226,14 +211,14 @@ const docTemplate = `{ ], "responses": { "204": { - "description": "" + "description": "No Content" } } } } }, "definitions": { - "dtoV1.ProductDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto": { "type": "object", "properties": { "createdAt": { @@ -256,7 +241,7 @@ const docTemplate = `{ } } }, - "dtos.CreateProductRequestDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto": { "type": "object", "properties": { "description": { @@ -270,7 +255,7 @@ const docTemplate = `{ } } }, - "dtos.CreateProductResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto": { "type": "object", "properties": { "productId": { @@ -278,31 +263,31 @@ const docTemplate = `{ } } }, - "dtos.GetProductByIdResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto": { "type": "object", "properties": { "product": { - "$ref": "#/definitions/dtoV1.ProductDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" } } }, - "dtos.GetProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" } } }, - "dtos.SearchProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" } } }, - "dtos.UpdateProductRequestDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto": { "type": "object", "properties": { "description": { @@ -329,6 +314,49 @@ const docTemplate = `{ "type": "string" } } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } } } }` @@ -343,6 +371,8 @@ var SwaggerInfo = &swag.Spec{ Description: "Catalogs Write-Service Api.", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/internal/services/catalog_write_service/docs/swagger.json b/internal/services/catalog_write_service/docs/swagger.json index 73c76643..87ed034e 100644 --- a/internal/services/catalog_write_service/docs/swagger.json +++ b/internal/services/catalog_write_service/docs/swagger.json @@ -44,7 +44,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto" } } } @@ -68,7 +68,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dtos.CreateProductRequestDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto" } } ], @@ -76,7 +76,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dtos.CreateProductResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto" } } } @@ -96,32 +96,17 @@ ], "summary": "Search products", "parameters": [ - { - "type": "string", - "name": "orderBy", - "in": "query" - }, - { - "type": "integer", - "name": "page", - "in": "query" - }, { "type": "string", "name": "search", "in": "query" - }, - { - "type": "integer", - "name": "size", - "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.SearchProductsResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto" } } } @@ -153,7 +138,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetProductByIdResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto" } } } @@ -177,7 +162,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dtos.UpdateProductRequestDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto" } }, { @@ -190,7 +175,7 @@ ], "responses": { "204": { - "description": "" + "description": "No Content" } } }, @@ -217,14 +202,14 @@ ], "responses": { "204": { - "description": "" + "description": "No Content" } } } } }, "definitions": { - "dtoV1.ProductDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto": { "type": "object", "properties": { "createdAt": { @@ -247,7 +232,7 @@ } } }, - "dtos.CreateProductRequestDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto": { "type": "object", "properties": { "description": { @@ -261,7 +246,7 @@ } } }, - "dtos.CreateProductResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto": { "type": "object", "properties": { "productId": { @@ -269,31 +254,31 @@ } } }, - "dtos.GetProductByIdResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto": { "type": "object", "properties": { "product": { - "$ref": "#/definitions/dtoV1.ProductDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" } } }, - "dtos.GetProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" } } }, - "dtos.SearchProductsResponseDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto": { "type": "object", "properties": { "products": { - "type": "object" + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto" } } }, - "dtos.UpdateProductRequestDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto": { "type": "object", "properties": { "description": { @@ -320,6 +305,49 @@ "type": "string" } } + }, + "utils.ListQuery": { + "type": "object", + "properties": { + "filters": { + "type": "array", + "items": { + "$ref": "#/definitions/utils.FilterModel" + } + }, + "orderBy": { + "type": "string" + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + } + } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } } } } \ No newline at end of file diff --git a/internal/services/catalog_write_service/docs/swagger.yaml b/internal/services/catalog_write_service/docs/swagger.yaml index 0541bbc2..3427a1bf 100644 --- a/internal/services/catalog_write_service/docs/swagger.yaml +++ b/internal/services/catalog_write_service/docs/swagger.yaml @@ -1,5 +1,5 @@ definitions: - dtoV1.ProductDto: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto: properties: createdAt: type: string @@ -14,8 +14,8 @@ definitions: updatedAt: type: string type: object - dtos.CreateProductRequestDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto + : properties: description: type: string name: @@ -23,28 +23,28 @@ definitions: price: type: number type: object - dtos.CreateProductResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto + : properties: productId: type: string type: object - dtos.GetProductByIdResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto + : properties: product: - $ref: '#/definitions/dtoV1.ProductDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto' type: object - dtos.GetProductsResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto + : properties: products: - type: object + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto' type: object - dtos.SearchProductsResponseDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto + : properties: products: - type: object + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto' type: object - dtos.UpdateProductRequestDto: - properties: + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto + : properties: description: type: string name: @@ -61,6 +61,34 @@ definitions: value: type: string type: object + utils.ListQuery: + properties: + filters: + items: + $ref: '#/definitions/utils.FilterModel' + type: array + orderBy: + type: string + page: + type: integer + size: + type: integer + type: object + ? utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1_ProductDto + : properties: + items: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_dto_v1.ProductDto' + type: array + page: + type: integer + size: + type: integer + totalItems: + type: integer + totalPage: + type: integer + type: object info: contact: name: Mehdi Hadeli @@ -90,7 +118,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dtos.GetProductsResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_products_v1_dtos.GetProductsResponseDto' summary: Get all product tags: - Products @@ -104,14 +132,14 @@ paths: name: CreateProductRequestDto required: true schema: - $ref: '#/definitions/dtos.CreateProductRequestDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductRequestDto' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/dtos.CreateProductResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_creating_product_v1_dtos.CreateProductResponseDto' summary: Create product tags: - Products @@ -130,7 +158,7 @@ paths: - application/json responses: "204": - description: "" + description: No Content summary: Delete product tags: - Products @@ -150,7 +178,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dtos.GetProductByIdResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_getting_product_by_id_v1_dtos.GetProductByIdResponseDto' summary: Get product by id tags: - Products @@ -164,7 +192,7 @@ paths: name: UpdateProductRequestDto required: true schema: - $ref: '#/definitions/dtos.UpdateProductRequestDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_updating_product_v1_dtos.UpdateProductRequestDto' - description: Product ID in: path name: id @@ -174,7 +202,7 @@ paths: - application/json responses: "204": - description: "" + description: No Content summary: Update product tags: - Products @@ -184,25 +212,16 @@ paths: - application/json description: Search products parameters: - - in: query - name: orderBy - type: string - - in: query - name: page - type: integer - in: query name: search type: string - - in: query - name: size - type: integer produces: - application/json responses: "200": description: OK schema: - $ref: '#/definitions/dtos.SearchProductsResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_catalogwriteservice_internal_products_features_searching_product_v1_dtos.SearchProductsResponseDto' summary: Search products tags: - Products diff --git a/internal/services/catalog_write_service/go.mod b/internal/services/catalog_write_service/go.mod index 9bd83089..c06a2c51 100644 --- a/internal/services/catalog_write_service/go.mod +++ b/internal/services/catalog_write_service/go.mod @@ -22,7 +22,7 @@ require ( github.com/spf13/viper v1.7.0 github.com/stretchr/testify v1.8.4 github.com/swaggo/echo-swagger v1.3.3 - github.com/swaggo/swag v1.8.3 + github.com/swaggo/swag v1.16.1 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/metric v1.16.0 go.opentelemetry.io/otel/trace v1.16.0 diff --git a/internal/services/catalog_write_service/go.sum b/internal/services/catalog_write_service/go.sum index b514b279..2f0e5917 100644 --- a/internal/services/catalog_write_service/go.sum +++ b/internal/services/catalog_write_service/go.sum @@ -1329,8 +1329,8 @@ github.com/swaggo/echo-swagger v1.3.3/go.mod h1:vbKcEBeJgOexLuPcsdZhrRAV508fsE79 github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= -github.com/swaggo/swag v1.8.3 h1:3pZSSCQ//gAH88lfmxM3Cd1+JCsxV8Md6f36b9hrZ5s= -github.com/swaggo/swag v1.8.3/go.mod h1:jMLeXOOmYyjk8PvHTsXBdrubsNd9gUJTTCzL5iBnseg= +github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= +github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= diff --git a/internal/services/catalog_write_service/internal/products/configurations/mappings/mapping_profile.go b/internal/services/catalog_write_service/internal/products/configurations/mappings/mapping_profile.go index 02a5d6cb..64027f39 100644 --- a/internal/services/catalog_write_service/internal/products/configurations/mappings/mapping_profile.go +++ b/internal/services/catalog_write_service/internal/products/configurations/mappings/mapping_profile.go @@ -3,12 +3,10 @@ package mappings import ( "google.golang.org/protobuf/types/known/timestamppb" - dtoV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/dto/v1" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - - productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" + dtoV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/dto/v1" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/models" + productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" ) func ConfigureProductsMappings() error { diff --git a/internal/services/catalog_write_service/internal/products/configurations/products_module_configurator.go b/internal/services/catalog_write_service/internal/products/configurations/products_module_configurator.go index 71c0abe1..868a0be4 100644 --- a/internal/services/catalog_write_service/internal/products/configurations/products_module_configurator.go +++ b/internal/services/catalog_write_service/internal/products/configurations/products_module_configurator.go @@ -3,18 +3,17 @@ package configurations import ( googleGrpc "google.golang.org/grpc" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/configurations/mappings" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/configurations/mediatr" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/data" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/params" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc" - productsservice "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" - contracts2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" grpcServer "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/producer" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/configurations/mappings" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/configurations/mediatr" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/data" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/params" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc" + productsservice "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" ) type ProductsModuleConfigurator struct { diff --git a/internal/services/catalog_write_service/internal/products/dto/v1/product_dto.go b/internal/services/catalog_write_service/internal/products/dto/v1/product_dto.go index ee1472c8..70f4e9c9 100644 --- a/internal/services/catalog_write_service/internal/products/dto/v1/product_dto.go +++ b/internal/services/catalog_write_service/internal/products/dto/v1/product_dto.go @@ -1,8 +1,9 @@ package dtoV1 import ( - uuid "github.com/satori/go.uuid" "time" + + uuid "github.com/satori/go.uuid" ) type ProductDto struct { diff --git a/internal/services/catalog_write_service/internal/products/features/creating_product/v1/commands/create_product.go b/internal/services/catalog_write_service/internal/products/features/creating_product/v1/commands/create_product.go index 5d5c2075..ee8fecfe 100644 --- a/internal/services/catalog_write_service/internal/products/features/creating_product/v1/commands/create_product.go +++ b/internal/services/catalog_write_service/internal/products/features/creating_product/v1/commands/create_product.go @@ -19,7 +19,13 @@ type CreateProduct struct { } func NewCreateProduct(name string, description string, price float64) (*CreateProduct, error) { - command := &CreateProduct{ProductID: uuid.NewV4(), Name: name, Description: description, Price: price, CreatedAt: time.Now()} + command := &CreateProduct{ + ProductID: uuid.NewV4(), + Name: name, + Description: description, + Price: price, + CreatedAt: time.Now(), + } err := validator.Validate(command) if err != nil { return nil, err diff --git a/internal/services/catalog_write_service/internal/products/features/deleting_product/v1/dtos/delete_product_request_dto.go b/internal/services/catalog_write_service/internal/products/features/deleting_product/v1/dtos/delete_product_request_dto.go index a7f91cb2..5f2ecfbd 100644 --- a/internal/services/catalog_write_service/internal/products/features/deleting_product/v1/dtos/delete_product_request_dto.go +++ b/internal/services/catalog_write_service/internal/products/features/deleting_product/v1/dtos/delete_product_request_dto.go @@ -3,5 +3,5 @@ package dtos import uuid "github.com/satori/go.uuid" type DeleteProductRequestDto struct { - ProductID uuid.UUID `param:"id" json:"-"` + ProductID uuid.UUID `param:"id" json:"-"` } diff --git a/internal/services/catalog_write_service/internal/products/features/getting_products/v1/dtos/get_products_request_dto.go b/internal/services/catalog_write_service/internal/products/features/getting_products/v1/dtos/get_products_request_dto.go index f8d310a4..a1395b3d 100644 --- a/internal/services/catalog_write_service/internal/products/features/getting_products/v1/dtos/get_products_request_dto.go +++ b/internal/services/catalog_write_service/internal/products/features/getting_products/v1/dtos/get_products_request_dto.go @@ -2,9 +2,9 @@ package dtos import "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" -//https://echo.labstack.com/guide/binding/ -//https://echo.labstack.com/guide/request/ -//https://github.com/go-playground/validator +// https://echo.labstack.com/guide/binding/ +// https://echo.labstack.com/guide/request/ +// https://github.com/go-playground/validator // GetProductsRequestDto validation will handle in command level type GetProductsRequestDto struct { diff --git a/internal/services/catalog_write_service/internal/products/features/searching_product/v1/dtos/search_products_request_dto.go b/internal/services/catalog_write_service/internal/products/features/searching_product/v1/dtos/search_products_request_dto.go index 1e28eab9..a427a2c4 100644 --- a/internal/services/catalog_write_service/internal/products/features/searching_product/v1/dtos/search_products_request_dto.go +++ b/internal/services/catalog_write_service/internal/products/features/searching_product/v1/dtos/search_products_request_dto.go @@ -6,5 +6,5 @@ import ( type SearchProductsRequestDto struct { SearchText string `query:"search" json:"search"` - *utils.ListQuery `json:"listQuery"` + *utils.ListQuery ` json:"listQuery"` } diff --git a/internal/services/catalog_write_service/internal/products/features/updating_product/v1/commands/update_product.go b/internal/services/catalog_write_service/internal/products/features/updating_product/v1/commands/update_product.go index 6e5cd91e..b6a37faa 100644 --- a/internal/services/catalog_write_service/internal/products/features/updating_product/v1/commands/update_product.go +++ b/internal/services/catalog_write_service/internal/products/features/updating_product/v1/commands/update_product.go @@ -17,7 +17,13 @@ type UpdateProduct struct { } func NewUpdateProduct(productID uuid.UUID, name string, description string, price float64) (*UpdateProduct, error) { - command := &UpdateProduct{ProductID: productID, Name: name, Description: description, Price: price, UpdatedAt: time.Now()} + command := &UpdateProduct{ + ProductID: productID, + Name: name, + Description: description, + Price: price, + UpdatedAt: time.Now(), + } err := validator.Validate(command) if err != nil { return nil, err diff --git a/internal/services/catalog_write_service/internal/products/features/updating_product/v1/dtos/update_product_request_dto.go b/internal/services/catalog_write_service/internal/products/features/updating_product/v1/dtos/update_product_request_dto.go index 5bbd40b7..106cdff1 100644 --- a/internal/services/catalog_write_service/internal/products/features/updating_product/v1/dtos/update_product_request_dto.go +++ b/internal/services/catalog_write_service/internal/products/features/updating_product/v1/dtos/update_product_request_dto.go @@ -5,7 +5,7 @@ import uuid "github.com/satori/go.uuid" // https://echo.labstack.com/guide/binding/ type UpdateProductRequestDto struct { - ProductID uuid.UUID `json:"-" param:"id"` + ProductID uuid.UUID `json:"-" param:"id"` Name string `json:"name"` Description string `json:"description"` Price float64 `json:"price"` diff --git a/internal/services/catalog_write_service/internal/products/products_fx.go b/internal/services/catalog_write_service/internal/products/products_fx.go index b72a9055..f47157a7 100644 --- a/internal/services/catalog_write_service/internal/products/products_fx.go +++ b/internal/services/catalog_write_service/internal/products/products_fx.go @@ -11,7 +11,7 @@ import ( getProductsV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/getting_products/v1/endpoints" searchProductsV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/searching_product/v1/endpoints" updateProductsV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/updating_product/v1/endpoints" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc" customEcho "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/custom_echo" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/web/route" diff --git a/internal/services/catalog_write_service/internal/shared/app/test/test_app.go b/internal/services/catalog_write_service/internal/shared/app/test/test_app.go index d40b7e08..34eafc4f 100644 --- a/internal/services/catalog_write_service/internal/shared/app/test/test_app.go +++ b/internal/services/catalog_write_service/internal/shared/app/test/test_app.go @@ -8,11 +8,6 @@ import ( gorm2 "gorm.io/gorm" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/config" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/data" - productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/configurations/catalogs" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" gormPostgres "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/gorm_postgres" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc" @@ -22,6 +17,10 @@ import ( config2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/config" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/gorm" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/rabbitmq" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/config" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/data" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/configurations/catalogs" + productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" ) type TestApp struct{} diff --git a/internal/services/catalog_write_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go b/internal/services/catalog_write_service/internal/shared/grpc/genproto/products.pb.go similarity index 52% rename from internal/services/catalog_write_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go rename to internal/services/catalog_write_service/internal/shared/grpc/genproto/products.pb.go index 2bbb2451..78f454d3 100644 --- a/internal/services/catalog_write_service/internal/products/grpc/proto/service_clients/products_service_client.pb.go +++ b/internal/services/catalog_write_service/internal/shared/grpc/genproto/products.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 -// protoc v3.20.1 -// source: api_docs/catalogs_write/catalogs_write/protobuf/products/service_clients/products.proto +// protoc-gen-go v1.26.0 +// protoc v4.23.4 +// source: catalog_write_service/products.proto package products_service @@ -37,7 +37,7 @@ type Product struct { func (x *Product) Reset() { *x = Product{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[0] + mi := &file_catalog_write_service_products_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -50,7 +50,7 @@ func (x *Product) String() string { func (*Product) ProtoMessage() {} func (x *Product) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[0] + mi := &file_catalog_write_service_products_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -63,7 +63,7 @@ func (x *Product) ProtoReflect() protoreflect.Message { // Deprecated: Use Product.ProtoReflect.Descriptor instead. func (*Product) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{0} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{0} } func (x *Product) GetProductId() string { @@ -121,7 +121,7 @@ type CreateProductReq struct { func (x *CreateProductReq) Reset() { *x = CreateProductReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[1] + mi := &file_catalog_write_service_products_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -134,7 +134,7 @@ func (x *CreateProductReq) String() string { func (*CreateProductReq) ProtoMessage() {} func (x *CreateProductReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[1] + mi := &file_catalog_write_service_products_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -147,7 +147,7 @@ func (x *CreateProductReq) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateProductReq.ProtoReflect.Descriptor instead. func (*CreateProductReq) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{1} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{1} } func (x *CreateProductReq) GetName() string { @@ -182,7 +182,7 @@ type CreateProductRes struct { func (x *CreateProductRes) Reset() { *x = CreateProductRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[2] + mi := &file_catalog_write_service_products_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -195,7 +195,7 @@ func (x *CreateProductRes) String() string { func (*CreateProductRes) ProtoMessage() {} func (x *CreateProductRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[2] + mi := &file_catalog_write_service_products_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -208,7 +208,7 @@ func (x *CreateProductRes) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateProductRes.ProtoReflect.Descriptor instead. func (*CreateProductRes) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{2} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{2} } func (x *CreateProductRes) GetProductId() string { @@ -232,7 +232,7 @@ type UpdateProductReq struct { func (x *UpdateProductReq) Reset() { *x = UpdateProductReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[3] + mi := &file_catalog_write_service_products_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -245,7 +245,7 @@ func (x *UpdateProductReq) String() string { func (*UpdateProductReq) ProtoMessage() {} func (x *UpdateProductReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[3] + mi := &file_catalog_write_service_products_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -258,7 +258,7 @@ func (x *UpdateProductReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProductReq.ProtoReflect.Descriptor instead. func (*UpdateProductReq) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{3} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{3} } func (x *UpdateProductReq) GetProductId() string { @@ -298,7 +298,7 @@ type UpdateProductRes struct { func (x *UpdateProductRes) Reset() { *x = UpdateProductRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[4] + mi := &file_catalog_write_service_products_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -311,7 +311,7 @@ func (x *UpdateProductRes) String() string { func (*UpdateProductRes) ProtoMessage() {} func (x *UpdateProductRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[4] + mi := &file_catalog_write_service_products_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -324,7 +324,7 @@ func (x *UpdateProductRes) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProductRes.ProtoReflect.Descriptor instead. func (*UpdateProductRes) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{4} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{4} } type GetProductByIdReq struct { @@ -338,7 +338,7 @@ type GetProductByIdReq struct { func (x *GetProductByIdReq) Reset() { *x = GetProductByIdReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[5] + mi := &file_catalog_write_service_products_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -351,7 +351,7 @@ func (x *GetProductByIdReq) String() string { func (*GetProductByIdReq) ProtoMessage() {} func (x *GetProductByIdReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[5] + mi := &file_catalog_write_service_products_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -364,7 +364,7 @@ func (x *GetProductByIdReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProductByIdReq.ProtoReflect.Descriptor instead. func (*GetProductByIdReq) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{5} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{5} } func (x *GetProductByIdReq) GetProductId() string { @@ -385,7 +385,7 @@ type GetProductByIdRes struct { func (x *GetProductByIdRes) Reset() { *x = GetProductByIdRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[6] + mi := &file_catalog_write_service_products_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -398,7 +398,7 @@ func (x *GetProductByIdRes) String() string { func (*GetProductByIdRes) ProtoMessage() {} func (x *GetProductByIdRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[6] + mi := &file_catalog_write_service_products_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -411,7 +411,7 @@ func (x *GetProductByIdRes) ProtoReflect() protoreflect.Message { // Deprecated: Use GetProductByIdRes.ProtoReflect.Descriptor instead. func (*GetProductByIdRes) Descriptor() ([]byte, []int) { - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP(), []int{6} + return file_catalog_write_service_products_proto_rawDescGZIP(), []int{6} } func (x *GetProductByIdRes) GetProduct() *Product { @@ -421,95 +421,92 @@ func (x *GetProductByIdRes) GetProduct() *Product { return nil } -var File_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto protoreflect.FileDescriptor - -var file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDesc = []byte{ - 0x0a, 0x5f, 0x61, 0x70, 0x69, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x2f, 0x63, 0x61, 0x74, 0x61, 0x6c, - 0x6f, 0x67, 0x73, 0x2f, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe7, 0x01, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x12, - 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x09, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x5e, - 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, - 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0x30, - 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, - 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, - 0x22, 0x7c, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0x12, - 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, - 0x65, 0x73, 0x22, 0x31, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, +var File_catalog_write_service_products_proto protoreflect.FileDescriptor + +var file_catalog_write_service_products_proto_rawDesc = []byte{ + 0x0a, 0x24, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x5f, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, + 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe7, 0x01, 0x0a, 0x07, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, 0x69, + 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, + 0x38, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x64, 0x41, 0x74, 0x22, 0x5e, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, + 0x69, 0x63, 0x65, 0x22, 0x30, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x50, 0x72, - 0x6f, 0x64, 0x75, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x72, - 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, - 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x32, - 0x9f, 0x02, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, - 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x12, 0x57, 0x0a, 0x0d, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x22, 0x2e, + 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x7c, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x44, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, + 0x69, 0x63, 0x65, 0x22, 0x12, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x22, 0x31, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, + 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x22, 0x48, 0x0a, 0x11, 0x47, 0x65, + 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x73, 0x12, + 0x33, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x07, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x32, 0x9f, 0x02, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x57, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, - 0x71, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x52, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, - 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x23, 0x2e, 0x70, + 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, + 0x73, 0x12, 0x57, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x12, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x22, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x47, 0x65, + 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x12, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, 0x79, 0x49, 0x64, 0x52, 0x65, - 0x73, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, - 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x71, 0x1a, 0x23, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x42, + 0x79, 0x49, 0x64, 0x52, 0x65, 0x73, 0x42, 0x15, 0x5a, 0x13, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescOnce sync.Once - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescData = file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDesc + file_catalog_write_service_products_proto_rawDescOnce sync.Once + file_catalog_write_service_products_proto_rawDescData = file_catalog_write_service_products_proto_rawDesc ) -func file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescGZIP() []byte { - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescOnce.Do(func() { - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescData) +func file_catalog_write_service_products_proto_rawDescGZIP() []byte { + file_catalog_write_service_products_proto_rawDescOnce.Do(func() { + file_catalog_write_service_products_proto_rawDescData = protoimpl.X.CompressGZIP(file_catalog_write_service_products_proto_rawDescData) }) - return file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDescData + return file_catalog_write_service_products_proto_rawDescData } -var file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_goTypes = []interface{}{ +var file_catalog_write_service_products_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_catalog_write_service_products_proto_goTypes = []interface{}{ (*Product)(nil), // 0: products_service.Product (*CreateProductReq)(nil), // 1: products_service.CreateProductReq (*CreateProductRes)(nil), // 2: products_service.CreateProductRes @@ -519,7 +516,7 @@ var file_api_docs_catalogs_write_service_protobuf_products_service_clients_produ (*GetProductByIdRes)(nil), // 6: products_service.GetProductByIdRes (*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp } -var file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_depIdxs = []int32{ +var file_catalog_write_service_products_proto_depIdxs = []int32{ 7, // 0: products_service.Product.CreatedAt:type_name -> google.protobuf.Timestamp 7, // 1: products_service.Product.UpdatedAt:type_name -> google.protobuf.Timestamp 0, // 2: products_service.GetProductByIdRes.Product:type_name -> products_service.Product @@ -536,15 +533,13 @@ var file_api_docs_catalogs_write_service_protobuf_products_service_clients_produ 0, // [0:3] is the sub-list for field type_name } -func init() { - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_init() -} -func file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_init() { - if File_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto != nil { +func init() { file_catalog_write_service_products_proto_init() } +func file_catalog_write_service_products_proto_init() { + if File_catalog_write_service_products_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Product); i { case 0: return &v.state @@ -556,7 +551,7 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod return nil } } - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CreateProductReq); i { case 0: return &v.state @@ -568,7 +563,7 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod return nil } } - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CreateProductRes); i { case 0: return &v.state @@ -580,7 +575,7 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod return nil } } - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateProductReq); i { case 0: return &v.state @@ -592,7 +587,7 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod return nil } } - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateProductRes); i { case 0: return &v.state @@ -604,7 +599,7 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod return nil } } - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetProductByIdReq); i { case 0: return &v.state @@ -616,7 +611,7 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod return nil } } - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_catalog_write_service_products_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetProductByIdRes); i { case 0: return &v.state @@ -633,18 +628,18 @@ func file_api_docs_catalogs_write_service_protobuf_products_service_clients_prod out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDesc, + RawDescriptor: file_catalog_write_service_products_proto_rawDesc, NumEnums: 0, NumMessages: 7, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_goTypes, - DependencyIndexes: file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_depIdxs, - MessageInfos: file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_msgTypes, + GoTypes: file_catalog_write_service_products_proto_goTypes, + DependencyIndexes: file_catalog_write_service_products_proto_depIdxs, + MessageInfos: file_catalog_write_service_products_proto_msgTypes, }.Build() - File_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto = out.File - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_rawDesc = nil - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_goTypes = nil - file_api_docs_catalogs_write_service_protobuf_products_service_clients_products_service_client_proto_depIdxs = nil + File_catalog_write_service_products_proto = out.File + file_catalog_write_service_products_proto_rawDesc = nil + file_catalog_write_service_products_proto_goTypes = nil + file_catalog_write_service_products_proto_depIdxs = nil } diff --git a/internal/services/catalog_write_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go b/internal/services/catalog_write_service/internal/shared/grpc/genproto/products_grpc.pb.go similarity index 87% rename from internal/services/catalog_write_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go rename to internal/services/catalog_write_service/internal/shared/grpc/genproto/products_grpc.pb.go index 2adcae17..e8174210 100644 --- a/internal/services/catalog_write_service/internal/products/grpc/proto/service_clients/products_service_client_grpc.pb.go +++ b/internal/services/catalog_write_service/internal/shared/grpc/genproto/products_grpc.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.20.1 -// source: api_docs/catalogs_write/catalogs_write/protobuf/products/service_clients/products.proto +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.4 +// source: catalog_write_service/products.proto package products_service @@ -18,6 +18,12 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + ProductsService_CreateProduct_FullMethodName = "/products_service.ProductsService/CreateProduct" + ProductsService_UpdateProduct_FullMethodName = "/products_service.ProductsService/UpdateProduct" + ProductsService_GetProductById_FullMethodName = "/products_service.ProductsService/GetProductById" +) + // ProductsServiceClient is the client API for ProductsService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -37,7 +43,7 @@ func NewProductsServiceClient(cc grpc.ClientConnInterface) ProductsServiceClient func (c *productsServiceClient) CreateProduct(ctx context.Context, in *CreateProductReq, opts ...grpc.CallOption) (*CreateProductRes, error) { out := new(CreateProductRes) - err := c.cc.Invoke(ctx, "/products_service.ProductsService/CreateProduct", in, out, opts...) + err := c.cc.Invoke(ctx, ProductsService_CreateProduct_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -46,7 +52,7 @@ func (c *productsServiceClient) CreateProduct(ctx context.Context, in *CreatePro func (c *productsServiceClient) UpdateProduct(ctx context.Context, in *UpdateProductReq, opts ...grpc.CallOption) (*UpdateProductRes, error) { out := new(UpdateProductRes) - err := c.cc.Invoke(ctx, "/products_service.ProductsService/UpdateProduct", in, out, opts...) + err := c.cc.Invoke(ctx, ProductsService_UpdateProduct_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -55,7 +61,7 @@ func (c *productsServiceClient) UpdateProduct(ctx context.Context, in *UpdatePro func (c *productsServiceClient) GetProductById(ctx context.Context, in *GetProductByIdReq, opts ...grpc.CallOption) (*GetProductByIdRes, error) { out := new(GetProductByIdRes) - err := c.cc.Invoke(ctx, "/products_service.ProductsService/GetProductById", in, out, opts...) + err := c.cc.Invoke(ctx, ProductsService_GetProductById_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -106,7 +112,7 @@ func _ProductsService_CreateProduct_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/products_service.ProductsService/CreateProduct", + FullMethod: ProductsService_CreateProduct_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ProductsServiceServer).CreateProduct(ctx, req.(*CreateProductReq)) @@ -124,7 +130,7 @@ func _ProductsService_UpdateProduct_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/products_service.ProductsService/UpdateProduct", + FullMethod: ProductsService_UpdateProduct_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ProductsServiceServer).UpdateProduct(ctx, req.(*UpdateProductReq)) @@ -142,7 +148,7 @@ func _ProductsService_GetProductById_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/products_service.ProductsService/GetProductById", + FullMethod: ProductsService_GetProductById_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ProductsServiceServer).GetProductById(ctx, req.(*GetProductByIdReq)) @@ -171,5 +177,5 @@ var ProductsService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "api_docs/catalogs_write/catalogs_write/protobuf/products/service_clients/products.proto", + Metadata: "catalog_write_service/products.proto", } diff --git a/internal/services/catalog_write_service/internal/products/grpc/product_grpc_service_server.go b/internal/services/catalog_write_service/internal/shared/grpc/product_grpc_service_server.go similarity index 98% rename from internal/services/catalog_write_service/internal/products/grpc/product_grpc_service_server.go rename to internal/services/catalog_write_service/internal/shared/grpc/product_grpc_service_server.go index 8afacae4..bd6c7a72 100644 --- a/internal/services/catalog_write_service/internal/products/grpc/product_grpc_service_server.go +++ b/internal/services/catalog_write_service/internal/shared/grpc/product_grpc_service_server.go @@ -9,21 +9,19 @@ import ( uuid "github.com/satori/go.uuid" attribute2 "go.opentelemetry.io/otel/attribute" api "go.opentelemetry.io/otel/metric" - "go.opentelemetry.io/otel/trace" customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing/attribute" - createProductCommandV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/creating_product/v1/commands" createProductDtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/creating_product/v1/dtos" getProductByIdDtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/getting_product_by_id/v1/dtos" getProductByIdQueryV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/getting_product_by_id/v1/queries" updateProductCommandV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/updating_product/v1/commands" - productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/contracts" + productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" ) var grpcMetricsAttr = api.WithAttributes( diff --git a/internal/services/catalog_write_service/internal/shared/test_fixtures/integration/integration_test_fixture.go b/internal/services/catalog_write_service/internal/shared/test_fixtures/integration/integration_test_fixture.go index 877e7aa4..8b79d81e 100644 --- a/internal/services/catalog_write_service/internal/shared/test_fixtures/integration/integration_test_fixture.go +++ b/internal/services/catalog_write_service/internal/shared/test_fixtures/integration/integration_test_fixture.go @@ -17,10 +17,10 @@ import ( "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/config" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/data" - productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/mocks/testData" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/models" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/app/test" + productsService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" gormPostgres "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/gorm_postgres" diff --git a/internal/services/catalog_write_service/internal/shared/test_fixtures/unit_test/unit_test_fixture.go b/internal/services/catalog_write_service/internal/shared/test_fixtures/unit_test/unit_test_fixture.go index ddb66319..fe600cca 100644 --- a/internal/services/catalog_write_service/internal/shared/test_fixtures/unit_test/unit_test_fixture.go +++ b/internal/services/catalog_write_service/internal/shared/test_fixtures/unit_test/unit_test_fixture.go @@ -9,17 +9,16 @@ import ( "github.com/stretchr/testify/suite" "go.opentelemetry.io/otel/trace" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" + defaultLogger "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger/default_logger" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" + mocks3 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/mocks" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/config" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/contracts/data" dto "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/dto/v1" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/mocks/testData" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/models" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/mocks" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" - defaultLogger "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger/default_logger" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - mocks3 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/mocks" ) type UnitTestSharedFixture struct { @@ -108,3 +107,11 @@ func (c *UnitTestSharedFixture) SetupTest() { c.ProductRepository = productRepository c.Bus = bus } + +func (c *UnitTestSharedFixture) CleanupMocks() { + c.SetupTest() +} + +func (c *UnitTestSharedFixture) TearDownSuite() { + mapper.ClearMappings() +} diff --git a/internal/services/catalog_write_service/mocks/ProductsServiceClient.go b/internal/services/catalog_write_service/mocks/ProductsServiceClient.go index 8f9ab553..30c74903 100644 --- a/internal/services/catalog_write_service/mocks/ProductsServiceClient.go +++ b/internal/services/catalog_write_service/mocks/ProductsServiceClient.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - products_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" + productsservice "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" ) // ProductsServiceClient is an autogenerated mock type for the ProductsServiceClient type @@ -26,7 +26,7 @@ func (_m *ProductsServiceClient) EXPECT() *ProductsServiceClient_Expecter { } // CreateProduct provides a mock function with given fields: ctx, in, opts -func (_m *ProductsServiceClient) CreateProduct(ctx context.Context, in *products_service.CreateProductReq, opts ...grpc.CallOption) (*products_service.CreateProductRes, error) { +func (_m *ProductsServiceClient) CreateProduct(ctx context.Context, in *productsservice.CreateProductReq, opts ...grpc.CallOption) (*productsservice.CreateProductRes, error) { _va := make([]interface{}, len(opts)) for _i := range opts { _va[_i] = opts[_i] @@ -36,20 +36,20 @@ func (_m *ProductsServiceClient) CreateProduct(ctx context.Context, in *products _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 *products_service.CreateProductRes + var r0 *productsservice.CreateProductRes var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) (*products_service.CreateProductRes, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.CreateProductReq, ...grpc.CallOption) (*productsservice.CreateProductRes, error)); ok { return rf(ctx, in, opts...) } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) *products_service.CreateProductRes); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.CreateProductReq, ...grpc.CallOption) *productsservice.CreateProductRes); ok { r0 = rf(ctx, in, opts...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.CreateProductRes) + r0 = ret.Get(0).(*productsservice.CreateProductRes) } } - if rf, ok := ret.Get(1).(func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *productsservice.CreateProductReq, ...grpc.CallOption) error); ok { r1 = rf(ctx, in, opts...) } else { r1 = ret.Error(1) @@ -72,7 +72,7 @@ func (_e *ProductsServiceClient_Expecter) CreateProduct(ctx interface{}, in inte append([]interface{}{ctx, in}, opts...)...)} } -func (_c *ProductsServiceClient_CreateProduct_Call) Run(run func(ctx context.Context, in *products_service.CreateProductReq, opts ...grpc.CallOption)) *ProductsServiceClient_CreateProduct_Call { +func (_c *ProductsServiceClient_CreateProduct_Call) Run(run func(ctx context.Context, in *productsservice.CreateProductReq, opts ...grpc.CallOption)) *ProductsServiceClient_CreateProduct_Call { _c.Call.Run(func(args mock.Arguments) { variadicArgs := make([]grpc.CallOption, len(args)-2) for i, a := range args[2:] { @@ -80,23 +80,23 @@ func (_c *ProductsServiceClient_CreateProduct_Call) Run(run func(ctx context.Con variadicArgs[i] = a.(grpc.CallOption) } } - run(args[0].(context.Context), args[1].(*products_service.CreateProductReq), variadicArgs...) + run(args[0].(context.Context), args[1].(*productsservice.CreateProductReq), variadicArgs...) }) return _c } -func (_c *ProductsServiceClient_CreateProduct_Call) Return(_a0 *products_service.CreateProductRes, _a1 error) *ProductsServiceClient_CreateProduct_Call { +func (_c *ProductsServiceClient_CreateProduct_Call) Return(_a0 *productsservice.CreateProductRes, _a1 error) *ProductsServiceClient_CreateProduct_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *ProductsServiceClient_CreateProduct_Call) RunAndReturn(run func(context.Context, *products_service.CreateProductReq, ...grpc.CallOption) (*products_service.CreateProductRes, error)) *ProductsServiceClient_CreateProduct_Call { +func (_c *ProductsServiceClient_CreateProduct_Call) RunAndReturn(run func(context.Context, *productsservice.CreateProductReq, ...grpc.CallOption) (*productsservice.CreateProductRes, error)) *ProductsServiceClient_CreateProduct_Call { _c.Call.Return(run) return _c } // GetProductById provides a mock function with given fields: ctx, in, opts -func (_m *ProductsServiceClient) GetProductById(ctx context.Context, in *products_service.GetProductByIdReq, opts ...grpc.CallOption) (*products_service.GetProductByIdRes, error) { +func (_m *ProductsServiceClient) GetProductById(ctx context.Context, in *productsservice.GetProductByIdReq, opts ...grpc.CallOption) (*productsservice.GetProductByIdRes, error) { _va := make([]interface{}, len(opts)) for _i := range opts { _va[_i] = opts[_i] @@ -106,20 +106,20 @@ func (_m *ProductsServiceClient) GetProductById(ctx context.Context, in *product _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 *products_service.GetProductByIdRes + var r0 *productsservice.GetProductByIdRes var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) (*products_service.GetProductByIdRes, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.GetProductByIdReq, ...grpc.CallOption) (*productsservice.GetProductByIdRes, error)); ok { return rf(ctx, in, opts...) } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) *products_service.GetProductByIdRes); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.GetProductByIdReq, ...grpc.CallOption) *productsservice.GetProductByIdRes); ok { r0 = rf(ctx, in, opts...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.GetProductByIdRes) + r0 = ret.Get(0).(*productsservice.GetProductByIdRes) } } - if rf, ok := ret.Get(1).(func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *productsservice.GetProductByIdReq, ...grpc.CallOption) error); ok { r1 = rf(ctx, in, opts...) } else { r1 = ret.Error(1) @@ -142,7 +142,7 @@ func (_e *ProductsServiceClient_Expecter) GetProductById(ctx interface{}, in int append([]interface{}{ctx, in}, opts...)...)} } -func (_c *ProductsServiceClient_GetProductById_Call) Run(run func(ctx context.Context, in *products_service.GetProductByIdReq, opts ...grpc.CallOption)) *ProductsServiceClient_GetProductById_Call { +func (_c *ProductsServiceClient_GetProductById_Call) Run(run func(ctx context.Context, in *productsservice.GetProductByIdReq, opts ...grpc.CallOption)) *ProductsServiceClient_GetProductById_Call { _c.Call.Run(func(args mock.Arguments) { variadicArgs := make([]grpc.CallOption, len(args)-2) for i, a := range args[2:] { @@ -150,23 +150,23 @@ func (_c *ProductsServiceClient_GetProductById_Call) Run(run func(ctx context.Co variadicArgs[i] = a.(grpc.CallOption) } } - run(args[0].(context.Context), args[1].(*products_service.GetProductByIdReq), variadicArgs...) + run(args[0].(context.Context), args[1].(*productsservice.GetProductByIdReq), variadicArgs...) }) return _c } -func (_c *ProductsServiceClient_GetProductById_Call) Return(_a0 *products_service.GetProductByIdRes, _a1 error) *ProductsServiceClient_GetProductById_Call { +func (_c *ProductsServiceClient_GetProductById_Call) Return(_a0 *productsservice.GetProductByIdRes, _a1 error) *ProductsServiceClient_GetProductById_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *ProductsServiceClient_GetProductById_Call) RunAndReturn(run func(context.Context, *products_service.GetProductByIdReq, ...grpc.CallOption) (*products_service.GetProductByIdRes, error)) *ProductsServiceClient_GetProductById_Call { +func (_c *ProductsServiceClient_GetProductById_Call) RunAndReturn(run func(context.Context, *productsservice.GetProductByIdReq, ...grpc.CallOption) (*productsservice.GetProductByIdRes, error)) *ProductsServiceClient_GetProductById_Call { _c.Call.Return(run) return _c } // UpdateProduct provides a mock function with given fields: ctx, in, opts -func (_m *ProductsServiceClient) UpdateProduct(ctx context.Context, in *products_service.UpdateProductReq, opts ...grpc.CallOption) (*products_service.UpdateProductRes, error) { +func (_m *ProductsServiceClient) UpdateProduct(ctx context.Context, in *productsservice.UpdateProductReq, opts ...grpc.CallOption) (*productsservice.UpdateProductRes, error) { _va := make([]interface{}, len(opts)) for _i := range opts { _va[_i] = opts[_i] @@ -176,20 +176,20 @@ func (_m *ProductsServiceClient) UpdateProduct(ctx context.Context, in *products _ca = append(_ca, _va...) ret := _m.Called(_ca...) - var r0 *products_service.UpdateProductRes + var r0 *productsservice.UpdateProductRes var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) (*products_service.UpdateProductRes, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.UpdateProductReq, ...grpc.CallOption) (*productsservice.UpdateProductRes, error)); ok { return rf(ctx, in, opts...) } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) *products_service.UpdateProductRes); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.UpdateProductReq, ...grpc.CallOption) *productsservice.UpdateProductRes); ok { r0 = rf(ctx, in, opts...) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.UpdateProductRes) + r0 = ret.Get(0).(*productsservice.UpdateProductRes) } } - if rf, ok := ret.Get(1).(func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *productsservice.UpdateProductReq, ...grpc.CallOption) error); ok { r1 = rf(ctx, in, opts...) } else { r1 = ret.Error(1) @@ -212,7 +212,7 @@ func (_e *ProductsServiceClient_Expecter) UpdateProduct(ctx interface{}, in inte append([]interface{}{ctx, in}, opts...)...)} } -func (_c *ProductsServiceClient_UpdateProduct_Call) Run(run func(ctx context.Context, in *products_service.UpdateProductReq, opts ...grpc.CallOption)) *ProductsServiceClient_UpdateProduct_Call { +func (_c *ProductsServiceClient_UpdateProduct_Call) Run(run func(ctx context.Context, in *productsservice.UpdateProductReq, opts ...grpc.CallOption)) *ProductsServiceClient_UpdateProduct_Call { _c.Call.Run(func(args mock.Arguments) { variadicArgs := make([]grpc.CallOption, len(args)-2) for i, a := range args[2:] { @@ -220,17 +220,17 @@ func (_c *ProductsServiceClient_UpdateProduct_Call) Run(run func(ctx context.Con variadicArgs[i] = a.(grpc.CallOption) } } - run(args[0].(context.Context), args[1].(*products_service.UpdateProductReq), variadicArgs...) + run(args[0].(context.Context), args[1].(*productsservice.UpdateProductReq), variadicArgs...) }) return _c } -func (_c *ProductsServiceClient_UpdateProduct_Call) Return(_a0 *products_service.UpdateProductRes, _a1 error) *ProductsServiceClient_UpdateProduct_Call { +func (_c *ProductsServiceClient_UpdateProduct_Call) Return(_a0 *productsservice.UpdateProductRes, _a1 error) *ProductsServiceClient_UpdateProduct_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *ProductsServiceClient_UpdateProduct_Call) RunAndReturn(run func(context.Context, *products_service.UpdateProductReq, ...grpc.CallOption) (*products_service.UpdateProductRes, error)) *ProductsServiceClient_UpdateProduct_Call { +func (_c *ProductsServiceClient_UpdateProduct_Call) RunAndReturn(run func(context.Context, *productsservice.UpdateProductReq, ...grpc.CallOption) (*productsservice.UpdateProductRes, error)) *ProductsServiceClient_UpdateProduct_Call { _c.Call.Return(run) return _c } diff --git a/internal/services/catalog_write_service/mocks/ProductsServiceServer.go b/internal/services/catalog_write_service/mocks/ProductsServiceServer.go index 6268166a..c7d82fbe 100644 --- a/internal/services/catalog_write_service/mocks/ProductsServiceServer.go +++ b/internal/services/catalog_write_service/mocks/ProductsServiceServer.go @@ -5,8 +5,9 @@ package mocks import ( context "context" - products_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" mock "github.com/stretchr/testify/mock" + + productsservice "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" ) // ProductsServiceServer is an autogenerated mock type for the ProductsServiceServer type @@ -23,23 +24,23 @@ func (_m *ProductsServiceServer) EXPECT() *ProductsServiceServer_Expecter { } // CreateProduct provides a mock function with given fields: _a0, _a1 -func (_m *ProductsServiceServer) CreateProduct(_a0 context.Context, _a1 *products_service.CreateProductReq) (*products_service.CreateProductRes, error) { +func (_m *ProductsServiceServer) CreateProduct(_a0 context.Context, _a1 *productsservice.CreateProductReq) (*productsservice.CreateProductRes, error) { ret := _m.Called(_a0, _a1) - var r0 *products_service.CreateProductRes + var r0 *productsservice.CreateProductRes var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq) (*products_service.CreateProductRes, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.CreateProductReq) (*productsservice.CreateProductRes, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.CreateProductReq) *products_service.CreateProductRes); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.CreateProductReq) *productsservice.CreateProductRes); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.CreateProductRes) + r0 = ret.Get(0).(*productsservice.CreateProductRes) } } - if rf, ok := ret.Get(1).(func(context.Context, *products_service.CreateProductReq) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *productsservice.CreateProductReq) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -60,41 +61,41 @@ func (_e *ProductsServiceServer_Expecter) CreateProduct(_a0 interface{}, _a1 int return &ProductsServiceServer_CreateProduct_Call{Call: _e.mock.On("CreateProduct", _a0, _a1)} } -func (_c *ProductsServiceServer_CreateProduct_Call) Run(run func(_a0 context.Context, _a1 *products_service.CreateProductReq)) *ProductsServiceServer_CreateProduct_Call { +func (_c *ProductsServiceServer_CreateProduct_Call) Run(run func(_a0 context.Context, _a1 *productsservice.CreateProductReq)) *ProductsServiceServer_CreateProduct_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*products_service.CreateProductReq)) + run(args[0].(context.Context), args[1].(*productsservice.CreateProductReq)) }) return _c } -func (_c *ProductsServiceServer_CreateProduct_Call) Return(_a0 *products_service.CreateProductRes, _a1 error) *ProductsServiceServer_CreateProduct_Call { +func (_c *ProductsServiceServer_CreateProduct_Call) Return(_a0 *productsservice.CreateProductRes, _a1 error) *ProductsServiceServer_CreateProduct_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *ProductsServiceServer_CreateProduct_Call) RunAndReturn(run func(context.Context, *products_service.CreateProductReq) (*products_service.CreateProductRes, error)) *ProductsServiceServer_CreateProduct_Call { +func (_c *ProductsServiceServer_CreateProduct_Call) RunAndReturn(run func(context.Context, *productsservice.CreateProductReq) (*productsservice.CreateProductRes, error)) *ProductsServiceServer_CreateProduct_Call { _c.Call.Return(run) return _c } // GetProductById provides a mock function with given fields: _a0, _a1 -func (_m *ProductsServiceServer) GetProductById(_a0 context.Context, _a1 *products_service.GetProductByIdReq) (*products_service.GetProductByIdRes, error) { +func (_m *ProductsServiceServer) GetProductById(_a0 context.Context, _a1 *productsservice.GetProductByIdReq) (*productsservice.GetProductByIdRes, error) { ret := _m.Called(_a0, _a1) - var r0 *products_service.GetProductByIdRes + var r0 *productsservice.GetProductByIdRes var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq) (*products_service.GetProductByIdRes, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.GetProductByIdReq) (*productsservice.GetProductByIdRes, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.GetProductByIdReq) *products_service.GetProductByIdRes); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.GetProductByIdReq) *productsservice.GetProductByIdRes); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.GetProductByIdRes) + r0 = ret.Get(0).(*productsservice.GetProductByIdRes) } } - if rf, ok := ret.Get(1).(func(context.Context, *products_service.GetProductByIdReq) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *productsservice.GetProductByIdReq) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -115,41 +116,41 @@ func (_e *ProductsServiceServer_Expecter) GetProductById(_a0 interface{}, _a1 in return &ProductsServiceServer_GetProductById_Call{Call: _e.mock.On("GetProductById", _a0, _a1)} } -func (_c *ProductsServiceServer_GetProductById_Call) Run(run func(_a0 context.Context, _a1 *products_service.GetProductByIdReq)) *ProductsServiceServer_GetProductById_Call { +func (_c *ProductsServiceServer_GetProductById_Call) Run(run func(_a0 context.Context, _a1 *productsservice.GetProductByIdReq)) *ProductsServiceServer_GetProductById_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*products_service.GetProductByIdReq)) + run(args[0].(context.Context), args[1].(*productsservice.GetProductByIdReq)) }) return _c } -func (_c *ProductsServiceServer_GetProductById_Call) Return(_a0 *products_service.GetProductByIdRes, _a1 error) *ProductsServiceServer_GetProductById_Call { +func (_c *ProductsServiceServer_GetProductById_Call) Return(_a0 *productsservice.GetProductByIdRes, _a1 error) *ProductsServiceServer_GetProductById_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *ProductsServiceServer_GetProductById_Call) RunAndReturn(run func(context.Context, *products_service.GetProductByIdReq) (*products_service.GetProductByIdRes, error)) *ProductsServiceServer_GetProductById_Call { +func (_c *ProductsServiceServer_GetProductById_Call) RunAndReturn(run func(context.Context, *productsservice.GetProductByIdReq) (*productsservice.GetProductByIdRes, error)) *ProductsServiceServer_GetProductById_Call { _c.Call.Return(run) return _c } // UpdateProduct provides a mock function with given fields: _a0, _a1 -func (_m *ProductsServiceServer) UpdateProduct(_a0 context.Context, _a1 *products_service.UpdateProductReq) (*products_service.UpdateProductRes, error) { +func (_m *ProductsServiceServer) UpdateProduct(_a0 context.Context, _a1 *productsservice.UpdateProductReq) (*productsservice.UpdateProductRes, error) { ret := _m.Called(_a0, _a1) - var r0 *products_service.UpdateProductRes + var r0 *productsservice.UpdateProductRes var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq) (*products_service.UpdateProductRes, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.UpdateProductReq) (*productsservice.UpdateProductRes, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(context.Context, *products_service.UpdateProductReq) *products_service.UpdateProductRes); ok { + if rf, ok := ret.Get(0).(func(context.Context, *productsservice.UpdateProductReq) *productsservice.UpdateProductRes); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*products_service.UpdateProductRes) + r0 = ret.Get(0).(*productsservice.UpdateProductRes) } } - if rf, ok := ret.Get(1).(func(context.Context, *products_service.UpdateProductReq) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *productsservice.UpdateProductReq) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -170,19 +171,19 @@ func (_e *ProductsServiceServer_Expecter) UpdateProduct(_a0 interface{}, _a1 int return &ProductsServiceServer_UpdateProduct_Call{Call: _e.mock.On("UpdateProduct", _a0, _a1)} } -func (_c *ProductsServiceServer_UpdateProduct_Call) Run(run func(_a0 context.Context, _a1 *products_service.UpdateProductReq)) *ProductsServiceServer_UpdateProduct_Call { +func (_c *ProductsServiceServer_UpdateProduct_Call) Run(run func(_a0 context.Context, _a1 *productsservice.UpdateProductReq)) *ProductsServiceServer_UpdateProduct_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*products_service.UpdateProductReq)) + run(args[0].(context.Context), args[1].(*productsservice.UpdateProductReq)) }) return _c } -func (_c *ProductsServiceServer_UpdateProduct_Call) Return(_a0 *products_service.UpdateProductRes, _a1 error) *ProductsServiceServer_UpdateProduct_Call { +func (_c *ProductsServiceServer_UpdateProduct_Call) Return(_a0 *productsservice.UpdateProductRes, _a1 error) *ProductsServiceServer_UpdateProduct_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *ProductsServiceServer_UpdateProduct_Call) RunAndReturn(run func(context.Context, *products_service.UpdateProductReq) (*products_service.UpdateProductRes, error)) *ProductsServiceServer_UpdateProduct_Call { +func (_c *ProductsServiceServer_UpdateProduct_Call) RunAndReturn(run func(context.Context, *productsservice.UpdateProductReq) (*productsservice.UpdateProductRes, error)) *ProductsServiceServer_UpdateProduct_Call { _c.Call.Return(run) return _c } diff --git a/internal/services/catalog_write_service/test/end_to_end/products/grpc/product_grpc_service_server_test.go b/internal/services/catalog_write_service/test/end_to_end/products/grpc/product_grpc_service_server_test.go index 8ea5f5b7..958bad1a 100644 --- a/internal/services/catalog_write_service/test/end_to_end/products/grpc/product_grpc_service_server_test.go +++ b/internal/services/catalog_write_service/test/end_to_end/products/grpc/product_grpc_service_server_test.go @@ -11,7 +11,7 @@ import ( "github.com/brianvoe/gofakeit/v6" "github.com/stretchr/testify/suite" - productService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/grpc/proto/service_clients" + productService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/grpc/genproto" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/test_fixtures/integration" ) diff --git a/internal/services/catalog_write_service/test/unit/products/features/getting_product_by_id/v1/queries/get_product_by_id_handler_unit_test.go b/internal/services/catalog_write_service/test/unit/products/features/getting_product_by_id/v1/queries/get_product_by_id_handler_unit_test.go index 70ab272e..5b98e9a5 100644 --- a/internal/services/catalog_write_service/test/unit/products/features/getting_product_by_id/v1/queries/get_product_by_id_handler_unit_test.go +++ b/internal/services/catalog_write_service/test/unit/products/features/getting_product_by_id/v1/queries/get_product_by_id_handler_unit_test.go @@ -35,7 +35,6 @@ func TestGetProductByIdHandlerUnit(t *testing.T) { func (c *getProductByIdHandlerTest) Test_Get_Product_By_Id() { product := c.Items[0] id := uuid.NewV4() - testCases := []struct { Name string id uuid.UUID @@ -93,6 +92,8 @@ func (c *getProductByIdHandlerTest) Test_Get_Product_By_Id() { c.Run(testCase.Name, func() { // arrange // create new mocks or clear mocks before executing + c.CleanupMocks() + getProductByIdHandler := getProductByIdQueryV1.NewGetProductByIdHandler( c.Log, c.ProductRepository, diff --git a/internal/services/catalog_write_service/test/unit/products/features/updating_product/v1/commands/update_product_handler_unit_test.go b/internal/services/catalog_write_service/test/unit/products/features/updating_product/v1/commands/update_product_handler_unit_test.go index 86433476..f3a55081 100644 --- a/internal/services/catalog_write_service/test/unit/products/features/updating_product/v1/commands/update_product_handler_unit_test.go +++ b/internal/services/catalog_write_service/test/unit/products/features/updating_product/v1/commands/update_product_handler_unit_test.go @@ -17,8 +17,6 @@ import ( "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/features/updating_product/v1/commands" customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/products/models" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/catalogwriteservice/internal/shared/test_fixtures/unit_test" ) @@ -151,46 +149,3 @@ func (c *updateProductHandlerUnitTests) Test_Handle_Should_Return_Error_For_Erro c.ErrorContains(err, "error in publishing 'ProductUpdated' message") c.NotNil(dto) } - -func (c *updateProductHandlerUnitTests) Test_Handle_Should_Return_Error_For_Error_In_Mapping() { - ctx := context.Background() - existing := c.Items[0] - - updateProductCommand, err := commands.NewUpdateProduct( - existing.ProductId, - gofakeit.Name(), - gofakeit.EmojiDescription(), - existing.Price, - ) - c.Require().NoError(err) - - updated := &models.Product{ - ProductId: existing.ProductId, - Name: updateProductCommand.Name, - Description: updateProductCommand.Description, - UpdatedAt: updateProductCommand.UpdatedAt, - CreatedAt: existing.CreatedAt, - Price: existing.Price, - } - - c.ProductRepository.On("GetProductById", mock.Anything, existing.ProductId). - Once(). - Return(existing, nil) - - c.ProductRepository.On("UpdateProduct", mock.Anything, mock.Anything). - Once(). - Return(updated, nil) - - mapper.ClearMappings() - - updateProductHandler := commands.NewUpdateProductHandler(c.Log, c.Uow, c.Bus, c.Tracer) - dto, err := updateProductHandler.Handle(ctx, updateProductCommand) - - c.Uow.AssertNumberOfCalls(c.T(), "Do", 1) - c.ProductRepository.AssertNumberOfCalls(c.T(), "GetProductById", 1) - c.ProductRepository.AssertNumberOfCalls(c.T(), "UpdateProduct", 1) - c.Bus.AssertNumberOfCalls(c.T(), "PublishMessage", 0) - c.ErrorContains(err, "error in the mapping ProductDto") - c.True(customErrors.IsApplicationError(err, http.StatusInternalServerError)) - c.NotNil(dto) -} diff --git a/internal/services/order_service/cmd/app/main.go b/internal/services/order_service/cmd/app/main.go index 0de93c1b..4f29c223 100644 --- a/internal/services/order_service/cmd/app/main.go +++ b/internal/services/order_service/cmd/app/main.go @@ -1,6 +1,8 @@ package main import ( + "os" + "github.com/spf13/cobra" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/app" diff --git a/internal/services/order_service/config/config.test.json b/internal/services/order_service/config/config.test.json index dface903..9dd29e39 100644 --- a/internal/services/order_service/config/config.test.json +++ b/internal/services/order_service/config/config.test.json @@ -5,13 +5,13 @@ }, "grpcOptions": { "name": "order_service", - "port": ":6005", + "port": ":2300", "host": "localhost", "development": true }, "echoHttpOptions": { "name": "order_service", - "port": ":8000", + "port": ":6100", "development": true, "timeout": 30, "basePath": "/api/v1", diff --git a/internal/services/order_service/docs/docs.go b/internal/services/order_service/docs/docs.go index f35945d1..281a2cbd 100644 --- a/internal/services/order_service/docs/docs.go +++ b/internal/services/order_service/docs/docs.go @@ -1,5 +1,5 @@ -// Package docs GENERATED BY SWAG; DO NOT EDIT -// This file was generated by swaggo/swag +// Code generated by swaggo/swag. DO NOT EDIT. + package docs import "github.com/swaggo/swag" @@ -53,7 +53,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetOrdersResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto" } } } @@ -77,7 +77,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dtos.CreateOrderRequestDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto" } } ], @@ -85,7 +85,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dtos.CreateOrderResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto" } } } @@ -117,7 +117,7 @@ const docTemplate = `{ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetOrderByIdResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto" } } } @@ -125,51 +125,7 @@ const docTemplate = `{ } }, "definitions": { - "dtos.CreateOrderRequestDto": { - "type": "object", - "properties": { - "accountEmail": { - "type": "string" - }, - "deliveryAddress": { - "type": "string" - }, - "deliveryTime": { - "type": "string" - }, - "shopItems": { - "type": "array", - "items": { - "$ref": "#/definitions/dtos.ShopItemDto" - } - } - } - }, - "dtos.CreateOrderResponseDto": { - "type": "object", - "properties": { - "orderId": { - "type": "string" - } - } - }, - "dtos.GetOrderByIdResponseDto": { - "type": "object", - "properties": { - "order": { - "$ref": "#/definitions/dtos.OrderReadDto" - } - } - }, - "dtos.GetOrdersResponseDto": { - "type": "object", - "properties": { - "orders": { - "type": "object" - } - } - }, - "dtos.OrderReadDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto": { "type": "object", "properties": { "accountEmail": { @@ -208,7 +164,7 @@ const docTemplate = `{ "shopItems": { "type": "array", "items": { - "$ref": "#/definitions/dtos.ShopItemReadDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto" } }, "submitted": { @@ -222,7 +178,7 @@ const docTemplate = `{ } } }, - "dtos.ShopItemDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto": { "type": "object", "properties": { "description": { @@ -239,7 +195,7 @@ const docTemplate = `{ } } }, - "dtos.ShopItemReadDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto": { "type": "object", "properties": { "description": { @@ -256,6 +212,50 @@ const docTemplate = `{ } } }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto": { + "type": "object", + "properties": { + "accountEmail": { + "type": "string" + }, + "deliveryAddress": { + "type": "string" + }, + "deliveryTime": { + "type": "string" + }, + "shopItems": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto" + } + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto": { + "type": "object", + "properties": { + "Id": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto": { + "type": "object", + "properties": { + "order": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto": { + "type": "object", + "properties": { + "orders": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto" + } + } + }, "utils.FilterModel": { "type": "object", "properties": { @@ -269,6 +269,29 @@ const docTemplate = `{ "type": "string" } } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } } } }` @@ -283,6 +306,8 @@ var SwaggerInfo = &swag.Spec{ Description: "Orders Service Api", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", } func init() { diff --git a/internal/services/order_service/docs/swagger.json b/internal/services/order_service/docs/swagger.json index e9affe1a..3af5fd5b 100644 --- a/internal/services/order_service/docs/swagger.json +++ b/internal/services/order_service/docs/swagger.json @@ -44,7 +44,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetOrdersResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto" } } } @@ -68,7 +68,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dtos.CreateOrderRequestDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto" } } ], @@ -76,7 +76,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dtos.CreateOrderResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto" } } } @@ -108,7 +108,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/dtos.GetOrderByIdResponseDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto" } } } @@ -116,51 +116,7 @@ } }, "definitions": { - "dtos.CreateOrderRequestDto": { - "type": "object", - "properties": { - "accountEmail": { - "type": "string" - }, - "deliveryAddress": { - "type": "string" - }, - "deliveryTime": { - "type": "string" - }, - "shopItems": { - "type": "array", - "items": { - "$ref": "#/definitions/dtos.ShopItemDto" - } - } - } - }, - "dtos.CreateOrderResponseDto": { - "type": "object", - "properties": { - "orderId": { - "type": "string" - } - } - }, - "dtos.GetOrderByIdResponseDto": { - "type": "object", - "properties": { - "order": { - "$ref": "#/definitions/dtos.OrderReadDto" - } - } - }, - "dtos.GetOrdersResponseDto": { - "type": "object", - "properties": { - "orders": { - "type": "object" - } - } - }, - "dtos.OrderReadDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto": { "type": "object", "properties": { "accountEmail": { @@ -199,7 +155,7 @@ "shopItems": { "type": "array", "items": { - "$ref": "#/definitions/dtos.ShopItemReadDto" + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto" } }, "submitted": { @@ -213,7 +169,7 @@ } } }, - "dtos.ShopItemDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto": { "type": "object", "properties": { "description": { @@ -230,7 +186,7 @@ } } }, - "dtos.ShopItemReadDto": { + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto": { "type": "object", "properties": { "description": { @@ -247,6 +203,50 @@ } } }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto": { + "type": "object", + "properties": { + "accountEmail": { + "type": "string" + }, + "deliveryAddress": { + "type": "string" + }, + "deliveryTime": { + "type": "string" + }, + "shopItems": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto" + } + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto": { + "type": "object", + "properties": { + "Id": { + "type": "string" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto": { + "type": "object", + "properties": { + "order": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + } + }, + "github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto": { + "type": "object", + "properties": { + "orders": { + "$ref": "#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto" + } + } + }, "utils.FilterModel": { "type": "object", "properties": { @@ -260,6 +260,29 @@ "type": "string" } } + }, + "utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto" + } + }, + "page": { + "type": "integer" + }, + "size": { + "type": "integer" + }, + "totalItems": { + "type": "integer" + }, + "totalPage": { + "type": "integer" + } + } } } } \ No newline at end of file diff --git a/internal/services/order_service/docs/swagger.yaml b/internal/services/order_service/docs/swagger.yaml index f110c98d..8229daac 100644 --- a/internal/services/order_service/docs/swagger.yaml +++ b/internal/services/order_service/docs/swagger.yaml @@ -1,33 +1,5 @@ definitions: - dtos.CreateOrderRequestDto: - properties: - accountEmail: - type: string - deliveryAddress: - type: string - deliveryTime: - type: string - shopItems: - items: - $ref: '#/definitions/dtos.ShopItemDto' - type: array - type: object - dtos.CreateOrderResponseDto: - properties: - orderId: - type: string - type: object - dtos.GetOrderByIdResponseDto: - properties: - order: - $ref: '#/definitions/dtos.OrderReadDto' - type: object - dtos.GetOrdersResponseDto: - properties: - orders: - type: object - type: object - dtos.OrderReadDto: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto: properties: accountEmail: type: string @@ -53,7 +25,7 @@ definitions: type: string shopItems: items: - $ref: '#/definitions/dtos.ShopItemReadDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto' type: array submitted: type: boolean @@ -62,7 +34,7 @@ definitions: updatedAt: type: string type: object - dtos.ShopItemDto: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto: properties: description: type: string @@ -73,7 +45,7 @@ definitions: title: type: string type: object - dtos.ShopItemReadDto: + github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemReadDto: properties: description: type: string @@ -84,6 +56,34 @@ definitions: title: type: string type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto + : properties: + accountEmail: + type: string + deliveryAddress: + type: string + deliveryTime: + type: string + shopItems: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.ShopItemDto' + type: array + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto + : properties: + Id: + type: string + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto + : properties: + order: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto' + type: object + ? github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto + : properties: + orders: + $ref: '#/definitions/utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto' + type: object utils.FilterModel: properties: comparison: @@ -93,6 +93,21 @@ definitions: value: type: string type: object + ? utils.ListResult-github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1_OrderReadDto + : properties: + items: + items: + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_dtos_v1.OrderReadDto' + type: array + page: + type: integer + size: + type: integer + totalItems: + type: integer + totalPage: + type: integer + type: object info: contact: name: Mehdi Hadeli @@ -122,7 +137,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dtos.GetOrdersResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_orders_v1_dtos.GetOrdersResponseDto' summary: Get all orders tags: - Orders @@ -136,14 +151,14 @@ paths: name: CreateOrderRequestDto required: true schema: - $ref: '#/definitions/dtos.CreateOrderRequestDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderRequestDto' produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/dtos.CreateOrderResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_creating_order_v1_dtos.CreateOrderResponseDto' summary: Create order tags: - Orders @@ -164,7 +179,7 @@ paths: "200": description: OK schema: - $ref: '#/definitions/dtos.GetOrderByIdResponseDto' + $ref: '#/definitions/github_com_mehdihadeli_go-ecommerce-microservices_internal_services_orderservice_internal_orders_features_getting_order_by_id_v1_dtos.GetOrderByIdResponseDto' summary: Get order by id tags: - Orders diff --git a/internal/services/order_service/go.mod b/internal/services/order_service/go.mod index 0b01cac0..cd655c72 100644 --- a/internal/services/order_service/go.mod +++ b/internal/services/order_service/go.mod @@ -22,7 +22,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/stretchr/testify v1.8.3 github.com/swaggo/echo-swagger v1.3.3 - github.com/swaggo/swag v1.8.3 + github.com/swaggo/swag v1.16.1 go.mongodb.org/mongo-driver v1.11.6 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/metric v1.16.0 diff --git a/internal/services/order_service/go.sum b/internal/services/order_service/go.sum index e19ef773..5a2c61da 100644 --- a/internal/services/order_service/go.sum +++ b/internal/services/order_service/go.sum @@ -1277,8 +1277,8 @@ github.com/swaggo/echo-swagger v1.3.3/go.mod h1:vbKcEBeJgOexLuPcsdZhrRAV508fsE79 github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe h1:K8pHPVoTgxFJt1lXuIzzOX7zZhZFldJQK/CgKx9BFIc= github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= -github.com/swaggo/swag v1.8.3 h1:3pZSSCQ//gAH88lfmxM3Cd1+JCsxV8Md6f36b9hrZ5s= -github.com/swaggo/swag v1.8.3/go.mod h1:jMLeXOOmYyjk8PvHTsXBdrubsNd9gUJTTCzL5iBnseg= +github.com/swaggo/swag v1.16.1 h1:fTNRhKstPKxcnoKsytm4sahr8FaYzUcT7i1/3nd/fBg= +github.com/swaggo/swag v1.16.1/go.mod h1:9/LMvHycG3NFHfR6LwvikHv5iFvmPADQ359cKikGxto= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= diff --git a/internal/services/order_service/internal/orders/configurations/mappings/mappings_profile.go b/internal/services/order_service/internal/orders/configurations/mappings/mappings_profile.go index ba7d0d86..e0f821f2 100644 --- a/internal/services/order_service/internal/orders/configurations/mappings/mappings_profile.go +++ b/internal/services/order_service/internal/orders/configurations/mappings/mappings_profile.go @@ -5,12 +5,11 @@ import ( "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" - - grpcOrderService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" dtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/dtos/v1" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/aggregate" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/read_models" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/value_objects" + grpcOrderService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) func ConfigureOrdersMappings() error { diff --git a/internal/services/order_service/internal/orders/configurations/orders_module_configurator.go b/internal/services/order_service/internal/orders/configurations/orders_module_configurator.go index c0c59b0b..bc614cf4 100644 --- a/internal/services/order_service/internal/orders/configurations/orders_module_configurator.go +++ b/internal/services/order_service/internal/orders/configurations/orders_module_configurator.go @@ -4,14 +4,6 @@ import ( "github.com/go-playground/validator" googleGrpc "google.golang.org/grpc" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/configurations/mappings" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/configurations/mediatr" - ordersservice "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/repositories" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/grpc" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/aggregate" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/contracts" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/contracts/store" contracts2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" grpcServer "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/grpc" @@ -19,6 +11,13 @@ import ( "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/web/route" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/configurations/mappings" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/configurations/mediatr" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/repositories" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/aggregate" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/contracts" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc" + ordersservice "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) type OrdersModuleConfigurator struct { diff --git a/internal/services/order_service/internal/orders/dtos/v1/order_dto.go b/internal/services/order_service/internal/orders/dtos/v1/order_dto.go index ed055323..639a40d2 100644 --- a/internal/services/order_service/internal/orders/dtos/v1/order_dto.go +++ b/internal/services/order_service/internal/orders/dtos/v1/order_dto.go @@ -1,8 +1,9 @@ package dtosV1 import ( - uuid "github.com/satori/go.uuid" "time" + + uuid "github.com/satori/go.uuid" ) type OrderDto struct { diff --git a/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_domain_errors_test.go b/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_domain_errors_test.go index 72c57059..54a8dd34 100644 --- a/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_domain_errors_test.go +++ b/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_domain_errors_test.go @@ -1,11 +1,11 @@ package domainExceptions import ( - "fmt" - "testing" + "fmt" + "testing" - errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" - "github.com/stretchr/testify/assert" + errorUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils/error_utils" + "github.com/stretchr/testify/assert" ) func Test_Order_Shop_Items_Required_Error(t *testing.T) { diff --git a/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_not_found_error.go b/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_not_found_error.go index ad376667..2db4b754 100644 --- a/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_not_found_error.go +++ b/internal/services/order_service/internal/orders/exceptions/domain_exceptions/order_not_found_error.go @@ -1,10 +1,10 @@ package domainExceptions import ( - "fmt" + "fmt" - "emperror.dev/errors" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" + "emperror.dev/errors" + customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" ) type orderNotFoundError struct { diff --git a/internal/services/order_service/internal/orders/features/getting_orders/v1/endpoints/getting_orders_endpoint_test.go b/internal/services/order_service/internal/orders/features/getting_orders/v1/endpoints/getting_orders_endpoint_test.go deleted file mode 100644 index 7f226d9d..00000000 --- a/internal/services/order_service/internal/orders/features/getting_orders/v1/endpoints/getting_orders_endpoint_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package endpoints - -import ( - "testing" -) - -func Test_Orders_E2E(t *testing.T) { - //testUtils.SkipCI(t) - //fixture := e2e.NewE2ETestFixture() - // - //e := NewGetOrdersEndpoint(delivery.NewOrderEndpointBase(fixture.InfrastructureConfigurations, fixture.V1.OrdersGroup, fixture.Bus, fixture.OrdersMetrics)) - //e.MapRoute() - // - //fixture.Run() - //defer fixture.Cleanup() - // - //s := httptest.NewServer(fixture.Echo) - //defer s.Close() - // - //// create httpexpect instance - //expect := httpexpect.New(t, s.URL) - // - //expect.GET("/api/v1/orders"). - // WithContext(context.Background()). - // Expect(). - // Status(http.StatusOK) -} diff --git a/internal/services/order_service/internal/orders/features/getting_orders/v1/queries/get_orders_handler_test.go b/internal/services/order_service/internal/orders/features/getting_orders/v1/queries/get_orders_handler_test.go deleted file mode 100644 index 90fc313c..00000000 --- a/internal/services/order_service/internal/orders/features/getting_orders/v1/queries/get_orders_handler_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package queries - -import ( - "context" - "testing" - - "github.com/mehdihadeli/go-mediatr" - "github.com/stretchr/testify/assert" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/utils" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/features/getting_orders/v1/dtos" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/test_fixtures/integration" -) - -func Test_Get_Orders_Query_Handler(t *testing.T) { - testUtils.SkipCI(t) - fixture := integration.NewIntegrationTestFixture() - - err := mediatr.RegisterRequestHandler[*GetOrders, *dtos.GetOrdersResponseDto]( - NewGetOrdersHandler(fixture.Log, fixture.Cfg, fixture.MongoOrderReadRepository), - ) - if err != nil { - return - } - - fixture.Run() - defer fixture.Cleanup() - - query := NewGetOrders(utils.NewListQuery(10, 1)) - queryResult, err := mediatr.Send[*GetOrders, *dtos.GetOrdersResponseDto]( - context.Background(), - query, - ) - - assert.NotNil(t, queryResult) - assert.NotNil(t, queryResult.Orders) - assert.NotEmpty(t, queryResult.Orders.Items) -} diff --git a/internal/services/order_service/internal/orders/models/orders/read_models/order_read.go b/internal/services/order_service/internal/orders/models/orders/read_models/order_read.go index 5e83be12..1963e9d8 100644 --- a/internal/services/order_service/internal/orders/models/orders/read_models/order_read.go +++ b/internal/services/order_service/internal/orders/models/orders/read_models/order_read.go @@ -1,32 +1,41 @@ package read_models import ( - uuid "github.com/satori/go.uuid" "time" + + uuid "github.com/satori/go.uuid" ) type OrderReadModel struct { // we generate id ourself because auto generate mongo string id column with type _id is not an uuid - Id string `json:"id" bson:"_id,omitempty"` //https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#the-_id-field - OrderId string `json:"orderId" bson:"orderId,omitempty"` - ShopItems []*ShopItemReadModel `json:"shopItems,omitempty" bson:"shopItems,omitempty"` - AccountEmail string `json:"accountEmail,omitempty" bson:"accountEmail,omitempty"` + Id string `json:"id" bson:"_id,omitempty"` //https://www.mongodb.com/docs/drivers/go/current/fundamentals/crud/write-operations/insert/#the-_id-field + OrderId string `json:"orderId" bson:"orderId,omitempty"` + ShopItems []*ShopItemReadModel `json:"shopItems,omitempty" bson:"shopItems,omitempty"` + AccountEmail string `json:"accountEmail,omitempty" bson:"accountEmail,omitempty"` DeliveryAddress string `json:"deliveryAddress,omitempty" bson:"deliveryAddress,omitempty"` - CancelReason string `json:"cancelReason,omitempty" bson:"cancelReason,omitempty"` - TotalPrice float64 `json:"totalPrice,omitempty" bson:"totalPrice,omitempty"` - DeliveredTime time.Time `json:"deliveredTime,omitempty" bson:"deliveredTime,omitempty"` - Paid bool `json:"paid,omitempty" bson:"paid,omitempty"` - Submitted bool `json:"submitted,omitempty" bson:"submitted,omitempty"` - Completed bool `json:"completed,omitempty" bson:"completed,omitempty"` - Canceled bool `json:"canceled,omitempty" bson:"canceled,omitempty"` - PaymentId string `json:"paymentId" bson:"paymentId,omitempty"` - CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"` + CancelReason string `json:"cancelReason,omitempty" bson:"cancelReason,omitempty"` + TotalPrice float64 `json:"totalPrice,omitempty" bson:"totalPrice,omitempty"` + DeliveredTime time.Time `json:"deliveredTime,omitempty" bson:"deliveredTime,omitempty"` + Paid bool `json:"paid,omitempty" bson:"paid,omitempty"` + Submitted bool `json:"submitted,omitempty" bson:"submitted,omitempty"` + Completed bool `json:"completed,omitempty" bson:"completed,omitempty"` + Canceled bool `json:"canceled,omitempty" bson:"canceled,omitempty"` + PaymentId string `json:"paymentId" bson:"paymentId,omitempty"` + CreatedAt time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty" bson:"updatedAt,omitempty"` } -func NewOrderReadModel(orderId uuid.UUID, items []*ShopItemReadModel, accountEmail string, deliveryAddress string, deliveryTime time.Time) *OrderReadModel { +func NewOrderReadModel( + orderId uuid.UUID, + items []*ShopItemReadModel, + accountEmail string, + deliveryAddress string, + deliveryTime time.Time, +) *OrderReadModel { return &OrderReadModel{ - Id: uuid.NewV4().String(), // we generate id ourself because auto generate mongo string id column with type _id is not an uuid + Id: uuid.NewV4(). + String(), + // we generate id ourself because auto generate mongo string id column with type _id is not an uuid OrderId: orderId.String(), ShopItems: items, AccountEmail: accountEmail, diff --git a/internal/services/order_service/internal/orders/models/orders/read_models/shop_item_read.go b/internal/services/order_service/internal/orders/models/orders/read_models/shop_item_read.go index 6ac91cb7..1027b093 100644 --- a/internal/services/order_service/internal/orders/models/orders/read_models/shop_item_read.go +++ b/internal/services/order_service/internal/orders/models/orders/read_models/shop_item_read.go @@ -1,10 +1,10 @@ package read_models type ShopItemReadModel struct { - Title string `json:"title,omitempty" bson:"title,omitempty"` + Title string `json:"title,omitempty" bson:"title,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` - Quantity uint64 `json:"quantity,omitempty" bson:"quantity,omitempty"` - Price float64 `json:"price,omitempty" bson:"price,omitempty"` + Quantity uint64 `json:"quantity,omitempty" bson:"quantity,omitempty"` + Price float64 `json:"price,omitempty" bson:"price,omitempty"` } func NewShopItemReadModel(title string, description string, quantity uint64, price float64) *ShopItemReadModel { diff --git a/internal/services/order_service/internal/shared/app/test/test_app.go b/internal/services/order_service/internal/shared/app/test/test_app.go index 2550d6c5..9b7bd7f0 100644 --- a/internal/services/order_service/internal/shared/app/test/test_app.go +++ b/internal/services/order_service/internal/shared/app/test/test_app.go @@ -9,13 +9,6 @@ import ( "github.com/EventStore/EventStore-Client-Go/esdb" "go.mongodb.org/mongo-driver/mongo" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/eventstoredb" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/config" - ordersService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/repositories" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/aggregate" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/configurations/orders" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/contracts/store" config4 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/eventstroredb/config" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" @@ -25,7 +18,13 @@ import ( "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mongodb" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/bus" config2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/config" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/eventstoredb" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/containers/testcontainer/rabbitmq" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/config" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/repositories" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/aggregate" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/configurations/orders" + ordersService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) type TestApp struct{} diff --git a/internal/services/order_service/internal/orders/contracts/proto/service_clients/orders_service_client.pb.go b/internal/services/order_service/internal/shared/grpc/genproto/orders.pb.go similarity index 55% rename from internal/services/order_service/internal/orders/contracts/proto/service_clients/orders_service_client.pb.go rename to internal/services/order_service/internal/shared/grpc/genproto/orders.pb.go index 827c9516..abccd5c3 100644 --- a/internal/services/order_service/internal/orders/contracts/proto/service_clients/orders_service_client.pb.go +++ b/internal/services/order_service/internal/shared/grpc/genproto/orders.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.0 -// protoc v3.20.1 -// source: api_docs/orders/protobuf/orders/service_clients/orders.proto +// protoc-gen-go v1.26.0 +// protoc v4.23.4 +// source: order_service/orders.proto package orders_service @@ -35,7 +35,7 @@ type ShopItem struct { func (x *ShopItem) Reset() { *x = ShopItem{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[0] + mi := &file_order_service_orders_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -48,7 +48,7 @@ func (x *ShopItem) String() string { func (*ShopItem) ProtoMessage() {} func (x *ShopItem) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[0] + mi := &file_order_service_orders_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -61,7 +61,7 @@ func (x *ShopItem) ProtoReflect() protoreflect.Message { // Deprecated: Use ShopItem.ProtoReflect.Descriptor instead. func (*ShopItem) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{0} + return file_order_service_orders_proto_rawDescGZIP(), []int{0} } func (x *ShopItem) GetTitle() string { @@ -97,7 +97,7 @@ type Order struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OrderId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` + OrderId string `protobuf:"bytes,1,opt,name=OrderId,proto3" json:"OrderId,omitempty"` ShopItems []*ShopItem `protobuf:"bytes,2,rep,name=ShopItems,proto3" json:"ShopItems,omitempty"` Paid bool `protobuf:"varint,3,opt,name=Paid,proto3" json:"Paid,omitempty"` Submitted bool `protobuf:"varint,4,opt,name=Submitted,proto3" json:"Submitted,omitempty"` @@ -116,7 +116,7 @@ type Order struct { func (x *Order) Reset() { *x = Order{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[1] + mi := &file_order_service_orders_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -129,7 +129,7 @@ func (x *Order) String() string { func (*Order) ProtoMessage() {} func (x *Order) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[1] + mi := &file_order_service_orders_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -142,7 +142,7 @@ func (x *Order) ProtoReflect() protoreflect.Message { // Deprecated: Use Order.ProtoReflect.Descriptor instead. func (*Order) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{1} + return file_order_service_orders_proto_rawDescGZIP(), []int{1} } func (x *Order) GetOrderId() string { @@ -249,7 +249,7 @@ type OrderReadModel struct { unknownFields protoimpl.UnknownFields Id string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` - OrderId string `protobuf:"bytes,2,opt,name=Id,proto3" json:"Id,omitempty"` + OrderId string `protobuf:"bytes,2,opt,name=OrderId,proto3" json:"OrderId,omitempty"` ShopItems []*ShopItemReadModel `protobuf:"bytes,3,rep,name=ShopItems,proto3" json:"ShopItems,omitempty"` Paid bool `protobuf:"varint,4,opt,name=Paid,proto3" json:"Paid,omitempty"` Submitted bool `protobuf:"varint,5,opt,name=Submitted,proto3" json:"Submitted,omitempty"` @@ -268,7 +268,7 @@ type OrderReadModel struct { func (x *OrderReadModel) Reset() { *x = OrderReadModel{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[2] + mi := &file_order_service_orders_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -281,7 +281,7 @@ func (x *OrderReadModel) String() string { func (*OrderReadModel) ProtoMessage() {} func (x *OrderReadModel) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[2] + mi := &file_order_service_orders_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -294,7 +294,7 @@ func (x *OrderReadModel) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderReadModel.ProtoReflect.Descriptor instead. func (*OrderReadModel) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{2} + return file_order_service_orders_proto_rawDescGZIP(), []int{2} } func (x *OrderReadModel) GetId() string { @@ -416,7 +416,7 @@ type ShopItemReadModel struct { func (x *ShopItemReadModel) Reset() { *x = ShopItemReadModel{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[3] + mi := &file_order_service_orders_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -429,7 +429,7 @@ func (x *ShopItemReadModel) String() string { func (*ShopItemReadModel) ProtoMessage() {} func (x *ShopItemReadModel) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[3] + mi := &file_order_service_orders_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -442,7 +442,7 @@ func (x *ShopItemReadModel) ProtoReflect() protoreflect.Message { // Deprecated: Use ShopItemReadModel.ProtoReflect.Descriptor instead. func (*ShopItemReadModel) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{3} + return file_order_service_orders_proto_rawDescGZIP(), []int{3} } func (x *ShopItemReadModel) GetTitle() string { @@ -487,7 +487,7 @@ type CreateOrderReq struct { func (x *CreateOrderReq) Reset() { *x = CreateOrderReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[4] + mi := &file_order_service_orders_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -500,7 +500,7 @@ func (x *CreateOrderReq) String() string { func (*CreateOrderReq) ProtoMessage() {} func (x *CreateOrderReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[4] + mi := &file_order_service_orders_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -513,7 +513,7 @@ func (x *CreateOrderReq) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateOrderReq.ProtoReflect.Descriptor instead. func (*CreateOrderReq) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{4} + return file_order_service_orders_proto_rawDescGZIP(), []int{4} } func (x *CreateOrderReq) GetAccountEmail() string { @@ -549,13 +549,13 @@ type CreateOrderRes struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OrderId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` + OrderId string `protobuf:"bytes,1,opt,name=OrderId,proto3" json:"OrderId,omitempty"` } func (x *CreateOrderRes) Reset() { *x = CreateOrderRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[5] + mi := &file_order_service_orders_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -568,7 +568,7 @@ func (x *CreateOrderRes) String() string { func (*CreateOrderRes) ProtoMessage() {} func (x *CreateOrderRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[5] + mi := &file_order_service_orders_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -581,7 +581,7 @@ func (x *CreateOrderRes) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateOrderRes.ProtoReflect.Descriptor instead. func (*CreateOrderRes) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{5} + return file_order_service_orders_proto_rawDescGZIP(), []int{5} } func (x *CreateOrderRes) GetOrderId() string { @@ -596,13 +596,13 @@ type SubmitOrderReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OrderId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` + OrderId string `protobuf:"bytes,1,opt,name=OrderId,proto3" json:"OrderId,omitempty"` } func (x *SubmitOrderReq) Reset() { *x = SubmitOrderReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[6] + mi := &file_order_service_orders_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -615,7 +615,7 @@ func (x *SubmitOrderReq) String() string { func (*SubmitOrderReq) ProtoMessage() {} func (x *SubmitOrderReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[6] + mi := &file_order_service_orders_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -628,7 +628,7 @@ func (x *SubmitOrderReq) ProtoReflect() protoreflect.Message { // Deprecated: Use SubmitOrderReq.ProtoReflect.Descriptor instead. func (*SubmitOrderReq) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{6} + return file_order_service_orders_proto_rawDescGZIP(), []int{6} } func (x *SubmitOrderReq) GetOrderId() string { @@ -643,13 +643,13 @@ type SubmitOrderRes struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OrderId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` + OrderId string `protobuf:"bytes,1,opt,name=OrderId,proto3" json:"OrderId,omitempty"` } func (x *SubmitOrderRes) Reset() { *x = SubmitOrderRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[7] + mi := &file_order_service_orders_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -662,7 +662,7 @@ func (x *SubmitOrderRes) String() string { func (*SubmitOrderRes) ProtoMessage() {} func (x *SubmitOrderRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[7] + mi := &file_order_service_orders_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -675,7 +675,7 @@ func (x *SubmitOrderRes) ProtoReflect() protoreflect.Message { // Deprecated: Use SubmitOrderRes.ProtoReflect.Descriptor instead. func (*SubmitOrderRes) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{7} + return file_order_service_orders_proto_rawDescGZIP(), []int{7} } func (x *SubmitOrderRes) GetOrderId() string { @@ -696,7 +696,7 @@ type GetOrderByIDReq struct { func (x *GetOrderByIDReq) Reset() { *x = GetOrderByIDReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[8] + mi := &file_order_service_orders_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -709,7 +709,7 @@ func (x *GetOrderByIDReq) String() string { func (*GetOrderByIDReq) ProtoMessage() {} func (x *GetOrderByIDReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[8] + mi := &file_order_service_orders_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -722,7 +722,7 @@ func (x *GetOrderByIDReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOrderByIDReq.ProtoReflect.Descriptor instead. func (*GetOrderByIDReq) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{8} + return file_order_service_orders_proto_rawDescGZIP(), []int{8} } func (x *GetOrderByIDReq) GetId() string { @@ -743,7 +743,7 @@ type GetOrderByIDRes struct { func (x *GetOrderByIDRes) Reset() { *x = GetOrderByIDRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[9] + mi := &file_order_service_orders_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -756,7 +756,7 @@ func (x *GetOrderByIDRes) String() string { func (*GetOrderByIDRes) ProtoMessage() {} func (x *GetOrderByIDRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[9] + mi := &file_order_service_orders_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -769,7 +769,7 @@ func (x *GetOrderByIDRes) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOrderByIDRes.ProtoReflect.Descriptor instead. func (*GetOrderByIDRes) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{9} + return file_order_service_orders_proto_rawDescGZIP(), []int{9} } func (x *GetOrderByIDRes) GetOrder() *OrderReadModel { @@ -784,14 +784,14 @@ type UpdateShoppingCartReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - OrderId string `protobuf:"bytes,1,opt,name=Id,proto3" json:"Id,omitempty"` + OrderId string `protobuf:"bytes,1,opt,name=OrderId,proto3" json:"OrderId,omitempty"` ShopItems []*ShopItem `protobuf:"bytes,2,rep,name=ShopItems,proto3" json:"ShopItems,omitempty"` } func (x *UpdateShoppingCartReq) Reset() { *x = UpdateShoppingCartReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[10] + mi := &file_order_service_orders_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -804,7 +804,7 @@ func (x *UpdateShoppingCartReq) String() string { func (*UpdateShoppingCartReq) ProtoMessage() {} func (x *UpdateShoppingCartReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[10] + mi := &file_order_service_orders_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -817,7 +817,7 @@ func (x *UpdateShoppingCartReq) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateShoppingCartReq.ProtoReflect.Descriptor instead. func (*UpdateShoppingCartReq) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{10} + return file_order_service_orders_proto_rawDescGZIP(), []int{10} } func (x *UpdateShoppingCartReq) GetOrderId() string { @@ -843,7 +843,7 @@ type UpdateShoppingCartRes struct { func (x *UpdateShoppingCartRes) Reset() { *x = UpdateShoppingCartRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[11] + mi := &file_order_service_orders_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -856,7 +856,7 @@ func (x *UpdateShoppingCartRes) String() string { func (*UpdateShoppingCartRes) ProtoMessage() {} func (x *UpdateShoppingCartRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[11] + mi := &file_order_service_orders_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -869,7 +869,7 @@ func (x *UpdateShoppingCartRes) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateShoppingCartRes.ProtoReflect.Descriptor instead. func (*UpdateShoppingCartRes) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{11} + return file_order_service_orders_proto_rawDescGZIP(), []int{11} } type GetOrdersReq struct { @@ -885,7 +885,7 @@ type GetOrdersReq struct { func (x *GetOrdersReq) Reset() { *x = GetOrdersReq{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[12] + mi := &file_order_service_orders_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -898,7 +898,7 @@ func (x *GetOrdersReq) String() string { func (*GetOrdersReq) ProtoMessage() {} func (x *GetOrdersReq) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[12] + mi := &file_order_service_orders_proto_msgTypes[12] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -911,7 +911,7 @@ func (x *GetOrdersReq) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOrdersReq.ProtoReflect.Descriptor instead. func (*GetOrdersReq) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{12} + return file_order_service_orders_proto_rawDescGZIP(), []int{12} } func (x *GetOrdersReq) GetSearchText() string { @@ -947,7 +947,7 @@ type GetOrdersRes struct { func (x *GetOrdersRes) Reset() { *x = GetOrdersRes{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[13] + mi := &file_order_service_orders_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -960,7 +960,7 @@ func (x *GetOrdersRes) String() string { func (*GetOrdersRes) ProtoMessage() {} func (x *GetOrdersRes) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[13] + mi := &file_order_service_orders_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -973,7 +973,7 @@ func (x *GetOrdersRes) ProtoReflect() protoreflect.Message { // Deprecated: Use GetOrdersRes.ProtoReflect.Descriptor instead. func (*GetOrdersRes) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{13} + return file_order_service_orders_proto_rawDescGZIP(), []int{13} } func (x *GetOrdersRes) GetPagination() *Pagination { @@ -1005,7 +1005,7 @@ type Pagination struct { func (x *Pagination) Reset() { *x = Pagination{} if protoimpl.UnsafeEnabled { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[14] + mi := &file_order_service_orders_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1018,7 +1018,7 @@ func (x *Pagination) String() string { func (*Pagination) ProtoMessage() {} func (x *Pagination) ProtoReflect() protoreflect.Message { - mi := &file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[14] + mi := &file_order_service_orders_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1031,7 +1031,7 @@ func (x *Pagination) ProtoReflect() protoreflect.Message { // Deprecated: Use Pagination.ProtoReflect.Descriptor instead. func (*Pagination) Descriptor() ([]byte, []int) { - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP(), []int{14} + return file_order_service_orders_proto_rawDescGZIP(), []int{14} } func (x *Pagination) GetTotalItems() int64 { @@ -1069,209 +1069,206 @@ func (x *Pagination) GetHasMore() bool { return false } -var File_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto protoreflect.FileDescriptor - -var file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDesc = []byte{ - 0x0a, 0x4b, 0x61, 0x70, 0x69, 0x5f, 0x64, 0x6f, 0x63, 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, - 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x73, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x1f, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, - 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, - 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, - 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, - 0x72, 0x69, 0x63, 0x65, 0x22, 0xab, 0x04, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x18, - 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, - 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x6f, - 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x50, 0x61, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, - 0x50, 0x61, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65, - 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, - 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, - 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, - 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x01, - 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, - 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x44, - 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x40, - 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x38, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0c, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, - 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x22, 0xcd, 0x04, 0x0a, 0x0e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, - 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, - 0x3f, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x61, 0x64, - 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x50, 0x61, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, - 0x50, 0x61, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, - 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, - 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, - 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, - 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, - 0x12, 0x22, 0x0a, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x44, - 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x40, - 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x38, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0d, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, - 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x49, 0x64, 0x22, 0x7d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, - 0x61, 0x64, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, - 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x50, - 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x22, 0xd6, 0x01, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, - 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x41, 0x63, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x36, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, - 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x6f, - 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, - 0x12, 0x28, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, - 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x0c, 0x44, 0x65, - 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x44, 0x65, - 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x2a, 0x0a, 0x0e, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, - 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, - 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, - 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, - 0x49, 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, - 0x72, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x21, - 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, 0x52, 0x65, - 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, - 0x64, 0x22, 0x47, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, - 0x44, 0x52, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4d, 0x6f, - 0x64, 0x65, 0x6c, 0x52, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x69, 0x0a, 0x15, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, - 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x36, 0x0a, - 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x18, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, - 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x17, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, - 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x22, 0x56, - 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x12, 0x1e, - 0x0a, 0x0a, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x65, 0x78, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x50, 0x61, - 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x82, 0x01, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4f, 0x72, - 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x50, 0x61, 0x67, 0x69, 0x6e, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6f, 0x72, - 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4d, 0x6f, - 0x64, 0x65, 0x6c, 0x52, 0x06, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x22, 0x8e, 0x01, 0x0a, 0x0a, - 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, - 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, - 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, - 0x74, 0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, - 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x61, - 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x69, - 0x7a, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x48, 0x61, 0x73, 0x4d, 0x6f, 0x72, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x48, 0x61, 0x73, 0x4d, 0x6f, 0x72, 0x65, 0x32, 0xac, 0x03, 0x0a, - 0x0d, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, - 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1e, 0x2e, - 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, - 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x4d, 0x0a, - 0x0b, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x75, - 0x62, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6f, - 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x75, - 0x62, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x62, 0x0a, 0x12, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, - 0x72, 0x74, 0x12, 0x25, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, - 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x25, 0x2e, 0x6f, 0x72, 0x64, 0x65, - 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, - 0x12, 0x50, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, - 0x12, 0x1f, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, +var File_order_service_orders_proto protoreflect.FileDescriptor + +var file_order_service_orders_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, + 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x1f, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, + 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, + 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, + 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, + 0x69, 0x63, 0x65, 0x22, 0xab, 0x04, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x18, 0x0a, + 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x6f, 0x70, + 0x49, 0x74, 0x65, 0x6d, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x50, 0x61, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x50, + 0x61, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x01, 0x52, + 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, + 0x22, 0x0a, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, + 0x73, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x44, 0x65, + 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x40, 0x0a, + 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x38, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x22, 0xcd, 0x04, 0x0a, 0x0e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4d, + 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x3f, + 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x21, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x61, 0x64, 0x4d, + 0x6f, 0x64, 0x65, 0x6c, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, + 0x12, 0x0a, 0x04, 0x50, 0x61, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x50, + 0x61, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x74, 0x65, + 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x12, + 0x1a, 0x0a, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x08, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x01, 0x52, + 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x41, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, + 0x22, 0x0a, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x52, 0x65, 0x61, + 0x73, 0x6f, 0x6e, 0x12, 0x28, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x44, 0x65, + 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x40, 0x0a, + 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x0d, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, + 0x38, 0x0a, 0x09, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0d, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x64, 0x41, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, + 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, + 0x64, 0x22, 0x7d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x61, + 0x64, 0x4d, 0x6f, 0x64, 0x65, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, + 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, + 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x72, + 0x69, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x50, 0x72, 0x69, 0x63, 0x65, + 0x22, 0xd6, 0x01, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x12, 0x22, 0x0a, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6d, + 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x36, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x68, 0x6f, 0x70, + 0x49, 0x74, 0x65, 0x6d, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, + 0x28, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x44, 0x65, 0x6c, 0x69, 0x76, 0x65, + 0x72, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3e, 0x0a, 0x0c, 0x44, 0x65, 0x6c, + 0x69, 0x76, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0c, 0x44, 0x65, 0x6c, + 0x69, 0x76, 0x65, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x2a, 0x0a, 0x0e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4f, + 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, + 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x4f, + 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, + 0x64, 0x22, 0x2a, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, + 0x52, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x21, 0x0a, + 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, 0x52, 0x65, 0x71, + 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x64, + 0x22, 0x47, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, + 0x52, 0x65, 0x73, 0x12, 0x34, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4d, 0x6f, 0x64, + 0x65, 0x6c, 0x52, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x69, 0x0a, 0x15, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, + 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x12, 0x36, 0x0a, 0x09, + 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x18, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x09, 0x53, 0x68, 0x6f, 0x70, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x22, 0x17, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x68, + 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x22, 0x56, 0x0a, + 0x0c, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, + 0x0a, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x54, 0x65, 0x78, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x50, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x50, 0x61, 0x67, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x04, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x82, 0x01, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x50, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x06, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4d, 0x6f, 0x64, + 0x65, 0x6c, 0x52, 0x06, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x22, 0x8e, 0x01, 0x0a, 0x0a, 0x50, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, + 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, + 0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x50, 0x61, 0x67, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x69, 0x7a, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x48, 0x61, 0x73, 0x4d, 0x6f, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x48, 0x61, 0x73, 0x4d, 0x6f, 0x72, 0x65, 0x32, 0xac, 0x03, 0x0a, 0x0d, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4d, 0x0a, + 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x6f, + 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6f, + 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0b, + 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x1e, 0x2e, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, + 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6f, 0x72, + 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x53, 0x75, 0x62, + 0x6d, 0x69, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x12, 0x62, 0x0a, 0x12, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, + 0x74, 0x12, 0x25, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x25, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x53, 0x68, 0x6f, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x12, + 0x50, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, 0x12, + 0x1f, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, 0x52, 0x65, 0x71, + 0x1a, 0x1f, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, 0x52, 0x65, - 0x71, 0x1a, 0x1f, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x42, 0x79, 0x49, 0x44, 0x52, - 0x65, 0x73, 0x12, 0x47, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x12, - 0x1c, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, - 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, - 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x42, 0x13, 0x5a, 0x11, 0x2e, - 0x2f, 0x3b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x12, 0x47, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x12, 0x1c, + 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, + 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x6f, + 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x47, 0x65, + 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x42, 0x13, 0x5a, 0x11, 0x2e, 0x2f, + 0x3b, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescOnce sync.Once - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescData = file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDesc + file_order_service_orders_proto_rawDescOnce sync.Once + file_order_service_orders_proto_rawDescData = file_order_service_orders_proto_rawDesc ) -func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescGZIP() []byte { - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescOnce.Do(func() { - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescData) +func file_order_service_orders_proto_rawDescGZIP() []byte { + file_order_service_orders_proto_rawDescOnce.Do(func() { + file_order_service_orders_proto_rawDescData = protoimpl.X.CompressGZIP(file_order_service_orders_proto_rawDescData) }) - return file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDescData + return file_order_service_orders_proto_rawDescData } -var file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes = make([]protoimpl.MessageInfo, 15) -var file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_goTypes = []interface{}{ +var file_order_service_orders_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_order_service_orders_proto_goTypes = []interface{}{ (*ShopItem)(nil), // 0: orders_service.ShopItem (*Order)(nil), // 1: orders_service.Order (*OrderReadModel)(nil), // 2: orders_service.OrderReadModel @@ -1289,7 +1286,7 @@ var file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_p (*Pagination)(nil), // 14: orders_service.Pagination (*timestamppb.Timestamp)(nil), // 15: google.protobuf.Timestamp } -var file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_depIdxs = []int32{ +var file_order_service_orders_proto_depIdxs = []int32{ 0, // 0: orders_service.Order.ShopItems:type_name -> orders_service.ShopItem 15, // 1: orders_service.Order.DeliveredTime:type_name -> google.protobuf.Timestamp 15, // 2: orders_service.Order.CreatedAt:type_name -> google.protobuf.Timestamp @@ -1321,13 +1318,13 @@ var file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_p 0, // [0:14] is the sub-list for field type_name } -func init() { file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_init() } -func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_init() { - if File_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto != nil { +func init() { file_order_service_orders_proto_init() } +func file_order_service_orders_proto_init() { + if File_order_service_orders_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ShopItem); i { case 0: return &v.state @@ -1339,7 +1336,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Order); i { case 0: return &v.state @@ -1351,7 +1348,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*OrderReadModel); i { case 0: return &v.state @@ -1363,7 +1360,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ShopItemReadModel); i { case 0: return &v.state @@ -1375,7 +1372,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CreateOrderReq); i { case 0: return &v.state @@ -1387,7 +1384,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CreateOrderRes); i { case 0: return &v.state @@ -1399,7 +1396,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SubmitOrderReq); i { case 0: return &v.state @@ -1411,7 +1408,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SubmitOrderRes); i { case 0: return &v.state @@ -1423,7 +1420,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetOrderByIDReq); i { case 0: return &v.state @@ -1435,7 +1432,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetOrderByIDRes); i { case 0: return &v.state @@ -1447,7 +1444,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateShoppingCartReq); i { case 0: return &v.state @@ -1459,7 +1456,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UpdateShoppingCartRes); i { case 0: return &v.state @@ -1471,7 +1468,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetOrdersReq); i { case 0: return &v.state @@ -1483,7 +1480,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetOrdersRes); i { case 0: return &v.state @@ -1495,7 +1492,7 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ return nil } } - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_order_service_orders_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Pagination); i { case 0: return &v.state @@ -1512,18 +1509,18 @@ func file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_ out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDesc, + RawDescriptor: file_order_service_orders_proto_rawDesc, NumEnums: 0, NumMessages: 15, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_goTypes, - DependencyIndexes: file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_depIdxs, - MessageInfos: file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_msgTypes, + GoTypes: file_order_service_orders_proto_goTypes, + DependencyIndexes: file_order_service_orders_proto_depIdxs, + MessageInfos: file_order_service_orders_proto_msgTypes, }.Build() - File_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto = out.File - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_rawDesc = nil - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_goTypes = nil - file_api_docs_orders_protobuf_orders_service_clients_orders_service_client_proto_depIdxs = nil + File_order_service_orders_proto = out.File + file_order_service_orders_proto_rawDesc = nil + file_order_service_orders_proto_goTypes = nil + file_order_service_orders_proto_depIdxs = nil } diff --git a/internal/services/order_service/internal/orders/contracts/proto/service_clients/orders_service_client_grpc.pb.go b/internal/services/order_service/internal/shared/grpc/genproto/orders_grpc.pb.go similarity index 86% rename from internal/services/order_service/internal/orders/contracts/proto/service_clients/orders_service_client_grpc.pb.go rename to internal/services/order_service/internal/shared/grpc/genproto/orders_grpc.pb.go index 2c28b386..6f5be25d 100644 --- a/internal/services/order_service/internal/orders/contracts/proto/service_clients/orders_service_client_grpc.pb.go +++ b/internal/services/order_service/internal/shared/grpc/genproto/orders_grpc.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.20.1 -// source: api_docs/orders/protobuf/orders/service_clients/orders.proto +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.4 +// source: order_service/orders.proto package orders_service @@ -18,6 +18,14 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + OrdersService_CreateOrder_FullMethodName = "/orders_service.OrdersService/CreateOrder" + OrdersService_SubmitOrder_FullMethodName = "/orders_service.OrdersService/SubmitOrder" + OrdersService_UpdateShoppingCart_FullMethodName = "/orders_service.OrdersService/UpdateShoppingCart" + OrdersService_GetOrderByID_FullMethodName = "/orders_service.OrdersService/GetOrderByID" + OrdersService_GetOrders_FullMethodName = "/orders_service.OrdersService/GetOrders" +) + // OrdersServiceClient is the client API for OrdersService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -39,7 +47,7 @@ func NewOrdersServiceClient(cc grpc.ClientConnInterface) OrdersServiceClient { func (c *ordersServiceClient) CreateOrder(ctx context.Context, in *CreateOrderReq, opts ...grpc.CallOption) (*CreateOrderRes, error) { out := new(CreateOrderRes) - err := c.cc.Invoke(ctx, "/orders_service.OrdersService/CreateOrder", in, out, opts...) + err := c.cc.Invoke(ctx, OrdersService_CreateOrder_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -48,7 +56,7 @@ func (c *ordersServiceClient) CreateOrder(ctx context.Context, in *CreateOrderRe func (c *ordersServiceClient) SubmitOrder(ctx context.Context, in *SubmitOrderReq, opts ...grpc.CallOption) (*SubmitOrderRes, error) { out := new(SubmitOrderRes) - err := c.cc.Invoke(ctx, "/orders_service.OrdersService/SubmitOrder", in, out, opts...) + err := c.cc.Invoke(ctx, OrdersService_SubmitOrder_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -57,7 +65,7 @@ func (c *ordersServiceClient) SubmitOrder(ctx context.Context, in *SubmitOrderRe func (c *ordersServiceClient) UpdateShoppingCart(ctx context.Context, in *UpdateShoppingCartReq, opts ...grpc.CallOption) (*UpdateShoppingCartRes, error) { out := new(UpdateShoppingCartRes) - err := c.cc.Invoke(ctx, "/orders_service.OrdersService/UpdateShoppingCart", in, out, opts...) + err := c.cc.Invoke(ctx, OrdersService_UpdateShoppingCart_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -66,7 +74,7 @@ func (c *ordersServiceClient) UpdateShoppingCart(ctx context.Context, in *Update func (c *ordersServiceClient) GetOrderByID(ctx context.Context, in *GetOrderByIDReq, opts ...grpc.CallOption) (*GetOrderByIDRes, error) { out := new(GetOrderByIDRes) - err := c.cc.Invoke(ctx, "/orders_service.OrdersService/GetOrderByID", in, out, opts...) + err := c.cc.Invoke(ctx, OrdersService_GetOrderByID_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -75,7 +83,7 @@ func (c *ordersServiceClient) GetOrderByID(ctx context.Context, in *GetOrderByID func (c *ordersServiceClient) GetOrders(ctx context.Context, in *GetOrdersReq, opts ...grpc.CallOption) (*GetOrdersRes, error) { out := new(GetOrdersRes) - err := c.cc.Invoke(ctx, "/orders_service.OrdersService/GetOrders", in, out, opts...) + err := c.cc.Invoke(ctx, OrdersService_GetOrders_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -134,7 +142,7 @@ func _OrdersService_CreateOrder_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/orders_service.OrdersService/CreateOrder", + FullMethod: OrdersService_CreateOrder_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OrdersServiceServer).CreateOrder(ctx, req.(*CreateOrderReq)) @@ -152,7 +160,7 @@ func _OrdersService_SubmitOrder_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/orders_service.OrdersService/SubmitOrder", + FullMethod: OrdersService_SubmitOrder_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OrdersServiceServer).SubmitOrder(ctx, req.(*SubmitOrderReq)) @@ -170,7 +178,7 @@ func _OrdersService_UpdateShoppingCart_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/orders_service.OrdersService/UpdateShoppingCart", + FullMethod: OrdersService_UpdateShoppingCart_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OrdersServiceServer).UpdateShoppingCart(ctx, req.(*UpdateShoppingCartReq)) @@ -188,7 +196,7 @@ func _OrdersService_GetOrderByID_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/orders_service.OrdersService/GetOrderByID", + FullMethod: OrdersService_GetOrderByID_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OrdersServiceServer).GetOrderByID(ctx, req.(*GetOrderByIDReq)) @@ -206,7 +214,7 @@ func _OrdersService_GetOrders_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/orders_service.OrdersService/GetOrders", + FullMethod: OrdersService_GetOrders_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(OrdersServiceServer).GetOrders(ctx, req.(*GetOrdersReq)) @@ -243,5 +251,5 @@ var OrdersService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "api_docs/orders/protobuf/orders/service_clients/orders.proto", + Metadata: "order_service/orders.proto", } diff --git a/internal/services/order_service/internal/orders/grpc/order_grpc_service_server.go b/internal/services/order_service/internal/shared/grpc/order_grpc_service_server.go similarity index 98% rename from internal/services/order_service/internal/orders/grpc/order_grpc_service_server.go rename to internal/services/order_service/internal/shared/grpc/order_grpc_service_server.go index f193c03e..6021a952 100644 --- a/internal/services/order_service/internal/orders/grpc/order_grpc_service_server.go +++ b/internal/services/order_service/internal/shared/grpc/order_grpc_service_server.go @@ -12,16 +12,13 @@ import ( api "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/trace" - dtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/dtos/v1" - customErrors "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/http/http_errors/custom_errors" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mapper" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing" attribute2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/otel/tracing/attribute" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" - - grpcOrderService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" + dtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/dtos/v1" createOrderCommandV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/features/creating_order/v1/commands" createOrderDtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/features/creating_order/v1/dtos" getOrderByIdDtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/features/getting_order_by_id/v1/dtos" @@ -29,6 +26,7 @@ import ( getOrdersDtosV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/features/getting_orders/v1/dtos" getOrdersQueryV1 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/features/getting_orders/v1/queries" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/contracts" + grpcOrderService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) type OrderGrpcServiceServer struct { diff --git a/internal/services/order_service/internal/orders/grpc/order_grpc_service_server_test.go b/internal/services/order_service/internal/shared/grpc/order_grpc_service_server_test.go similarity index 99% rename from internal/services/order_service/internal/orders/grpc/order_grpc_service_server_test.go rename to internal/services/order_service/internal/shared/grpc/order_grpc_service_server_test.go index 315a1baf..811fac4c 100644 --- a/internal/services/order_service/internal/orders/grpc/order_grpc_service_server_test.go +++ b/internal/services/order_service/internal/shared/grpc/order_grpc_service_server_test.go @@ -11,7 +11,7 @@ package grpc // "google.golang.org/protobuf/types/known/timestamppb" // // testUtils "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/test/utils" -// ordersService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" +// ordersService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto" // "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/test_fixtures/e2e" //) // diff --git a/internal/services/order_service/internal/shared/test_fixtures/integration/integration_test_fixture.go b/internal/services/order_service/internal/shared/test_fixtures/integration/integration_test_fixture.go index 92d04554..ab9bdf6f 100644 --- a/internal/services/order_service/internal/shared/test_fixtures/integration/integration_test_fixture.go +++ b/internal/services/order_service/internal/shared/test_fixtures/integration/integration_test_fixture.go @@ -12,23 +12,22 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/contracts/store" config3 "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/eventstroredb/config" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/bus" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mongodb" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/config" "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/utils" config2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/config" - ordersService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/repositories" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/mocks/testData" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/aggregate" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/models/orders/read_models" "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/app/test" contracts2 "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/contracts" - - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/es/contracts/store" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/fxapp/contracts" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/logger" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/messaging/bus" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/mongodb" - "github.com/mehdihadeli/go-ecommerce-microservices/internal/pkg/rabbitmq/config" + ordersService "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) const ( diff --git a/internal/services/order_service/mocks/OrdersServiceClient.go b/internal/services/order_service/mocks/OrdersServiceClient.go index ebd64b77..1cbde85b 100644 --- a/internal/services/order_service/mocks/OrdersServiceClient.go +++ b/internal/services/order_service/mocks/OrdersServiceClient.go @@ -9,7 +9,7 @@ import ( mock "github.com/stretchr/testify/mock" - orders_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" + "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) // OrdersServiceClient is an autogenerated mock type for the OrdersServiceClient type diff --git a/internal/services/order_service/mocks/OrdersServiceServer.go b/internal/services/order_service/mocks/OrdersServiceServer.go index 0d605402..77db8195 100644 --- a/internal/services/order_service/mocks/OrdersServiceServer.go +++ b/internal/services/order_service/mocks/OrdersServiceServer.go @@ -5,8 +5,9 @@ package mocks import ( context "context" - orders_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/orders/contracts/proto/service_clients" mock "github.com/stretchr/testify/mock" + + orders_service "github.com/mehdihadeli/go-ecommerce-microservices/internal/services/orderservice/internal/shared/grpc/genproto" ) // OrdersServiceServer is an autogenerated mock type for the OrdersServiceServer type diff --git a/internal/services/order_service/test/end_to_end/orders/features/creating_order/v1/create_order_test.go b/internal/services/order_service/test/end_to_end/orders/features/creating_order/v1/create_order_test.go index 5f853849..6c639ef9 100644 --- a/internal/services/order_service/test/end_to_end/orders/features/creating_order/v1/create_order_test.go +++ b/internal/services/order_service/test/end_to_end/orders/features/creating_order/v1/create_order_test.go @@ -1,7 +1,9 @@ +//go:build e2e +// +build e2e + package v1 import ( - "context" "net/http" "testing" "time" @@ -49,7 +51,6 @@ func (c *createOrderE2ETest) Test_Should_Return_Created_Status_With_Valid_Input( expect.POST("orders"). WithJSON(request). - WithContext(context.Background()). Expect(). Status(http.StatusCreated) } diff --git a/internal/services/order_service/test/end_to_end/orders/features/getting_order_by_id/v1/get_order_by_id_test.go b/internal/services/order_service/test/end_to_end/orders/features/getting_order_by_id/v1/get_order_by_id_test.go index d5897b63..9ac3f329 100644 --- a/internal/services/order_service/test/end_to_end/orders/features/getting_order_by_id/v1/get_order_by_id_test.go +++ b/internal/services/order_service/test/end_to_end/orders/features/getting_order_by_id/v1/get_order_by_id_test.go @@ -1,3 +1,6 @@ +//go:build e2e +// +build e2e + package v1 import ( diff --git a/internal/services/order_service/test/integration/orders/features/getting_order_by_id/v1/get_order_by_id_test.go b/internal/services/order_service/test/integration/orders/features/getting_order_by_id/v1/get_order_by_id_test.go index abe6a93f..a417b1bd 100644 --- a/internal/services/order_service/test/integration/orders/features/getting_order_by_id/v1/get_order_by_id_test.go +++ b/internal/services/order_service/test/integration/orders/features/getting_order_by_id/v1/get_order_by_id_test.go @@ -1,3 +1,6 @@ +//go:build integration +// +build integration + package v1 import ( diff --git a/scripts/.gitkeep b/scripts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/build-docker.sh b/scripts/build-docker.sh index 980fe871..3a705bfc 100644 --- a/scripts/build-docker.sh +++ b/scripts/build-docker.sh @@ -1,6 +1,10 @@ #!/bin/bash + +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). +set -e + readonly service="$1" readonly project_name="$2" docker build -t "gcr.io/$project_name/$service" "./internal" -f "./docker/app-prod/Dockerfile" --build-arg "SERVICE=$service" -docker push "gcr.io/$project_name/$service" \ No newline at end of file +docker push "gcr.io/$project_name/$service" diff --git a/scripts/build.sh b/scripts/build.sh index ea2539ec..5f192b5b 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,15 +1,16 @@ #!/bin/bash +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" +echo "start building $service" + if [ "$service" = "pkg" ]; then - cd "./internal/pkg" - go build ./... + cd "./internal/pkg" && go build ./... # Check if input is not empty or null elif [ -n "$service" ]; then - cd "./internal/services/$service" - make build + cd "./internal/services/$service" && go build ./... fi diff --git a/scripts/format.sh b/scripts/format.sh index b2a8623d..a60437da 100644 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -1,7 +1,9 @@ #!/bin/bash -#https://blog.devgenius.io/sort-go-imports-acb76224dfa7 +# ref: https://blog.devgenius.io/sort-go-imports-acb76224dfa7 +# https://yolken.net/blog/cleaner-go-code-golines +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" @@ -19,12 +21,13 @@ gofumpt -l -w . # https://golang.org/cmd/gofmt/ # gofmt -w . -# https://github.com/incu6us/goimports-reviser -goimports-reviser -rm-unused -set-alias -format -recursive ./... - # # https://pkg.go.dev/golang.org/x/tools/cmd/goimports # goimports . -l -w +# https://github.com/incu6us/goimports-reviser +# will do `gofmt` and `goimports` internally +goimports-reviser -rm-unused -set-alias -format -recursive ./... + # https://github.com/segmentio/golines golines . -m 120 -w --ignore-generated diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh new file mode 100644 index 00000000..d66f86e9 --- /dev/null +++ b/scripts/install-dependencies.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). +set -e + +readonly service="$1" + +# https://www.reddit.com/r/golang/comments/x722i0/go_install_vs_go_mod_tidy_vs_go_get/ +if [ "$service" = "pkg" ]; then + cd "./internal/pkg" && go mod download && go mod tidy +# Check if input is not empty or null +elif [ -n "$service" ]; then + cd "./internal/services/$service" && go mod download && go mod tidy +fi + + + diff --git a/scripts/install-tools.sh b/scripts/install-tools.sh index fb489fc8..800d845a 100644 --- a/scripts/install-tools.sh +++ b/scripts/install-tools.sh @@ -1,5 +1,8 @@ #!/bin/bash +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). +set -e + # `go install package@version` command works directly when we specified exact version, elsewhere it needs a `go.mod` and specifying corresponding version for each package # https://github.com/incu6us/goimports-reviser @@ -19,8 +22,10 @@ go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest go install google.golang.org/protobuf/proto@latest -# https://community.chocolatey.org/packages/protoc +# https://dev.to/techschoolguru/how-to-define-a-protobuf-message-and-generate-go-code-4g4e +# https://stackoverflow.com/questions/13616033/install-protocol-buffers-on-windows go install github.com/golang/protobuf/protoc-gen-go@latest +go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest # https://github.com/swaggo/swag/ # https://github.com/swaggo/swag/issues/817 @@ -55,6 +60,9 @@ if [[ "$OS" == "Linux" ]]; then echo "deb [signed-by=/usr/share/keyrings/k6-archive-keyring.gpg] https://dl.k6.io/deb stable main" | sudo tee /etc/apt/sources.list.d/k6.list sudo apt-get update sudo apt-get install k6 + + # https://grpc.io/docs/protoc-installation/ + apt install -y protobuf-compiler elif [[ "$OS" == "MINGW"* || "$OS" == "MSYS"* ]]; then # https://github.com/bufbuild/buf echo "Installing Buff on Windows..." @@ -67,6 +75,10 @@ elif [[ "$OS" == "MINGW"* || "$OS" == "MSYS"* ]]; then # https://k6.io/docs/get-started/installation/ echo "Installing k6 on Windows..." winget install k6 + + # https://community.chocolatey.org/packages/protoc + # https://grpc.io/docs/protoc-installation/ + choco install protoc else echo "Unsupported operating system: $OS" exit 1 diff --git a/scripts/k6-generator.sh b/scripts/k6-generator.sh index f7495f8d..4213aa02 100644 --- a/scripts/k6-generator.sh +++ b/scripts/k6-generator.sh @@ -3,6 +3,7 @@ # https://craftbakery.dev/testing-rest-api-using-k6/ # https://k6.io/blog/load-testing-your-api-with-swagger-openapi-and-k6/ +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" diff --git a/scripts/lint.sh b/scripts/lint.sh index 2878d036..12298257 100644 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,4 +1,8 @@ #!/bin/bash + +# ref: https://freshman.tech/linting-golang/ + +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" diff --git a/scripts/openapi.sh b/scripts/openapi.sh index e566da2d..db4cc6ba 100644 --- a/scripts/openapi.sh +++ b/scripts/openapi.sh @@ -1,4 +1,6 @@ #!/bin/bash + +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" diff --git a/scripts/proto.sh b/scripts/proto.sh index c73b6aed..60f8e258 100644 --- a/scripts/proto.sh +++ b/scripts/proto.sh @@ -1,10 +1,15 @@ #!/bin/bash + +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" +readonly outPath="./internal/services/$service/internal/shared/grpc/genproto" +# https://stackoverflow.com/questions/13616033/install-protocol-buffers-on-windows +# https://dev.to/techschoolguru/how-to-define-a-protobuf-message-and-generate-go-code-4g4e protoc \ - --proto_path=api/protobuf "api/proto/$service.proto" \ - "--go_out=internal/services/$service/proto/service_clients/" --go_opt=paths=source_relative \ - --go-grpc_opt=require_unimplemented_servers=false \ - "--go-grpc_out=internal/services/$service/proto/service_clients/" --go-grpc_opt=paths=source_relativ + --proto_path=api/protobuf "api/protobuf/$service/*.proto" \ + "--go_out=$outPath" \ + "--go-grpc_out=$outPath" \ + --go-grpc_opt=require_unimplemented_servers=false diff --git a/scripts/run.sh b/scripts/run.sh index 15d97d70..2e360b8e 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -1,9 +1,10 @@ #!/bin/bash +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). set -e readonly service="$1" -cd "./internal/services/$service" +cd "./internal/services/$service" && go run "./cmd/app/main.go" + -make run diff --git a/scripts/test.sh b/scripts/test.sh index c568a420..7f8789bd 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,8 +1,10 @@ #!/bin/bash -set -e # https://blog.devgenius.io/go-golang-testing-tools-tips-to-step-up-your-game-4ed165a5b3b5 +# In a bash script, set -e is a command that enables the "exit immediately" option. When this option is set, the script will terminate immediately if any command within the script exits with a non-zero status (indicating an error). +set -e + readonly service="$1" readonly type="$2" @@ -16,7 +18,7 @@ if [ "$type" = "load-test" ]; then # go run ./cmd/app/main.go k6 run ./load_tests/script.js --insecure-skip-tls-verify else - go test -tags="$type" -count=1 -p=8 -parallel=8 -race ./... + go test -tags="$type" -count=1 -p=1 -parallel=1 ./... fi diff --git a/taskfile.yml b/taskfile.yml index ed72a03d..fd4323d2 100644 --- a/taskfile.yml +++ b/taskfile.yml @@ -1,3 +1,114 @@ #https://taskfile.dev/#/installation +#https://github.com/go-task/task/issues/1115 +version: '3' -version: "3" +tasks: + install-tools: + desc: Install necessary tools + cmds: + - sh ./scripts/install-tools.sh + + run-catalogs-write-service: + desc: Run catalog write service + cmds: + - sh ./scripts/run.sh catalog_write_service + + run-catalog-read-service: + desc: Run catalog read service + cmds: + - sh ./scripts/run.sh catalog_read_service + + run-order-service: + desc: Run order service + cmds: + - sh ./scripts/run.sh order_service + + build: + desc: Build project components + cmds: + - sh ./scripts/build.sh pkg + - sh ./scripts/build.sh catalog_write_service + - sh ./scripts/build.sh catalog_read_service + - sh ./scripts/build.sh order_service + + install-dependencies: + desc: Install project dependencies + cmds: + - sh ./scripts/install-dependencies.sh pkg + - sh ./scripts/install-dependencies.sh catalog_write_service + - sh ./scripts/install-dependencies.sh catalog_read_service + - sh ./scripts/install-dependencies.sh order_service + + docker-compose-infra-up: + desc: Start infrastructure using docker-compose + cmds: + - docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml up --build -d + + docker-compose-infra-down: + desc: Stop infrastructure using docker-compose + cmds: + - docker-compose -f deployments/docker-compose/docker-compose.infrastructure.yaml down + + openapi: + desc: Generate OpenAPI documentation + cmds: + - sh ./scripts/openapi.sh catalog_write_service + - sh ./scripts/openapi.sh catalog_read_service + - sh ./scripts/openapi.sh order_service + + proto: + desc: Generate protobuf files + cmds: + - sh ./scripts/proto.sh catalog_write_service + - sh ./scripts/proto.sh order_service + + unit-test: + desc: Run unit tests + cmds: + - sh ./scripts/test.sh catalog_write_service unit + - sh ./scripts/test.sh catalog_read_service unit + - sh ./scripts/test.sh order_service unit + + integration-test: + desc: Run integration tests + cmds: + - sh ./scripts/test.sh catalog_write_service integration + - sh ./scripts/test.sh catalog_read_service integration + - sh ./scripts/test.sh order_service integration + + e2e-test: + desc: Run end-to-end tests + cmds: + - sh ./scripts/test.sh catalog_write_service e2e + - sh ./scripts/test.sh catalog_read_service e2e + - sh ./scripts/test.sh order_service e2e + + format: + desc: Format codebase + cmds: + - sh ./scripts/format.sh catalog_write_service + - sh ./scripts/format.sh catalog_read_service + - sh ./scripts/format.sh order_service + - sh ./scripts/format.sh pkg + + lint: + desc: Run linters + cmds: + - sh ./scripts/lint.sh catalog_write_service + - sh ./scripts/lint.sh catalog_read_service + - sh ./scripts/lint.sh order_service + - sh ./scripts/lint.sh pkg + + pkg-mocks: + desc: Generate package mocks + cmds: + - cd internal/pkg/messaging && mockery --output mocks --all + - cd internal/pkg/es && mockery --output mocks --all + - cd internal/pkg/core && mockery --output mocks --all + + services-mocks: + desc: Generate service mocks + cmds: + - cd internal/services/catalog_write_service && mockery --output mocks --all + - cd internal/services/catalog_read_service && mockery --output mocks --all + - cd internal/services/order_service && mockery --output mocks --all diff --git a/taskfile_test.yml b/taskfile_test.yml deleted file mode 100644 index 38b68088..00000000 --- a/taskfile_test.yml +++ /dev/null @@ -1,33 +0,0 @@ -#https://taskfile.dev/#/installation - -version: "3" - -tasks: - pkg-mock: - desc: Generate pkg interfaces mocks - cmds: - - cd internal/pkg/messaging && mockery --output mocks --all - - cd internal/pkg/es && mockery --output mocks --all - - cd internal/pkg/core && mockery --output mocks --all - - services-mock: - desc: Generate services interfaces mocks - cmds: - - cd internal/services/catalogs_write && mockery --output mocks --all - - cd internal/services/catalogs_read && mockery --output mocks --all - - cd internal/services/orders && mockery --output mocks --all - - integration: - desc: Run integration tests - cmds: - - go test -v -tags=integration ./... - - e2e: - desc: Run integration tests - cmds: - - go test -v -tags=e2e ./... - - unit: - desc: Run unit tests - cmds: - - go test -v -tags=unit ./...