| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | | use crate::events::{hook_topics, LiveBus}; |
| 28 | | use crate::live::{RoomEvent, RoomKey}; |
| 29 | | use crate::Shared; |
| 30 | | use hub_api::ProposalEvent; |
| 31 | | use tokio::sync::broadcast; |
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
| 36 | | pub enum Topic { |
| 37 | | |
| 38 | | Deliveries, |
| 39 | | |
| 40 | | Proposals, |
| 41 | | |
| 42 | | |
| 43 | | Live, |
| 44 | | |
| 45 | | Rooms, |
| 46 | | } |
| 47 | |
|
| 48 | | impl Topic { |
| 49 | | pub const ALL: [Topic; 4] = [Topic::Deliveries, Topic::Proposals, Topic::Live, Topic::Rooms]; |
| 50 | |
|
| 51 | 10× | pub fn name(self) -> &'static str { |
| 52 | 10× | match self { |
| 53 | 1× | Topic::Deliveries => "deliveries", |
| 54 | 1× | Topic::Proposals => "proposals", |
| 55 | 6× | Topic::Live => "live", |
| 56 | 2× | Topic::Rooms => "rooms", |
| 57 | | } |
| 58 | 10× | } |
| 59 | |
|
| 60 | | |
| 61 | 820× | fn capacity(self) -> usize { |
| 62 | 820× | match self { |
| 63 | 205× | Topic::Deliveries => 16, |
| 64 | 410× | Topic::Proposals | Topic::Rooms => 256, |
| 65 | 205× | Topic::Live => 1024, |
| 66 | | } |
| 67 | 820× | } |
| 68 | | } |
| 69 | |
|
| 70 | |
|
| 71 | | #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] |
| 72 | | #[serde(tag = "t", rename_all = "snake_case")] |
| 73 | | pub enum Event { |
| 74 | | |
| 75 | | DeliveryWaiting, |
| 76 | | |
| 77 | | |
| 78 | | Proposal { repo: i64, event: ProposalEvent }, |
| 79 | | |
| 80 | | |
| 81 | | Live { topic: String, kind: String }, |
| 82 | | |
| 83 | | Room { room: RoomKey, event: RoomEvent }, |
| 84 | | } |
| 85 | |
|
| 86 | | impl Event { |
| 87 | 2255× | pub fn topic(&self) -> Topic { |
| 88 | 2255× | match self { |
| 89 | 22× | Event::DeliveryWaiting => Topic::Deliveries, |
| 90 | 726× | Event::Proposal { .. } => Topic::Proposals, |
| 91 | 1502× | Event::Live { .. } => Topic::Live, |
| 92 | 5× | Event::Room { .. } => Topic::Rooms, |
| 93 | | } |
| 94 | 2255× | } |
| 95 | | } |
| 96 | |
|
| 97 | |
|
| 98 | | pub struct Bus { |
| 99 | | |
| 100 | | |
| 101 | | #[cfg_attr(not(feature = "postgres"), allow(dead_code))] |
| 102 | | origin: String, |
| 103 | | |
| 104 | | channels: Vec<broadcast::Sender<Event>>, |
| 105 | | |
| 106 | | |
| 107 | | pub live: LiveBus, |
| 108 | | #[cfg(feature = "postgres")] |
| 109 | | remote: pg::Remote, |
| 110 | | } |
| 111 | |
|
| 112 | | impl Default for Bus { |
| 113 | 205× | fn default() -> Self { |
| 114 | | Bus { |
| 115 | 205× | origin: crate::auth::random_hex(8), |
| 116 | 820× | channels: Topic::ALL.iter().map(|t| broadcast::channel(t.capacity()).0).collect(), |
| 117 | 205× | live: LiveBus::default(), |
| 118 | | #[cfg(feature = "postgres")] |
| 119 | | remote: pg::Remote::default(), |
| 120 | | } |
| 121 | 205× | } |
| 122 | | } |
| 123 | |
|
| 124 | | impl Bus { |
| 125 | | |
| 126 | | |
| 127 | 2255× | pub fn publish(&self, event: Event) { |
| 128 | | #[cfg(feature = "postgres")] |
| 129 | | self.remote.send(&self.origin, &event); |
| 130 | 2255× | self.deliver(event); |
| 131 | 2255× | } |
| 132 | |
|
| 133 | | |
| 134 | | |
| 135 | 407× | pub fn subscribe(&self, topic: Topic) -> broadcast::Receiver<Event> { |
| 136 | 407× | self.channels[Self::index(topic)].subscribe() |
| 137 | 407× | } |
| 138 | |
|
| 139 | | |
| 140 | 1502× | pub fn live(&self, topic: &str, kind: &str) { |
| 141 | 1502× | self.publish(Event::Live { topic: topic.to_string(), kind: kind.to_string() }); |
| 142 | 1502× | } |
| 143 | |
|
| 144 | | |
| 145 | | |
| 146 | 1118× | pub fn hook(&self, repo_id: i64, event: &str, data: &serde_json::Value) { |
| 147 | 1225× | for (topic, kind) in hook_topics(repo_id, event, data) { |
| 148 | 1225× | self.live(&topic, &kind); |
| 149 | 1225× | } |
| 150 | 1118× | } |
| 151 | |
|
| 152 | | |
| 153 | 22× | pub fn delivery_waiting(&self) { |
| 154 | 22× | self.publish(Event::DeliveryWaiting); |
| 155 | 22× | } |
| 156 | |
|
| 157 | | |
| 158 | 726× | pub fn proposal(&self, repo_id: i64, event: ProposalEvent) { |
| 159 | 726× | self.publish(Event::Proposal { repo: repo_id, event }); |
| 160 | 726× | } |
| 161 | |
|
| 162 | | |
| 163 | | |
| 164 | 2255× | fn deliver(&self, event: Event) { |
| 165 | 2255× | if let Event::Live { topic, kind } = &event { |
| 166 | 1502× | self.live.publish(topic, kind); |
| 167 | 1502× | } |
| 168 | 2255× | let _ = self.channels[Self::index(event.topic())].send(event); |
| 169 | 2255× | } |
| 170 | |
|
| 171 | 2662× | fn index(topic: Topic) -> usize { |
| 172 | 6813× | Topic::ALL.iter().position(|t| *t == topic).expect("every topic is in ALL") |
| 173 | 2662× | } |
| 174 | |
|
| 175 | | |
| 176 | | |
| 177 | | #[cfg(feature = "postgres")] |
| 178 | | pub fn listener_pid(&self) -> Option<i32> { |
| 179 | | *self.remote.pid.lock().unwrap_or_else(|p| p.into_inner()) |
| 180 | | } |
| 181 | | } |
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | 203× | pub async fn start(app: &Shared) -> anyhow::Result<()> { |
| 186 | | #[cfg(feature = "postgres")] |
| 187 | | pg::start(app).await?; |
| 188 | | #[cfg(not(feature = "postgres"))] |
| 189 | 203× | let _ = app; |
| 190 | 203× | Ok(()) |
| 191 | 203× | } |
| 192 | |
|
| 193 | |
|
| 194 | |
|
| 195 | | pub const MAX_PAYLOAD: usize = 7999; |
| 196 | |
|
| 197 | |
|
| 198 | | #[derive(serde::Serialize, serde::Deserialize)] |
| 199 | | struct Envelope { |
| 200 | | o: String, |
| 201 | | e: Event, |
| 202 | | } |
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | | #[cfg_attr(not(feature = "postgres"), allow(dead_code))] |
| 209 | 6× | fn encode(origin: &str, event: &Event) -> Option<String> { |
| 210 | 6× | let mut envelope = Envelope { o: origin.to_string(), e: event.clone() }; |
| 211 | | loop { |
| 212 | 7× | let text = serde_json::to_string(&envelope).ok()?; |
| 213 | 7× | if text.len() <= MAX_PAYLOAD { |
| 214 | 5× | return Some(text); |
| 215 | 2× | } |
| 216 | 1× | let Event::Proposal { event: ProposalEvent { check: Some(check), .. }, .. } = &mut envelope.e else { return None }; |
| 217 | 1× | if check.summary.is_empty() { |
| 218 | 0× | return None; |
| 219 | 1× | } |
| 220 | | |
| 221 | | |
| 222 | 1× | let over = text.len() - MAX_PAYLOAD; |
| 223 | 1× | let mut keep = check.summary.trim_end_matches('…').len().saturating_sub(over + 3); |
| 224 | 1× | while !check.summary.is_char_boundary(keep) { |
| 225 | 0× | keep -= 1; |
| 226 | 0× | } |
| 227 | 1× | check.summary.truncate(keep); |
| 228 | 1× | check.summary.push('…'); |
| 229 | 1× | if keep == 0 { |
| 230 | 0× | check.summary.clear(); |
| 231 | 1× | } |
| 232 | | } |
| 233 | 6× | } |
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | | #[cfg_attr(not(feature = "postgres"), allow(dead_code))] |
| 238 | 10× | fn decode(origin: &str, payload: &str) -> Option<Event> { |
| 239 | 10× | match serde_json::from_str::<Envelope>(payload) { |
| 240 | 9× | Ok(e) if e.o != origin => Some(e.e), |
| 241 | 4× | Ok(_) => None, |
| 242 | 1× | Err(err) => { |
| 243 | 1× | tracing::warn!("bus: an event that could not be read: {err}"); |
| 244 | 1× | None |
| 245 | | } |
| 246 | | } |
| 247 | 10× | } |
| 248 | |
|
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | | #[cfg_attr(not(feature = "postgres"), allow(dead_code))] |
| 253 | 10× | fn channel(schema: &str, topic: Topic) -> String { |
| 254 | 10× | let h = blake3::hash(format!("oxygenhub bus\0{schema}").as_bytes()); |
| 255 | 10× | format!("oxyhub_{}_{}", &h.to_hex()[..16], topic.name()) |
| 256 | 10× | } |
| 257 | |
|
| 258 | | #[cfg(feature = "postgres")] |
| 259 | | mod pg { |
| 260 | | use super::{channel, decode, encode, Event, Topic}; |
| 261 | | use crate::{App, Shared}; |
| 262 | | use sqlx::postgres::{PgListener, PgPool, PgPoolOptions}; |
| 263 | | use std::sync::{Mutex, OnceLock}; |
| 264 | | use std::time::Duration; |
| 265 | | use tokio::sync::mpsc; |
| 266 | |
|
| 267 | | |
| 268 | | |
| 269 | | const CHECK: Duration = Duration::from_secs(5); |
| 270 | |
|
| 271 | | |
| 272 | | const RETRY: Duration = Duration::from_secs(2); |
| 273 | |
|
| 274 | | |
| 275 | | |
| 276 | | const QUEUE: usize = 4096; |
| 277 | |
|
| 278 | | #[derive(Default)] |
| 279 | | pub(super) struct Remote { |
| 280 | | |
| 281 | | out: OnceLock<(String, mpsc::Sender<(String, String)>)>, |
| 282 | | |
| 283 | | pub(super) pid: Mutex<Option<i32>>, |
| 284 | | } |
| 285 | |
|
| 286 | | impl Remote { |
| 287 | | |
| 288 | | |
| 289 | | pub(super) fn send(&self, origin: &str, event: &Event) { |
| 290 | | let Some((schema, tx)) = self.out.get() else { return }; |
| 291 | | let Some(payload) = encode(origin, event) else { |
| 292 | | tracing::warn!("bus: a {} event too large to send to other processes stays in this one", event.topic().name()); |
| 293 | | return; |
| 294 | | }; |
| 295 | | if tx.try_send((channel(schema, event.topic()), payload)).is_err() { |
| 296 | | tracing::warn!("bus: too many events waiting to go to other processes; one was dropped"); |
| 297 | | } |
| 298 | | } |
| 299 | | } |
| 300 | |
|
| 301 | | pub(super) async fn start(app: &Shared) -> anyhow::Result<()> { |
| 302 | | let schema: String = sqlx::query_scalar("SELECT CAST(current_schema() AS TEXT)").fetch_one(&app.db).await?; |
| 303 | | let (tx, rx) = mpsc::channel(QUEUE); |
| 304 | | if app.bus.remote.out.set((schema.clone(), tx)).is_err() { |
| 305 | | return Ok(()); |
| 306 | | } |
| 307 | | tokio::spawn(send_all(app.db.clone(), rx)); |
| 308 | | tokio::spawn(listen(app.clone(), schema)); |
| 309 | | Ok(()) |
| 310 | | } |
| 311 | |
|
| 312 | | |
| 313 | | async fn send_all(db: crate::db::Pool, mut rx: mpsc::Receiver<(String, String)>) { |
| 314 | | while let Some((channel, payload)) = rx.recv().await { |
| 315 | | if let Err(e) = sqlx::query("SELECT pg_notify($1, $2)").bind(&channel).bind(&payload).execute(&db).await { |
| 316 | | tracing::warn!("bus: sending an event to other processes: {e}"); |
| 317 | | } |
| 318 | | } |
| 319 | | } |
| 320 | |
|
| 321 | | |
| 322 | | async fn connect(app: &App, channels: &[String]) -> anyhow::Result<(PgPool, PgListener, i32)> { |
| 323 | | let options = (*app.db.connect_options()).clone(); |
| 324 | | let pool = PgPoolOptions::new().max_connections(1).max_lifetime(None).idle_timeout(None).connect_with(options).await?; |
| 325 | | let mut listener = PgListener::connect_with(&pool).await?; |
| 326 | | listener.ignore_pool_close_event(true); |
| 327 | | |
| 328 | | listener.eager_reconnect(false); |
| 329 | | listener.listen_all(channels.iter().map(String::as_str)).await?; |
| 330 | | let pid: i32 = sqlx::query_scalar("SELECT pg_backend_pid()").fetch_one(&mut listener).await?; |
| 331 | | Ok((pool, listener, pid)) |
| 332 | | } |
| 333 | |
|
| 334 | | |
| 335 | | |
| 336 | | async fn listen(app: Shared, schema: String) { |
| 337 | | let channels: Vec<String> = Topic::ALL.iter().map(|t| channel(&schema, *t)).collect(); |
| 338 | | let mut lost = false; |
| 339 | | loop { |
| 340 | | let (pool, mut listener, pid) = match tokio::time::timeout(CHECK * 2, connect(&app, &channels)).await { |
| 341 | | Ok(Ok(c)) => c, |
| 342 | | Ok(Err(e)) => { |
| 343 | | tracing::warn!("bus: listening for other processes' events: {e}"); |
| 344 | | tokio::time::sleep(RETRY).await; |
| 345 | | continue; |
| 346 | | } |
| 347 | | Err(_) => { |
| 348 | | tracing::warn!("bus: listening for other processes' events: timed out"); |
| 349 | | tokio::time::sleep(RETRY).await; |
| 350 | | continue; |
| 351 | | } |
| 352 | | }; |
| 353 | | *app.bus.remote.pid.lock().unwrap_or_else(|p| p.into_inner()) = Some(pid); |
| 354 | | if lost { |
| 355 | | tracing::warn!("bus: listening again; events other processes published meanwhile were missed"); |
| 356 | | |
| 357 | | app.bus.deliver(Event::DeliveryWaiting); |
| 358 | | } |
| 359 | | loop { |
| 360 | | tokio::select! { |
| 361 | | heard = listener.try_recv() => match heard { |
| 362 | | Ok(Some(n)) => relay(&app, n.payload()), |
| 363 | | Ok(None) => { |
| 364 | | tracing::warn!("bus: the connection listening for other processes' events was lost"); |
| 365 | | break; |
| 366 | | } |
| 367 | | Err(e) => { |
| 368 | | tracing::warn!("bus: the connection listening for other processes' events failed: {e}"); |
| 369 | | break; |
| 370 | | } |
| 371 | | }, |
| 372 | | _ = tokio::time::sleep(CHECK) => { |
| 373 | | let ping = sqlx::query_scalar::<_, i32>("SELECT 1").fetch_one(&mut listener); |
| 374 | | if !matches!(tokio::time::timeout(CHECK, ping).await, Ok(Ok(_))) { |
| 375 | | tracing::warn!("bus: the connection listening for other processes' events stopped answering"); |
| 376 | | break; |
| 377 | | } |
| 378 | | } |
| 379 | | } |
| 380 | | } |
| 381 | | lost = true; |
| 382 | | *app.bus.remote.pid.lock().unwrap_or_else(|p| p.into_inner()) = None; |
| 383 | | drop(listener); |
| 384 | | let _ = tokio::time::timeout(CHECK, pool.close()).await; |
| 385 | | } |
| 386 | | } |
| 387 | |
|
| 388 | | |
| 389 | | |
| 390 | | fn relay(app: &App, payload: &str) { |
| 391 | | let Some(event) = decode(&app.bus.origin, payload) else { return }; |
| 392 | | if let Event::Room { room, event } = &event { |
| 393 | | app.rooms.apply(room, event); |
| 394 | | } |
| 395 | | app.bus.deliver(event); |
| 396 | | } |
| 397 | | } |
| 398 | |
|
| 399 | | #[cfg(test)] |
| 400 | | mod tests { |
| 401 | | use super::*; |
| 402 | | use crate::events::Replay; |
| 403 | |
|
| 404 | 4× | fn check(summary: &str) -> ProposalEvent { |
| 405 | 4× | ProposalEvent { |
| 406 | 4× | number: 0, |
| 407 | 4× | kind: "check".into(), |
| 408 | 4× | check: Some(hub_api::Check { |
| 409 | 4× | state: "s".into(), |
| 410 | 4× | name: "build".into(), |
| 411 | 4× | status: hub_api::CheckStatus::Passed, |
| 412 | 4× | summary: summary.into(), |
| 413 | 4× | url: String::new(), |
| 414 | 4× | reporter: "ci".into(), |
| 415 | 4× | seal: None, |
| 416 | 4× | started_ms: 0, |
| 417 | 4× | finished_ms: None, |
| 418 | 4× | }), |
| 419 | 4× | } |
| 420 | 4× | } |
| 421 | |
|
| 422 | | #[test] |
| 423 | 1× | fn subscribers_hear_their_topic_in_order_and_nothing_else() { |
| 424 | 1× | let bus = Bus::default(); |
| 425 | 1× | let mut deliveries = bus.subscribe(Topic::Deliveries); |
| 426 | 1× | let mut proposals = bus.subscribe(Topic::Proposals); |
| 427 | 1× | let mut live = bus.subscribe(Topic::Live); |
| 428 | 1× | bus.delivery_waiting(); |
| 429 | 1× | bus.proposal(7, check("ok")); |
| 430 | 1× | bus.live("repo:7", "push"); |
| 431 | 1× | bus.live("repo:7", "check"); |
| 432 | 1× | assert_eq!(deliveries.try_recv().unwrap(), Event::DeliveryWaiting); |
| 433 | 1× | assert!(deliveries.try_recv().is_err(), "once"); |
| 434 | 1× | assert_eq!(proposals.try_recv().unwrap(), Event::Proposal { repo: 7, event: check("ok") }); |
| 435 | 1× | assert!(proposals.try_recv().is_err()); |
| 436 | 1× | assert_eq!(live.try_recv().unwrap(), Event::Live { topic: "repo:7".into(), kind: "push".into() }); |
| 437 | 1× | assert_eq!(live.try_recv().unwrap(), Event::Live { topic: "repo:7".into(), kind: "check".into() }); |
| 438 | | |
| 439 | 1× | let Replay::Events(kept) = bus.live.since(0, &["repo:7".into()]) else { panic!() }; |
| 440 | 2× | assert_eq!(kept.iter().map(|e| (e.id, e.version, e.kind.as_str())).collect::<Vec<_>>(), [(1, 1, "push"), (2, 2, "check")]); |
| 441 | 1× | } |
| 442 | |
|
| 443 | | #[test] |
| 444 | 1× | fn a_webhook_event_is_heard_on_its_live_topics() { |
| 445 | 1× | let bus = Bus::default(); |
| 446 | 1× | let mut live = bus.subscribe(Topic::Live); |
| 447 | 1× | bus.hook(7, "review", &serde_json::json!({ "number": 4 })); |
| 448 | 1× | assert_eq!(live.try_recv().unwrap(), Event::Live { topic: "repo:7".into(), kind: "review".into() }); |
| 449 | 1× | assert_eq!(live.try_recv().unwrap(), Event::Live { topic: "repo:7/proposal:4".into(), kind: "review".into() }); |
| 450 | 1× | } |
| 451 | |
|
| 452 | | #[test] |
| 453 | 1× | fn events_travel_with_their_origin_and_a_process_skips_its_own() { |
| 454 | 1× | let room = RoomKey { repo_id: 1, bookmark: "main".into(), path: "a.txt".into() }; |
| 455 | 1× | let events = [ |
| 456 | 1× | Event::DeliveryWaiting, |
| 457 | 1× | Event::Proposal { repo: 7, event: check("42 tests") }, |
| 458 | 1× | Event::Live { topic: "repo:7".into(), kind: "push".into() }, |
| 459 | 1× | Event::Room { |
| 460 | 1× | room, |
| 461 | 1× | event: RoomEvent::Choice { |
| 462 | 1× | region: "1".into(), |
| 463 | 1× | choice: crate::live::Choice { choice: "side2".into(), text: String::new(), by: "andy".into() }, |
| 464 | 1× | client: "tab-a".into(), |
| 465 | 1× | }, |
| 466 | 1× | }, |
| 467 | 1× | ]; |
| 468 | 4× | for e in events { |
| 469 | 4× | let payload = encode("aaaa", &e).unwrap(); |
| 470 | 4× | assert_eq!(decode("bbbb", &payload), Some(e.clone()), "another process hears it"); |
| 471 | 4× | assert_eq!(decode("aaaa", &payload), None, "its sender skips it"); |
| 472 | | } |
| 473 | 1× | assert_eq!(decode("bbbb", "not json"), None); |
| 474 | 1× | } |
| 475 | |
|
| 476 | | #[test] |
| 477 | 1× | fn payloads_fit_a_notification() { |
| 478 | | |
| 479 | 1× | let long = "é\"".repeat(6000); |
| 480 | 1× | let payload = encode("aaaa", &Event::Proposal { repo: 7, event: check(&long) }).unwrap(); |
| 481 | 1× | assert!(payload.len() <= MAX_PAYLOAD, "{}", payload.len()); |
| 482 | 1× | let Some(Event::Proposal { event, .. }) = decode("bbbb", &payload) else { panic!() }; |
| 483 | 1× | let summary = event.check.unwrap().summary; |
| 484 | 1× | assert!(summary.ends_with('…') && long.starts_with(summary.trim_end_matches('…')), "{}", summary.len()); |
| 485 | | |
| 486 | 1× | let big = Event::Room { |
| 487 | 1× | room: RoomKey { repo_id: 1, bookmark: "main".into(), path: "a".into() }, |
| 488 | 1× | event: RoomEvent::Choice { |
| 489 | 1× | region: "1".into(), |
| 490 | 1× | choice: crate::live::Choice { choice: "text".into(), text: "x".repeat(9000), by: "andy".into() }, |
| 491 | 1× | client: "c".into(), |
| 492 | 1× | }, |
| 493 | 1× | }; |
| 494 | 1× | assert_eq!(encode("aaaa", &big), None); |
| 495 | 1× | } |
| 496 | |
|
| 497 | | #[test] |
| 498 | 1× | fn channels_are_per_schema_and_topic_and_plain() { |
| 499 | 1× | assert_eq!(channel("hub_a", Topic::Live), channel("hub_a", Topic::Live)); |
| 500 | 1× | assert_ne!(channel("hub_a", Topic::Live), channel("hub_b", Topic::Live)); |
| 501 | 1× | assert_ne!(channel("hub_a", Topic::Live), channel("hub_a", Topic::Rooms)); |
| 502 | 4× | for t in Topic::ALL { |
| 503 | 4× | let c = channel(&"x".repeat(200), t); |
| 504 | 124× | assert!(c.len() < 64 && c.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_'), "{c}"); |
| 505 | | } |
| 506 | 1× | } |
| 507 | | } |