feat: checkout retry + idempotency key (v14)

Abierto
#21 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
42/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
dart, flutter

Línea de trabajo

Start with backend/bin/server.dart and the checkout cubit and service tests described in the issue. Reproduce the lost-response case with the fake service and FlightServer().handler, then trace how checkout sends requests and records orders. Done when retries with the same key replay the original booking reference, cart changes produce a new key, and the listed cubit, service, and backend tests pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

Checkout'ta ağ koparsa sunucu siparişi oluşturur ama istemci hata görür. Kullanıcı retry'a basınca ikinci sipariş yaratılır (çift rezervasyon). Bugün backend/bin/server.dart siparişi 1 sn'lik delay'den önce kaydediyor ve idempotency desteği yok.

Hedef (v14: Checkout retry + idempotency key)

Aynı ödeme niyeti kaç kez denenirse denensin tek sipariş oluşsun.

Kapsam (IN)

  • Önce repro: başarısız cubit testi (fake servis: ilk çağrı hata, ikinci başarı) + in-process backend testi (FlightServer().handler) ile 2 sipariş gösterimi. Demo için backend'de X-Simulate-Drop: after-commit anahtarı. Uygulama koduna debug header eklenmez, sunucu tarafında env var / flag / POST /debug/drop-next ile açılır.
  • Key, uygulama genelindeki CartCubit içinde tutulur. CartState Equatable olduğu için lazy set emit'te düşer, bu yüzden state dışında private alan + String ensureCheckoutKey(). add / removeAt / restore / clear ile sıfırlanır. Random.secure() ile 128-bit hex, uuid paketi yok.
  • IProductNetworkManager.sendRequest için Map<String, String>? headers (Options(headers:)). IFlightService.checkout için idempotencyKey → Idempotency-Key header'ı.
  • Backend: key → orderId haritası orders.add anında yazılır (delay'den önce), tekrarda 200 + Idempotent-Replayed: true ve ilk bookingReference. Sadece commit edilmiş siparişler saklanır. CORS allowHeaders içine Idempotency-Key.
  • Testler: cubit (error→retry aynı key; ikinci CartCheckoutCubit aynı CartCubit ile aynı key; başarı veya sepet değişiminde yeni key; replay aynı referansı gösterir; clear() yalnızca onaylı başarıdan sonra), servis unit testi (fake network manager header'ı yakalar), backend (aynı key iki kez = 1 sipariş).
  • docs/video/v14_*.md (v12 stilinde) + README satırı.

Kapsam dışı

Otomatik retry/backoff (sonraki bölümün teaser'ı), 409 in-flight, key'i ICacheManager ile kalıcı yapma (bilinen sınırlama, sepet de bellekte), TTL, 422 body-mismatch testi (tek cümle anlatılır).

Lenguaje dominante
Dart
Estrellas
32
Forks
5
Merge medio
1 d 8 h
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de VB10/flight_booking

Todos los issues de VB10/flight_booking

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.