A small service builds a notification summary for a user and stores it. It currently has two failures: an error while reading the incoming request can be lost, and the success build counter can be updated before the write actually completes.
NotificationService::build_and_store method must:
&self and RequestId;Result<StoredSummary, ServiceError>;success_count only after a successful write to Storage;Err, not an empty summary.Storage may fail; in that case the service state must not change.title header read returns an error.Storage::save fails after the summary has been built.Ok, and when writing fails, the success counter must not increase.success_count property changes only after the write is confirmed.request_id and the number of notifications.thiserror = 2.0.11, parking_lot = 0.12.3Use line comments to explain the problem, its impact, the fix and how to test it.