Overview
| Comment: | make token return error on failure, be sync, add docs (by CodeRabbit) |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
b23050a4ea6ef11c03f608b1b6dff049 |
| User & Date: | arcade on 2026-01-06 12:17:43.829 |
| Other Links: | manifest | tags |
Context
|
2026-01-06
| ||
| 13:06 | change default rust toolchain action check-in: e9d3c3d224 user: arcade tags: trunk | |
| 12:17 | make token return error on failure, be sync, add docs (by CodeRabbit) check-in: b23050a4ea user: arcade tags: trunk | |
| 09:32 | add README check-in: e4165e1e85 user: arcade tags: trunk | |
Changes
Modified src/core.rs
from [a596b3f681]
to [f3c7f4ade2].
| ︙ | |||
63 64 65 66 67 68 69 | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | + + + + + + + + + + + + + + - + - - - + + - - - - - - - - + + + + + + + + - + + + + |
// This one does nothing except making sure only one token exists for each id
pub struct Token {
running: Arc<Mutex<HashSet<i32>>>,
my_id: i32,
}
impl Token {
/// Attempts to acquire a per-id token by inserting `my_id` into the shared `running` set.
///
/// If the id was not already present, the function inserts it and returns `Some(Token)`.
/// When the returned `Token` is dropped, the id will be removed from the `running` set,
/// allowing subsequent acquisitions for the same id.
///
/// # Parameters
///
/// - `running`: Shared set tracking active ids.
/// - `my_id`: Identifier to acquire a token for.
///
/// # Returns
///
/// `Ok(Token)` if the id was successfully acquired, `Error` if a token for the id is already active.
|
| ︙ | |||
164 165 166 167 168 169 170 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | - + - - - |
).await.stack()
}
pub async fn check (&self, id: i32, real: bool, last_scrape: Option<DateTime<Local>>) -> Result<String> {
let mut posted: i32 = 0;
let mut conn = self.db.begin().await.stack()?;
|
| ︙ |