Skip to content

Homework 2#1

Merged
async-human merged 10 commits intomainfrom
homework-2
Jan 19, 2026
Merged

Homework 2#1
async-human merged 10 commits intomainfrom
homework-2

Conversation

@async-human
Copy link
Copy Markdown
Owner

No description provided.

The inventory service's implementation has been refactored to follow a layered architecture. This change introduces distinct API, service, and repository layers for improved modularity, maintainability, and scalability.

The previous monolithic InventoryServer and InventoryStorage components have been replaced by dedicated modules for gRPC API handling, business logic, and data access, along with appropriate model and converter packages.
Introduces initial API definitions for the payment service under `payment/internal/api/payment/v1`.
Refactors internal 'order' related components within the inventory service
to 'inventory' to improve semantic consistency and align with the service's domain.
Moved payment processing logic from `cmd/main.go` to a dedicated
`internal/service` layer. Introduced `internal/api` layer to handle
gRPC requests and delegate to the service. Added `internal/model`
for domain-specific data structures and `internal/converter` for
mapping requests to internal models.

This change improves separation of concerns, enhances maintainability,
and provides a clear structure for future feature development.
Restructures the order service into distinct API, Service, Repository, and Client layers. This change improves modularity, testability, and maintainability by separating concerns:

- API layer (`internal/api`): Handles HTTP request/response mapping.
- Service layer (`internal/service`): Contains core business logic for order operations.
- Repository layer (`internal/repository`): Manages data persistence (currently in-memory).
- Client layer (`internal/client`): Abstracts external gRPC service calls (Inventory, Payment).

This refactoring enhances the service's internal structure and prepares it for future feature development and scalability.
Integrated the `mockery` tool for automatic generation of Go interface mocks.
Added `Taskfile` commands (`mockery:install`, `mockery:gen`) to manage
and generate mocks, and `test-coverage`/`coverage:html` for code coverage.
Implemented unit tests for the `payment` service and API layers,
utilizing generated mocks for isolated testing. This enhances testability
and code quality for the payment module.
The `OrderService` interface in the `inventory` module was renamed to `InventoryService` for improved domain alignment and clarity. Corresponding updates were made in `inventory/internal/api/inventory/v1/api.go` to use the new interface.

Comprehensive unit tests were added for the `GetPart` and `ListParts` methods in both the `inventory` service and API layers, significantly increasing test coverage.

Mockery configuration (`.mockery.yaml`) was updated to include the new service and repository paths, leading to the generation of new mocks for `InventoryService` and `OrderRepository`.

The `payorder_test.go` in the `payment` service was refactored to remove mock-based assertions and instead verify the actual output of the `PayOrder` method, improving test quality.
Added extensive unit tests for the order microservice's API handlers and service layer logic.
Refactored client interfaces (`PaymentClient`, `InventoryClient`) and the `order` service constructor to enhance testability through dependency injection.
Updated `.mockery.yaml` configuration and generated new mocks for `OrderService`, `OrderRepository`, `PaymentClient`, and `InventoryClient`.
Includes a minor fix in `order/internal/service/order/get.go` to correctly handle order not found scenarios.
Introduces a new GitHub Actions CI workflow to streamline linting.
- A new script `.github/scripts/extract-versions.sh` is added to parse
  `Taskfile.yml` and extract essential tool versions (e.g., Go,
  golangci-lint) and module paths. These are then exported as GitHub
  Actions environment and output variables.
- The main `.github/workflows/ci.yml` workflow orchestrates this version
  extraction.
- A new reusable workflow, `.github/workflows/lint-reusable.yml`, is
  introduced to perform Go linting using the versions and module paths
  extracted in the previous step.

This setup centralizes tool version management within `Taskfile.yml` and
enhances the reusability of CI steps.
This configuration sets up golangci-lint with a comprehensive set of
linters for Go projects. It ensures code quality, style consistency,
and security best practices.

Key aspects include:
- Linters for error handling, static analysis, code style, security,
  and performance.
- Specific exclusions for test files.
- Custom rules for gosec, cyclop, depguard, revive, and forbidigo.
- Integration of gofumpt and gci for code formatting.
Updated Go to 1.25 and golangci-lint to its latest version.
Adjusted the golangci-lint command for proper module linting.
Introduced local module replacement for 'pkg' in go.mod files across
all services (inventory, order, payment).
Performed widespread code formatting, import reordering, and ensured
consistent trailing newlines.
Enhanced gRPC client connection error handling in the order service.
Simplified variable declarations in test files and standardized
error message casing.
@async-human async-human merged commit b1c9ed4 into main Jan 19, 2026
3 checks passed
@async-human async-human deleted the homework-2 branch January 19, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant