Skip to content

Homework 3#2

Merged
async-human merged 3 commits intomainfrom
homework-3
Jan 21, 2026
Merged

Homework 3#2
async-human merged 3 commits intomainfrom
homework-3

Conversation

@async-human
Copy link
Copy Markdown
Owner

No description provided.

Replaces in-memory order storage with PostgreSQL for the Order service.
This change introduces a robust and persistent data layer, enabling
reliable order management.

Key changes include:
- Integration of `pgxpool` for efficient database connection pooling.
- Implementation of `goose` for managing database schema migrations.
- Addition of `docker-compose` configurations for core services,
  Inventory (MongoDB), and Order (PostgreSQL) within a shared network.
- Updated `OrderRepository` interface and concrete implementation
  to use `pgxpool.Pool` for database operations (Get, Save).
- Modification of the `Order` repository model to include `db` tags,
  `created_at`, `updated_at` timestamps, and nullable fields
  (`transaction_uuid`, `payment_method`).
- Introduction of a `.env` file for environment-specific database
  credentials and `Taskfile` commands (`up-all`, `down-all`, etc.)
  for simplified environment setup and teardown.
- Updates to service logic and API error handling to reflect
  the new persistence layer.
This introduces MongoDB as the primary data store for the inventory service.
The previous in-memory repository has been replaced with a MongoDB-backed
implementation, allowing for persistent storage of inventory parts.

Key changes include:
- New MongoDB repository with CRUD operations and initial data generation.
- MongoDB connection details are now loaded from the `.env` file.
- The `docker-compose.yml` for inventory service is updated to use the
  `MONGO_PORT` environment variable.
- Added dependencies for `godotenv` and `go.mongodb.org/mongo-driver`.
Refactors the order service's data persistence layer to support multiple
repository implementations.
- Moves PostgreSQL-specific repository logic from `order/internal/repository/order`
  to `order/internal/repository/postgres`.
- Encapsulates database migration within the `postgres` package's initialization.
- Adds a new `order/internal/repository/inmemory` package providing a simple
  in-memory data store for orders.
- Updates `main.go` to leverage the new `postgres.NewRepository` function,
  allowing for easier swapping of persistence backends.
This change improves modularity and enables easier testing with different data
storage mechanisms.
@async-human async-human merged commit 0a37e97 into main Jan 21, 2026
4 checks passed
@async-human async-human deleted the homework-3 branch January 21, 2026 19:12
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