feat: checkout retry + idempotency key (v14)

Aperta
#21 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
dart, flutter

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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).

Lingua principale
Dart
Stelle
32
Fork
5
Merge medio
1g 8h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di VB10/flight_booking

Tutte le issue di VB10/flight_booking

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.