📝 refine async failure helper docs

This commit is contained in:
Nanaloveyuki
2026-06-14 00:45:31 +08:00
parent 911dcd840c
commit 5ce4c29760
3 changed files with 21 additions and 6 deletions
+7 -2
View File
@@ -2,8 +2,8 @@
name: async-logger-has-failed
group: api
category: async
update-time: 20260512
description: Read whether the async logger worker has encountered a failure during queue drain.
update-time: 20260614
description: Read whether the async logger worker has recorded a runtime failure after run() startup reset and drain execution.
key-word:
- async
- logger
@@ -34,6 +34,7 @@ pub fn[S] AsyncLogger::has_failed(self : AsyncLogger[S]) -> Bool {}
Detailed rules explaining key parameters and behaviors
- `run()` clears previous failure state at startup.
- `run()` also clears the stored `last_error()` string at startup before drain work begins.
- If the worker loop raises an error, the logger records that failure and exposes it through this flag.
- This helper is intentionally compact and should usually be paired with `last_error()` for details.
- Failure state is about runtime drain execution, not whether records were dropped due to overflow policy.
@@ -67,6 +68,8 @@ In this example, the helper exposes a simple pass-fail runtime indicator.
e.g.:
- If `has_failed()` is `false`, queue pressure or dropped records may still exist for non-failure reasons.
- If `has_failed()` becomes `true`, `wait_idle()` may stop early while pending records still remain until a later close or clear path handles them.
- If `has_failed()` is `true`, callers should inspect `last_error()` or `state()` for more context.
### Notes
@@ -74,3 +77,5 @@ e.g.:
1. This helper reports worker failure, not general queue stress.
2. Pair it with `last_error()` when you need actionable detail.
3. Pair it with `is_running()` or `state()` when you also need to know whether the worker has already exited and whether backlog remains.