A small service collects text notifications for participants and sends them through an abstract AlertSender. After a recent PR, the behavior changed: some invalid input data no longer stops the operation, and the service state is updated even when sending ends in an error.
send_batch method accepts a list of member_ids and for each identifier must:
Directory::member_name;alert:{id}:{name};AlertSender::send_all in a single call.send_all.sent_batches counter in the shared state must increase only after a successful send.Notifier::send_batch after the PR changes.Directory::member_name(2) returns an error:
send_batch(&[1, 2, 3]) must fail;AlertSender::send_all must not be called.AlertSender::send_all returns an error:
send_batch(&[1]) must return the send error;sent_batches must not increase after the failed send.MutexGuard while preparing data and while calling send_all.Mutex<State> is used only for short access to the counter, not held for the entire operation lifecycle.1.85.02021AlertSender::send_all may be slow or may return an error, so its call is considered an external operationUse line comments to explain the problem, its impact, the fix and how to test it.