Skip to content

Commit 6e1c192

Browse files
committed
feat: #103 show number of routes before loading workers
``` $$ target/debug/wws . --ignore 'src/**/*' --ignore 'target/**/*' --ignore 'docs/**/*' --ignore 'crates/**/*' | ts May 26 08:49:33 ⚙️ Loading routes from: . May 26 08:49:35 ⏳ Loading workers from 14 routes... May 26 08:50:13 ✅ Workers loaded in 38.128146575s. ... ```
1 parent ecc42af commit 6e1c192

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

crates/router/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ mod route;
1111

1212
use files::Files;
1313
use route::{Route, RouteAffinity};
14-
use std::path::Path;
14+
use std::path::{Path, PathBuf};
15+
use std::time::{Instant};
1516
use wws_config::Config;
1617

1718
/// Contains all registered routes
@@ -36,10 +37,18 @@ impl Routes {
3637

3738
let files = Files::new(path, runtime_extensions, ignore_patterns);
3839

40+
let mut route_paths: Vec<PathBuf> = Vec::new();
3941
for entry in files.walk() {
40-
routes.push(Route::new(path, entry.into_path(), &prefix, config));
42+
route_paths.push(entry.into_path());
4143
}
4244

45+
println!("⏳ Loading workers from {} routes...", route_paths.len());
46+
let start = Instant::now();
47+
for route_path in route_paths {
48+
routes.push(Route::new(path, route_path, &prefix, config));
49+
}
50+
println!("✅ Workers loaded in {:?}.", start.elapsed());
51+
4352
Self { routes, prefix }
4453
}
4554

src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ async fn main() -> std::io::Result<()> {
107107

108108
println!("⚙️ Loading routes from: {}", &args.path.display());
109109
let routes = Routes::new(&args.path, &args.prefix, args.ignore, &config);
110-
111-
println!("🗺 Detected {} routes:", routes.routes.len());
112110
for route in routes.routes.iter() {
113111
println!(
114112
" - http://{}:{}{}\n => {}",

0 commit comments

Comments
 (0)