P0-8: идемпотентность телеметрии (dedup по message_id)
Envelope получил MessageID (UUID); таблица iot_telemetry — столбец message_id + UNIQUE(device_id,message_id); батч-INSERT ON CONFLICT DO NOTHING. Дубли при at-least-once повторе из SQS больше не вставляются. Пустой message_id → NULL (без ложного дедупа).
This commit is contained in:
@@ -160,7 +160,7 @@ func processSQSTelemetry(ctx context.Context, body string, store *iotpg.IoTPostg
|
||||
return err
|
||||
}
|
||||
|
||||
if err := store.InsertTelemetry(ctx, envelope.Namespace, envelope.DeviceID, envelope.Payload); err != nil {
|
||||
if err := store.InsertTelemetry(ctx, envelope.Namespace, envelope.DeviceID, "", envelope.Payload); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user