Skip to content

Conversation

@ymoldabe
Copy link

Добавил учебный проект wheres-my-pizza ­— трёх­сервисное Go-приложение, построенное на RabbitMQ + PostgreSQL с шаблоном «Transactional Outbox / Inbox». Цель - показать, как реализовать надёжную event-driven цепочку Order Placed => Kitchen => Delivery с ретраями, DLQ и идемпотентной обработкой.

Comment on lines 204 to 212
## Guidelines from Author

1. Tests first. Spin up PostgreSQL + RabbitMQ with Testcontainers-go and create unit/contract/e2e tests that should fail until each step is implemented.
2. Implement database schema and outbox publisher.
3. Wire minimal consumer in `kitchen`; emit `Boxed`.
4. Add `delivery` with payment simulation.
5. Introduce retry exchange & DLQ.
6. Write e2e tests with **Testcontainers-go**.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-check что нужно использовать что нет

Comment on lines 5 to 11
- Event-driven architecture
- RabbitMQ: work-queue, fan-out, dead-letter / retry queues, manual **ACK/NACK + QoS**
- Exchange types & routing keys
- Transactional Outbox pattern (**events** table) + PostgreSQL
- Idempotent message processing (Inbox tables)
- Docker-Compose orchestration
- Unit, contract & end-to-end testing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком много

Comment on lines 17 to 21
Build **wheres-my-pizza**, a three-service Go application that tracks a pizza order from placement to delivery.
All inter-service communication happens through RabbitMQ events—**no synchronous HTTP**.
A single transactional outbox keeps the DB and broker consistent; consumers stay idempotent via inbox tables.
The public REST API is **read-only** and lets clients query order status and full event history.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Слишком сложно, многие понятие студенту не открыты, твоя цель провести студента по образовательному пути, а не дать пощечину и почувствовать себя глупым

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может в optional добавить? чего много/сложно.

Comment on lines 19 to 20
> you can’t polish your way out of bad architecture
>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> you can’t polish your way out of bad architecture
>
> You can’t polish your way out of bad architecture.


**Work Queue Pattern**
- One producer sends tasks to a queue
- Multiple consumers compete to receive tasks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Multiple consumers compete to receive tasks
- Multiple consumers wait for the task to arrive, but only one receives it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Таблицы, сделай как в в техдизайне. Каждый сервис должен иметь свою таблицу
  • Формат логов
  • Нарисовать в виде ASCII схему взаимодейсвтия

Comment on lines 103 to 106
## Database Schema

### Orders Table

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не хватает описания каждой таблицы, для чего где используется

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В таблицах используй простой text, а не varchar

Comment on lines 142 to 149
create table order_status_log (
"id" uuid primary key default gen_random_uuid(),
"created_at" timestamptz not null default now(),
order_id varchar(20) references orders(id),
"status" varchar(20),
"changed_by" varchar(50),
"changed_at" timestamp default current_timestamp,
"notes" text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order_id без кавычек

Comment on lines 167 to 188
## RabbitMQ Configuration

### Exchanges and Queues Setup

```
Exchanges:
├── orders_direct (type: direct, durable: true)
│ └── Routing Keys:
│ ├── kitchen.dine-in
│ ├── kitchen.takeout
│ └── kitchen.delivery
└── notifications_fanout (type: fanout, durable: true)
└── Broadcasts to all subscribers

Queues:
├── kitchen_queue (durable: true, x-max-priority: 10)
├── kitchen_dine_in_queue (durable: true, x-max-priority: 10)
├── kitchen_takeout_queue (durable: true, x-max-priority: 10)
├── kitchen_delivery_queue (durable: true, x-max-priority: 10)
└── notifications_queue (durable: true, auto-delete: false)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо объяснить, даже мне непонятно. Нужно раскрыть в чем отличие fanout от direct

Comment on lines 190 to 223
### Message Formats

**Order Message**
```json
{
"order_number": "ORD_20241216_001",
"customer_name": "John Doe",
"customer_type": "vip",
"order_type": "delivery",
"table_number": null,
"delivery_address": "123 Main St, City",
"items": [
{
"name": "Margherita Pizza",
"quantity": 1,
"price": 15.99
}
],
"total_amount": 15.99,
"priority": 10
}
```

**Status Update Message**
```json
{
"order_number": "ORD_20241216_001",
"old_status": "received",
"new_status": "cooking",
"changed_by": "chef_mario",
"timestamp": "2024-12-16T10:32:00Z",
"estimated_completion": "2024-12-16T10:42:00Z"
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Описать что за message, куда падает, кто читает

Comment on lines 254 to 259
**Required Log Events:**
- Order received/processed/completed
- Worker connected/disconnected
- Status changes
- Error conditions and recoveries
- Performance metrics (processing times)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Где какой уровень использовать

Comment on lines 304 to 316
#### Order Processing Flow:

1. Order Service receives HTTP POST request
2. Validates request data and calculates totals
3. Stores order in PostgreSQL orders table
4. Publishes order message to RabbitMQ
5. Kitchen Worker consumes order from queue
6. Updates order status to 'cooking' in database
7. Simulates cooking process (configurable duration)
8. Updates order status to 'ready' in database
9. Logs completion and acknowledges message

Outcomes:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не хватает консистенси: #### Order Processing Flow: и Orders:
Надо использовать хеши

Comment on lines 304 to 314
#### Order Processing Flow:

1. Order Service receives HTTP POST request
2. Validates request data and calculates totals
3. Stores order in PostgreSQL orders table
4. Publishes order message to RabbitMQ
5. Kitchen Worker consumes order from queue
6. Updates order status to 'cooking' in database
7. Simulates cooking process (configurable duration)
8. Updates order status to 'ready' in database
9. Logs completion and acknowledges message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если бы ты делал этот проект, ты бы много уточнял у Аяжан. А как валидировать, как высчитывать. Не хватает деталей

Comment on lines 342 to 344
# Initialize database and queues
$ ./restaurant-system --setup-db --db="postgres://user:password@localhost/restaurant"
$ ./restaurant-system --setup-queues --rabbitmq="localhost:5672"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Где он хранит эти конфигурации?

Copy link
Contributor

@atlekbai atlekbai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Раздели задачи по фичам, чтобы в каждом задании были описаны элементы только одной части микросервиса: форматы сообщений, запросы, логи, флаги, примеры
  • Добавь диаграммы, контекст и описание и этого маркдауна

complete_wheres_my_pizza.md

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.

3 participants