Async recognition pipeline:
- POST /ai/recognize-dish → 202 {job_id, queue_position, estimated_seconds}
- GET /ai/jobs/{id}/stream — SSE stream: queued → processing → done/failed
- Kafka topics: ai.recognize.paid (3 partitions) + ai.recognize.free (1 partition)
- 5-worker WorkerPool with priority loop (paid consumers first)
- SSEBroker via PostgreSQL LISTEN/NOTIFY
- Kafka adapter migrated from franz-go to Watermill (watermill-kafka/v2)
- Docker Compose: added Kafka + Zookeeper + kafka-init service
- Flutter: recognition_service.dart uses SSE; home_screen shows live job status
Remove google/wire (archived):
- Deleted wire.go (wireinject spec) and wire_gen.go
- Added cmd/server/init.go — plain Go manual DI, same initApp() logic
- Removed github.com/google/wire from go.mod
Consolidate migrations:
- Merged 001_initial_schema + 002_seed_data + 003_recognition_jobs into single 001_initial_schema.sql
- Deleted 002_seed_data.sql and 003_recognition_jobs.sql
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
716 B
Go
38 lines
716 B
Go
package recognition
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/food-ai/backend/internal/adapters/ai"
|
|
)
|
|
|
|
// Job status constants.
|
|
const (
|
|
JobStatusPending = "pending"
|
|
JobStatusProcessing = "processing"
|
|
JobStatusDone = "done"
|
|
JobStatusFailed = "failed"
|
|
)
|
|
|
|
// Kafka topic names.
|
|
const (
|
|
TopicPaid = "ai.recognize.paid"
|
|
TopicFree = "ai.recognize.free"
|
|
)
|
|
|
|
// Job represents an async dish recognition task stored in recognition_jobs.
|
|
type Job struct {
|
|
ID string
|
|
UserID string
|
|
UserPlan string
|
|
ImageBase64 string
|
|
MimeType string
|
|
Lang string
|
|
Status string
|
|
Result *ai.DishResult
|
|
Error *string
|
|
CreatedAt time.Time
|
|
StartedAt *time.Time
|
|
CompletedAt *time.Time
|
|
}
|